From owner-p4-projects@FreeBSD.ORG Sun Apr 30 05:43:11 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 21E0116A400; Sun, 30 Apr 2006 05:43:05 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 93E4A16A401 for ; Sun, 30 Apr 2006 05:43:04 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 12E7943D4C for ; Sun, 30 Apr 2006 05:43:04 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3U5h3vU044985 for ; Sun, 30 Apr 2006 05:43:03 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3U5h3lq044979 for perforce@freebsd.org; Sun, 30 Apr 2006 05:43:03 GMT (envelope-from jb@freebsd.org) Date: Sun, 30 Apr 2006 05:43:03 GMT Message-Id: <200604300543.k3U5h3lq044979@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 96396 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Apr 2006 05:43:11 -0000 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;