Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 May 2012 17:32:32 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Alexander Motin <mav@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r235911 - in head: share/examples/ses share/examples/ses/srcs sys/cam/scsi sys/conf sys/fs/devfs sys/modules/cam usr.bin/kdump
Message-ID:  <20120524143232.GM2358@deviant.kiev.zoral.com.ua>
In-Reply-To: <201205241407.q4OE7i47042313@svn.freebsd.org>
References:  <201205241407.q4OE7i47042313@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--3ALZ8E19BIoSIFJn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, May 24, 2012 at 02:07:44PM +0000, Alexander Motin wrote:
> Author: mav
> Date: Thu May 24 14:07:44 2012
> New Revision: 235911
> URL: http://svn.freebsd.org/changeset/base/235911
>=20
> Log:
>   MFprojects/zfsd:
>   Revamp the CAM enclosure services driver.
>   This updated driver uses an in-kernel daemon to track state changes and
>   publishes physical path location information\for disk elements into the
>   CAM device database.
>  =20
>   Sponsored by:   Spectra Logic Corporation
>   Sponsored by:   iXsystems, Inc.
>   Submitted by:   gibbs, will, mav
>=20
> Added:
>   head/sys/cam/scsi/scsi_enc.c   (contents, props changed)
>   head/sys/cam/scsi/scsi_enc.h   (contents, props changed)
>   head/sys/cam/scsi/scsi_enc_internal.h   (contents, props changed)
>   head/sys/cam/scsi/scsi_enc_safte.c   (contents, props changed)
>   head/sys/cam/scsi/scsi_enc_ses.c   (contents, props changed)
> Deleted:
>   head/sys/cam/scsi/scsi_ses.c
> Modified:
>   head/share/examples/ses/Makefile.inc
>   head/share/examples/ses/srcs/eltsub.c
>   head/share/examples/ses/srcs/getencstat.c
>   head/share/examples/ses/srcs/getnobj.c
>   head/share/examples/ses/srcs/getobjmap.c
>   head/share/examples/ses/srcs/getobjstat.c
>   head/share/examples/ses/srcs/inienc.c
>   head/share/examples/ses/srcs/sesd.c
>   head/share/examples/ses/srcs/setencstat.c
>   head/share/examples/ses/srcs/setobjstat.c
>   head/sys/cam/scsi/scsi_ses.h
>   head/sys/conf/files
>   head/sys/fs/devfs/devfs_vnops.c
>   head/sys/modules/cam/Makefile
>   head/usr.bin/kdump/mkioctls

The devfs change should have been committed separately. Also, I do not
see why devfs should do this to aliases at all. Also, your change only
handles jails and not chroots, why ?


Index: devfs_vnops.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- devfs_vnops.c	(revision 235910)
+++ devfs_vnops.c	(revision 235911)
@@ -1266,8 +1266,53 @@ static int
 devfs_readlink(struct vop_readlink_args *ap)
 {
 	struct devfs_dirent *de;
+	struct cdev_priv *cdp;
=20
 	de =3D ap->a_vp->v_data;
+	cdp =3D de->de_cdp;
+
+	if (cdp !=3D NULL && (cdp->cdp_c.si_flags & SI_ALIAS) !=3D 0) {
+		struct devfs_mount *dmp;
+		struct prison *pr;
+		char *mp;
+		int mp_len;
+		int pr_path_len;
+		int err;
The declarations should be placed at the start of the function, not
at the start of the block.

+
+		/*
+		 * For device aliases, construct an absolute symlink (to
+		 * shorten its length and avoid the ugliness of a relative
+		 * link) by prepending the fully qualified path to the root
+		 * of this devfs.  For a non-jailed process, the devfs root
+		 * is our mount point.  For a jailed process, we must remove
+		 * any jail prefix in our mount point so that our response
+		 * matches the user process's world view.
+		 */
+		dmp =3D VFSTODEVFS(ap->a_vp->v_mount);
+		mp =3D dmp->dm_mount->mnt_stat.f_mntonname;
+		mp_len =3D strlen(mp);
+
+		pr =3D ap->a_cred->cr_prison;
+		pr_path_len =3D strlen(pr->pr_path);
+
+		if (strncmp(pr->pr_path, mp, pr_path_len) =3D=3D 0
+		 && mp[pr_path_len] =3D=3D '/') {
Style prefers to put '&&' on the first line, and not on the continuation
line.

I suspect that you may access mp past the end of its memory there, no ?

+			mp +=3D pr_path_len;
+			mp_len -=3D pr_path_len;
+		}
+
+		err =3D uiomove(mp, mp_len, ap->a_uio);
+		if (err !=3D 0)
+			return (err);
+
+		/*
+		 * Devfs cannot be the root file system, so its
+		 * mount point must always be terminated by a '/'.
+		 */
+		err =3D uiomove("/", 1, ap->a_uio);
+		if (err !=3D 0)
+			return (err);
+	}
 	return (uiomove(de->de_symlink, strlen(de->de_symlink), ap->a_uio));
 }
=20

--3ALZ8E19BIoSIFJn
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (FreeBSD)

iEYEARECAAYFAk++RoAACgkQC3+MBN1Mb4gqeQCaA6EWcqa8XjZJ1CXvzcJ5eTcC
nKkAn1Spf4091kLGqz3FKcUCpSsg3krT
=UtQq
-----END PGP SIGNATURE-----

--3ALZ8E19BIoSIFJn--



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