init: add an init_utimes helper
authorChristoph Hellwig <hch@lst.de>
Tue, 21 Jul 2020 14:05:31 +0000 (16:05 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 31 Jul 2020 06:17:54 +0000 (08:17 +0200)
Add a simple helper to set timestamps with a kernel space file name and
switch the early init code over to it.

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

index 51646ba..db5c48a 100644 (file)
--- a/fs/init.c
+++ b/fs/init.c
@@ -238,3 +238,16 @@ int __init init_rmdir(const char *pathname)
 {
        return do_rmdir(AT_FDCWD, getname_kernel(pathname));
 }
+
+int __init init_utimes(char *filename, struct timespec64 *ts)
+{
+       struct path path;
+       int error;
+
+       error = kern_path(filename, 0, &path);
+       if (error)
+               return error;
+       error = vfs_utimes(&path, ts);
+       path_put(&path);
+       return error;
+}
index b2fda50..3654b52 100644 (file)
@@ -15,3 +15,4 @@ 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);
+int __init init_utimes(char *filename, struct timespec64 *ts);
index 744e111..e6dbfb7 100644 (file)
@@ -111,8 +111,7 @@ static long __init do_utime(char *filename, time64_t mtime)
        t[0].tv_nsec = 0;
        t[1].tv_sec = mtime;
        t[1].tv_nsec = 0;
-
-       return do_utimes(AT_FDCWD, filename, t, AT_SYMLINK_NOFOLLOW);
+       return init_utimes(filename, t);
 }
 
 static __initdata LIST_HEAD(dir_list);