Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Ostapenko <igoreisberg@gmail.com>
To: linux-erofs@lists.ozlabs.org
Cc: Igor Eisberg <igoreisberg@gmail.com>
Subject: [PATCH] erofs-utils: fsck: fix issues related to --extract=X
Date: Fri, 28 Jan 2022 18:00:36 +0200	[thread overview]
Message-ID: <20220128160036.101-1-igoreisberg@gmail.com> (raw)
In-Reply-To: <YfNvloN0RAX0mHRn@B-P7TQMD6M-0146>

From: Igor Eisberg <igoreisberg@gmail.com>

Fix "--[no-]preserve[-owner/-perms] must be used..." error always thrown
for superuser when fsck used without --extract=X, due to default values
for preserve_owner/preserve_perms being already pre-set to true,
as if the --preserve option was explicitly given by the user.

Signed-off-by: Igor Ostapenko <igoreisberg@gmail.com>
---
 fsck/main.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/fsck/main.c b/fsck/main.c
index 5667f2a..9e3756d 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -95,7 +95,7 @@ static void erofsfsck_print_version(void)
 static int erofsfsck_parse_options_cfg(int argc, char **argv)
 {
 	int opt, ret;
-	bool no_preserve_owner = false, no_preserve_perms = false;
+	bool has_opt_preserve = false;
 
 	while ((opt = getopt_long(argc, argv, "Vd:p",
 				  long_options, NULL)) != -1) {
@@ -154,27 +154,27 @@ static int erofsfsck_parse_options_cfg(int argc, char **argv)
 			break;
 		case 6:
 			fsckcfg.preserve_owner = fsckcfg.preserve_perms = true;
-			no_preserve_owner = no_preserve_perms = false;
+			has_opt_preserve = true;
 			break;
 		case 7:
 			fsckcfg.preserve_owner = true;
-			no_preserve_owner = false;
+			has_opt_preserve = true;
 			break;
 		case 8:
 			fsckcfg.preserve_perms = true;
-			no_preserve_perms = false;
+			has_opt_preserve = true;
 			break;
 		case 9:
 			fsckcfg.preserve_owner = fsckcfg.preserve_perms = false;
-			no_preserve_owner = no_preserve_perms = true;
+			has_opt_preserve = true;
 			break;
 		case 10:
 			fsckcfg.preserve_owner = false;
-			no_preserve_owner = true;
+			has_opt_preserve = true;
 			break;
 		case 11:
 			fsckcfg.preserve_perms = false;
-			no_preserve_perms = true;
+			has_opt_preserve = true;
 			break;
 		default:
 			return -EINVAL;
@@ -195,8 +195,7 @@ static int erofsfsck_parse_options_cfg(int argc, char **argv)
 			erofs_err("--overwrite must be used together with --extract=X");
 			return -EINVAL;
 		}
-		if (fsckcfg.preserve_owner || fsckcfg.preserve_perms ||
-			  no_preserve_owner || no_preserve_perms) {
+		if (has_opt_preserve) {
 			erofs_err("--[no-]preserve[-owner/-perms] must be used together with --extract=X");
 			return -EINVAL;
 		}
-- 
2.30.2


  parent reply	other threads:[~2022-01-28 16:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <YfC7rIs7%2FaAVdcS9@B-P7TQMD6M-0146.local>
2022-01-28  4:05 ` [PATCH] erofs-utils: fsck: fix issues related to --extract=X Igor Ostapenko
2022-01-28  4:22   ` Gao Xiang
2022-01-28  4:46     ` Igor Ostapenko
2022-01-28  4:50     ` Igor Ostapenko
2022-01-28  5:12       ` Gao Xiang
2022-01-28 16:00     ` Igor Ostapenko [this message]
2022-01-29  4:48       ` Gao Xiang
2022-01-21  0:31 Igor Ostapenko
2022-01-21  1:47 ` Gao Xiang
2022-01-26  3:10   ` Gao Xiang

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=20220128160036.101-1-igoreisberg@gmail.com \
    --to=igoreisberg@gmail.com \
    --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