Skip to content

Commit 5e787db

Browse files
author
Dominik Brodowski
committed
devtmpfs: use do_mount() instead of ksys_mount()
In devtmpfs, do_mount() can be called directly instead of complex wrapping by ksys_mount(): - the first and third arguments are const strings in the kernel, and do not need to be copied over from userspace; - the fifth argument is NULL, and therefore no page needs to be copied over from userspace; - the second and fourth argument are passed through anyway. Signed-off-by: Dominik Brodowski <[email protected]>
1 parent ae4b064 commit 5e787db

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

drivers/base/devtmpfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ static int handle_remove(const char *nodename, struct device *dev)
359359
* If configured, or requested by the commandline, devtmpfs will be
360360
* auto-mounted after the kernel mounted the root filesystem.
361361
*/
362-
int devtmpfs_mount(const char *mntdir)
362+
int devtmpfs_mount(void)
363363
{
364364
int err;
365365

@@ -369,7 +369,7 @@ int devtmpfs_mount(const char *mntdir)
369369
if (!thread)
370370
return 0;
371371

372-
err = ksys_mount("devtmpfs", mntdir, "devtmpfs", MS_SILENT, NULL);
372+
err = do_mount("devtmpfs", "dev", "devtmpfs", MS_SILENT, NULL);
373373
if (err)
374374
printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
375375
else
@@ -394,7 +394,7 @@ static int devtmpfsd(void *p)
394394
*err = ksys_unshare(CLONE_NEWNS);
395395
if (*err)
396396
goto out;
397-
*err = ksys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, NULL);
397+
*err = do_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, NULL);
398398
if (*err)
399399
goto out;
400400
ksys_chdir("/.."); /* will traverse into overmounted root */

include/linux/device.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,11 +1666,11 @@ extern bool kill_device(struct device *dev);
16661666
#ifdef CONFIG_DEVTMPFS
16671667
extern int devtmpfs_create_node(struct device *dev);
16681668
extern int devtmpfs_delete_node(struct device *dev);
1669-
extern int devtmpfs_mount(const char *mntdir);
1669+
extern int devtmpfs_mount(void);
16701670
#else
16711671
static inline int devtmpfs_create_node(struct device *dev) { return 0; }
16721672
static inline int devtmpfs_delete_node(struct device *dev) { return 0; }
1673-
static inline int devtmpfs_mount(const char *mountpoint) { return 0; }
1673+
static inline int devtmpfs_mount(void) { return 0; }
16741674
#endif
16751675

16761676
/* drivers/base/power/shutdown.c */

init/do_mounts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ void __init prepare_namespace(void)
670670

671671
mount_root();
672672
out:
673-
devtmpfs_mount("dev");
673+
devtmpfs_mount();
674674
ksys_mount(".", "/", NULL, MS_MOVE, NULL);
675675
ksys_chroot(".");
676676
}

0 commit comments

Comments
 (0)