mount-tool: never bind to device on explicit x-systemd.device-bound=no
This commit is contained in:
+15
-8
@@ -263,15 +263,22 @@
|
|||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>--bind-device</option></term>
|
<term><option>--bind-device</option></term>
|
||||||
|
|
||||||
<listitem><para>This option only has an effect in automount mode,
|
<listitem><para>Controls whether the generated mount/automount unit shall be bound to the backing device's
|
||||||
and controls whether the automount unit shall be bound to the backing device's lifetime. If set, the
|
lifetime. This setting is especially useful in automount mode. If set, the units will be stopped automatically
|
||||||
automount unit will be stopped automatically when the backing device vanishes. By default, the automount unit
|
when the backing device vanishes. By default, the automount unit stays around, and subsequent accesses
|
||||||
stays around, and subsequent accesses will block until backing device is replugged. This option has no effect
|
will block until backing device is replugged. This option has no effect in case of non-device mounts,
|
||||||
in case of non-device mounts, such as network or virtual file system mounts.</para>
|
such as network or virtual file system mounts.</para>
|
||||||
|
|
||||||
<para>Note that if <option>--discover</option> is used (or only a single argument passed, which implies
|
<para>If <option>--discover</option> is used (or only a single argument passed, which implies
|
||||||
<option>--discover</option>, see above), and the file system block device is detected to be removable, this
|
<option>--discover</option>, see above), and the file system block device is detected to be removable,
|
||||||
option is implied.</para>
|
this option is implied.</para>
|
||||||
|
|
||||||
|
<para>Note that mount units by default gain a <varname>Requires=</varname> dependency on
|
||||||
|
the backing device. This behavior can be controlled via <option>x-systemd.device-bound=</option>
|
||||||
|
mount option, see <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||||
|
for details. In particular, <option>x-systemd.device-bound=no</option> takes precedence over this option,
|
||||||
|
which suppresses device dependencies both in the generated mount units and what's implied by service manager.
|
||||||
|
</para>
|
||||||
|
|
||||||
<xi:include href="version-info.xml" xpointer="v232"/></listitem>
|
<xi:include href="version-info.xml" xpointer="v232"/></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|||||||
@@ -502,6 +502,24 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
if (arg_discover && arg_transport != BUS_TRANSPORT_LOCAL)
|
if (arg_discover && arg_transport != BUS_TRANSPORT_LOCAL)
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||||
"Automatic mount location discovery is only supported locally.");
|
"Automatic mount location discovery is only supported locally.");
|
||||||
|
|
||||||
|
_cleanup_free_ char *dev_bound = NULL;
|
||||||
|
r = fstab_filter_options(arg_mount_options, "x-systemd.device-bound\0",
|
||||||
|
/* ret_namefound = */ NULL, &dev_bound, /* ret_values = */ NULL, /* ret_filtered = */ NULL);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to parse mount options for x-systemd.device-bound=: %m");
|
||||||
|
if (r > 0 && !isempty(dev_bound)) {
|
||||||
|
/* If x-systemd.device-bound=no is explicitly specified, never bind automount unit
|
||||||
|
* to device either. */
|
||||||
|
r = parse_boolean(dev_bound);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Invalid x-systemd.device-bound= option: %s", dev_bound);
|
||||||
|
if (r == 0) {
|
||||||
|
log_full(arg_bind_device > 0 ? LOG_NOTICE : LOG_DEBUG,
|
||||||
|
"x-systemd.device-bound=no set, automatically disabling --bind-device.");
|
||||||
|
arg_bind_device = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user