Skip to content

Commit

Permalink
initramfs: use vfs_utimes in do_copy
Browse files Browse the repository at this point in the history
Don't bother saving away the pathname and just use the new struct path
based utimes helper instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Christoph Hellwig committed Jul 31, 2020
1 parent fd5ad30 commit 38b0822
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions init/initramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ static inline void __init eat(unsigned n)
byte_count -= n;
}

static __initdata char *vcollected;
static __initdata char *collected;
static long remains __initdata;
static __initdata char *collect;
Expand Down Expand Up @@ -345,7 +344,6 @@ static int __init do_name(void)
vfs_fchmod(wfile, mode);
if (body_len)
vfs_truncate(&wfile->f_path, body_len);
vcollected = kstrdup(collected, GFP_KERNEL);
state = CopyFile;
}
} else if (S_ISDIR(mode)) {
Expand All @@ -368,11 +366,15 @@ static int __init do_name(void)
static int __init do_copy(void)
{
if (byte_count >= body_len) {
struct timespec64 t[2] = { };
if (xwrite(wfile, victim, body_len, &wfile_pos) != body_len)
error("write error");

t[0].tv_sec = mtime;
t[1].tv_sec = mtime;
vfs_utimes(&wfile->f_path, t);

fput(wfile);
do_utime(vcollected, mtime);
kfree(vcollected);
eat(body_len);
state = SkipIt;
return 0;
Expand Down

0 comments on commit 38b0822

Please sign in to comment.