summaryrefslogtreecommitdiff
path: root/src/mount/mount-tool.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2017-11-30 17:55:04 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2017-12-03 00:28:59 +0900
commit6442c2109c18af9fd208b2631cacaf1347c384a7 (patch)
treecc68b7a0e232854b496d07e290818d4cf9b29323 /src/mount/mount-tool.c
parent95f35cccf045b76cd2a4c28d873c239f5b50f638 (diff)
downloadsystemd-6442c2109c18af9fd208b2631cacaf1347c384a7.tar.gz
mount: ignore error when stop non-existing automount unit
The command `systemd-mount -u` tries to stop both mount and automount units. If the corresponding mount unit does not exist, then it is user's fault, that is, the specified path is not a mount point. However, not all mount units have corresponding autmount units. Thus, the error about non-existing automount unit is not user's falut, and showing the error may confuse users. So, let's ignore the error of such case.
Diffstat (limited to 'src/mount/mount-tool.c')
-rw-r--r--src/mount/mount-tool.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c
index dd5f62e824..f9ac20be5b 100644
--- a/src/mount/mount-tool.c
+++ b/src/mount/mount-tool.c
@@ -829,7 +829,7 @@ static int stop_mount(
r = unit_name_from_path(where, suffix, &mount_unit);
if (r < 0)
- return log_error_errno(r, "Failed to make mount unit name from path %s: %m", where);
+ return log_error_errno(r, "Failed to make %s unit name from path %s: %m", suffix + 1, where);
r = sd_bus_message_new_method_call(
bus,
@@ -853,8 +853,12 @@ static int stop_mount(
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = sd_bus_call(bus, m, 0, &error, &reply);
- if (r < 0)
- return log_error_errno(r, "Failed to stop mount unit: %s", bus_error_message(&error, r));
+ if (r < 0) {
+ if (streq(suffix, ".automount") &&
+ sd_bus_error_has_name(&error, "org.freedesktop.systemd1.NoSuchUnit"))
+ return 0;
+ return log_error_errno(r, "Failed to stop %s unit: %s", suffix + 1, bus_error_message(&error, r));
+ }
if (w) {
const char *object;