Date: Sun, 30 Apr 2006 05:43:03 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 96396 for review Message-ID: <200604300543.k3U5h3lq044979@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=96396 Change 96396 by jb@jb_freebsd2 on 2006/04/30 05:42:27 Create all the dtrace device nodes below /dev/dtrace so that provides don't use the same name space as other devices. This exposes a quirk with the device cloning code. The first time after booting that /dev/dtrace/dtrace is opened, the clone function gets the name 'dtrace' it then creates /dev/dtrace/dtrace1. If the module is unloaded and reloaded, the next time that /dev/dtrace/dtrace is opened, the clone function gets the name 'dtrace/dtrace'. This is non-intuitive. Affected files ... .. //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_open.c#9 edit .. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_clone.c#4 edit Differences ... ==== //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_open.c#9 (text) ==== @@ -782,7 +782,7 @@ dfp->df_size = size; } - (void) snprintf(path, sizeof (path), "/dev/%s", p1); + (void) snprintf(path, sizeof (path), "/dev/dtrace/%s", p1); if ((fd = open(path, O_RDONLY)) == -1) continue; /* failed to open driver; just skip it */ @@ -919,17 +919,13 @@ */ dt_provmod_open(&provmod, &df); -#if defined(sun) dtfd = open("/dev/dtrace/dtrace", O_RDWR); -#else - dtfd = open("/dev/dtrace", O_RDWR | O_DEBUG); -#endif err = errno; /* save errno from opening dtfd */ #if defined(sun) ftfd = open("/dev/dtrace/provider/fasttrap", O_RDWR); #else - ftfd = open("/dev/fasttrap", O_RDWR); + ftfd = open("/dev/dtrace/fasttrap", O_RDWR); #endif fterr = ftfd == -1 ? errno : 0; /* save errno from open ftfd */ ==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_clone.c#4 (text+ko) ==== @@ -33,11 +33,20 @@ dtrace_clone(void *arg, struct ucred *cred, char *name, int namelen, struct cdev **dev) { int u; + size_t len; if (*dev != NULL) return; - if (strlen(name) != 6 || bcmp(name,"dtrace",6) != 0) + len = strlen(name); + + if (len != 6 && len != 13) + return; + + if (bcmp(name,"dtrace",6) != 0) + return; + + if (len == 13 && bcmp(name,"dtrace/dtrace",13) != 0) return; /* Allocate a unique minor number. */ @@ -45,9 +54,9 @@ /* Clone the device to the new minor number. */ if (clone_create(&dtrace_clones, &dtrace_cdevsw, &u, dev, 0) != 0) - /* Create the /dev/dtraceNN entry. */ + /* Create the /dev/dtrace/dtraceNN entry. */ *dev = make_dev_cred(&dtrace_cdevsw, unit2minor(u), cred, - UID_ROOT, GID_WHEEL, 0600, "dtrace%d", u); + UID_ROOT, GID_WHEEL, 0600, "dtrace/dtrace%d", u); if (*dev != NULL) { dev_ref(*dev); (*dev)->si_flags |= SI_CHEAPCLONE;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604300543.k3U5h3lq044979>