All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Dongyang <dongyangli@ddn.com>
To: linux-ext4@vger.kernel.org
Cc: adilger@dilger.ca, lczerner@redhat.com
Subject: [PATCH] tune2fs: fall back to old get/set fs label on error
Date: Sat, 20 May 2023 20:43:29 +1000	[thread overview]
Message-ID: <20230520104329.2402182-1-dongyangli@ddn.com> (raw)

If we fail to get/open the mount point for get/set
fs label ioctl, just fall back to old method and
silence the error messages.

Fixes: f85b4526f ("tune2fs: implement support for set/get label iocts")
Signed-off-by: Li Dongyang <dongyangli@ddn.com>
---
 misc/tune2fs.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 458f7cf6a..460d81c9e 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -3096,24 +3096,19 @@ static int handle_fslabel(int setlabel)
 
 	ret = ext2fs_check_mount_point(device_name, &mnt_flags,
 					  mntpt, sizeof(mntpt));
-	if (ret) {
-		com_err(device_name, ret, _("while checking mount status"));
-		return 1;
-	}
+	if (ret)
+		return -1;
+
 	if (!(mnt_flags & EXT2_MF_MOUNTED) ||
 	    (setlabel && (mnt_flags & EXT2_MF_READONLY)))
 		return -1;
 
-	if (!mntpt[0]) {
-		fprintf(stderr,_("Unknown mount point for %s\n"), device_name);
-		return 1;
-	}
+	if (!mntpt[0])
+		return -1;
 
 	fd = open(mntpt, O_RDONLY);
-	if (fd < 0) {
-		com_err(mntpt, errno, _("while opening mount point"));
-		return 1;
-	}
+	if (fd < 0)
+		return -1;
 
 	/* Get fs label */
 	if (!setlabel) {
-- 
2.39.2


             reply	other threads:[~2023-05-20 11:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-20 10:43 Li Dongyang [this message]
2023-12-07 16:05 ` [PATCH] tune2fs: fall back to old get/set fs label on error Theodore Ts'o

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=20230520104329.2402182-1-dongyangli@ddn.com \
    --to=dongyangli@ddn.com \
    --cc=adilger@dilger.ca \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.