Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Aug 2005 15:54:31 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 81605 for review
Message-ID:  <200508071554.j77FsVeP096889@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=81605

Change 81605 by rwatson@rwatson_peppercorn on 2005/08/07 15:53:56

	Replace clone_dev with clone_dev_cred, rather than supplementing
	it, in order to avoid multiple event handlers for device cloning.
	
	Requested by:	phk

Affected files ...

.. //depot/projects/trustedbsd/mac/sys/cam/scsi/scsi_target.c#16 edit
.. //depot/projects/trustedbsd/mac/sys/coda/coda_fbsd.c#13 edit
.. //depot/projects/trustedbsd/mac/sys/dev/firewire/firewirereg.h#17 edit
.. //depot/projects/trustedbsd/mac/sys/dev/firewire/fwdev.c#17 edit
.. //depot/projects/trustedbsd/mac/sys/dev/nmdm/nmdm.c#14 edit
.. //depot/projects/trustedbsd/mac/sys/dev/snp/snp.c#16 edit
.. //depot/projects/trustedbsd/mac/sys/dev/sound/pcm/dsp.c#17 edit
.. //depot/projects/trustedbsd/mac/sys/dev/sound/pcm/mixer.c#13 edit
.. //depot/projects/trustedbsd/mac/sys/dev/vkbd/vkbd.c#5 edit
.. //depot/projects/trustedbsd/mac/sys/fs/devfs/devfs_vnops.c#59 edit
.. //depot/projects/trustedbsd/mac/sys/kern/tty_pty.c#21 edit
.. //depot/projects/trustedbsd/mac/sys/kern/tty_tty.c#23 edit
.. //depot/projects/trustedbsd/mac/sys/net/bpf.c#39 edit
.. //depot/projects/trustedbsd/mac/sys/net/if_tap.c#25 edit
.. //depot/projects/trustedbsd/mac/sys/net/if_tun.c#33 edit
.. //depot/projects/trustedbsd/mac/sys/netsmb/smb_dev.c#18 edit
.. //depot/projects/trustedbsd/mac/sys/sys/conf.h#27 edit

Differences ...

==== //depot/projects/trustedbsd/mac/sys/cam/scsi/scsi_target.c#16 (text+ko) ====

@@ -141,8 +141,8 @@
 static struct targ_cmd_descr *
 			targgetdescr(struct targ_softc *softc);
 static periph_init_t	targinit;
-static void		targclone(void *arg, char *name, int namelen,
-				  struct cdev **dev);
+static void		targclone(void *arg, struct ucred *cred, char *name,
+				  int namelen, struct cdev **dev);
 static void		targasync(void *callback_arg, u_int32_t code,
 				  struct cam_path *path, void *arg);
 static void		abort_all_pending(struct targ_softc *softc);
@@ -1025,7 +1025,8 @@
 }
 
 static void
