]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
umount: fix --graceful option cosmetics and tests
authorKarel Zak <kzak@redhat.com>
Tue, 10 Mar 2026 12:31:09 +0000 (13:31 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 10 Mar 2026 12:31:09 +0000 (13:31 +0100)
- fix missing comma in man page option syntax
- fix typo "succesfully" -> "successfully"
- move --graceful before --namespace in help text
- shorten help text to single line
- improve man page description, add root-only note
- add test for non-existent path with --graceful

Addresses: https://github.com/util-linux/util-linux/pull/4059
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/umount.8.adoc
sys-utils/umount.c
tests/ts/mount/umount-recursive

index 5fbc715e1b56cd73aea56ef201c253c83c935765..a568016c99cefa193cfa61333694e1cba93d9ac0 100644 (file)
@@ -100,8 +100,8 @@ Unmount only the filesystems that have the specified option set in _/etc/fstab_.
 *-q*, *--quiet*::
 Suppress "not mounted" error messages.
 
-*-g* *--graceful*::
-Exit successfully even if the filesystem has already been unmounted or does not exist.
+*-g*, *--graceful*::
+Exit successfully even if the target is not mounted or does not exist. This option is designed for use in shutdown scripts and service managers where idempotent unmount behavior is desired. Only effective for the root user.
 
 *-R*, *--recursive*::
 Recursively unmount each specified directory. Recursion for each directory will stop if any unmount operation in the chain fails for any reason. The relationship between mountpoints is determined by _/proc/self/mountinfo_ entries. The filesystem must be specified by mountpoint path; a recursive unmount by device name (or UUID) is unsupported. Since version 2.37 it umounts also all over-mounted filesystems (more filesystems on the same mountpoint).
index 3cdc200bf6d9252a6a60b4b91b7fa15807dea5d1..5e213c20043c9faa797239160852193f9d6cefad 100644 (file)
@@ -104,9 +104,8 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(_(" -t, --types <list>      limit the set of filesystem types\n"), out);
        fputs(_(" -v, --verbose           say what is being done\n"), out);
        fputs(_(" -q, --quiet             suppress 'not mounted' error messages\n"), out);
+       fputs(_(" -g, --graceful          exit successfully if the target is not mounted\n"), out);
        fputs(_(" -N, --namespace <ns>    perform umount in another namespace\n"), out);
-       fputs(_(" -g, --graceful          don't return an error when the mountpoint has already\n"
-               "                           been unmounted or the directory does not exist\n"), out);
 
        fputs(USAGE_SEPARATOR, out);
        fprintf(out, USAGE_HELP_OPTIONS(25));
@@ -163,7 +162,7 @@ static int mk_exit_code(struct libmnt_context *cxt, int api_rc)
        int rc;
 
        rc = mnt_context_get_excode(cxt, api_rc, buf, sizeof(buf));
-       /* exit succesfully even if the filesystem has already been unmounted or does not exist */
+       /* exit successfully even if the filesystem has already been unmounted or does not exist */
        if (graceful && rc == MNT_EX_FAIL && mnt_context_syscall_called(cxt)
                                && (mnt_context_get_syscall_errno(cxt) == EINVAL
                                || mnt_context_get_syscall_errno(cxt) == ENOENT))
index fc03b1c26222d7a6e99cc8eaacbd737a7141a119..a099c75ea85e5c5b598a40d6d4d33a8d6e4e6c5e 100755 (executable)
@@ -97,7 +97,11 @@ $TS_CMD_UMOUNT --recursive $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
 
 # the mountpoint has already been unmounted, so this second call should not fail
 $TS_CMD_UMOUNT --graceful $TS_MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
-[ $? == 0 ] || ts_die "--graceful option failed"
+[ $? == 0 ] || ts_die "--graceful on unmounted mountpoint failed"
+
+# non-existent path should not fail with --graceful
+$TS_CMD_UMOUNT --graceful /non-existent-path-$$ >> $TS_OUTPUT 2>> $TS_ERRLOG
+[ $? == 0 ] || ts_die "--graceful on non-existent path failed"
 
 ts_log "Success"
 ts_finalize