Merge branch 'hch.init_path' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull init and set_fs() cleanups from Al Viro: "Christoph's 'getting rid of ksys_...() uses under KERNEL_DS' series" * 'hch.init_path' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (50 commits) init: add an init_dup helper init: add an init_utimes helper init: add an init_stat helper init: add an init_mknod helper init: add an init_mkdir helper init: add an init_symlink helper init: add an init_link helper init: add an init_eaccess helper init: add an init_chmod helper init: add an init_chown helper init: add an init_chroot helper init: add an init_chdir helper init: add an init_rmdir helper init: add an init_unlink helper init: add an init_umount helper init: add an init_mount helper init: mark create_dev as __init init: mark console_on_rootfs as __init init: initialize ramdisk_execute_command at compile time devtmpfs: refactor devtmpfsd() ...
This commit is contained in:
78
fs/open.c
78
fs/open.c
@@ -394,7 +394,7 @@ static const struct cred *access_override_creds(void)
|
||||
return old_cred;
|
||||
}
|
||||
|
||||
long do_faccessat(int dfd, const char __user *filename, int mode, int flags)
|
||||
static long do_faccessat(int dfd, const char __user *filename, int mode, int flags)
|
||||
{
|
||||
struct path path;
|
||||
struct inode *inode;
|
||||
@@ -482,7 +482,7 @@ SYSCALL_DEFINE2(access, const char __user *, filename, int, mode)
|
||||
return do_faccessat(AT_FDCWD, filename, mode, 0);
|
||||
}
|
||||
|
||||
int ksys_chdir(const char __user *filename)
|
||||
SYSCALL_DEFINE1(chdir, const char __user *, filename)
|
||||
{
|
||||
struct path path;
|
||||
int error;
|
||||
@@ -508,11 +508,6 @@ out:
|
||||
return error;
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE1(chdir, const char __user *, filename)
|
||||
{
|
||||
return ksys_chdir(filename);
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE1(fchdir, unsigned int, fd)
|
||||
{
|
||||
struct fd f = fdget_raw(fd);
|
||||
@@ -535,7 +530,7 @@ out:
|
||||
return error;
|
||||
}
|
||||
|
||||
int ksys_chroot(const char __user *filename)
|
||||
SYSCALL_DEFINE1(chroot, const char __user *, filename)
|
||||
{
|
||||
struct path path;
|
||||
int error;
|
||||
@@ -568,12 +563,7 @@ out:
|
||||
return error;
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE1(chroot, const char __user *, filename)
|
||||
{
|
||||
return ksys_chroot(filename);
|
||||
}
|
||||
|
||||
static int chmod_common(const struct path *path, umode_t mode)
|
||||
int chmod_common(const struct path *path, umode_t mode)
|
||||
{
|
||||
struct inode *inode = path->dentry->d_inode;
|
||||
struct inode *delegated_inode = NULL;
|
||||
@@ -602,25 +592,25 @@ out_unlock:
|
||||
return error;
|
||||
}
|
||||
|
||||
int ksys_fchmod(unsigned int fd, umode_t mode)
|
||||
int vfs_fchmod(struct file *file, umode_t mode)
|
||||
{
|
||||
audit_file(file);
|
||||
return chmod_common(&file->f_path, mode);
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE2(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;
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
|
||||
{
|
||||
return ksys_fchmod(fd, mode);
|
||||
}
|
||||
|
||||
int do_fchmodat(int dfd, const char __user *filename, umode_t mode)
|
||||
static int do_fchmodat(int dfd, const char __user *filename, umode_t mode)
|
||||
{
|
||||
struct path path;
|
||||
int error;
|
||||
@@ -649,7 +639,7 @@ SYSCALL_DEFINE2(chmod, const char __user *, filename, umode_t, mode)
|
||||
return do_fchmodat(AT_FDCWD, filename, mode);
|
||||
}
|
||||
|
||||
static int chown_common(const struct path *path, uid_t user, gid_t group)
|
||||
int chown_common(const struct path *path, uid_t user, gid_t group)
|
||||
{
|
||||
struct inode *inode = path->dentry->d_inode;
|
||||
struct inode *delegated_inode = NULL;
|
||||
@@ -740,23 +730,28 @@ SYSCALL_DEFINE3(lchown, const char __user *, filename, uid_t, user, gid_t, group
|
||||
AT_SYMLINK_NOFOLLOW);
|
||||
}
|
||||
|
||||
int vfs_fchown(struct file *file, uid_t user, gid_t group)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = mnt_want_write_file(file);
|
||||
if (error)
|
||||
return error;
|
||||
audit_file(file);
|
||||
error = chown_common(&file->f_path, user, group);
|
||||
mnt_drop_write_file(file);
|
||||
return error;
|
||||
}
|
||||
|
||||
int ksys_fchown(unsigned int fd, uid_t user, gid_t group)
|
||||
{
|
||||
struct fd f = fdget(fd);
|
||||
int error = -EBADF;
|
||||
|
||||
if (!f.file)
|
||||
goto out;
|
||||
|
||||
error = mnt_want_write_file(f.file);
|
||||
if (error)
|
||||
goto out_fput;
|
||||
audit_file(f.file);
|
||||
error = chown_common(&f.file->f_path, user, group);
|
||||
mnt_drop_write_file(f.file);
|
||||
out_fput:
|
||||
fdput(f);
|
||||
out:
|
||||
if (f.file) {
|
||||
error = vfs_fchown(f.file, user, group);
|
||||
fdput(f);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1198,7 +1193,9 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
|
||||
|
||||
SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)
|
||||
{
|
||||
return ksys_open(filename, flags, mode);
|
||||
if (force_o_largefile())
|
||||
flags |= O_LARGEFILE;
|
||||
return do_sys_open(AT_FDCWD, filename, flags, mode);
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags,
|
||||
@@ -1260,9 +1257,12 @@ COMPAT_SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, fla
|
||||
*/
|
||||
SYSCALL_DEFINE2(creat, const char __user *, pathname, umode_t, mode)
|
||||
{
|
||||
return ksys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);
|
||||
}
|
||||
int flags = O_CREAT | O_WRONLY | O_TRUNC;
|
||||
|
||||
if (force_o_largefile())
|
||||
flags |= O_LARGEFILE;
|
||||
return do_sys_open(AT_FDCWD, pathname, flags, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user