From: Gao Xiang <xiang@kernel.org>
To: linux-erofs@lists.ozlabs.org
Subject: [PATCH] erofs-utils: fsck: check extract_path in erofsfsck_set_attributes()
Date: Sat, 29 Jan 2022 15:45:40 +0800 [thread overview]
Message-ID: <20220129074540.5501-1-xiang@kernel.org> (raw)
Just cleanup.
Signed-off-by: Gao Xiang <xiang@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
reply other threads:[~2022-01-29 7:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220129074540.5501-1-xiang@kernel.org \
--to=xiang@kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox