diff options
author | Gao Xiang <xiang@kernel.org> | 2022-01-29 15:45:40 +0800 |
---|---|---|
committer | Kelvin Zhang <zhangkelvin@google.com> | 2022-01-31 10:36:48 -0800 |
commit | 3e4df222bb8c730e8641258ce193177f0c8a91f5 (patch) | |
tree | 718f31e482ceb9d231045cd25abec1c00aed532f /fsck/main.c | |
parent | b26e187fa5411a9599bc858367c60d66d72befe7 (diff) | |
download | erofs-utils-3e4df222bb8c730e8641258ce193177f0c8a91f5.tar.gz |
UPSTREAM: erofs-utils: fsck: check extract_path in erofsfsck_set_attributes()
Just cleanup.
Link: https://lore.kernel.org/r/20220129074540.5501-1-xiang@kernel.org
Signed-off-by: Gao Xiang <xiang@kernel.org>
Change-Id: Iaa4d9b5a42fee1c2f4957aa2a3391a499c994911
Diffstat (limited to 'fsck/main.c')
-rw-r--r-- | fsck/main.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/fsck/main.c b/fsck/main.c index 92e0c76..ff7d9fe 100644 --- a/fsck/main.c +++ b/fsck/main.c @@ -173,15 +173,17 @@ static void erofsfsck_set_attributes(struct erofs_inode *inode, char *path) { int ret; -#ifdef HAVE_UTIMENSAT - const struct timespec times[2] = { - [0] = { .tv_sec = inode->i_ctime, - .tv_nsec = inode->i_ctime_nsec }, - [1] = { .tv_sec = inode->i_ctime, - .tv_nsec = inode->i_ctime_nsec }, - }; + /* don't apply attributes when fsck is used without extraction */ + if (!fsckcfg.extract_path) + return; - if (utimensat(AT_FDCWD, path, times, AT_SYMLINK_NOFOLLOW) < 0) +#ifdef HAVE_UTIMENSAT + if (utimensat(AT_FDCWD, path, (struct timespec []) { + [0] = { .tv_sec = inode->i_ctime, + .tv_nsec = inode->i_ctime_nsec }, + [1] = { .tv_sec = inode->i_ctime, + .tv_nsec = inode->i_ctime_nsec }, + }, AT_SYMLINK_NOFOLLOW) < 0) #else if (utime(path, &((struct utimbuf){.actime = inode->i_ctime, .modtime = inode->i_ctime})) < 0) @@ -665,7 +667,7 @@ verify: ret = erofs_iterate_dir(&ctx, true); } - if (!ret && fsckcfg.extract_path) + if (!ret) erofsfsck_set_attributes(&inode, fsckcfg.extract_path); out: |