Re: HEADS UP - DEVFS ON MASTER

看板DFBSD_kernel作者時間16年前 (2009/08/05 19:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/8 (看更多)
Hi. Is there any policy on how device major/minor numbers are determined? I haven't gone through the devfs change, but `ls -l /dev' looks a bit weird :), in that most of device nodes have either 0 or 2 as their major number, and the minor number are rather high. I noticed that while I was trying to fix tap and vke. Somehow make_dev() seems to ignore the minor passed as its second argument. diff --git a/sys/net/tap/if_tap.c b/sys/net/tap/if_tap.c index 1e49439..3cacea9 100644 --- a/sys/net/tap/if_tap.c +++ b/sys/net/tap/if_tap.c @@ -211,7 +211,6 @@ tapmodevent(module_t mod, int type, void *data) static cdev_t tapcreate(int unit) { - cdev_t dev = NULL; struct ifnet *ifp = NULL; struct tap_softc *tp = NULL; uint8_t ether_addr[ETHER_ADDR_LEN]; @@ -235,9 +234,9 @@ tapcreate(int unit) } #endif - tp->tap_dev = make_dev(&tap_ops, minor(dev), UID_ROOT, GID_WHEEL, + tp->tap_dev = make_dev(&tap_ops, unit, UID_ROOT, GID_WHEEL, 0600, "%s%d", name, unit); - tp->tap_dev->si_drv1 = dev->si_drv1 = tp; + tp->tap_dev->si_drv1 = tp; reference_dev(tp->tap_dev); /* so we can destroy it later */ /* generate fake MAC address: 00 bd xx xx xx unit_no */ @@ -270,7 +269,7 @@ tapcreate(int unit) SLIST_INSERT_HEAD(&tap_listhead, tp, tap_link); TAPDEBUG(ifp, "created. minor = %#x\n", minor(tp->tap_dev)); - return dev; + return tp->tap_dev; } /* tapcreate */ /* diff --git a/sys/platform/vkernel/platform/init.c b/sys/platform/vkernel/platform/init.c index 2d3fd72..7caaf5b 100644 --- a/sys/platform/vkernel/platform/init.c +++ b/sys/platform/vkernel/platform/init.c @@ -955,9 +955,7 @@ netif_open_tap(const char *netif, int *tap_unit, int s) */ failed = 1; if (fstat(tap_fd, &st) == 0 && S_ISCHR(st.st_mode) && - TAPDEV_MAJOR(st.st_rdev) == TAP_CDEV_MAJOR) { - *tap_unit = TAPDEV_MINOR(st.st_rdev); - + sscanf(tap_dev, "/dev/tap%d", tap_unit) == 1) { /* * Bring up the corresponding tap(4) interface */
文章代碼(AID): #1AUMPp29 (DFBSD_kernel)
討論串 (同標題文章)
文章代碼(AID): #1AUMPp29 (DFBSD_kernel)