forked from luck/tmp_suning_uos_patched
init: add an init_mkdir helper
Add a simple helper to mkdir with a kernel space file name and switch the early init code over to it. Remove the now unused ksys_mkdir. Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
cd3acb6a79
commit
83ff98c3e9
18
fs/init.c
18
fs/init.c
|
@ -176,6 +176,24 @@ int __init init_unlink(const char *pathname)
|
|||
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
|
||||
}
|
||||
|
||||
int __init init_mkdir(const char *pathname, umode_t mode)
|
||||
{
|
||||
struct dentry *dentry;
|
||||
struct path path;
|
||||
int error;
|
||||
|
||||
dentry = kern_path_create(AT_FDCWD, pathname, &path, LOOKUP_DIRECTORY);
|
||||
if (IS_ERR(dentry))
|
||||
return PTR_ERR(dentry);
|
||||
if (!IS_POSIXACL(path.dentry->d_inode))
|
||||
mode &= ~current_umask();
|
||||
error = security_path_mkdir(&path, dentry, mode);
|
||||
if (!error)
|
||||
error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
|
||||
done_path_create(&path, dentry);
|
||||
return error;
|
||||
}
|
||||
|
||||
int __init init_rmdir(const char *pathname)
|
||||
{
|
||||
return do_rmdir(AT_FDCWD, getname_kernel(pathname));
|
||||
|
|
|
@ -64,7 +64,6 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
|
|||
const char *, unsigned int, struct path *);
|
||||
long do_mknodat(int dfd, const char __user *filename, umode_t mode,
|
||||
unsigned int dev);
|
||||
long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
|
||||
long do_rmdir(int dfd, struct filename *name);
|
||||
long do_unlinkat(int dfd, struct filename *name);
|
||||
int may_linkat(struct path *link);
|
||||
|
|
|
@ -3645,7 +3645,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
|||
}
|
||||
EXPORT_SYMBOL(vfs_mkdir);
|
||||
|
||||
long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
|
||||
static long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
|
||||
{
|
||||
struct dentry *dentry;
|
||||
struct path path;
|
||||
|
|
|
@ -11,4 +11,5 @@ int __init init_eaccess(const char *filename);
|
|||
int __init init_link(const char *oldname, const char *newname);
|
||||
int __init init_symlink(const char *oldname, const char *newname);
|
||||
int __init init_unlink(const char *pathname);
|
||||
int __init init_mkdir(const char *pathname, umode_t mode);
|
||||
int __init init_rmdir(const char *pathname);
|
||||
|
|
|
@ -1270,13 +1270,6 @@ int compat_ksys_ipc(u32 call, int first, int second,
|
|||
* The following kernel syscall equivalents are just wrappers to fs-internal
|
||||
* functions. Therefore, provide stubs to be inlined at the callsites.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
extern long do_mknodat(int dfd, const char __user *filename, umode_t mode,
|
||||
unsigned int dev);
|
||||
|
||||
|
|
|
@ -81,7 +81,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);
|
||||
ksys_mkdir("/old", 0700);
|
||||
init_mkdir("/old", 0700);
|
||||
init_chdir("/old");
|
||||
|
||||
/*
|
||||
|
|
|
@ -348,7 +348,7 @@ static int __init do_name(void)
|
|||
state = CopyFile;
|
||||
}
|
||||
} else if (S_ISDIR(mode)) {
|
||||
ksys_mkdir(collected, mode);
|
||||
init_mkdir(collected, mode);
|
||||
init_chown(collected, uid, gid, 0);
|
||||
init_chmod(collected, mode);
|
||||
dir_add(collected, mtime);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <linux/stat.h>
|
||||
#include <linux/kdev_t.h>
|
||||
#include <linux/syscalls.h>
|
||||
#include <linux/init_syscalls.h>
|
||||
|
||||
/*
|
||||
* Create a simple rootfs that is similar to the default initramfs
|
||||
|
@ -17,7 +18,7 @@ static int __init default_rootfs(void)
|
|||
{
|
||||
int err;
|
||||
|
||||
err = ksys_mkdir((const char __user __force *) "/dev", 0755);
|
||||
err = init_mkdir("/dev", 0755);
|
||||
if (err < 0)
|
||||
goto out;
|
||||
|
||||
|
@ -27,7 +28,7 @@ static int __init default_rootfs(void)
|
|||
if (err < 0)
|
||||
goto out;
|
||||
|
||||
err = ksys_mkdir((const char __user __force *) "/root", 0700);
|
||||
err = init_mkdir("/root", 0700);
|
||||
if (err < 0)
|
||||
goto out;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user