Skip to contentSkip to conversation

give may_open() a local 'mnt' variable

PATCH RESEND New Dave Hansen 1 participant 1 message Sep 20, 2007 VFS

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 3/25 give may_open() a local 'mnt' variable

First of all, this makes the structure jumping look a little bit cleaner. So, this stands alone as a tiny cleanup. But, we also need 'mnt' by itself a few more times later in this series, so this isn't _just_ a cleanup.

---

 lxc-dave/fs/namei.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/namei.c renamed from fs/namei.c~give-may_open-a-local-mnt-variable +5 -1
diff -puN fs/namei.c~give-may_open-a-local-mnt-variable fs/namei.c
@@ -230,6 +230,10 @@ int permission(struct inode *inode, int 
 {
 	umode_t mode = inode->i_mode;
 	int retval, submask;
+	struct vfsmount *mnt = NULL;
+
+	if (nd)
+		mnt = nd->mnt;
 
 	if (mask & MAY_WRITE) {
 
@@ -254,7 +258,7 @@ int permission(struct inode *inode, int 
 	 * the fs is mounted with the "noexec" flag.
 	 */
 	if ((mask & MAY_EXEC) && S_ISREG(mode) && (!(mode & S_IXUGO) ||
-			(nd && nd->mnt && (nd->mnt->mnt_flags & MNT_NOEXEC))))
+			(mnt && (mnt->mnt_flags & MNT_NOEXEC))))
 		return -EACCES;
 
 	/* Ordinary permission routines do not understand MAY_APPEND. */

_
-- Dave