-targclone(void *arg, char *name, int namelen, struct cdev **dev)
+targclone(void *arg, struct ucred *cred, char *name, int namelen,
+    struct cdev **dev)
 {
 	int u;
 

==== //depot/projects/trustedbsd/mac/sys/coda/coda_fbsd.c#13 (text+ko) ====

@@ -70,8 +70,8 @@
 #define VCDEBUG if (vcdebug) printf
 
 /* for DEVFS, using bpf & tun drivers as examples*/
-static void coda_fbsd_clone(void *arg, char *name, int namelen,
-    struct cdev **dev);
+static void coda_fbsd_clone(void *arg, struct ucred *cred, char *name,
+    int namelen, struct cdev **dev);
 
 static int
 codadev_modevent(module_t mod, int type, void *data)
@@ -105,8 +105,9 @@
 };
 DECLARE_MODULE(codadev, codadev_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
 
-static void coda_fbsd_clone(arg, name, namelen, dev)
+static void coda_fbsd_clone(arg, cred, name, namelen, dev)
     void *arg;
+    struct ucred *cred;
     char *name;
     int namelen;
     struct cdev **dev;

==== //depot/projects/trustedbsd/mac/sys/dev/firewire/firewirereg.h#17 (text+ko) ====

@@ -303,7 +303,7 @@
 void fw_drain_txq (struct firewire_comm *);
 int fwdev_makedev (struct firewire_softc *);
 int fwdev_destroydev (struct firewire_softc *);
-void fwdev_clone (void *, char *, int, struct cdev **);
+void fwdev_clone (void *, struct ucred *, char *, int, struct cdev **);
 
 extern int firewire_debug;
 extern devclass_t firewire_devclass;

==== //depot/projects/trustedbsd/mac/sys/dev/firewire/fwdev.c#17 (text+ko) ====

@@ -840,7 +840,8 @@
 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
 #define NDEVTYPE 2
 void
-fwdev_clone(void *arg, char *name, int namelen, struct cdev **dev)
+fwdev_clone(void *arg, struct ucred *cred, char *name, int namelen,
+    struct cdev **dev)
 {
 	struct firewire_softc *sc;
 	char *devnames[NDEVTYPE] = {"fw", "fwmem"};

==== //depot/projects/trustedbsd/mac/sys/dev/nmdm/nmdm.c#14 (text+ko) ====

@@ -104,7 +104,8 @@
 static TAILQ_HEAD(,nm_softc) nmdmhead = TAILQ_HEAD_INITIALIZER(nmdmhead);
 
 static void
-nmdm_clone(void *arg, char *name, int nameen, struct cdev **dev)
+nmdm_clone(void *arg, struct ucred *cred, char *name, int nameen,
+    struct cdev **dev)
 {
 	int i, unit;
 	char *p;

==== //depot/projects/trustedbsd/mac/sys/dev/snp/snp.c#16 (text+ko) ====

@@ -114,7 +114,7 @@
 static struct clonedevs	  *snpclones;
 
 static struct tty	*snpdevtotty(struct cdev *dev);
-static void		snp_clone(void *arg, char *name,
+static void		snp_clone(void *arg, struct ucred *cred, char *name,
 			    int namelen, struct cdev **dev);
 static int		snp_detach(struct snoop *snp);
 static int		snp_down(struct snoop *snp);
@@ -627,8 +627,9 @@
 }
 
 static void
-snp_clone(arg, name, namelen, dev)
+snp_clone(arg, cred, name, namelen, dev)
 	void *arg;
+	struct ucred *cred;
 	char *name;
 	int namelen;
 	struct cdev **dev;

==== //depot/projects/trustedbsd/mac/sys/dev/sound/pcm/dsp.c#17 (text+ko) ====

@@ -1123,7 +1123,8 @@
  *    	if xN.i isn't busy, return its dev_t
  */
 static void
-dsp_clone(void *arg, char *name, int namelen, struct cdev **dev)
+dsp_clone(void *arg, struct ucred *cred, char *name, int namelen,
+    struct cdev **dev)
 {
 	struct cdev *pdev;
 	struct snddev_info *pcm_dev;

==== //depot/projects/trustedbsd/mac/sys/dev/sound/pcm/mixer.c#13 (text+ko) ====

@@ -486,7 +486,8 @@
 
 #ifdef USING_DEVFS
 static void
-mixer_clone(void *arg, char *name, int namelen, struct cdev **dev)
+mixer_clone(void *arg, struct ucred *cred, char *name, int namelen,
+    struct cdev **dev)
 {
 	struct snddev_info *sd;
 

==== //depot/projects/trustedbsd/mac/sys/dev/vkbd/vkbd.c#5 (text+ko) ====

@@ -124,7 +124,8 @@
  *****************************************************************************
  *****************************************************************************/
 
-static void		vkbd_dev_clone(void *, char *, int, struct cdev **);
+static void		vkbd_dev_clone(void *, struct ucred *, char *, int,
+			    struct cdev **);
 static d_open_t		vkbd_dev_open;
 static d_close_t	vkbd_dev_close;
 static d_read_t		vkbd_dev_read;
@@ -152,7 +153,8 @@
 
 /* Clone device */
 static void
-vkbd_dev_clone(void *arg, char *name, int namelen, struct cdev **dev)
+vkbd_dev_clone(void *arg, struct ucred *cred, char *name, int namelen,
+    struct cdev **dev)
 {
 	int	unit;
 

==== //depot/projects/trustedbsd/mac/sys/fs/devfs/devfs_vnops.c#59 (text+ko) ====

@@ -703,13 +703,10 @@
 		goto notfound;
 
 	cdev = NULL;
-	EVENTHANDLER_INVOKE(dev_clone_cred, td->td_ucred, pname,
-	    strlen(pname), &cdev);
-	if (cdev == NULL) {
-		EVENTHANDLER_INVOKE(dev_clone, pname, strlen(pname), &cdev);
-		if (cdev == NULL)
-			goto notfound;
-	}
+	EVENTHANDLER_INVOKE(dev_clone, td->td_ucred, pname, strlen(pname),
+	    &cdev);
+	if (cdev == NULL)
+		goto notfound;
 
 	devfs_populate(dmp);
 

==== //depot/projects/trustedbsd/mac/sys/kern/tty_pty.c#21 (text+ko) ====

@@ -720,7 +720,7 @@
 ptc_drvinit(void *unused)
 {
 
-	EVENTHANDLER_REGISTER(dev_clone_cred, pty_clone, 0, 1000);
+	EVENTHANDLER_REGISTER(dev_clone, pty_clone, 0, 1000);
 }
 
 SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE,ptc_drvinit,NULL)

==== //depot/projects/trustedbsd/mac/sys/kern/tty_tty.c#23 (text+ko) ====

@@ -52,7 +52,8 @@
 }
 
 static void
-ctty_clone(void *arg, char *name, int namelen, struct cdev **dev)
+ctty_clone(void *arg, struct ucred *cred, char *name, int namelen,
+    struct cdev **dev)
 {
 
 	if (*dev != NULL)

==== //depot/projects/trustedbsd/mac/sys/net/bpf.c#39 (text+ko) ====

@@ -121,7 +121,7 @@
 static void	filt_bpfdetach(struct knote *);
 static int	filt_bpfread(struct knote *, long);
 static void	bpf_drvinit(void *);
-static void	bpf_clone(void *, char *, int, struct cdev **);
+static void	bpf_clone(void *, struct ucred *, char *, int, struct cdev **);
 
 static	d_open_t	bpfopen;
 static	d_close_t	bpfclose;
@@ -1602,8 +1602,9 @@
 }
 
 static void
-bpf_clone(arg, name, namelen, dev)
+bpf_clone(arg, cred, name, namelen, dev)
 	void *arg;
+	struct ucred *cred;
 	char *name;
 	int namelen;
 	struct cdev **dev;

==== //depot/projects/trustedbsd/mac/sys/net/if_tap.c#25 (text+ko) ====

@@ -82,7 +82,8 @@
 static int		tapmodevent(module_t, int, void *);
 
 /* device */
-static void		tapclone(void *, char *, int, struct cdev **);
+static void		tapclone(void *, struct ucred *, char *, int,
+			    struct cdev **);
 static void		tapcreate(struct cdev *);
 
 /* network interface */
@@ -231,8 +232,9 @@
  * We need to support two kind of devices - tap and vmnet
  */
 static void
-tapclone(arg, name, namelen, dev)
+tapclone(arg, cred, name, namelen, dev)
 	void	*arg;
+	struct ucred *cred;
 	char	*name;
 	int	 namelen;
 	struct cdev **dev;

==== //depot/projects/trustedbsd/mac/sys/net/if_tun.c#33 (text+ko) ====

@@ -114,7 +114,8 @@
 static TAILQ_HEAD(,tun_softc)	tunhead = TAILQ_HEAD_INITIALIZER(tunhead);
 SYSCTL_INT(_debug, OID_AUTO, if_tun_debug, CTLFLAG_RW, &tundebug, 0, "");
 
-static void	tunclone(void *arg, char *name, int namelen, struct cdev **dev);
+static void	tunclone(void *arg, struct ucred *cred, char *name,
+		    int namelen, struct cdev **dev);
 static void	tuncreate(struct cdev *dev);
 static int	tunifioctl(struct ifnet *, u_long, caddr_t);
 static int	tuninit(struct ifnet *);
@@ -143,7 +144,8 @@
 };
 
 static void
-tunclone(void *arg, char *name, int namelen, struct cdev **dev)
+tunclone(void *arg, struct ucred *cred, char *name, int namelen,
+    struct cdev **dev)
 {
 	int u, i;
 

==== //depot/projects/trustedbsd/mac/sys/netsmb/smb_dev.c#18 (text+ko) ====

@@ -99,7 +99,8 @@
 static eventhandler_tag nsmb_dev_tag;
 
 static void
-nsmb_dev_clone(void *arg, char *name, int namelen, struct cdev **dev)
+nsmb_dev_clone(void *arg, struct ucred *cred, char *name, int namelen,
+    struct cdev **dev)
 {
 	int u;
 

==== //depot/projects/trustedbsd/mac/sys/sys/conf.h#27 (text+ko) ====

@@ -68,7 +68,7 @@
 	uid_t		si_uid;
 	gid_t		si_gid;
 	mode_t		si_mode;
-	struct ucred	*si_cred;
+	struct ucred	*si_cred;	/* cached clone-time credential */
 	u_int		si_drv0;
 	int		si_refcount;
 	LIST_ENTRY(cdev)	si_list;
@@ -279,15 +279,12 @@
 #define		GID_GAMES	13
 #define		GID_DIALER	68
 
-typedef void (*dev_clone_fn)(void *arg, char *name, int namelen, struct cdev **result);
+typedef void (*dev_clone_fn)(void *arg, struct ucred *cred, char *name,
+	    int namelen, struct cdev **result);
 
 int dev_stdclone(char *_name, char **_namep, const char *_stem, int *_unit);
 EVENTHANDLER_DECLARE(dev_clone, dev_clone_fn);
 
-typedef void (*dev_clone_cred_fn)(void *arg, struct ucred *cred, char *name,
-	int namelen, struct cdev **result);
-EVENTHANDLER_DECLARE(dev_clone_cred, dev_clone_cred_fn);
-
 /* Stuff relating to kernel-dump */
 
 struct dumperinfo {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508071554.j77FsVeP096889>