Skip to content

Commit

Permalink
fs: add a vfs_fchmod helper
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig committed Jul 16, 2020
1 parent c04011f commit 9e96c8c
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fs/open.c
Original file line number Diff line number Diff line change
@@ -602,14 +602,19 @@ static int chmod_common(const struct path *path, umode_t mode)
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;
1 change: 1 addition & 0 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 9e96c8c

Please sign in to comment.