fs: add a vfs_fchmod helper
authorChristoph Hellwig <hch@lst.de>
Tue, 14 Jul 2020 06:55:05 +0000 (08:55 +0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 16 Jul 2020 13:33:04 +0000 (15:33 +0200)
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>
fs/open.c
include/linux/fs.h

index 103c66309bee673eae050e3ae66a9d38a9c516a7..75166f071d280a4fee5faccc2594c9d02898761b 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -602,14 +602,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 0ddd64ca0b45c02b84374be7a94d8fed6b54806d..635086726f2053c30332024859b95e7ca6b841ba 100644 (file)
@@ -1745,6 +1745,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);