From beb29e058c35ab69e96e455a12ccf7505f6de425 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Tue, 1 Jul 2008 15:01:29 +0200 Subject: [patch 4/4] vfs: immutable inode checking cleanup Move the immutable and append-only checks from chmod, chown and utimes into notify_change(). Checks for immutable and append-only files are always performed by the VFS and not by the filesystem (see permission() and may_...() in namei.c), so these belong in notify_change(), and not in inode_change_ok(). This should be completely equivalent. CC: Ulrich Drepper CC: Michael Kerrisk Signed-off-by: Miklos Szeredi Signed-off-by: Al Viro --- fs/attr.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'fs/attr.c') diff --git a/fs/attr.c b/fs/attr.c index 765fc75fab3b..26c71ba1eed4 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -108,6 +108,11 @@ int notify_change(struct dentry * dentry, struct iattr * attr) struct timespec now; unsigned int ia_valid = attr->ia_valid; + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) { + if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) + return -EPERM; + } + now = current_fs_time(inode->i_sb); attr->ia_ctime = now; -- cgit v1.2.3