Skip to content

Commit 235e579

Browse files
author
Christoph Hellwig
committed
init: add an init_utimes helper
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 <[email protected]>
1 parent 716308a commit 235e579

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

fs/init.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,16 @@ int __init init_rmdir(const char *pathname)
238238
{
239239
return do_rmdir(AT_FDCWD, getname_kernel(pathname));
240240
}
241+
242+
int __init init_utimes(char *filename, struct timespec64 *ts)
243+
{
244+
struct path path;
245+
int error;
246+
247+
error = kern_path(filename, 0, &path);
248+
if (error)
249+
return error;
250+
error = vfs_utimes(&path, ts);
251+
path_put(&path);
252+
return error;
253+
}

include/linux/init_syscalls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ int __init init_symlink(const char *oldname, const char *newname);
1515
int __init init_unlink(const char *pathname);
1616
int __init init_mkdir(const char *pathname, umode_t mode);
1717
int __init init_rmdir(const char *pathname);
18+
int __init init_utimes(char *filename, struct timespec64 *ts);

init/initramfs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ static long __init do_utime(char *filename, time64_t mtime)
111111
t[0].tv_nsec = 0;
112112
t[1].tv_sec = mtime;
113113
t[1].tv_nsec = 0;
114-
115-
return do_utimes(AT_FDCWD, filename, t, AT_SYMLINK_NOFOLLOW);
114+
return init_utimes(filename, t);
116115
}
117116

118117
static __initdata LIST_HEAD(dir_list);

0 commit comments

Comments
 (0)