Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Jan 2009 14:05:55 +0000
From:      Andrew Brampton <brampton+freebsd-fs@gmail.com>
To:        =?UTF-8?Q?Dag=2DErling_Sm=C3=B8rgrav?= <des@des.no>,  freebsd-fs <freebsd-fs@freebsd.org>
Subject:   Re: Pseudofs and pfs_attr_t for non-process based files
Message-ID:  <d41814900901230605o7a65efb3m4b6b99e9b171f1b7@mail.gmail.com>
In-Reply-To: <86iqo74ba1.fsf@ds4.des.no>
References:  <d41814900901181701n7928e40cv2aa1dc4dff582fda@mail.gmail.com> <868wp4pqwm.fsf@ds4.des.no> <d41814900901210937y390cdff3pf6a9551df2c4bcd3@mail.gmail.com> <86iqo74ba1.fsf@ds4.des.no>

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

[-- Attachment #1 --]
2009/1/22 Dag-Erling Smørgrav <des@des.no>:
> In procfs_attr(), the vap->va_[ug]id assignments are redundant, since at
> this point pfs_getattr() has already done the exact same thing.  The
> rest of the patch is fine, modulo style issues which already existed in
> my code.

Here are both patches again, but only the procfs patch has changed. I
have now removed the redundant code.

thanks
Andrew

[-- Attachment #2 --]
Index: sys/fs/pseudofs/pseudofs_vnops.c
===================================================================
--- sys/fs/pseudofs/pseudofs_vnops.c	(revision 187415)
+++ sys/fs/pseudofs/pseudofs_vnops.c	(working copy)
@@ -226,14 +226,17 @@ pfs_getattr(struct vop_getattr_args *va)
 	if (proc != NULL) {
 		vap->va_uid = proc->p_ucred->cr_ruid;
 		vap->va_gid = proc->p_ucred->cr_rgid;
-		if (pn->pn_attr != NULL)
-			error = pn_attr(curthread, proc, pn, vap);
-		PROC_UNLOCK(proc);
 	} else {
 		vap->va_uid = 0;
 		vap->va_gid = 0;
 	}
 
+	if (pn->pn_attr != NULL)
+		error = pn_attr(curthread, proc, pn, vap);
+
+	if(proc != NULL)
+		PROC_UNLOCK(proc);
+
 	PFS_RETURN (error);
 }
 

[-- Attachment #3 --]
Index: sys/fs/procfs/procfs.c
===================================================================
--- sys/fs/procfs/procfs.c	(revision 187415)
+++ sys/fs/procfs/procfs.c	(working copy)
@@ -99,7 +99,6 @@ procfs_docurproc(PFS_FILL_ARGS)
 int
 procfs_attr(PFS_ATTR_ARGS)
 {
-	PROC_LOCK_ASSERT(p, MA_OWNED);
 
 	/* XXX inefficient, split into separate functions */
 	if (strcmp(pn->pn_name, "ctl") == 0 ||
@@ -112,11 +111,12 @@ procfs_attr(PFS_ATTR_ARGS)
 	    strcmp(pn->pn_name, "fpregs") == 0)
 		vap->va_mode = 0600;
 
-	if ((p->p_flag & P_SUGID) && pn->pn_type != pfstype_procdir)
-		vap->va_mode = 0;
+	if (p != NULL) {
+		PROC_LOCK_ASSERT(p, MA_OWNED);
 
-	vap->va_uid = p->p_ucred->cr_uid;
-	vap->va_gid = p->p_ucred->cr_gid;
+		if ((p->p_flag & P_SUGID) && pn->pn_type != pfstype_procdir)
+			vap->va_mode = 0;
+	}
 
 	return (0);
 }

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