Deleted Added
full compact
kern_conf.c (177858) kern_conf.c (178991)
1/*-
2 * Copyright (c) 1999-2002 Poul-Henning Kamp
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1999-2002 Poul-Henning Kamp
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/kern/kern_conf.c 177858 2008-04-02 11:11:58Z kib $");
28__FBSDID("$FreeBSD: head/sys/kern/kern_conf.c 178991 2008-05-14 14:29:54Z kib $");
29
30#include <sys/param.h>
31#include <sys/kernel.h>
32#include <sys/systm.h>
29
30#include <sys/param.h>
31#include <sys/kernel.h>
32#include <sys/systm.h>
33#include <sys/bus.h>
33#include <sys/bio.h>
34#include <sys/lock.h>
35#include <sys/mutex.h>
36#include <sys/module.h>
37#include <sys/malloc.h>
38#include <sys/conf.h>
39#include <sys/vnode.h>
40#include <sys/queue.h>

--- 480 unchanged lines hidden (view full) ---

521int
522unit2minor(int unit)
523{
524
525 KASSERT(unit <= 0xffffff, ("Invalid unit (%d) in unit2minor", unit));
526 return ((unit & 0xff) | ((unit << 8) & ~0xffff));
527}
528
34#include <sys/bio.h>
35#include <sys/lock.h>
36#include <sys/mutex.h>
37#include <sys/module.h>
38#include <sys/malloc.h>
39#include <sys/conf.h>
40#include <sys/vnode.h>
41#include <sys/queue.h>

--- 480 unchanged lines hidden (view full) ---

522int
523unit2minor(int unit)
524{
525
526 KASSERT(unit <= 0xffffff, ("Invalid unit (%d) in unit2minor", unit));
527 return ((unit & 0xff) | ((unit << 8) & ~0xffff));
528}
529
530static void
531notify(struct cdev *dev, const char *ev)
532{
533 static const char prefix[] = "cdev=";
534 char *data;
535 int namelen;
536
537 if (cold)
538 return;
539 namelen = strlen(dev->si_name);
540 data = malloc(namelen + sizeof(prefix), M_TEMP, M_WAITOK);
541 memcpy(data, prefix, sizeof(prefix) - 1);
542 memcpy(data + sizeof(prefix) - 1, dev->si_name, namelen + 1);
543 devctl_notify("DEVFS", "CDEV", ev, data);
544 free(data, M_TEMP);
545}
546
547static void
548notify_create(struct cdev *dev)
549{
550
551 notify(dev, "CREATE");
552}
553
554static void
555notify_destroy(struct cdev *dev)
556{
557
558 notify(dev, "DESTROY");
559}
560
529static struct cdev *
530newdev(struct cdevsw *csw, int y, struct cdev *si)
531{
532 struct cdev *si2;
533 dev_t udev;
534
535 mtx_assert(&devmtx, MA_OWNED);
536 udev = y;

--- 164 unchanged lines hidden (view full) ---

701 dev->si_cred = NULL;
702 dev->si_uid = uid;
703 dev->si_gid = gid;
704 dev->si_mode = mode;
705
706 devfs_create(dev);
707 clean_unrhdrl(devfs_inos);
708 dev_unlock_and_free();
561static struct cdev *
562newdev(struct cdevsw *csw, int y, struct cdev *si)
563{
564 struct cdev *si2;
565 dev_t udev;
566
567 mtx_assert(&devmtx, MA_OWNED);
568 udev = y;

--- 164 unchanged lines hidden (view full) ---

733 dev->si_cred = NULL;
734 dev->si_uid = uid;
735 dev->si_gid = gid;
736 dev->si_mode = mode;
737
738 devfs_create(dev);
739 clean_unrhdrl(devfs_inos);
740 dev_unlock_and_free();
741
742 notify_create(dev);
743
709 return (dev);
710}
711
712struct cdev *
713make_dev(struct cdevsw *devsw, int minornr, uid_t uid, gid_t gid, int mode,
714 const char *fmt, ...)
715{
716 struct cdev *dev;

--- 72 unchanged lines hidden (view full) ---

789 dev->__si_namebuf);
790 }
791 va_end(ap);
792
793 devfs_create(dev);
794 clean_unrhdrl(devfs_inos);
795 dev_unlock();
796 dev_depends(pdev, dev);
744 return (dev);
745}
746
747struct cdev *
748make_dev(struct cdevsw *devsw, int minornr, uid_t uid, gid_t gid, int mode,
749 const char *fmt, ...)
750{
751 struct cdev *dev;

--- 72 unchanged lines hidden (view full) ---

824 dev->__si_namebuf);
825 }
826 va_end(ap);
827
828 devfs_create(dev);
829 clean_unrhdrl(devfs_inos);
830 dev_unlock();
831 dev_depends(pdev, dev);
832
833 notify_create(dev);
834
797 return (dev);
798}
799
800static void
801destroy_devl(struct cdev *dev)
802{
803 struct cdevsw *csw;
804

--- 32 unchanged lines hidden (view full) ---

837 printf("Still %lu threads in %s\n",
838 dev->si_threadcount, devtoname(dev));
839 }
840 while (dev->si_threadcount != 0) {
841 /* Use unique dummy wait ident */
842 msleep(&csw, &devmtx, PRIBIO, "devdrn", hz / 10);
843 }
844
835 return (dev);
836}
837
838static void
839destroy_devl(struct cdev *dev)
840{
841 struct cdevsw *csw;
842

--- 32 unchanged lines hidden (view full) ---

875 printf("Still %lu threads in %s\n",
876 dev->si_threadcount, devtoname(dev));
877 }
878 while (dev->si_threadcount != 0) {
879 /* Use unique dummy wait ident */
880 msleep(&csw, &devmtx, PRIBIO, "devdrn", hz / 10);
881 }
882
883 mtx_unlock(&devmtx);
884 notify_destroy(dev);
885 mtx_lock(&devmtx);
886
845 dev->si_drv1 = 0;
846 dev->si_drv2 = 0;
847 bzero(&dev->__si_u, sizeof(dev->__si_u));
848
849 if (!(dev->si_flags & SI_ALIAS)) {
850 /* Remove from cdevsw list */
851 LIST_REMOVE(dev, si_list);
852

--- 312 unchanged lines hidden ---
887 dev->si_drv1 = 0;
888 dev->si_drv2 = 0;
889 bzero(&dev->__si_u, sizeof(dev->__si_u));
890
891 if (!(dev->si_flags & SI_ALIAS)) {
892 /* Remove from cdevsw list */
893 LIST_REMOVE(dev, si_list);
894

--- 312 unchanged lines hidden ---