[PATCH] erofs-utils: fsck: check extract_path in erofsfsck_set_attributes()

Gao Xiang xiang at kernel.org
Sat Jan 29 18:45:40 AEDT 2022


Just cleanup.

Signed-off-by: Gao Xiang <xiang at kernel.org>
---
 fsck/main.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/fsck/main.c b/fsck/main.c
index a906ee85cf7a..42f7751be1ee 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -219,15 +219,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)
@@ -711,7 +713,7 @@ verify:
 		ret = erofs_iterate_dir(&ctx, true);
 	}
 
-	if (!ret && fsckcfg.extract_path)
+	if (!ret)
 		erofsfsck_set_attributes(&inode, fsckcfg.extract_path);
 
 out:
-- 
2.20.1



More information about the Linux-erofs mailing list