Skip to content

Commit 83ff98c

Browse files
author
Christoph Hellwig
committed
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>
1 parent cd3acb6 commit 83ff98c

File tree

8 files changed

+25
-13
lines changed

8 files changed

+25
-13
lines changed

fs/init.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,24 @@ int __init init_unlink(const char *pathname)
176176
return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
177177
}
178178

179+
int __init init_mkdir(const char *pathname, umode_t mode)
180+
{
181+
struct dentry *dentry;
182+
struct path path;
183+
int error;
184+
185+
dentry = kern_path_create(AT_FDCWD, pathname, &path, LOOKUP_DIRECTORY);
186+
if (IS_ERR(dentry))
187+
return PTR_ERR(dentry);
188+
if (!IS_POSIXACL(path.dentry->d_inode))
189+
mode &= ~current_umask();
190+
error = security_path_mkdir(&path, dentry, mode);
191+
if (!error)
192+
error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
193+
done_path_create(&path, dentry);
194+
return error;
195+
}
196+
179197
int __init init_rmdir(const char *pathname)
180198
{
181199
return do_rmdir(AT_FDCWD, getname_kernel(pathname));

fs/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
6464
const char *, unsigned int, struct path *);
6565
long do_mknodat(int dfd, const char __user *filename, umode_t mode,
6666
unsigned int dev);
67-
long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
6867
long do_rmdir(int dfd, struct filename *name);
6968
long do_unlinkat(int dfd, struct filename *name);
7069
int may_linkat(struct path *link);

fs/namei.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3645,7 +3645,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
36453645
}
36463646
EXPORT_SYMBOL(vfs_mkdir);
36473647

3648-
long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
3648+
static long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
36493649
{
36503650
struct dentry *dentry;
36513651
struct path path;

include/linux/init_syscalls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ int __init init_eaccess(const char *filename);
1111
int __init init_link(const char *oldname, const char *newname);
1212
int __init init_symlink(const char *oldname, const char *newname);
1313
int __init init_unlink(const char *pathname);
14+
int __init init_mkdir(const char *pathname, umode_t mode);
1415
int __init init_rmdir(const char *pathname);

include/linux/syscalls.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,13 +1270,6 @@ int compat_ksys_ipc(u32 call, int first, int second,
12701270
* The following kernel syscall equivalents are just wrappers to fs-internal
12711271
* functions. Therefore, provide stubs to be inlined at the callsites.
12721272
*/
1273-
extern long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
1274-
1275-
static inline long ksys_mkdir(const char __user *pathname, umode_t mode)
1276-
{
1277-
return do_mkdirat(AT_FDCWD, pathname, mode);
1278-
}
1279-
12801273
extern long do_mknodat(int dfd, const char __user *filename, umode_t mode,
12811274
unsigned int dev);
12821275

init/do_mounts_initrd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void __init handle_initrd(void)
8181
create_dev("/dev/root.old", Root_RAM0);
8282
/* mount initrd on rootfs' /root */
8383
mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
84-
ksys_mkdir("/old", 0700);
84+
init_mkdir("/old", 0700);
8585
init_chdir("/old");
8686

8787
/*

init/initramfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static int __init do_name(void)
348348
state = CopyFile;
349349
}
350350
} else if (S_ISDIR(mode)) {
351-
ksys_mkdir(collected, mode);
351+
init_mkdir(collected, mode);
352352
init_chown(collected, uid, gid, 0);
353353
init_chmod(collected, mode);
354354
dir_add(collected, mtime);

init/noinitramfs.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/stat.h>
1010
#include <linux/kdev_t.h>
1111
#include <linux/syscalls.h>
12+
#include <linux/init_syscalls.h>
1213

1314
/*
1415
* Create a simple rootfs that is similar to the default initramfs
@@ -17,7 +18,7 @@ static int __init default_rootfs(void)
1718
{
1819
int err;
1920

20-
err = ksys_mkdir((const char __user __force *) "/dev", 0755);
21+
err = init_mkdir("/dev", 0755);
2122
if (err < 0)
2223
goto out;
2324

@@ -27,7 +28,7 @@ static int __init default_rootfs(void)
2728
if (err < 0)
2829
goto out;
2930

30-
err = ksys_mkdir((const char __user __force *) "/root", 0700);
31+
err = init_mkdir("/root", 0700);
3132
if (err < 0)
3233
goto out;
3334

0 commit comments

Comments
 (0)