*-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).
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));
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))
# 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