2 * Copyright (c) 2010,2018 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Alex Hornung <ahornung@gmail.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
40 #include <sys/event.h>
41 #include <sys/vnode.h>
42 #include <sys/malloc.h>
43 #include <sys/objcache.h>
44 #include <sys/ctype.h>
45 #include <sys/syslog.h>
47 #include <sys/devfs.h>
48 #include <libprop/proplib.h>
50 MALLOC_DEFINE(M_UDEV, "udev", "udev allocs");
51 static struct objcache *udev_event_kernel_cache;
53 /* XXX: use UUIDs for identification; would need help from devfs */
55 static cdev_t udev_dev;
56 static d_open_t udev_dev_open;
57 static d_close_t udev_dev_close;
58 static d_read_t udev_dev_read;
59 static d_kqfilter_t udev_dev_kqfilter;
60 static d_ioctl_t udev_dev_ioctl;
61 static d_clone_t udev_dev_clone;
63 struct udev_prop_ctx {
68 struct udev_event_kernel {
70 TAILQ_ENTRY(udev_event_kernel) link;
74 TAILQ_ENTRY(udev_softc) entry;
80 struct udev_event_kernel marker; /* udev_evq marker */
85 int (*fn)(struct udev_softc *, struct plistref *,
86 u_long, prop_dictionary_t);
89 static int _udev_dict_set_cstr(prop_dictionary_t, const char *, char *);
90 static int _udev_dict_set_int(prop_dictionary_t, const char *, int64_t);
91 static int _udev_dict_set_uint(prop_dictionary_t, const char *, uint64_t);
92 static int _udev_dict_delete_key(prop_dictionary_t, const char *);
93 static prop_dictionary_t udev_init_dict_event(cdev_t, const char *);
94 static int udev_init_dict(cdev_t);
95 static int udev_destroy_dict(cdev_t);
96 static void udev_event_insert(int, prop_dictionary_t);
97 static void udev_clean_events_locked(void);
98 static char *udev_event_externalize(struct udev_event_kernel *);
99 static void udev_getdevs_scan_callback(char *, cdev_t, bool, void *);
100 static int udev_getdevs_ioctl(struct udev_softc *, struct plistref *,
101 u_long, prop_dictionary_t);
102 static void udev_dev_filter_detach(struct knote *);
103 static int udev_dev_filter_read(struct knote *, long);
105 static struct dev_ops udev_dev_ops = {
107 .d_open = udev_dev_open,
108 .d_close = udev_dev_close,
109 .d_read = udev_dev_read,
110 .d_kqfilter = udev_dev_kqfilter,
111 .d_ioctl = udev_dev_ioctl
114 static struct cmd_function cmd_fn[] = {
115 { .cmd = "getdevs", .fn = udev_getdevs_ioctl},
119 DEVFS_DEFINE_CLONE_BITMAP(udev);
121 static TAILQ_HEAD(, udev_softc) udevq;
122 static TAILQ_HEAD(, udev_event_kernel) udev_evq;
123 static struct kqinfo udev_kq;
124 static struct lock udev_lk;
125 static int udev_evqlen;
126 static int udev_initiated_count;
127 static int udev_open_count;
128 static int udev_seqwait;
130 static struct lock udev_dict_lk = LOCK_INITIALIZER("dict", 0, 0);
133 * Acquire the device's si_dict and lock the device's si_dict field.
134 * If the device does not have an attached dictionary, NULL is returned.
136 * This function must be matched by a udev_put_dict() call regardless of
137 * the return value. The device field is STILL LOCKED even when NULL is
140 * Currently a single global lock is implemented.
142 static prop_dictionary_t
143 udev_get_dict(cdev_t dev)
145 prop_dictionary_t udict;
147 lockmgr(&udev_dict_lk, LK_EXCLUSIVE|LK_CANRECURSE);
148 udict = dev->si_dict;
150 prop_object_retain(udict);
155 * Release the dictionary previously returned by udev_get_dict() and unlock
156 * the device's si_dict field. udict may be NULL.
159 udev_put_dict(cdev_t dev, prop_dictionary_t udict)
162 prop_object_release(udict);
163 lockmgr(&udev_dict_lk, LK_RELEASE);
167 _udev_dict_set_cstr(prop_dictionary_t dict, const char *key, char *str)
171 KKASSERT(dict != NULL);
173 ps = prop_string_create_cstring(str);
178 if (prop_dictionary_set(dict, key, ps) == false) {
179 prop_object_release(ps);
183 prop_object_release(ps);
188 _udev_dict_set_int(prop_dictionary_t dict, const char *key, int64_t val)
192 KKASSERT(dict != NULL);
194 pn = prop_number_create_integer(val);
198 if (prop_dictionary_set(dict, key, pn) == false) {
199 prop_object_release(pn);
203 prop_object_release(pn);
208 _udev_dict_set_uint(prop_dictionary_t dict, const char *key, uint64_t val)
212 KKASSERT(dict != NULL);
214 pn = prop_number_create_unsigned_integer(val);
218 if (prop_dictionary_set(dict, key, pn) == false) {
219 prop_object_release(pn);
223 prop_object_release(pn);
228 _udev_dict_delete_key(prop_dictionary_t dict, const char *key)
230 KKASSERT(dict != NULL);
232 prop_dictionary_remove(dict, key);
238 * Initialize an event dictionary, which contains three parameters to
239 * identify the device referred to (name, devnum, kptr) and the affected key.
241 static prop_dictionary_t
242 udev_init_dict_event(cdev_t dev, const char *key)
244 prop_dictionary_t dict;
248 kptr = (uint64_t)(uintptr_t)dev;
249 KKASSERT(dev != NULL);
251 dict = prop_dictionary_create();
253 log(LOG_DEBUG, "udev_init_dict_event: prop_dictionary_create() failed\n");
257 if ((error = _udev_dict_set_cstr(dict, "name", dev->si_name)))
259 if ((error = _udev_dict_set_uint(dict, "devnum", dev->si_inode)))
261 if ((error = _udev_dict_set_uint(dict, "devtype", (dev_dflags(dev) & D_TYPEMASK))))
263 if ((error = _udev_dict_set_uint(dict, "kptr", kptr)))
265 if ((error = _udev_dict_set_cstr(dict, "key", __DECONST(char *, key))))
271 prop_object_release(dict);
276 udev_dict_set_cstr(cdev_t dev, const char *key, char *str)
278 prop_dictionary_t dict;
279 prop_dictionary_t udict;
282 KKASSERT(dev != NULL);
284 while ((udict = udev_get_dict(dev)) == NULL) {
285 error = udev_init_dict(dev);
286 udev_put_dict(dev, udict);
291 /* Queue a key update event */
292 dict = udev_init_dict_event(dev, key);
298 if ((error = _udev_dict_set_cstr(dict, "value", str))) {
299 prop_object_release(dict);
302 udev_event_insert(UDEV_EV_KEY_UPDATE, dict);
303 prop_object_release(dict);
304 error = _udev_dict_set_cstr(udict, key, str);
307 udev_put_dict(dev, udict);
313 udev_dict_set_int(cdev_t dev, const char *key, int64_t val)
315 prop_dictionary_t dict;
316 prop_dictionary_t udict;
319 KKASSERT(dev != NULL);
321 while ((udict = udev_get_dict(dev)) == NULL) {
322 error = udev_init_dict(dev);
323 udev_put_dict(dev, udict);
328 /* Queue a key update event */
329 dict = udev_init_dict_event(dev, key);
334 if ((error = _udev_dict_set_int(dict, "value", val))) {
335 prop_object_release(dict);
338 udev_event_insert(UDEV_EV_KEY_UPDATE, dict);
339 prop_object_release(dict);
340 error = _udev_dict_set_int(udict, key, val);
342 udev_put_dict(dev, udict);
348 udev_dict_set_uint(cdev_t dev, const char *key, uint64_t val)
350 prop_dictionary_t dict;
351 prop_dictionary_t udict;
354 KKASSERT(dev != NULL);
356 while ((udict = udev_get_dict(dev)) == NULL) {
357 error = udev_init_dict(dev);
358 udev_put_dict(dev, udict);
363 /* Queue a key update event */
364 dict = udev_init_dict_event(dev, key);
369 if ((error = _udev_dict_set_uint(dict, "value", val))) {
370 prop_object_release(dict);
373 udev_event_insert(UDEV_EV_KEY_UPDATE, dict);
374 prop_object_release(dict);
375 error = _udev_dict_set_uint(udict, key, val);
377 udev_put_dict(dev, udict);
383 udev_dict_delete_key(cdev_t dev, const char *key)
385 prop_dictionary_t dict;
386 prop_dictionary_t udict;
389 KKASSERT(dev != NULL);
390 udict = udev_get_dict(dev);
396 /* Queue a key removal event */
397 dict = udev_init_dict_event(dev, key);
402 udev_event_insert(UDEV_EV_KEY_REMOVE, dict);
403 prop_object_release(dict);
404 error = _udev_dict_delete_key(udict, key);
406 udev_put_dict(dev, udict);
412 * device dictionary access already locked
415 udev_init_dict(cdev_t dev)
417 prop_dictionary_t dict;
421 kptr = (uint64_t)(uintptr_t)dev;
423 KKASSERT(dev != NULL);
425 if (dev->si_dict != NULL) {
427 "udev_init_dict: new dict for %s, but has "
428 "dict already (%p)!\n",
429 dev->si_name, dev->si_dict);
433 dict = prop_dictionary_create();
436 "udev_init_dict: prop_dictionary_create() failed\n");
440 if ((error = _udev_dict_set_cstr(dict, "name", dev->si_name)))
442 if ((error = _udev_dict_set_uint(dict, "devnum", dev->si_inode)))
444 if ((error = _udev_dict_set_uint(dict, "kptr", kptr)))
446 if ((error = _udev_dict_set_uint(dict, "devtype",
447 (dev_dflags(dev) & D_TYPEMASK)))) {
451 /* XXX: The next 3 are marginallly useful, if at all */
452 if ((error = _udev_dict_set_uint(dict, "uid", dev->si_uid)))
454 if ((error = _udev_dict_set_uint(dict, "gid", dev->si_gid)))
456 if ((error = _udev_dict_set_int(dict, "mode", dev->si_perms)))
459 if ((error = _udev_dict_set_int(dict, "major", dev->si_umajor)))
461 if ((error = _udev_dict_set_int(dict, "minor", dev->si_uminor)))
463 if (dev->si_ops->head.name != NULL) {
464 if ((error = _udev_dict_set_cstr(dict, "driver",
465 __DECONST(char *, dev->si_ops->head.name))))
474 prop_object_release(dict);
479 * device dictionary access already locked
482 udev_destroy_dict(cdev_t dev)
484 prop_dictionary_t udict;
486 KKASSERT(dev != NULL);
487 udict = udev_get_dict(dev);
489 /* field is now locked, use directly to handle races */
491 prop_object_release(dev->si_dict);
494 udev_put_dict(dev, udict);
500 udev_event_insert(int ev_type, prop_dictionary_t dict)
502 struct udev_event_kernel *ev;
503 prop_dictionary_t dict_copy;
505 /* Only start queing events after client has initiated properly */
506 if (udev_initiated_count) {
507 dict_copy = prop_dictionary_copy(dict);
508 if (dict_copy == NULL)
510 ev = objcache_get(udev_event_kernel_cache, M_WAITOK);
511 ev->ev.ev_dict = dict_copy;
512 ev->ev.ev_type = ev_type;
514 lockmgr(&udev_lk, LK_EXCLUSIVE);
515 TAILQ_INSERT_TAIL(&udev_evq, ev, link);
519 wakeup(&udev_seqwait);
520 lockmgr(&udev_lk, LK_RELEASE);
522 KNOTE(&udev_kq.ki_note, 0);
523 } else if (udev_open_count) {
524 lockmgr(&udev_lk, LK_EXCLUSIVE);
527 wakeup(&udev_seqwait);
528 lockmgr(&udev_lk, LK_RELEASE);
529 KNOTE(&udev_kq.ki_note, 0);
534 udev_clean_events_locked(void)
536 struct udev_event_kernel *ev;
538 while ((ev = TAILQ_FIRST(&udev_evq)) &&
539 ev->ev.ev_dict != NULL) {
540 TAILQ_REMOVE(&udev_evq, ev, link);
541 objcache_put(udev_event_kernel_cache, ev);
547 udev_event_externalize(struct udev_event_kernel *ev)
549 prop_dictionary_t dict;
553 dict = prop_dictionary_create();
556 "udev_event_externalize: prop_dictionary_create() failed\n");
560 if ((error = _udev_dict_set_int(dict, "evtype", ev->ev.ev_type))) {
561 prop_object_release(dict);
565 if (prop_dictionary_set(dict, "evdict", ev->ev.ev_dict) == false) {
566 prop_object_release(dict);
570 prop_object_release(ev->ev.ev_dict);
572 xml = prop_dictionary_externalize(dict);
574 prop_object_release(dict);
580 udev_event_attach(cdev_t dev, char *name, int alias)
582 prop_dictionary_t dict;
583 prop_dictionary_t udict;
586 KKASSERT(dev != NULL);
590 udict = udev_get_dict(dev);
594 dict = prop_dictionary_copy(udict);
598 if ((error = _udev_dict_set_cstr(dict, "name", name))) {
599 prop_object_release(dict);
603 _udev_dict_set_int(dict, "alias", 1);
605 udev_event_insert(UDEV_EVENT_ATTACH, dict);
606 prop_object_release(dict);
608 while (udict == NULL) {
609 error = udev_init_dict(dev);
612 udev_put_dict(dev, udict);
613 udict = udev_get_dict(dev);
615 _udev_dict_set_int(udict, "alias", 0);
616 udev_event_insert(UDEV_EVENT_ATTACH, udict);
619 udev_put_dict(dev, udict);
625 udev_event_detach(cdev_t dev, char *name, int alias)
627 prop_dictionary_t dict;
628 prop_dictionary_t udict;
630 KKASSERT(dev != NULL);
632 udict = udev_get_dict(dev);
634 dict = prop_dictionary_copy(udict);
638 if (_udev_dict_set_cstr(dict, "name", name)) {
639 prop_object_release(dict);
643 _udev_dict_set_int(dict, "alias", 1);
645 udev_event_insert(UDEV_EVENT_DETACH, dict);
646 prop_object_release(dict);
649 udev_event_insert(UDEV_EVENT_DETACH, udict);
653 udev_destroy_dict(dev);
654 udev_put_dict(dev, udict);
660 * Allow multiple opens. Each opener gets a different device.
661 * Messages are replicated to all devices using a marker system.
664 udev_dev_clone(struct dev_clone_args *ap)
666 struct udev_softc *softc;
669 unit = devfs_clone_bitmap_get(&DEVFS_CLONE_BITMAP(udev), 1000);
675 softc = kmalloc(sizeof(*softc), M_UDEV, M_WAITOK | M_ZERO);
677 lockmgr(&udev_lk, LK_EXCLUSIVE);
678 TAILQ_INSERT_TAIL(&udevq, softc, entry);
679 lockmgr(&udev_lk, LK_RELEASE);
681 softc->dev = make_only_dev(&udev_dev_ops, unit, ap->a_cred->cr_ruid,
682 0, 0600, "udevs/%d", unit);
683 softc->dev->si_drv1 = softc;
684 ap->a_dev = softc->dev;
692 udev_dev_open(struct dev_open_args *ap)
694 struct udev_softc *softc = ap->a_head.a_dev->si_drv1;
696 lockmgr(&udev_lk, LK_EXCLUSIVE);
697 if (softc == NULL || softc->opened) {
698 lockmgr(&udev_lk, LK_RELEASE);
703 lockmgr(&udev_lk, LK_RELEASE);
709 udev_dev_close(struct dev_close_args *ap)
711 struct udev_softc *softc = ap->a_head.a_dev->si_drv1;
713 KKASSERT(softc->dev == ap->a_head.a_dev);
714 KKASSERT(softc->opened == 1);
716 destroy_dev(ap->a_head.a_dev);
717 lockmgr(&udev_lk, LK_EXCLUSIVE);
718 TAILQ_REMOVE(&udevq, softc, entry);
720 if (softc->initiated) {
721 TAILQ_REMOVE(&udev_evq, &softc->marker, link);
722 softc->initiated = 0;
723 --udev_initiated_count;
724 udev_clean_events_locked();
728 ap->a_head.a_dev->si_drv1 = NULL;
730 lockmgr(&udev_lk, LK_RELEASE);
733 * WARNING! devfs_clone_bitmap_put() interacts with the devfs
734 * thread, avoid deadlocks by ensuring we are unlocked
737 devfs_clone_bitmap_put(&DEVFS_CLONE_BITMAP(udev), softc->unit);
740 kfree(softc, M_UDEV);
745 static struct filterops udev_dev_read_filtops =
746 { FILTEROP_ISFD | FILTEROP_MPSAFE, NULL,
747 udev_dev_filter_detach, udev_dev_filter_read };
750 udev_dev_kqfilter(struct dev_kqfilter_args *ap)
752 struct udev_softc *softc = ap->a_head.a_dev->si_drv1;
753 struct knote *kn = ap->a_kn;
757 lockmgr(&udev_lk, LK_EXCLUSIVE);
759 switch (kn->kn_filter) {
761 kn->kn_fop = &udev_dev_read_filtops;
762 kn->kn_hook = (caddr_t)softc;
765 ap->a_result = EOPNOTSUPP;
766 lockmgr(&udev_lk, LK_RELEASE);
770 klist = &udev_kq.ki_note;
771 knote_insert(klist, kn);
773 lockmgr(&udev_lk, LK_RELEASE);
779 udev_dev_filter_detach(struct knote *kn)
783 lockmgr(&udev_lk, LK_EXCLUSIVE);
784 klist = &udev_kq.ki_note;
785 knote_remove(klist, kn);
786 lockmgr(&udev_lk, LK_RELEASE);
790 udev_dev_filter_read(struct knote *kn, long hint)
792 struct udev_softc *softc = (void *)kn->kn_hook;
793 struct udev_event_kernel *ev;
796 lockmgr(&udev_lk, LK_EXCLUSIVE);
797 if (softc->initiated) {
798 ev = TAILQ_NEXT(&softc->marker, link);
799 while (ev && ev->ev.ev_dict == NULL)
800 ev = TAILQ_NEXT(ev, link);
804 lockmgr(&udev_lk, LK_RELEASE);
810 udev_dev_read(struct dev_read_args *ap)
812 struct udev_softc *softc = ap->a_head.a_dev->si_drv1;
813 struct udev_event_kernel *ev;
814 struct uio *uio = ap->a_uio;
819 lockmgr(&udev_lk, LK_EXCLUSIVE);
822 * Automatically enable message collection if it has not already
825 if (softc->initiated == 0) {
826 softc->initiated = 1;
827 ++udev_initiated_count;
828 TAILQ_INSERT_HEAD(&udev_evq, &softc->marker, link);
832 * Loop, sleep interruptably until we get an event or signal.
836 if (softc->initiated) {
837 ev = TAILQ_NEXT(&softc->marker, link);
838 while (ev && ev->ev.ev_dict == NULL)
839 ev = TAILQ_NEXT(ev, link);
841 if ((xml = udev_event_externalize(ev)) == NULL) {
845 len = strlen(xml) + 1; /* include terminator */
846 if (uio->uio_resid < len)
849 error = uiomove((caddr_t)xml, len, uio);
855 TAILQ_REMOVE(&udev_evq, &softc->marker, link);
856 TAILQ_INSERT_AFTER(&udev_evq,
857 ev, &softc->marker, link);
858 udev_clean_events_locked();
862 if (ap->a_ioflag & IO_NDELAY) {
866 if ((error = lksleep(&udev_evq, &udev_lk, PCATCH, "udevq", 0)))
870 lockmgr(&udev_lk, LK_RELEASE);
875 udev_dev_ioctl(struct dev_ioctl_args *ap)
877 struct udev_softc *softc = ap->a_head.a_dev->si_drv1;
878 prop_dictionary_t dict;
881 struct plistref *pref;
889 /* Use proplib(3) for userspace/kernel communication */
890 pref = (struct plistref *)ap->a_data;
891 error = prop_dictionary_copyin_ioctl(pref, ap->a_cmd, &dict);
895 po = prop_dictionary_get(dict, "command");
896 if (po == NULL || prop_object_type(po) != PROP_TYPE_STRING) {
897 log(LOG_DEBUG, "udev: prop_dictionary_get() failed\n");
898 prop_object_release(dict);
904 for(i = 0; cmd_fn[i].cmd != NULL; i++) {
905 if (prop_string_equals_cstring(ps, cmd_fn[i].cmd))
909 if (cmd_fn[i].cmd != NULL) {
910 error = cmd_fn[i].fn(softc, pref, ap->a_cmd, dict);
915 //prop_object_release(po);
916 prop_object_release(dict);
920 * Wait for events based on sequence number. Updates
921 * sequence number for loop.
923 lockmgr(&udev_lk, LK_EXCLUSIVE);
924 seq = *(int *)ap->a_data;
926 while (seq == udev_seq) {
927 error = lksleep(&udev_seqwait, &udev_lk,
933 *(int *)ap->a_data = udev_seq;
934 lockmgr(&udev_lk, LK_RELEASE);
937 error = ENOTTY; /* Inappropriate ioctl for device */
945 udev_getdevs_scan_callback(char *name, cdev_t cdev, bool is_alias, void *arg)
947 struct udev_prop_ctx *ctx = arg;
949 KKASSERT(arg != NULL);
951 if (cdev->si_dict == NULL)
954 if (prop_array_add(ctx->cdevs, cdev->si_dict) == false) {
961 udev_getdevs_ioctl(struct udev_softc *softc, struct plistref *pref,
962 u_long cmd, prop_dictionary_t dict)
964 prop_dictionary_t odict;
965 struct udev_prop_ctx ctx;
969 * Ensure event notification is enabled before doing the devfs
970 * scan so nothing gets missed.
972 lockmgr(&udev_lk, LK_EXCLUSIVE);
973 if (softc->initiated == 0) {
974 softc->initiated = 1;
975 ++udev_initiated_count;
976 TAILQ_INSERT_HEAD(&udev_evq, &softc->marker, link);
978 lockmgr(&udev_lk, LK_RELEASE);
981 * Devfs scan to build full dictionary.
984 ctx.cdevs = prop_array_create();
985 if (ctx.cdevs == NULL) {
987 "udev_getdevs_ioctl: prop_array_create() failed\n");
991 devfs_scan_callback(udev_getdevs_scan_callback, &ctx);
993 if (ctx.error != 0) {
994 prop_object_release(ctx.cdevs);
998 odict = prop_dictionary_create();
1003 if ((prop_dictionary_set(odict, "array", ctx.cdevs)) == 0) {
1005 "udev_getdevs_ioctl: prop_dictionary_set failed\n");
1006 prop_object_release(odict);
1010 error = prop_dictionary_copyout_ioctl(pref, cmd, odict);
1012 prop_object_release(odict);
1023 lockinit(&udev_lk, "udevlk", 0, LK_CANRECURSE);
1025 TAILQ_INIT(&udev_evq);
1026 udev_event_kernel_cache = objcache_create_simple(M_UDEV, sizeof(struct udev_event_kernel));
1032 objcache_destroy(udev_event_kernel_cache);
1038 udev_dev = make_autoclone_dev(&udev_dev_ops, &DEVFS_CLONE_BITMAP(udev),
1040 UID_ROOT, GID_WHEEL, 0600, "udev");
1044 udev_dev_uninit(void)
1046 destroy_dev(udev_dev);
1049 SYSINIT(subr_udev_register, SI_SUB_CREATE_INIT, SI_ORDER_ANY,
1051 SYSUNINIT(subr_udev_register, SI_SUB_CREATE_INIT, SI_ORDER_ANY,
1053 SYSINIT(subr_udev_dev_register, SI_SUB_DRIVERS, SI_ORDER_ANY,
1054 udev_dev_init, NULL);
1055 SYSUNINIT(subr_udev_dev_register, SI_SUB_DRIVERS, SI_ORDER_ANY,
1056 udev_dev_uninit, NULL);