mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
Merge pull request #3909 from poettering/mount-tool
add a new tool for creating transient mount and automount units
This commit is contained in:
commit
29272c04a7
1
.gitignore
vendored
1
.gitignore
vendored
@ -89,6 +89,7 @@
|
||||
/systemd-machine-id-setup
|
||||
/systemd-machined
|
||||
/systemd-modules-load
|
||||
/systemd-mount
|
||||
/systemd-networkd
|
||||
/systemd-networkd-wait-online
|
||||
/systemd-notify
|
||||
|
@ -121,6 +121,7 @@ MANPAGES += \
|
||||
man/systemd-journald.service.8 \
|
||||
man/systemd-machine-id-commit.service.8 \
|
||||
man/systemd-machine-id-setup.1 \
|
||||
man/systemd-mount.1 \
|
||||
man/systemd-notify.1 \
|
||||
man/systemd-nspawn.1 \
|
||||
man/systemd-path.1 \
|
||||
@ -2651,6 +2652,7 @@ EXTRA_DIST += \
|
||||
man/systemd-machine-id-setup.xml \
|
||||
man/systemd-machined.service.xml \
|
||||
man/systemd-modules-load.service.xml \
|
||||
man/systemd-mount.xml \
|
||||
man/systemd-networkd-wait-online.service.xml \
|
||||
man/systemd-networkd.service.xml \
|
||||
man/systemd-notify.xml \
|
||||
|
@ -384,6 +384,7 @@ bin_PROGRAMS = \
|
||||
systemd-delta \
|
||||
systemd-analyze \
|
||||
systemd-run \
|
||||
systemd-mount \
|
||||
systemd-stdio-bridge \
|
||||
systemd-path
|
||||
|
||||
@ -3145,6 +3146,13 @@ systemd_run_SOURCES = \
|
||||
systemd_run_LDADD = \
|
||||
libsystemd-shared.la
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
systemd_mount_SOURCES = \
|
||||
src/mount/mount-tool.c
|
||||
|
||||
systemd_mount_LDADD = \
|
||||
libsystemd-shared.la
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
systemd_stdio_bridge_SOURCES = \
|
||||
src/stdio-bridge/stdio-bridge.c
|
||||
|
@ -28,6 +28,12 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id='no-ask-password'>
|
||||
<term><option>--no-ask-password</option></term>
|
||||
|
||||
<listitem><para>Do not query the user for authentication for privileged operations.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id='no-legend'>
|
||||
<term><option>--no-legend</option></term>
|
||||
|
||||
|
295
man/systemd-mount.xml
Normal file
295
man/systemd-mount.xml
Normal file
@ -0,0 +1,295 @@
|
||||
<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
||||
|
||||
<!--
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2016 Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<refentry id="systemd-mount"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
|
||||
<refentryinfo>
|
||||
<title>systemd-mount</title>
|
||||
<productname>systemd</productname>
|
||||
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Lennart</firstname>
|
||||
<surname>Poettering</surname>
|
||||
<email>lennart@poettering.net</email>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
|
||||
<refmeta>
|
||||
<refentrytitle>systemd-mount</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>systemd-mount</refname>
|
||||
<refpurpose>Establish a mount or auto-mount point transiently</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>systemd-mount</command>
|
||||
<arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
|
||||
<arg choice="plain"><replaceable>WHAT</replaceable></arg>
|
||||
<arg choice="opt"><replaceable>WHERE</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
<cmdsynopsis>
|
||||
<command>systemd-mount</command>
|
||||
<arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
|
||||
<arg choice="plain"><option>--list</option></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<para><command>systemd-mount</command> may be used to create and start a transient <filename>.mount</filename> or
|
||||
<filename>.automount</filename> unit of the file system <replaceable>WHAT</replaceable> on the mount point
|
||||
<replaceable>WHERE</replaceable>.</para>
|
||||
|
||||
<para>In many ways, <command>systemd-mount</command> is similar to the lower-level
|
||||
<citerefentry><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry> command, however instead
|
||||
of executing the mount operation directly and immediately, <command>systemd-mount</command> schedules it through
|
||||
the service manager job queue, so that it may pull in further dependencies (such as parent mounts, or a file system
|
||||
checker to execute a priori), and may make use of the auto-mounting logic.</para>
|
||||
|
||||
<para>The command takes either one or two arguments. If only one argument is specified it should refer to a block
|
||||
device containing a file system (e.g. <literal>/dev/sdb1</literal>), which is then probed for a label and other
|
||||
metadata, and is mounted to a directory whose name is generated from the label. In this mode the block device must
|
||||
exist at the time of invocation of the command, so that it may be probed. If the device is found to be a removable
|
||||
block device (e.g. a USB stick) an automount point instead of a regular mount point is created (i.e. the
|
||||
<option>--automount=</option> option is implied, see below).</para>
|
||||
|
||||
<para>If two arguments are specified the first indicates the mount source (the <replaceable>WHAT</replaceable>) and
|
||||
the second indicates the path to mount it on (the <replaceable>WHERE</replaceable>). In this mode no probing of the
|
||||
source is attempted, and a backing device node doesn't have to exist yet. However, if this mode is combined with
|
||||
<option>--discover</option>, device node probing for additional metadata is enabled, and – much like in the
|
||||
single-argument case discussed above – the specified device has to exist at the time of invocation of the
|
||||
command.</para>
|
||||
|
||||
<para>Use the <option>--list</option> command to show a terse table of all local, known block devices with file
|
||||
systems that may be mounted with this command.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Options</title>
|
||||
|
||||
<para>The following options are understood:</para>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--no-block</option></term>
|
||||
|
||||
<listitem>
|
||||
<para>Do not synchronously wait for the requested operation to finish. If this is not specified, the job will
|
||||
be verified, enqueued and <command>systemd-mount</command> will wait until the mount or automount unit's
|
||||
start-up is completed. By passing this argument, it is only verified and enqueued.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<xi:include href="standard-options.xml" xpointer="no-pager"/>
|
||||
<xi:include href="standard-options.xml" xpointer="no-ask-password"/>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--quiet</option></term>
|
||||
<term><option>-q</option></term>
|
||||
|
||||
<listitem><para>Suppresses additional informational output while running.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--discover</option></term>
|
||||
|
||||
<listitem><para>Enable probing of the mount source. This switch is implied if a single argument is specified on
|
||||
the command line. If passed, additional metadata is read from the device to enhance the unit to create. For
|
||||
example, a descriptive string for the transient units is generated from the file system label and device
|
||||
model. Moreover if a removable block device (e.g. USB stick) is detected an automount unit instead of a regular
|
||||
mount unit is created, with a short idle time-out, in order to ensure the file-system is placed in a clean
|
||||
state quickly after each access.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--type=</option></term>
|
||||
<term><option>-t</option></term>
|
||||
|
||||
<listitem><para>Specifies the file system type to mount (e.g. <literal>vfat</literal>, <literal>ext4</literal>,
|
||||
…). If omitted (or set to <literal>auto</literal>) the file system is determined automatically.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--options=</option></term>
|
||||
<term><option>-o</option></term>
|
||||
|
||||
<listitem><para>Additional mount options for the mount point.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--fsck=</option></term>
|
||||
|
||||
<listitem><para>Takes a boolean argument, defaults to on. Controls whether to run a file system check
|
||||
immediately before the mount operation. In the automount case (see <option>--automount=</option> below) the
|
||||
check will be run the moment the first access to the device is made, which might slightly delay the
|
||||
access.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--description=</option></term>
|
||||
|
||||
<listitem><para>Provide a description for the mount or automount unit. See <varname>Description=</varname> in
|
||||
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--property=</option></term>
|
||||
<term><option>-p</option></term>
|
||||
|
||||
<listitem><para>Sets a unit property for the mount unit that is created. This takes an assignment in the same
|
||||
format as <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
|
||||
<command>set-property</command> command.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--automount=</option></term>
|
||||
|
||||
<listitem><para>Takes a boolean argument. Controls whether to create an automount point or a regular mount
|
||||
point. If true an automount point is created that is backed by the actual file system at the time of first
|
||||
access. If false a plain mount point is created that is backed by the actual file system immediately. Automount
|
||||
points have the benefit that the file system stays unmounted and hence in clean state until it is first
|
||||
accessed. In automount mode the <option>--timeout-idle-sec=</option> switch (see below) may be used to ensure
|
||||
the mount point is unmounted automatically after the last access and an idle period passed.</para>
|
||||
|
||||
<para>If this switch is not specified it defaults to false. If not specified and <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, it is set to true, in order to increase the chance that the
|
||||
file system is in a fully clean state if the device is unplugged abruptly.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-A</option></term>
|
||||
|
||||
<listitem><para>Equivalent to <option>--automount=yes</option>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--timeout-idle-sec=</option></term>
|
||||
|
||||
<listitem><para>Takes a time value that controls the idle timeout in automount mode. If set to
|
||||
<literal>infinity</literal> (the default) no automatic unmounts are done. Otherwise the file system backing the
|
||||
automount point is detached after the last access and the idle timeout passed. See
|
||||
<citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> for details on
|
||||
the time syntax supported. This option has no effect if only a regular mount is established, and automounting
|
||||
is not used.</para>
|
||||
|
||||
<para>Note that 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,
|
||||
<option>--timeout-idle-sec=1s</option> is implied.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--automount-property=</option></term>
|
||||
|
||||
<listitem><para>Similar to <option>--property=</option>, but applies additional properties to the automount
|
||||
unit created, instead of the mount unit.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--bind-device=</option></term>
|
||||
|
||||
<listitem><para>Takes a boolean argument, defaults to off. This option only has an effect in automount mode,
|
||||
and controls whether the automount unit shall be bound to the backing device's lifetime. If enabled, the
|
||||
automount point will be removed automatically when the backing device vanishes. If disabled the automount point
|
||||
stays around, and subsequent accesses will block until backing device is replugged. This option has no effect
|
||||
in case of non-device mounts, 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
|
||||
<option>--discover</option>, see above), and the file system block device is detected to be removable, this
|
||||
option is implied.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--list</option></term>
|
||||
|
||||
<listitem><para>Instead of establishing a mount or automount point, print a terse list of block devices
|
||||
containing file systems that may be mounted with <literal>systemd-mount</literal>, along with useful metadata
|
||||
such as labels, etc.</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" />
|
||||
<xi:include href="user-system-options.xml" xpointer="machine" />
|
||||
|
||||
<xi:include href="standard-options.xml" xpointer="help" />
|
||||
<xi:include href="standard-options.xml" xpointer="version" />
|
||||
</variablelist>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Exit status</title>
|
||||
|
||||
<para>On success, 0 is returned, a non-zero failure
|
||||
code otherwise.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>The udev Database</title>
|
||||
|
||||
<para>If <option>--discover</option> is used, <command>systemd-mount</command> honours a couple of additional udev
|
||||
properties of block devices:</para>
|
||||
|
||||
<variablelist class='udev-directives'>
|
||||
<varlistentry>
|
||||
<term><varname>SYSTEMD_MOUNT_OPTIONS=</varname></term>
|
||||
|
||||
<listitem><para>The mount options to use, if <option>--options=</option> is not used.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>SYSTEMD_MOUNT_WHERE=</varname></term>
|
||||
|
||||
<listitem><para>The file system path to place the mount point at, instead of the automatically generated
|
||||
one.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>See Also</title>
|
||||
<para>
|
||||
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
@ -45,7 +45,7 @@
|
||||
|
||||
<refnamediv>
|
||||
<refname>systemd-run</refname>
|
||||
<refpurpose>Run programs in transient scope or service or timer units</refpurpose>
|
||||
<refpurpose>Run programs in transient scope units, service units, or timer-scheduled service units</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
@ -452,6 +452,7 @@ There is a screen on:
|
||||
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>systemd-mount</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
@ -75,7 +75,6 @@ static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *mnt_id
|
||||
return safe_atoi(p, mnt_id);
|
||||
}
|
||||
|
||||
|
||||
int fd_is_mount_point(int fd, const char *filename, int flags) {
|
||||
union file_handle_union h = FILE_HANDLE_INIT, h_parent = FILE_HANDLE_INIT;
|
||||
int mount_id = -1, mount_id_parent = -1;
|
||||
|
1
src/mount/Makefile
Symbolic link
1
src/mount/Makefile
Symbolic link
@ -0,0 +1 @@
|
||||
../Makefile
|
1112
src/mount/mount-tool.c
Normal file
1112
src/mount/mount-tool.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -68,7 +68,6 @@ int register_machine(
|
||||
local_ifindex > 0 ? 1 : 0, local_ifindex);
|
||||
} else {
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
|
||||
char **i;
|
||||
unsigned j;
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
@ -157,11 +156,9 @@ int register_machine(
|
||||
return bus_log_create_error(r);
|
||||
}
|
||||
|
||||
STRV_FOREACH(i, properties) {
|
||||
r = bus_append_unit_property_assignment(m, *i);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = bus_append_unit_property_assignment_many(m, properties);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_message_close_container(m);
|
||||
if (r < 0)
|
||||
|
@ -83,9 +83,7 @@ static void polkit_agent_open_if_enabled(void) {
|
||||
|
||||
static void help(void) {
|
||||
printf("%s [OPTIONS...] {COMMAND} [ARGS...]\n\n"
|
||||
"Run the specified command in a transient scope or service or timer\n"
|
||||
"unit. If a timer option is specified and the unit specified with\n"
|
||||
"the --unit option exists, the command can be omitted.\n\n"
|
||||
"Run the specified command in a transient scope or service.\n\n"
|
||||
" -h --help Show this help\n"
|
||||
" --version Show package version\n"
|
||||
" --no-ask-password Do not prompt for password\n"
|
||||
@ -94,7 +92,7 @@ static void help(void) {
|
||||
" -M --machine=CONTAINER Operate on local container\n"
|
||||
" --scope Run this as scope rather than service\n"
|
||||
" --unit=UNIT Run under the specified unit name\n"
|
||||
" -p --property=NAME=VALUE Set unit property\n"
|
||||
" -p --property=NAME=VALUE Set service or scope unit property\n"
|
||||
" --description=TEXT Description for unit\n"
|
||||
" --slice=SLICE Run in the specified slice\n"
|
||||
" --no-block Do not wait until operation finished\n"
|
||||
@ -107,15 +105,15 @@ static void help(void) {
|
||||
" -E --setenv=NAME=VALUE Set environment\n"
|
||||
" -t --pty Run service on pseudo tty\n"
|
||||
" -q --quiet Suppress information messages during runtime\n\n"
|
||||
"Timer options:\n\n"
|
||||
"Timer options:\n"
|
||||
" --on-active=SECONDS Run after SECONDS delay\n"
|
||||
" --on-boot=SECONDS Run SECONDS after machine was booted up\n"
|
||||
" --on-startup=SECONDS Run SECONDS after systemd activation\n"
|
||||
" --on-unit-active=SECONDS Run SECONDS after the last activation\n"
|
||||
" --on-unit-inactive=SECONDS Run SECONDS after the last deactivation\n"
|
||||
" --on-calendar=SPEC Realtime timer\n"
|
||||
" --timer-property=NAME=VALUE Set timer unit property\n",
|
||||
program_invocation_short_name);
|
||||
" --timer-property=NAME=VALUE Set timer unit property\n"
|
||||
, program_invocation_short_name);
|
||||
}
|
||||
|
||||
static bool with_timer(void) {
|
||||
@ -178,7 +176,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
{ "on-calendar", required_argument, NULL, ARG_ON_CALENDAR },
|
||||
{ "timer-property", required_argument, NULL, ARG_TIMER_PROPERTY },
|
||||
{ "no-block", no_argument, NULL, ARG_NO_BLOCK },
|
||||
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
|
||||
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
|
||||
{},
|
||||
};
|
||||
|
||||
@ -195,13 +193,13 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
help();
|
||||
return 0;
|
||||
|
||||
case ARG_VERSION:
|
||||
return version();
|
||||
|
||||
case ARG_NO_ASK_PASSWORD:
|
||||
arg_ask_password = false;
|
||||
break;
|
||||
|
||||
case ARG_VERSION:
|
||||
return version();
|
||||
|
||||
case ARG_USER:
|
||||
arg_user = true;
|
||||
break;
|
||||
@ -410,18 +408,15 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
static int transient_unit_set_properties(sd_bus_message *m, char **properties) {
|
||||
char **i;
|
||||
int r;
|
||||
|
||||
r = sd_bus_message_append(m, "(sv)", "Description", "s", arg_description);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
STRV_FOREACH(i, properties) {
|
||||
r = bus_append_unit_property_assignment(m, *i);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = bus_append_unit_property_assignment_many(m, properties);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1144,7 +1139,7 @@ static int start_transient_timer(
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
if (argv[0]) {
|
||||
if (!strv_isempty(argv)) {
|
||||
r = sd_bus_message_open_container(m, 'r', "sa(sv)");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
@ -568,6 +568,21 @@ finish:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bus_append_unit_property_assignment_many(sd_bus_message *m, char **l) {
|
||||
char **i;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
||||
STRV_FOREACH(i, l) {
|
||||
r = bus_append_unit_property_assignment(m, *i);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct BusWaitForJobs {
|
||||
sd_bus *bus;
|
||||
Set *jobs;
|
||||
|
@ -41,6 +41,7 @@ typedef struct UnitInfo {
|
||||
int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u);
|
||||
|
||||
int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignment);
|
||||
int bus_append_unit_property_assignment_many(sd_bus_message *m, char **l);
|
||||
|
||||
typedef struct BusWaitForJobs BusWaitForJobs;
|
||||
|
||||
|
@ -5093,7 +5093,6 @@ static int set_property(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_free_ char *n = NULL;
|
||||
sd_bus *bus;
|
||||
char **i;
|
||||
int r;
|
||||
|
||||
r = acquire_bus(BUS_MANAGER, &bus);
|
||||
@ -5124,11 +5123,9 @@ static int set_property(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
STRV_FOREACH(i, strv_skip(argv, 2)) {
|
||||
r = bus_append_unit_property_assignment(m, *i);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = bus_append_unit_property_assignment_many(m, strv_skip(argv, 2));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_message_close_container(m);
|
||||
if (r < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user