Merge pull request #7357 from yuwata/7314-mod

mount: add "-G" as shortcut for "--property=CollectMode=inactive-or-failed"
This commit is contained in:
Lennart Poettering
2017-11-17 09:49:07 +01:00
committed by GitHub
2 changed files with 34 additions and 6 deletions
+15
View File
@@ -264,6 +264,21 @@
supported.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-G</option></term>
<term><option>--collect</option></term>
<listitem><para>Unload the transient unit after it completed, even if it failed. Normally, without this option,
all mount units that mount and failed are kept in memory until the user explicitly resets their failure state with
<command>systemctl reset-failed</command> or an equivalent command. On the other hand, units that stopped
successfully are unloaded immediately. If this option is turned on the "garbage collection" of units is more
agressive, and unloads units regardless if they exited successfully or failed. This option is a shortcut for
<command>--property=CollectMode=inactive-or-failed</command>, see the explanation for
<varname>CollectMode=</varname> in
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for further
information.</para></listitem>
</varlistentry>
<xi:include href="user-system-options.xml" xpointer="user" />
<xi:include href="user-system-options.xml" xpointer="system" />
<xi:include href="user-system-options.xml" xpointer="host" />
+19 -6
View File
@@ -68,6 +68,7 @@ static bool arg_timeout_idle_set = false;
static char **arg_automount_property = NULL;
static int arg_bind_device = -1;
static bool arg_fsck = true;
static bool arg_aggressive_gc = false;
static void help(void) {
printf("systemd-mount [OPTIONS...] WHAT [WHERE]\n"
@@ -95,7 +96,8 @@ static void help(void) {
" Set automount unit property\n"
" --bind-device Bind automount unit to device\n"
" --list List mountable block devices\n"
" -u --umount Unmount mount points\n",
" -u --umount Unmount mount points\n"
" -G --collect Unload unit after it stopped, even when failed\n",
program_invocation_short_name,
streq(program_invocation_short_name, "systemd-umount") ? "" : "--umount ");
}
@@ -145,6 +147,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "list", no_argument, NULL, ARG_LIST },
{ "umount", no_argument, NULL, 'u' },
{ "unmount", no_argument, NULL, 'u' },
{ "collect", no_argument, NULL, 'G' },
{},
};
@@ -156,7 +159,7 @@ static int parse_argv(int argc, char *argv[]) {
if (strstr(program_invocation_short_name, "systemd-umount"))
arg_action = ACTION_UMOUNT;
while ((c = getopt_long(argc, argv, "hqH:M:t:o:p:Au", options, NULL)) >= 0)
while ((c = getopt_long(argc, argv, "hqH:M:t:o:p:AuG", options, NULL)) >= 0)
switch (c) {
@@ -271,6 +274,10 @@ static int parse_argv(int argc, char *argv[]) {
arg_action = ACTION_UMOUNT;
break;
case 'G':
arg_aggressive_gc = true;
break;
case '?':
return -EINVAL;
@@ -333,11 +340,11 @@ static int parse_argv(int argc, char *argv[]) {
r = path_make_absolute_cwd(u, &p);
if (r < 0)
return log_error_errno(r, "Failed to make path absolute: %m");
return log_error_errno(r, "Failed to make path %s absolute: %m", u);
arg_mount_what = canonicalize_file_name(p);
if (!arg_mount_what)
return log_error_errno(errno, "Failed to canonicalize path: %m");
return log_error_errno(errno, "Failed to canonicalize path %s: %m", p);
} else {
arg_mount_what = strdup(argv[optind]);
if (!arg_mount_what)
@@ -357,11 +364,11 @@ static int parse_argv(int argc, char *argv[]) {
r = path_make_absolute_cwd(argv[optind+1], &p);
if (r < 0)
return log_error_errno(r, "Failed to make path absolute: %m");
return log_error_errno(r, "Failed to make path %s absolute: %m", argv[optind+1]);
arg_mount_where = canonicalize_file_name(p);
if (!arg_mount_where)
return log_error_errno(errno, "Failed to canonicalize path: %m");
return log_error_errno(errno, "Failed to canonicalize path %s: %m", p);
} else {
arg_mount_where = strdup(argv[optind+1]);
@@ -410,6 +417,12 @@ static int transient_unit_set_properties(sd_bus_message *m, char **properties) {
return r;
}
if (arg_aggressive_gc) {
r = sd_bus_message_append(m, "(sv)", "CollectMode", "s", "inactive-or-failed");
if (r < 0)
return r;
}
r = bus_append_unit_property_assignment_many(m, properties);
if (r < 0)
return r;