init: add an init_unlink helper
authorChristoph Hellwig <hch@lst.de>
Thu, 23 Jul 2020 06:23:40 +0000 (08:23 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 31 Jul 2020 06:17:52 +0000 (08:17 +0200)
Add a simple helper to unlink with a kernel space file name and switch
the early init code over to it.  Remove the now unused ksys_unlink.

Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/init.c
include/linux/init_syscalls.h
include/linux/syscalls.h
init/do_mounts.h
init/do_mounts_initrd.c
init/do_mounts_rd.c
init/initramfs.c

index 9c8e31fdb048c89c80a50be4b2537acf685d4e52..507ffbb5d146d6e27e2cdc3d8de4cbbf7f0bc95a 100644 (file)
--- a/fs/init.c
+++ b/fs/init.c
@@ -37,3 +37,8 @@ int __init init_umount(const char *name, int flags)
                return ret;
        return path_umount(&path, flags);
 }
+
+int __init init_unlink(const char *pathname)
+{
+       return do_unlinkat(AT_FDCWD, getname_kernel(pathname));
+}
index a5a2e7f19916918cbc28e5d48cb387a915f76a05..00d597249549ee43186e2544ff5858bbb361e727 100644 (file)
@@ -3,3 +3,4 @@
 int __init init_mount(const char *dev_name, const char *dir_name,
                const char *type_page, unsigned long flags, void *data_page);
 int __init init_umount(const char *name, int flags);
+int __init init_unlink(const char *pathname);
index 1a4f5d8ee7044b9f1ce12d3e08dc105127827fd9..26f9738e5ab8613d0deec2f8fb039d13be9d1680 100644 (file)
@@ -1273,13 +1273,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_unlinkat(int dfd, struct filename *name);
-
-static inline long ksys_unlink(const char __user *pathname)
-{
-       return do_unlinkat(AT_FDCWD, getname(pathname));
-}
-
 long do_rmdir(int dfd, struct filename *name);
 
 static inline long ksys_rmdir(const char __user *pathname)
index 20e7fec8cb499ef06ca32ea313b38584cdc5c618..104d8431725aebdd4260d0956b860ea0c86320a6 100644 (file)
@@ -16,7 +16,7 @@ extern int root_mountflags;
 
 static inline __init int create_dev(char *name, dev_t dev)
 {
-       ksys_unlink(name);
+       init_unlink(name);
        return ksys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
 }
 
index 6b020a0699025179d177800ecd85003415d34616..8b44dd017842a8929d7893a37b53eacae4ed6d0e 100644 (file)
@@ -137,11 +137,11 @@ bool __init initrd_load(void)
                 * mounted in the normal path.
                 */
                if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
-                       ksys_unlink("/initrd.image");
+                       init_unlink("/initrd.image");
                        handle_initrd();
                        return true;
                }
        }
-       ksys_unlink("/initrd.image");
+       init_unlink("/initrd.image");
        return false;
 }
index d4255c10432a8bb606a06622a1c5774a1eb919e2..ac021ae6e6fa78c7b7828a78ab2fa3af3611bef3 100644 (file)
@@ -272,7 +272,7 @@ noclose_input:
        fput(out_file);
 out:
        kfree(buf);
-       ksys_unlink("/dev/ram");
+       init_unlink("/dev/ram");
        return res;
 }
 
index 9820fca4d4e36ced878d8a2a4827e888aff34385..eb58cee6dadb433bdf4c4361b4dbe6ae9a633d5c 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/file.h>
 #include <linux/memblock.h>
 #include <linux/namei.h>
+#include <linux/init_syscalls.h>
 
 static ssize_t __init xwrite(struct file *file, const char *p, size_t count,
                loff_t *pos)
@@ -301,7 +302,7 @@ static void __init clean_path(char *path, umode_t fmode)
                if (S_ISDIR(st.mode))
                        ksys_rmdir(path);
                else
-                       ksys_unlink(path);
+                       init_unlink(path);
        }
 }