aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Dongyang <dongyangli@ddn.com>2023-05-20 20:43:29 +1000
committerTheodore Ts'o <tytso@mit.edu>2023-12-01 12:35:33 -0500
commit569074c65d7b3a2022e53f0d6abd405dbe5320a3 (patch)
treeec22fa631d6dee793496db9cf737d313aa5e9814
parentcc20e3c4320ae34dd06ec4d6a71d07aa7d6599d7 (diff)
downloade2fsprogs-569074c65d7b3a2022e53f0d6abd405dbe5320a3.tar.gz
tune2fs: fall back to old get/set fs label on error
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> Link: https://lore.kernel.org/r/20230520104329.2402182-1-dongyangli@ddn.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--misc/tune2fs.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 9ffe0d199..78b58347f 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -3100,24 +3100,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) {