forked from luck/tmp_suning_uos_patched
fs: add do_mkdirat() helper and ksys_mkdir() wrapper; remove in-kernel calls to syscall
Using the fs-internal do_mkdirat() helper allows us to get rid of fs-internal calls to the sys_mkdirat() syscall. Introducing the ksys_mkdir() wrapper allows us to avoid the in-kernel calls to the sys_mkdir() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_mkdir(). This patch is part of a series which removes in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined. For details, see http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
This commit is contained in:
parent
f459dffae1
commit
0101db7a30
|
@ -55,6 +55,7 @@ extern void __init chrdev_init(void);
|
|||
extern int user_path_mountpoint_at(int, const char __user *, unsigned int, struct path *);
|
||||
extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
|
||||
const char *, unsigned int, struct path *);
|
||||
long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
|
||||
long do_rmdir(int dfd, const char __user *pathname);
|
||||
long do_unlinkat(int dfd, struct filename *name);
|
||||
|
||||
|
|
|
@ -3803,7 +3803,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
|||
}
|
||||
EXPORT_SYMBOL(vfs_mkdir);
|
||||
|
||||
SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
|
||||
long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
|
||||
{
|
||||
struct dentry *dentry;
|
||||
struct path path;
|
||||
|
@ -3828,9 +3828,14 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
|
|||
return error;
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
|
||||
{
|
||||
return do_mkdirat(dfd, pathname, mode);
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode)
|
||||
{
|
||||
return sys_mkdirat(AT_FDCWD, pathname, mode);
|
||||
return do_mkdirat(AT_FDCWD, pathname, mode);
|
||||
}
|
||||
|
||||
int vfs_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
|
|
|
@ -972,4 +972,11 @@ static inline long ksys_rmdir(const char __user *pathname)
|
|||
return do_rmdir(AT_FDCWD, pathname);
|
||||
}
|
||||
|
||||
extern long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
|
||||
|
||||
static inline long ksys_mkdir(const char __user *pathname, umode_t mode)
|
||||
{
|
||||
return do_mkdirat(AT_FDCWD, pathname, mode);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -60,7 +60,7 @@ static void __init handle_initrd(void)
|
|||
create_dev("/dev/root.old", Root_RAM0);
|
||||
/* mount initrd on rootfs' /root */
|
||||
mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
|
||||
sys_mkdir("/old", 0700);
|
||||
ksys_mkdir("/old", 0700);
|
||||
ksys_chdir("/old");
|
||||
|
||||
/* try loading default modules from initrd */
|
||||
|
|
|
@ -352,7 +352,7 @@ static int __init do_name(void)
|
|||
}
|
||||
}
|
||||
} else if (S_ISDIR(mode)) {
|
||||
sys_mkdir(collected, mode);
|
||||
ksys_mkdir(collected, mode);
|
||||
sys_chown(collected, uid, gid);
|
||||
sys_chmod(collected, mode);
|
||||
dir_add(collected, mtime);
|
||||
|
|
|
@ -29,7 +29,7 @@ static int __init default_rootfs(void)
|
|||
{
|
||||
int err;
|
||||
|
||||
err = sys_mkdir((const char __user __force *) "/dev", 0755);
|
||||
err = ksys_mkdir((const char __user __force *) "/dev", 0755);
|
||||
if (err < 0)
|
||||
goto out;
|
||||
|
||||
|
@ -39,7 +39,7 @@ static int __init default_rootfs(void)
|
|||
if (err < 0)
|
||||
goto out;
|
||||
|
||||
err = sys_mkdir((const char __user __force *) "/root", 0700);
|
||||
err = ksys_mkdir((const char __user __force *) "/root", 0700);
|
||||
if (err < 0)
|
||||
goto out;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user