Compare commits

...

4 Commits

Author SHA1 Message Date
Daan De Meyer f74067dfbd sd-bus: Add sd_bus_list_names docs 2020-04-21 22:20:54 +02:00
Frantisek Sumsal ff3518f1f4 test: drop Disk (Size|Free|Floor|Ceiling) fields prior comparing
The disk attributes can take some time to update on certain filesystems,
so let's strip them from inputs of both `homectl` and `userdbctl` before
comparing them to avoid unexpected fails.

Also, switch from `cmp` to `diff` to make a potential test fail a bit more
debuggable.

Fixes: #14755
2020-04-21 22:09:35 +02:00
Lennart Poettering c5ca6d9076 update TODO 2020-04-21 21:23:01 +02:00
Lennart Poettering 33b58dfb41 core: automatically add udev dependency for units using RootImage=
We use udev to wait for /dev/loopX devices to be fully proped hence we
need an implicit ordering dependency on it, for RootImage= to work
reliably in early boot, too.

Fixes: #14972
2020-04-21 16:31:06 +02:00
8 changed files with 137 additions and 1 deletions

3
TODO
View File

@ -22,6 +22,9 @@ Janitorial Clean-ups:
Features:
* homed: maybe pre-create ~/.cache as subvol so that it can have separate quota
easily?
* journalctl --image= which is like --root= but operates on disk images
* when systemd-nspawn and suchlike dissect an OS image, and there are multiple

View File

@ -263,6 +263,7 @@ manpages = [
''],
['sd_bus_get_n_queued_read', '3', ['sd_bus_get_n_queued_write'], ''],
['sd_bus_is_open', '3', ['sd_bus_is_ready'], ''],
['sd_bus_list_names', '3', [], ''],
['sd_bus_message_append', '3', ['sd_bus_message_appendv'], ''],
['sd_bus_message_append_array',
'3',

View File

@ -86,6 +86,7 @@
<citerefentry><refentrytitle>sd_bus_get_unique_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_is_bus_client</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_is_server</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_list_names</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append_array</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append_basic</refentrytitle><manvolnum>3</manvolnum></citerefentry>,

111
man/sd_bus_list_names.xml Normal file
View File

@ -0,0 +1,111 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1+ -->
<refentry id="sd_bus_list_names"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_list_names</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_list_names</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_list_names</refname>
<refpurpose>Retrieve information about registered names on a bus</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_bus_list_names</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>char ***<parameter>acquired</parameter></paramdef>
<paramdef>char ***<parameter>activatable</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_bus_list_names()</function> retrieves information about the registered names on a bus.
If <parameter>acquired</parameter> is not <constant>NULL</constant>, this function calls
<ulink url="https://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-list-names">
org.freedesktop.DBus.ListNames</ulink> to retrieve the list of currently-owned names on the bus. If
<parameter>acquired</parameter> is not <constant>NULL</constant>, the function calls
<ulink url="https://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-list-activatable-names">
org.freedesktop.DBus.ListActivableNames</ulink> to retrieve the list of all names on the bus that can be
activated. Note that ownership of any string arrays returned by <function>sd_bus_list_names()</function>
is transferred to the caller and hence, the caller is responsible for freeing any results stored by
<function>sd_bus_list_names()</function> in <parameter>acquired</parameter> and
<parameter>activatable</parameter>.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success, <function>sd_bus_list_names()</function> returns a non-negative integer. On failure,
it returns a negative errno-style error code.</para>
<refsect2>
<title>Errors</title>
<para>Returned errors may indicate the following problems:</para>
<variablelist>
<varlistentry>
<term><constant>-EINVAL</constant></term>
<listitem><para><parameter>bus</parameter> or both <parameter>acquired</parameter> and
<parameter>activatable</parameter> were <constant>NULL</constant>.
</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOPKG</constant></term>
<listitem><para>The bus cannot be resolved.</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ECHILD</constant></term>
<listitem><para>The bus was created in a different process.</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOMEM</constant></term>
<listitem><para>Memory allocation failed.</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOTCONN</constant></term>
<listitem><para>The bus is not connected.</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -139,6 +139,9 @@
<varname>PrivateDevices=</varname> below, as it may change the setting of
<varname>DevicePolicy=</varname>.</para>
<para>Units making use of <varname>RootImage=</varname> automatically gain an
<varname>After=</varname> dependency on <filename>systemd-udevd.service</filename>.</para>
<xi:include href="system-only.xml" xpointer="singular"/></listitem>
</varlistentry>

View File

@ -82,6 +82,7 @@
#define SPECIAL_QUOTAON_SERVICE "quotaon.service"
#define SPECIAL_REMOUNT_FS_SERVICE "systemd-remount-fs.service"
#define SPECIAL_VOLATILE_ROOT_SERVICE "systemd-volatile-root.service"
#define SPECIAL_UDEVD_SERVICE "systemd-udevd.service"
/* Services systemd relies on */
#define SPECIAL_DBUS_SERVICE "dbus.service"

View File

@ -1079,6 +1079,15 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
return r;
}
if (c->root_image) {
/* We need to wait for /dev/loopX to appear when doing RootImage=, hence let's add an
* implicit dependency on udev */
r = unit_add_dependency_by_name(u, UNIT_AFTER, SPECIAL_UDEVD_SERVICE, true, UNIT_DEPENDENCY_FILE);
if (r < 0)
return r;
}
if (!IN_SET(c->std_output,
EXEC_OUTPUT_JOURNAL, EXEC_OUTPUT_JOURNAL_AND_CONSOLE,
EXEC_OUTPUT_KMSG, EXEC_OUTPUT_KMSG_AND_CONSOLE,

View File

@ -9,9 +9,16 @@ if ! test -x /usr/bin/homectl ; then
fi
inspect() {
# As updating disk-size-related attributes can take some time on
# some filesystems, let's drop these fields before comparing the
# outputs to avoid unexpected fails. To see the full outputs of both
# homectl & userdbctl (for debugging purposes) drop the fields just
# before the comparison.
homectl inspect $1 | tee /tmp/a
userdbctl user $1 | tee /tmp/b
cmp /tmp/a /tmp/b
local PATTERN='/^\s*Disk (Size|Free|Floor|Ceiling):/d'
diff <(sed -r "$PATTERN" /tmp/a) <(sed -r "$PATTERN" /tmp/b)
rm /tmp/a /tmp/b
}