]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs: add a vfs_fchmod helper
authorChristoph Hellwig <hch@lst.de>
Tue, 14 Jul 2020 06:55:05 +0000 (08:55 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Apr 2024 10:50:14 +0000 (12:50 +0200)
[ Upstream commit 9e96c8c0e94eea2f69a9705f5d0f51928ea26c17 ]

Add a helper for struct file based chmode operations.  To be used by
the initramfs code soon.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Stable-dep-of: 4624b346cf67 ("init: open /initrd.image with O_LARGEFILE")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/open.c
include/linux/fs.h

index e072e86003f567835e61babf3b11c7e8db803af9..fc634ab5af0d6741dbc65cc35467767f1b8c4b54 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -569,14 +569,19 @@ out_unlock:
        return error;
 }
 
+int vfs_fchmod(struct file *file, umode_t mode)
+{
+       audit_file(file);
+       return chmod_common(&file->f_path, mode);
+}
+
 int ksys_fchmod(unsigned int fd, umode_t mode)
 {
        struct fd f = fdget(fd);
        int err = -EBADF;
 
        if (f.file) {
-               audit_file(f.file);
-               err = chmod_common(&f.file->f_path, mode);
+               err = vfs_fchmod(f.file, mode);
                fdput(f);
        }
        return err;
index 7d93d22ad10629f13c91f5ce4382c9d45649333e..95e35e07401175c3291ad2bd5e8177928bb6d7d9 100644 (file)
@@ -1661,6 +1661,7 @@ int vfs_mkobj(struct dentry *, umode_t,
                void *);
 
 int vfs_fchown(struct file *file, uid_t user, gid_t group);
+int vfs_fchmod(struct file *file, umode_t mode);
 
 extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);