[PATCH 34/38] union-mount: Implement union-aware chmod()/fchmodat()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Valerie Aurora
Date: Tuesday, June 15, 2010 - 11:40 am

---
 fs/open.c |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/fs/open.c b/fs/open.c
index 3c1ae55..336fe01 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -669,18 +669,32 @@ out:
 SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, mode_t, mode)
 {
 	struct path path;
+	struct nameidata nd;
+	struct vfsmount *mnt;
 	struct inode *inode;
+	char *tmp;
 	int error;
 	struct iattr newattrs;
 
-	error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
+	error = user_path_nd(dfd, filename, LOOKUP_FOLLOW, &nd,
+				     &path, &tmp);
 	if (error)
 		goto out;
-	inode = path.dentry->d_inode;
 
-	error = mnt_want_write(path.mnt);
+	if (IS_DIR_UNIONED(nd.path.dentry))
+		mnt = nd.path.mnt;
+	else
+		mnt = path.mnt;
+
+	error = mnt_want_write(mnt);
 	if (error)
 		goto dput_and_out;
+
+	error = union_copyup(&nd, &path);
+	if (error)
+		goto mnt_drop_write_and_out;
+
+	inode = path.dentry->d_inode;
 	mutex_lock(&inode->i_mutex);
 	error = security_path_chmod(path.dentry, path.mnt, mode);
 	if (error)
@@ -692,9 +706,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, mode_t, mode)
 	error = notify_change(path.dentry, &newattrs);
 out_unlock:
 	mutex_unlock(&inode->i_mutex);
-	mnt_drop_write(path.mnt);
+mnt_drop_write_and_out:
+	mnt_drop_write(mnt);
 dput_and_out:
 	path_put(&path);
+	path_put(&nd.path);
+	putname(tmp);
 out:
 	return error;
 }
-- 
1.6.3.3

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/38] Union mounts - union stack as linked list, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 01/38] VFS: Comment follow_mount() and friends, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 02/38] VFS: Make lookup_hash() return a struct path, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 03/38] VFS: Add read-only users count to superblock, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 09/38] whiteout: tmpfs whiteout support, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 11/38] whiteout: ext2 whiteout support, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 12/38] whiteout: jffs2 whiteout support, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 14/38] fallthru: ext2 fallthru support, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 16/38] fallthru: tmpfs fallthru support, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 17/38] union-mount: Union mounts documentation, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 22/38] union-mount: Implement union lookup, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 27/38] union-mount: In-kernel file copyup routines, Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 29/38] union-mount: Implement union-aware link(), Valerie Aurora, (Tue Jun 15, 11:39 am)
[PATCH 30/38] union-mount: Implement union-aware rename(), Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 32/38] union-mount: Implement union-aware chown(), Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 33/38] union-mount: Implement union-aware truncate(), Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 34/38] union-mount: Implement union-aware chmod()/f ..., Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 35/38] union-mount: Implement union-aware lchown(), Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 36/38] union-mount: Implement union-aware utimensat(), Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 37/38] union-mount: Implement union-aware setxattr(), Valerie Aurora, (Tue Jun 15, 11:40 am)
[PATCH 38/38] union-mount: Implement union-aware lsetxattr(), Valerie Aurora, (Tue Jun 15, 11:40 am)
Re: [PATCH 17/38] union-mount: Union mounts documentation, Valerie Aurora, (Thu Jun 17, 11:39 am)
Re: [PATCH 17/38] union-mount: Union mounts documentation, Valerie Aurora, (Fri Jun 18, 2:06 pm)
Re: [PATCH 17/38] union-mount: Union mounts documentation, Miklos Szeredi, (Mon Jun 21, 6:14 am)
Re: [PATCH 17/38] union-mount: Union mounts documentation, Valerie Aurora, (Mon Jun 21, 4:17 pm)
Re: [PATCH 11/38] whiteout: ext2 whiteout support, Ian Kent, (Mon Jul 12, 9:24 pm)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Ian Kent, (Mon Jul 12, 9:30 pm)
Re: [PATCH 22/38] union-mount: Implement union lookup, Valerie Aurora, (Mon Jul 19, 2:58 pm)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Miklos Szeredi, (Wed Aug 4, 7:44 am)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Valerie Aurora, (Wed Aug 4, 3:48 pm)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Miklos Szeredi, (Thu Aug 5, 3:36 am)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Miklos Szeredi, (Thu Aug 5, 4:13 am)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Valerie Aurora, (Thu Aug 5, 4:30 pm)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Valerie Aurora, (Fri Aug 6, 10:12 am)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Valerie Aurora, (Fri Aug 6, 10:16 am)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Miklos Szeredi, (Fri Aug 6, 10:44 am)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Valerie Aurora, (Tue Aug 17, 3:27 pm)
Re: [PATCH 14/38] fallthru: ext2 fallthru support, Miklos Szeredi, (Wed Aug 18, 1:26 am)