Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Feb 2012 12:35:57 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r231378 - in head/sys: compat/linux dev/iscsi/initiator dev/sound/pcm dev/usb dev/wtap netgraph security/mac_biba security/mac_lomac security/mac_mls vm
Message-ID:  <201202101235.q1ACZv2I073419@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Fri Feb 10 12:35:57 2012
New Revision: 231378
URL: http://svn.freebsd.org/changeset/base/231378

Log:
  Remove direct access to si_name.
  
  Code should just use the devtoname() function to obtain the name of a
  character device. Also add const keywords to pieces of code that need it
  to build properly.
  
  MFC after:	2 weeks

Modified:
  head/sys/compat/linux/linux_stats.c
  head/sys/compat/linux/linux_util.c
  head/sys/compat/linux/linux_util.h
  head/sys/dev/iscsi/initiator/isc_sm.c
  head/sys/dev/sound/pcm/mixer.c
  head/sys/dev/usb/usb_dev.c
  head/sys/dev/wtap/if_wtap.c
  head/sys/netgraph/ng_device.c
  head/sys/security/mac_biba/mac_biba.c
  head/sys/security/mac_lomac/mac_lomac.c
  head/sys/security/mac_mls/mac_mls.c
  head/sys/vm/swap_pager.c

Modified: head/sys/compat/linux/linux_stats.c
==============================================================================
--- head/sys/compat/linux/linux_stats.c	Fri Feb 10 12:01:19 2012	(r231377)
+++ head/sys/compat/linux/linux_stats.c	Fri Feb 10 12:35:57 2012	(r231378)
@@ -66,7 +66,7 @@ translate_vnhook_major_minor(struct vnod
 	int major, minor;
 
 	if (vp->v_type == VCHR && vp->v_rdev != NULL &&
-	    linux_driver_get_major_minor(vp->v_rdev->si_name,
+	    linux_driver_get_major_minor(devtoname(vp->v_rdev),
 	    &major, &minor) == 0) {
 		sb->st_rdev = (major << 8 | minor);
 	}
@@ -149,14 +149,14 @@ translate_fd_major_minor(struct thread *
 		return;
 	vp = fp->f_vnode;
 	if (vp != NULL && vp->v_rdev != NULL &&
-	    linux_driver_get_major_minor(vp->v_rdev->si_name,
+	    linux_driver_get_major_minor(devtoname(vp->v_rdev),
 					 &major, &minor) == 0) {
 		buf->st_rdev = (major << 8 | minor);
 	} else if (fp->f_type == DTYPE_PTS) {
 		struct tty *tp = fp->f_data;
 
 		/* Convert the numbers for the slave device. */
-		if (linux_driver_get_major_minor(tp->t_dev->si_name,
+		if (linux_driver_get_major_minor(devtoname(tp->t_dev),
 					 &major, &minor) == 0) {
 			buf->st_rdev = (major << 8 | minor);
 		}

Modified: head/sys/compat/linux/linux_util.c
==============================================================================
--- head/sys/compat/linux/linux_util.c	Fri Feb 10 12:01:19 2012	(r231377)
+++ head/sys/compat/linux/linux_util.c	Fri Feb 10 12:35:57 2012	(r231378)
@@ -124,7 +124,7 @@ linux_driver_get_name_dev(device_t dev)
 }
 
 int
-linux_driver_get_major_minor(char *node, int *major, int *minor)
+linux_driver_get_major_minor(const char *node, int *major, int *minor)
 {
 	struct device_element *de;
 

Modified: head/sys/compat/linux/linux_util.h
==============================================================================
--- head/sys/compat/linux/linux_util.h	Fri Feb 10 12:01:19 2012	(r231377)
+++ head/sys/compat/linux/linux_util.h	Fri Feb 10 12:35:57 2012	(r231378)
@@ -97,7 +97,7 @@ struct linux_device_handler {
 int	linux_device_register_handler(struct linux_device_handler *h);
 int	linux_device_unregister_handler(struct linux_device_handler *h);
 char	*linux_driver_get_name_dev(device_t dev);
-int	linux_driver_get_major_minor(char *node, int *major, int *minor);
+int	linux_driver_get_major_minor(const char *node, int *major, int *minor);
 char	*linux_get_char_devices(void);
 void	linux_free_get_char_devices(char *string);
 

Modified: head/sys/dev/iscsi/initiator/isc_sm.c
==============================================================================
--- head/sys/dev/iscsi/initiator/isc_sm.c	Fri Feb 10 12:01:19 2012	(r231377)
+++ head/sys/dev/iscsi/initiator/isc_sm.c	Fri Feb 10 12:35:57 2012	(r231378)
@@ -652,13 +652,13 @@ static void
 isc_add_sysctls(isc_session_t *sp)
 {
      debug_called(8);
-     sdebug(6, "sid=%d %s", sp->sid, sp->dev->si_name);
+     sdebug(6, "sid=%d %s", sp->sid, devtoname(sp->dev));
 
      sysctl_ctx_init(&sp->clist);
      sp->oid = SYSCTL_ADD_NODE(&sp->clist,
 			       SYSCTL_CHILDREN(sp->isc->oid),
 			       OID_AUTO,
-			       sp->dev->si_name+5, // iscsi0
+			       devtoname(sp->dev) + 5, // iscsi0
 			       CTLFLAG_RD,
 			       0,
 			       "initiator");

Modified: head/sys/dev/sound/pcm/mixer.c
==============================================================================
--- head/sys/dev/sound/pcm/mixer.c	Fri Feb 10 12:01:19 2012	(r231377)
+++ head/sys/dev/sound/pcm/mixer.c	Fri Feb 10 12:35:57 2012	(r231378)
@@ -1463,7 +1463,7 @@ mixer_oss_mixerinfo(struct cdev *i_dev, 
 			 *
 			 * XXX Described by Hannu@4Front, but not found in
 			 *     soundcard.h.
-			strlcpy(mi->devnode, d->mixer_dev->si_name,
+			strlcpy(mi->devnode, devtoname(d->mixer_dev),
 			sizeof(mi->devnode));
 			mi->legacy_device = i;
 			 */

Modified: head/sys/dev/usb/usb_dev.c
==============================================================================
--- head/sys/dev/usb/usb_dev.c	Fri Feb 10 12:01:19 2012	(r231377)
+++ head/sys/dev/usb/usb_dev.c	Fri Feb 10 12:35:57 2012	(r231378)
@@ -842,7 +842,7 @@ usb_open(struct cdev *dev, int fflags, i
 	struct usb_cdev_privdata *cpd;
 	int err, ep;
 
-	DPRINTFN(2, "%s fflags=0x%08x\n", dev->si_name, fflags);
+	DPRINTFN(2, "%s fflags=0x%08x\n", devtoname(dev), fflags);
 
 	KASSERT(fflags & (FREAD|FWRITE), ("invalid open flags"));
 	if (((fflags & FREAD) && !(pd->mode & FREAD)) ||

Modified: head/sys/dev/wtap/if_wtap.c
==============================================================================
--- head/sys/dev/wtap/if_wtap.c	Fri Feb 10 12:01:19 2012	(r231377)
+++ head/sys/dev/wtap/if_wtap.c	Fri Feb 10 12:35:57 2012	(r231378)
@@ -84,7 +84,7 @@ wtap_node_write(struct cdev *dev, struct
 	uint8_t buf[1024];
 	int buf_len;
 
-	uprintf("write device %s \"echo.\"\n", dev->si_name);
+	uprintf("write device %s \"echo.\"\n", devtoname(dev));
 	buf_len = MIN(uio->uio_iov->iov_len, 1024);
 	err = copyin(uio->uio_iov->iov_base, buf, buf_len);
 
@@ -101,7 +101,7 @@ wtap_node_write(struct cdev *dev, struct
 
 	TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
 		printf("ifp->if_xname = %s\n", ifp->if_xname);
-		if(strcmp(dev->si_name, ifp->if_xname) == 0){
+		if(strcmp(devtoname(dev), ifp->if_xname) == 0){
 			printf("found match, correspoding wtap = %s\n",
 			    ifp->if_xname);
 			sc = (struct wtap_softc *)ifp->if_softc;

Modified: head/sys/netgraph/ng_device.c
==============================================================================
--- head/sys/netgraph/ng_device.c	Fri Feb 10 12:01:19 2012	(r231377)
+++ head/sys/netgraph/ng_device.c	Fri Feb 10 12:35:57 2012	(r231378)
@@ -203,6 +203,7 @@ ng_device_rcvmsg(node_p node, item_p ite
 	const priv_p priv = NG_NODE_PRIVATE(node);
 	struct ng_mesg *msg;
 	struct ng_mesg *resp = NULL;
+	const char *dn;
 	int error = 0;
 
 	NGI_GET_MSG(item, msg);
@@ -217,8 +218,8 @@ ng_device_rcvmsg(node_p node, item_p ite
 			if (resp == NULL)
 				ERROUT(ENOMEM);
 
-			strlcpy((char *)resp->data, priv->ngddev->si_name,
-			    strlen(priv->ngddev->si_name) + 1);
+			dn = devtoname(priv->ngddev);
+			strlcpy((char *)resp->data, dn, strlen(dn) + 1);
 			break;
 
 		default:

Modified: head/sys/security/mac_biba/mac_biba.c
==============================================================================
--- head/sys/security/mac_biba/mac_biba.c	Fri Feb 10 12:01:19 2012	(r231377)
+++ head/sys/security/mac_biba/mac_biba.c	Fri Feb 10 12:35:57 2012	(r231378)
@@ -948,18 +948,20 @@ biba_devfs_create_device(struct ucred *c
     struct cdev *dev, struct devfs_dirent *de, struct label *delabel)
 {
 	struct mac_biba *mb;
+	const char *dn;
 	int biba_type;
 
 	mb = SLOT(delabel);
-	if (strcmp(dev->si_name, "null") == 0 ||
-	    strcmp(dev->si_name, "zero") == 0 ||
-	    strcmp(dev->si_name, "random") == 0 ||
-	    strncmp(dev->si_name, "fd/", strlen("fd/")) == 0)
+	dn = devtoname(dev);
+	if (strcmp(dn, "null") == 0 ||
+	    strcmp(dn, "zero") == 0 ||
+	    strcmp(dn, "random") == 0 ||
+	    strncmp(dn, "fd/", strlen("fd/")) == 0)
 		biba_type = MAC_BIBA_TYPE_EQUAL;
 	else if (ptys_equal &&
-	    (strncmp(dev->si_name, "ttyp", strlen("ttyp")) == 0 ||
-	    strncmp(dev->si_name, "pts/", strlen("pts/")) == 0 ||
-	    strncmp(dev->si_name, "ptyp", strlen("ptyp")) == 0))
+	    (strncmp(dn, "ttyp", strlen("ttyp")) == 0 ||
+	    strncmp(dn, "pts/", strlen("pts/")) == 0 ||
+	    strncmp(dn, "ptyp", strlen("ptyp")) == 0))
 		biba_type = MAC_BIBA_TYPE_EQUAL;
 	else
 		biba_type = MAC_BIBA_TYPE_HIGH;

Modified: head/sys/security/mac_lomac/mac_lomac.c
==============================================================================
--- head/sys/security/mac_lomac/mac_lomac.c	Fri Feb 10 12:01:19 2012	(r231377)
+++ head/sys/security/mac_lomac/mac_lomac.c	Fri Feb 10 12:35:57 2012	(r231378)
@@ -1032,19 +1032,21 @@ lomac_devfs_create_device(struct ucred *
     struct cdev *dev, struct devfs_dirent *de, struct label *delabel)
 {
 	struct mac_lomac *ml;
+	const char *dn;
 	int lomac_type;
 
 	ml = SLOT(delabel);
-	if (strcmp(dev->si_name, "null") == 0 ||
-	    strcmp(dev->si_name, "zero") == 0 ||
-	    strcmp(dev->si_name, "random") == 0 ||
-	    strncmp(dev->si_name, "fd/", strlen("fd/")) == 0 ||
-	    strncmp(dev->si_name, "ttyv", strlen("ttyv")) == 0)
+	dn = devtoname(dev);
+	if (strcmp(dn, "null") == 0 ||
+	    strcmp(dn, "zero") == 0 ||
+	    strcmp(dn, "random") == 0 ||
+	    strncmp(dn, "fd/", strlen("fd/")) == 0 ||
+	    strncmp(dn, "ttyv", strlen("ttyv")) == 0)
 		lomac_type = MAC_LOMAC_TYPE_EQUAL;
 	else if (ptys_equal &&
-	    (strncmp(dev->si_name, "ttyp", strlen("ttyp")) == 0 ||
-	    strncmp(dev->si_name, "pts/", strlen("pts/")) == 0 ||
-	    strncmp(dev->si_name, "ptyp", strlen("ptyp")) == 0))
+	    (strncmp(dn, "ttyp", strlen("ttyp")) == 0 ||
+	    strncmp(dn, "pts/", strlen("pts/")) == 0 ||
+	    strncmp(dn, "ptyp", strlen("ptyp")) == 0))
 		lomac_type = MAC_LOMAC_TYPE_EQUAL;
 	else
 		lomac_type = MAC_LOMAC_TYPE_HIGH;

Modified: head/sys/security/mac_mls/mac_mls.c
==============================================================================
--- head/sys/security/mac_mls/mac_mls.c	Fri Feb 10 12:01:19 2012	(r231377)
+++ head/sys/security/mac_mls/mac_mls.c	Fri Feb 10 12:35:57 2012	(r231378)
@@ -908,21 +908,23 @@ mls_devfs_create_device(struct ucred *cr
     struct cdev *dev, struct devfs_dirent *de, struct label *delabel)
 {
 	struct mac_mls *mm;
+	const char *dn;
 	int mls_type;
 
 	mm = SLOT(delabel);
-	if (strcmp(dev->si_name, "null") == 0 ||
-	    strcmp(dev->si_name, "zero") == 0 ||
-	    strcmp(dev->si_name, "random") == 0 ||
-	    strncmp(dev->si_name, "fd/", strlen("fd/")) == 0)
+	dn = devtoname(dev);
+	if (strcmp(dn, "null") == 0 ||
+	    strcmp(dn, "zero") == 0 ||
+	    strcmp(dn, "random") == 0 ||
+	    strncmp(dn, "fd/", strlen("fd/")) == 0)
 		mls_type = MAC_MLS_TYPE_EQUAL;
-	else if (strcmp(dev->si_name, "kmem") == 0 ||
-	    strcmp(dev->si_name, "mem") == 0)
+	else if (strcmp(dn, "kmem") == 0 ||
+	    strcmp(dn, "mem") == 0)
 		mls_type = MAC_MLS_TYPE_HIGH;
 	else if (ptys_equal &&
-	    (strncmp(dev->si_name, "ttyp", strlen("ttyp")) == 0 ||
-	    strncmp(dev->si_name, "pts/", strlen("pts/")) == 0 ||
-	    strncmp(dev->si_name, "ptyp", strlen("ptyp")) == 0))
+	    (strncmp(dn, "ttyp", strlen("ttyp")) == 0 ||
+	    strncmp(dn, "pts/", strlen("pts/")) == 0 ||
+	    strncmp(dn, "ptyp", strlen("ptyp")) == 0))
 		mls_type = MAC_MLS_TYPE_EQUAL;
 	else
 		mls_type = MAC_MLS_TYPE_LOW;

Modified: head/sys/vm/swap_pager.c
==============================================================================
--- head/sys/vm/swap_pager.c	Fri Feb 10 12:01:19 2012	(r231377)
+++ head/sys/vm/swap_pager.c	Fri Feb 10 12:35:57 2012	(r231378)
@@ -2320,7 +2320,7 @@ swapoff_all(void)
 	TAILQ_FOREACH_SAFE(sp, &swtailq, sw_list, spt) {
 		mtx_unlock(&sw_dev_mtx);
 		if (vn_isdisk(sp->sw_vp, NULL))
-			devname = sp->sw_vp->v_rdev->si_name;
+			devname = devtoname(sp->sw_vp->v_rdev);
 		else
 			devname = "[file]";
 		error = swapoff_one(sp, thread0.td_ucred);
@@ -2358,7 +2358,7 @@ int
 swap_dev_info(int name, struct xswdev *xs, char *devname, size_t len)
 {
 	struct swdevt *sp;
-	char *tmp_devname;
+	const char *tmp_devname;
 	int error, n;
 
 	n = 0;
@@ -2376,7 +2376,7 @@ swap_dev_info(int name, struct xswdev *x
 		xs->xsw_used = sp->sw_used;
 		if (devname != NULL) {
 			if (vn_isdisk(sp->sw_vp, NULL))
-				tmp_devname = sp->sw_vp->v_rdev->si_name;
+				tmp_devname = devtoname(sp->sw_vp->v_rdev);
 			else
 				tmp_devname = "[file]";
 			strncpy(devname, tmp_devname, len);



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