mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
Merge pull request #14605 from aerusso/pulls/x-systemd-wantedby-requiredby
Implemented x-systemd.{required,wanted}-by= options
This commit is contained in:
commit
fbbe240b21
@ -211,9 +211,9 @@
|
|||||||
<term><option>x-systemd.before=</option></term>
|
<term><option>x-systemd.before=</option></term>
|
||||||
<term><option>x-systemd.after=</option></term>
|
<term><option>x-systemd.after=</option></term>
|
||||||
|
|
||||||
<listitem><para>Configures a <varname>Before=</varname>
|
<listitem><para>In the created mount unit, configures a
|
||||||
dependency or <varname>After=</varname> between the created
|
<varname>Before=</varname> or <varname>After=</varname>
|
||||||
mount unit and another systemd unit, such as a mount unit.
|
dependency on another systemd unit, such as a mount unit.
|
||||||
The argument should be a unit name or an absolute path
|
The argument should be a unit name or an absolute path
|
||||||
to a mount point. This option may be specified more than once.
|
to a mount point. This option may be specified more than once.
|
||||||
This option is particularly useful for mount point declarations
|
This option is particularly useful for mount point declarations
|
||||||
@ -226,6 +226,21 @@
|
|||||||
for details.</para></listitem>
|
for details.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>x-systemd.wanted-by=</option></term>
|
||||||
|
<term><option>x-systemd.required-by=</option></term>
|
||||||
|
|
||||||
|
<listitem><para>In the created mount unit, configures a
|
||||||
|
<varname>WantedBy=</varname> or <varname>RequiredBy=</varname>
|
||||||
|
dependency on another unit. This option may be
|
||||||
|
specified more than once. If this is specified, the normal
|
||||||
|
automatic dependencies on the created mount unit, e.g.,
|
||||||
|
<filename>local-fs.target</filename>, are not automatically
|
||||||
|
created. See <varname>WantedBy=</varname> and <varname>RequiredBy=</varname> in
|
||||||
|
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||||
|
for details.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>x-systemd.requires-mounts-for=</option></term>
|
<term><option>x-systemd.requires-mounts-for=</option></term>
|
||||||
|
|
||||||
|
@ -306,6 +306,7 @@ static int add_mount(
|
|||||||
*automount_name = NULL,
|
*automount_name = NULL,
|
||||||
*filtered = NULL,
|
*filtered = NULL,
|
||||||
*where_escaped = NULL;
|
*where_escaped = NULL;
|
||||||
|
_cleanup_strv_free_ char **wanted_by = NULL, **required_by = NULL;
|
||||||
_cleanup_fclose_ FILE *f = NULL;
|
_cleanup_fclose_ FILE *f = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -327,6 +328,14 @@ static int add_mount(
|
|||||||
mount_point_ignore(where))
|
mount_point_ignore(where))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
r = fstab_extract_values(opts, "x-systemd.wanted-by", &wanted_by);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = fstab_extract_values(opts, "x-systemd.required-by", &required_by);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
if (path_equal(where, "/")) {
|
if (path_equal(where, "/")) {
|
||||||
if (flags & NOAUTO)
|
if (flags & NOAUTO)
|
||||||
log_warning("Ignoring \"noauto\" for root device");
|
log_warning("Ignoring \"noauto\" for root device");
|
||||||
@ -334,7 +343,13 @@ static int add_mount(
|
|||||||
log_warning("Ignoring \"nofail\" for root device");
|
log_warning("Ignoring \"nofail\" for root device");
|
||||||
if (flags & AUTOMOUNT)
|
if (flags & AUTOMOUNT)
|
||||||
log_warning("Ignoring automount option for root device");
|
log_warning("Ignoring automount option for root device");
|
||||||
|
if (!strv_isempty(wanted_by))
|
||||||
|
log_warning("Ignoring \"x-systemd.wanted-by=\" for root device");
|
||||||
|
if (!strv_isempty(required_by))
|
||||||
|
log_warning("Ignoring \"x-systemd.required-by=\" for root device");
|
||||||
|
|
||||||
|
required_by = strv_free(required_by);
|
||||||
|
wanted_by = strv_free(wanted_by);
|
||||||
SET_FLAG(flags, NOAUTO | NOFAIL | AUTOMOUNT, false);
|
SET_FLAG(flags, NOAUTO | NOFAIL | AUTOMOUNT, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,14 +466,28 @@ static int add_mount(
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & NOAUTO) && !(flags & AUTOMOUNT)) {
|
if (!FLAGS_SET(flags, AUTOMOUNT)) {
|
||||||
r = generator_add_symlink(dest, post,
|
if (!FLAGS_SET(flags, NOAUTO) && strv_isempty(wanted_by) && strv_isempty(required_by)) {
|
||||||
(flags & NOFAIL) ? "wants" : "requires", name);
|
r = generator_add_symlink(dest, post,
|
||||||
if (r < 0)
|
(flags & NOFAIL) ? "wants" : "requires", name);
|
||||||
return r;
|
if (r < 0)
|
||||||
}
|
return r;
|
||||||
|
} else {
|
||||||
|
char **s;
|
||||||
|
|
||||||
if (flags & AUTOMOUNT) {
|
STRV_FOREACH(s, wanted_by) {
|
||||||
|
r = generator_add_symlink(dest, *s, "wants", name);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
STRV_FOREACH(s, required_by) {
|
||||||
|
r = generator_add_symlink(dest, *s, "requires", name);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
r = unit_name_from_path(where, ".automount", &automount_name);
|
r = unit_name_from_path(where, ".automount", &automount_name);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to generate unit name: %m");
|
return log_error_errno(r, "Failed to generate unit name: %m");
|
||||||
|
Loading…
Reference in New Issue
Block a user