mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: akpm@linux-foundation.org
Cc: hch@infradead.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: [patch 1/5] VFS: pass open file to ->setattr()
Date: Fri, 21 Sep 2007 14:23:44 +0200	[thread overview]
Message-ID: <20070921123330.357683322@szeredi.hu> (raw)
In-Reply-To: <20070921122343.307289079@szeredi.hu>

[-- Attachment #1: vfs_setattr_file.patch --]
[-- Type: text/plain, Size: 3340 bytes --]

From: Miklos Szeredi <mszeredi@suse.cz>

Pass the open file into the filesystem's ->setattr() method for
fchmod, fchown and some of the utimes variants.

This is needed to be able to correctly implement open-unlink-fsetattr
semantics in some filesystem such as sshfs, without having to resort
to "silly-renaming".

The infrastructure is already there, so just need to fill in
attrs.ia_file and set ATTR_FILE in attrs.ia_valid.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---

Index: linux/fs/open.c
===================================================================
--- linux.orig/fs/open.c	2007-09-21 13:44:57.000000000 +0200
+++ linux/fs/open.c	2007-09-21 13:45:04.000000000 +0200
@@ -581,7 +581,8 @@ asmlinkage long sys_fchmod(unsigned int 
 	if (mode == (mode_t) -1)
 		mode = inode->i_mode;
 	newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
-	newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
+	newattrs.ia_valid = ATTR_MODE | ATTR_CTIME | ATTR_FILE;
+	newattrs.ia_file = file;
 	err = notify_change(dentry, &newattrs);
 	mutex_unlock(&inode->i_mutex);
 
@@ -631,7 +632,8 @@ asmlinkage long sys_chmod(const char __u
 	return sys_fchmodat(AT_FDCWD, filename, mode);
 }
 
-static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
+static int chown_common(struct dentry * dentry, uid_t user, gid_t group,
+			struct file *file)
 {
 	struct inode * inode;
 	int error;
@@ -660,6 +662,10 @@ static int chown_common(struct dentry * 
 	if (!S_ISDIR(inode->i_mode))
 		newattrs.ia_valid |=
 			ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV;
+	if (file) {
+		newattrs.ia_file = file;
+		newattrs.ia_valid |= ATTR_FILE;
+	}
 	mutex_lock(&inode->i_mutex);
 	error = notify_change(dentry, &newattrs);
 	mutex_unlock(&inode->i_mutex);
@@ -675,7 +681,7 @@ asmlinkage long sys_chown(const char __u
 	error = user_path_walk(filename, &nd);
 	if (error)
 		goto out;
-	error = chown_common(nd.dentry, user, group);
+	error = chown_common(nd.dentry, user, group, NULL);
 	path_release(&nd);
 out:
 	return error;
@@ -695,7 +701,7 @@ asmlinkage long sys_fchownat(int dfd, co
 	error = __user_walk_fd(dfd, filename, follow, &nd);
 	if (error)
 		goto out;
-	error = chown_common(nd.dentry, user, group);
+	error = chown_common(nd.dentry, user, group, NULL);
 	path_release(&nd);
 out:
 	return error;
@@ -709,7 +715,7 @@ asmlinkage long sys_lchown(const char __
 	error = user_path_walk_link(filename, &nd);
 	if (error)
 		goto out;
-	error = chown_common(nd.dentry, user, group);
+	error = chown_common(nd.dentry, user, group, NULL);
 	path_release(&nd);
 out:
 	return error;
@@ -728,7 +734,7 @@ asmlinkage long sys_fchown(unsigned int 
 
 	dentry = file->f_path.dentry;
 	audit_inode(NULL, dentry);
-	error = chown_common(dentry, user, group);
+	error = chown_common(dentry, user, group, file);
 	fput(file);
 out:
 	return error;
Index: linux/fs/utimes.c
===================================================================
--- linux.orig/fs/utimes.c	2007-09-21 13:44:57.000000000 +0200
+++ linux/fs/utimes.c	2007-09-21 13:45:04.000000000 +0200
@@ -130,6 +130,10 @@ long do_utimes(int dfd, char __user *fil
 			}
 		}
 	}
+	if (f) {
+		newattrs.ia_file = f;
+		newattrs.ia_valid |= ATTR_FILE;
+	}
 	mutex_lock(&inode->i_mutex);
 	error = notify_change(dentry, &newattrs);
 	mutex_unlock(&inode->i_mutex);

--

  reply	other threads:[~2007-09-21 12:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-21 12:23 [patch 0/5] VFS changes Miklos Szeredi
2007-09-21 12:23 ` Miklos Szeredi [this message]
2007-09-21 12:23 ` [patch 2/5] VFS: pass open file to ->getattr() Miklos Szeredi
2007-09-21 18:37   ` Andreas Dilger
2007-09-21 21:07     ` Miklos Szeredi
2007-09-21 12:23 ` [patch 3/5] VFS: pass open file to ->xattr() Miklos Szeredi
2007-09-21 12:43   ` Christoph Hellwig
2007-09-21 13:00     ` Miklos Szeredi
2007-09-21 13:06       ` Christoph Hellwig
2007-09-21 13:16         ` Miklos Szeredi
2007-09-21 14:32           ` Trond Myklebust
2007-09-21 14:34             ` Christoph Hellwig
2007-09-21 14:59               ` Miklos Szeredi
2007-09-21 18:44                 ` Andreas Dilger
2007-09-21 21:15                   ` Miklos Szeredi
2007-09-21 14:43             ` Miklos Szeredi
2007-09-21 18:39   ` Andreas Dilger
2007-09-21 12:23 ` [patch 4/5] VFS: allow filesystems to implement atomic open+truncate Miklos Szeredi
2007-09-21 12:44   ` Christoph Hellwig
2007-09-21 13:01     ` Miklos Szeredi
2007-09-21 18:47   ` Andreas Dilger
2007-09-21 12:23 ` [patch 5/5] VFS: allow filesystem to override mknod capability checks Miklos Szeredi
2007-09-21 12:45   ` Christoph Hellwig
2007-09-21 13:10     ` Miklos Szeredi
2007-09-21 13:14       ` Christoph Hellwig
2007-09-21 13:18         ` Miklos Szeredi
2007-09-21 14:33           ` Christoph Hellwig
2007-09-21 14:48             ` Miklos Szeredi
2007-09-21 14:53               ` Christoph Hellwig
2007-09-21 15:11                 ` Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070921123330.357683322@szeredi.hu \
    --to=miklos@szeredi.hu \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®