Merge pull request #23868 from keszybz/lib-resplit-2

Export sd-netlink and clean up exported interfaces a bit
This commit is contained in:
Yu Watanabe
2022-07-01 13:13:42 +09:00
committed by GitHub
58 changed files with 861 additions and 561 deletions

View File

@@ -9,8 +9,8 @@ SPDX-License-Identifier: LGPL-2.1-or-later
## Code Map
This section will attempt to provide a high-level overview of the various
components of the systemd repository.
This document provides a high-level overview of the various components of the
systemd repository.
## Source Code
@@ -21,30 +21,60 @@ names are self-explanatory.
### Shared Code
You might wonder what kind of common code belongs in `src/shared/` and what
belongs in `src/basic/`. The split is like this: anything that is used to
implement the public shared objects we provide (`sd-bus`, `sd-login`,
`sd-id128`, `nss-systemd`, `nss-mymachines`, `nss-resolve`, `nss-myhostname`,
`pam_systemd`), must be located in `src/basic` (those objects are not allowed
to link to `libsystemd-shared.so`). Conversely, anything which is shared
between multiple components and does not need to be in `src/basic/`, should be
in `src/shared/`.
The code that is shared between components is split into a few directories,
each with a different purpose:
- `src/basic/` and `src/fundamental/` — those directories contain code
primitives that are used by all other code. `src/fundamental/` is stricter,
because it used for EFI and user-space code, while `src/basic/` is only used
for user-space code. The code in `src/fundamental/` cannot depend on any
other code in the tree, and `src/basic/` can depend only on itself and
`src/fundamental/`. For user-space, a static library is built from this code
and linked statically in various places.
- `src/libsystemd/` implements the `libsystemd.so` shared library (also
available as static `libsystemd.a`). This code may use anything in
`src/basic/` or `src/fundamental/`.
- `src/shared/` provides various utilities and code shared between other
components that is exposed as the `libsystemd-shared-<nnn>.so` shared library.
The other subdirectories implement individual components. They may depend only
on `src/fundamental/` + `src/basic/`, or also on `src/libsystemd/`, or also on
`src/shared/`.
You might wonder what kind of code belongs where. In general, the rule is that
code should linked as few times as possible, ideally only once. Thus code that
is used by "higher-level" components (e.g. our binaries which are linked to
`libsystemd-shared-<nnn>.so`), would go to a subdirectory specific to that
component if it is only used there. If the code is to be shared between
components, it'd go to `src/shared/`. Shared code that that is used by multiple
components that do not link to `libsystemd-shared-<nnn>.so` may live either in
`src/libsystemd/`, `src/basic/`, or `src/fundamental/`. Any code that is used
only for EFI goes under `src/boot/efi/`, and `src/fundamental/` if is shared
with non-EFI compoenents.
To summarize:
`src/fundamental/`
- may be used by all code in the tree
- may not use any code outside of `src/fundamental/`
`src/basic/`
- may be used by all code in the tree
- may not use any code outside of `src/basic/`
- may not use any code outside of `src/fundamental/` and `src/basic/`
`src/libsystemd/`
- may be used by all code in the tree, except for code in `src/basic/`
- may not use any code outside of `src/basic/`, `src/libsystemd/`
- may be used by all code in the tree that links to `libsystem.so`
- may not use any code outside of `src/fundamental/`, `src/basic/`, and
`src/libsystemd/`
`src/shared/`
- may be used by all code in the tree, except for code in `src/basic/`,
`src/libsystemd/`, `src/nss-*`, `src/login/pam_systemd.*`, and files under
`src/journal/` that end up in `libjournal-client.a` convenience library.
- may not use any code outside of `src/basic/`, `src/libsystemd/`, `src/shared/`
`src/libsystemd/`, `src/nss-*`, `src/login/pam_systemd.*`, and files under
`src/journal/` that end up in `libjournal-client.a` convenience library.
- may not use any code outside of `src/fundamental/`, `src/basic/`,
`src/libsystemd/`, `src/shared/`
### PID 1

View File

@@ -137,6 +137,7 @@ manpages = [
'sd_id128_in_setv',
'sd_id128_is_allf',
'sd_id128_is_null',
'sd_id128_string_equal',
'sd_id128_t'],
''],
['sd-journal', '3', [], ''],
@@ -267,7 +268,8 @@ manpages = [
'sd_bus_error_set_errno',
'sd_bus_error_set_errnof',
'sd_bus_error_set_errnofv',
'sd_bus_error_setf'],
'sd_bus_error_setf',
'sd_bus_error_setfv'],
''],
['sd_bus_error_add_map',
'3',
@@ -359,7 +361,7 @@ manpages = [
''],
['sd_bus_message_read_array', '3', [], ''],
['sd_bus_message_read_basic', '3', [], ''],
['sd_bus_message_read_strv', '3', [], ''],
['sd_bus_message_read_strv', '3', ['sd_bus_message_read_strv_extend'], ''],
['sd_bus_message_rewind', '3', [], ''],
['sd_bus_message_seal', '3', [], ''],
['sd_bus_message_sensitive', '3', [], ''],
@@ -646,7 +648,10 @@ manpages = [
'3',
['SD_HWDB_FOREACH_PROPERTY', 'sd_hwdb_enumerate', 'sd_hwdb_seek'],
''],
['sd_hwdb_new', '3', ['sd_hwdb_ref', 'sd_hwdb_unref'], ''],
['sd_hwdb_new',
'3',
['sd_hwdb_new_from_path', 'sd_hwdb_ref', 'sd_hwdb_unref'],
''],
['sd_id128_get_machine',
'3',
['sd_id128_get_boot',

View File

@@ -28,6 +28,7 @@
<refname>SD_ID128_NULL</refname>
<refname>SD_ID128_UUID_FORMAT_STR</refname>
<refname>sd_id128_equal</refname>
<refname>sd_id128_string_equal</refname>
<refname>sd_id128_in_set</refname>
<refname>sd_id128_in_set_sentinel</refname>
<refname>sd_id128_in_setv</refname>
@@ -40,6 +41,75 @@
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-id128.h&gt;</funcsynopsisinfo>
<para>
<constant>SD_ID128_ALLF</constant>
</para>
<para>
<constant>SD_ID128_NULL</constant>
</para>
<para>
<constant>SD_ID128_CONST_STR(<replaceable>id</replaceable>)</constant>
</para>
<para>
<constant>SD_ID128_FORMAT_STR</constant>
</para>
<para>
<constant>SD_ID128_FORMAT_VAL(<replaceable>id</replaceable>)</constant>
</para>
<para>
<constant>SD_ID128_MAKE(<replaceable>v0</replaceable>, <replaceable>v1</replaceable>, <replaceable>v2</replaceable>, <replaceable>v3</replaceable>, <replaceable>v4</replaceable>, <replaceable>v5</replaceable>, <replaceable>v6</replaceable>, <replaceable>v7</replaceable>, <replaceable>v8</replaceable>, <replaceable>v9</replaceable>, <replaceable>vA</replaceable>, <replaceable>vB</replaceable>, <replaceable>vC</replaceable>, <replaceable>vD</replaceable>, <replaceable>vE</replaceable>, <replaceable>vF</replaceable>)</constant>
</para>
<para>
<constant>SD_ID128_MAKE_STR(<replaceable>v0</replaceable>, <replaceable>v1</replaceable>, <replaceable>v2</replaceable>, <replaceable>v3</replaceable>, <replaceable>v4</replaceable>, <replaceable>v5</replaceable>, <replaceable>v6</replaceable>, <replaceable>v7</replaceable>, <replaceable>v8</replaceable>, <replaceable>v9</replaceable>, <replaceable>vA</replaceable>, <replaceable>vB</replaceable>, <replaceable>vC</replaceable>, <replaceable>vD</replaceable>, <replaceable>vE</replaceable>, <replaceable>vF</replaceable>)</constant>
</para>
<para>
<constant>SD_ID128_MAKE_UUID_STR(<replaceable>v0</replaceable>, <replaceable>v1</replaceable>, <replaceable>v2</replaceable>, <replaceable>v3</replaceable>, <replaceable>v4</replaceable>, <replaceable>v5</replaceable>, <replaceable>v6</replaceable>, <replaceable>v7</replaceable>, <replaceable>v8</replaceable>, <replaceable>v9</replaceable>, <replaceable>vA</replaceable>, <replaceable>vB</replaceable>, <replaceable>vC</replaceable>, <replaceable>vD</replaceable>, <replaceable>vE</replaceable>, <replaceable>vF</replaceable>)</constant>
</para>
<para>
<constant>SD_ID128_UUID_FORMAT_STR</constant>
</para>
<funcprototype>
<funcdef>int <function>sd_id128_equal</function></funcdef>
<paramdef>sd_id128_t <parameter>a</parameter></paramdef>
<paramdef>sd_id128_t <parameter>b</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_id128_string_equal</function></funcdef>
<paramdef>const char *<parameter>a</parameter></paramdef>
<paramdef>sd_id128_t <parameter>b</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_id128_is_null</function></funcdef>
<paramdef>sd_id128_t <parameter>id</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_id128_is_allf</function></funcdef>
<paramdef>sd_id128_t <parameter>id</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_id128_in_setv</function></funcdef>
<paramdef>sd_id128_t <parameter>id</parameter></paramdef>
<paramdef>va_list <parameter>ap</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_id128_in_set_sentinel</function></funcdef>
<paramdef>sd_id128_t <parameter>id</parameter></paramdef>
<paramdef></paramdef>
<paramdef><constant>SD_ID128_NULL</constant></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_id128_in_set</function></funcdef>
<paramdef>sd_id128_t <parameter>id</parameter></paramdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
<cmdsynopsis>
@@ -51,20 +121,13 @@
<refsect1>
<title>Description</title>
<para><filename>sd-id128.h</filename> provides APIs to process and generate 128-bit ID values. The
128-bit ID values processed and generated by these APIs are a generalization of OSF UUIDs as defined by
<ulink url="https://tools.ietf.org/html/rfc4122">RFC 4122</ulink> but use a simpler string format. These
functions impose no structure on the used IDs, much unlike OSF UUIDs or Microsoft GUIDs, but are mostly
compatible with those types of IDs.
<para><filename>sd-id128.h</filename> provides APIs to generate, convert, and compare 128-bit ID values.
The 128-bit ID values processed and generated by these APIs are a generalization of OSF UUIDs as defined
by <ulink url="https://tools.ietf.org/html/rfc4122">RFC 4122</ulink> but use a simpler string format.
These functions impose no structure on the used IDs, much unlike OSF UUIDs or Microsoft GUIDs, but are
mostly compatible with those types of IDs.
</para>
<para>See
<citerefentry><refentrytitle>sd_id128_to_string</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_id128_randomize</refentrytitle><manvolnum>3</manvolnum></citerefentry>
and
<citerefentry><refentrytitle>sd_id128_get_machine</refentrytitle><manvolnum>3</manvolnum></citerefentry>
for more information about the implemented functions.</para>
<para>A 128-bit ID is implemented as the following
union type:</para>
@@ -73,30 +136,28 @@
uint64_t qwords[2];
} sd_id128_t;</programlisting>
<para>This union type allows accessing the 128-bit ID as 16
separate bytes or two 64-bit words. It is generally safer to
access the ID components by their 8-bit array to avoid endianness
issues. This union is intended to be passed call-by-value (as
opposed to call-by-reference) and may be directly manipulated by
<para>This union type allows accessing the 128-bit ID as 16 separate bytes or two 64-bit words. It is
generally safer to access the ID components by their 8-bit array to avoid endianness issues. This union
is intended to be passed by value (as opposed to pass-by-reference) and may be directly manipulated by
clients.</para>
<para>A couple of macros are defined to denote and decode 128-bit
IDs:</para>
<para><function>SD_ID128_MAKE()</function> may be used to denote a
constant 128-bit ID in source code. A commonly used idiom is to
assign a name to a 128-bit ID using this macro:</para>
<para><function>SD_ID128_MAKE()</function> is used to write a constant ID in source code. A commonly used
idiom is to assign a name to an ID using this macro:</para>
<programlisting>#define SD_MESSAGE_COREDUMP SD_ID128_MAKE(fc,2e,22,bc,6e,e6,47,b6,b9,07,29,ab,34,a2,50,b1)</programlisting>
<para><constant>SD_ID128_NULL</constant> may be used to refer to the 128-bit ID consisting of only
<constant>NUL</constant> bytes (i.e. all bits off).</para>
<para><constant>SD_ID128_NULL</constant> defines an ID consisting of only <constant>NUL</constant> bytes
(i.e. all bits off).</para>
<para><constant>SD_ID128_ALLF</constant> may be used to refer to the 128-bit ID consisting of only
<constant>0xFF</constant> bytes (i.e. all bits on).</para>
<para><constant>SD_ID128_ALLF</constant> defines an ID consisting of only <constant>0xFF</constant> bytes
(i.e. all bits on).</para>
<para><function>SD_ID128_MAKE_STR()</function> is similar to <function>SD_ID128_MAKE()</function>, but creates a
<type>const char*</type> expression that can be conveniently used in message formats and such:</para>
<para><function>SD_ID128_MAKE_STR()</function> is similar to <function>SD_ID128_MAKE()</function>, but
creates a <type>const char*</type> expression that can be conveniently used in message formats and
such:</para>
<programlisting>#include &lt;stdio.h&gt;
#define SD_MESSAGE_COREDUMP_STR SD_ID128_MAKE_STR(fc,2e,22,bc,6e,e6,47,b6,b9,07,29,ab,34,a2,50,b1)
@@ -105,18 +166,16 @@ int main(int argc, char **argv) {
puts("Match for coredumps: MESSAGE_ID=" SD_MESSAGE_COREDUMP_STR);
}</programlisting>
<para><function>SD_ID128_CONST_STR()</function> may be used to
convert constant 128-bit IDs into constant strings for output. The
following example code will output the string
"fc2e22bc6ee647b6b90729ab34a250b1":</para>
<para><function>SD_ID128_CONST_STR()</function> converts constant IDs into constant strings for
output. The following example code will output the string "fc2e22bc6ee647b6b90729ab34a250b1":</para>
<programlisting>int main(int argc, char *argv[]) {
puts("Match for coredumps: %s", SD_ID128_CONST_STR(SD_MESSAGE_COREDUMP));
}</programlisting>
<para><constant>SD_ID128_FORMAT_STR</constant> and <function>SD_ID128_FORMAT_VAL()</function> may
be used to format a 128-bit ID in a
<citerefentry project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
format string, as shown in the following example:</para>
<para><constant>SD_ID128_FORMAT_STR</constant> and <function>SD_ID128_FORMAT_VAL()</function> is used to
format an ID in a <citerefentry
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry> format
string, as shown in the following example:</para>
<programlisting>int main(int argc, char *argv[]) {
sd_id128_t id;
@@ -136,7 +195,7 @@ int main(int argc, char **argv) {
best to avoid UUIDs of other variants, in order to avoid unnecessary ambiguities. All 128-bit IDs
generated by the sd-id128 APIs strictly conform to Variant 1 Version 4 UUIDs, as per RFC 4122.</para>
<para>Use <function>sd_id128_equal()</function> to compare two 128-bit IDs:</para>
<para><function>sd_id128_equal()</function> compares two 128-bit IDs:</para>
<programlisting>int main(int argc, char *argv[]) {
sd_id128_t a, b, c;
@@ -148,18 +207,26 @@ int main(int argc, char **argv) {
return 0;
}</programlisting>
<para>Use <function>sd_id128_is_null()</function> to check if an 128-bit ID consists of only
<constant>NUL</constant> bytes:</para>
<para><function>sd_id128_string_equal()</function> is similar to <function>sd_id128_equal()</function>,
but the first ID is formatted as <type>const char*</type>. The same restrictions apply as to the first
argument of <function>sd_id128_from_string()</function>.</para>
<para><function>sd_id128_is_null()</function> checks if an ID consists of only <constant>NUL</constant>
bytes:</para>
<programlisting>assert(sd_id128_is_null(SD_ID128_NULL));</programlisting>
<para>Similarly, use <function>sd_id128_is_allf()</function> to check if an 128-bit ID consists of only
<para>Similarly, <function>sd_id128_is_allf()</function> checks if an ID consists of only
<constant>0xFF</constant> bytes (all bits on):</para>
<programlisting>assert(sd_id128_is_allf(SD_ID128_ALLF));</programlisting>
<para>For convenience, <function>sd_id128_in_set()</function> takes a list of IDs and
returns true if any are equal to the first argument:</para>
<para><function>sd_id128_in_set_sentinel()</function> takes a list of IDs and returns true if the first
argument is equal to any of the subsequent arguments. The argument list is terminated by an
<constant>SD_ID128_NULL</constant> sentinel, which must be present.</para>
<para><function>sd_id128_in_set()</function> is a convenience function that takes a list of IDs and
returns true if the first argument is equal to any of the subsequent arguments:</para>
<programlisting>int main(int argc, char *argv[]) {
sd_id12_t a = SD_ID128_MAKE(ee,89,be,71,bd,6e,43,d6,91,e6,c5,5d,eb,03,02,07);
@@ -175,18 +242,25 @@ int main(int argc, char **argv) {
</programlisting>
<para><function>sd_id128_in_set()</function> is defined as a macro over
<function>sd_id128_in_set_sentinel()</function>, adding the <constant>SD_ID128_NULL</constant>
sentinel. Since <function>sd_id128_in_set_sentinel()</function> uses <constant>SD_ID128_NULL</constant>
as the sentinel, <constant>SD_ID128_NULL</constant> cannot be otherwise placed in the argument list.
</para>
<function>sd_id128_in_set_sentinel()</function>, adding the <constant>SD_ID128_NULL</constant> sentinel
automatically. Since <function>sd_id128_in_set_sentinel()</function> uses
<constant>SD_ID128_NULL</constant> as the sentinel, <constant>SD_ID128_NULL</constant> cannot be
otherwise placed in the argument list.</para>
<para><function>sd_id128_in_setv()</function> is similar to
<function>sd_id128_in_set_sentinel()</function>, but takes a <structname>struct varargs</structname>
argument.</para>
<para>Note that new, randomized IDs may be generated with
<para>New randomized IDs may be generated with
<citerefentry><refentrytitle>systemd-id128</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
<command>new</command> command.</para>
<para>See
<citerefentry><refentrytitle>sd_id128_to_string</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_id128_randomize</refentrytitle><manvolnum>3</manvolnum></citerefentry>
and
<citerefentry><refentrytitle>sd_id128_get_machine</refentrytitle><manvolnum>3</manvolnum></citerefentry>
for information about other implemented functions.</para>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />

View File

@@ -22,6 +22,7 @@
<refname>sd_bus_error_free</refname>
<refname>sd_bus_error_set</refname>
<refname>sd_bus_error_setf</refname>
<refname>sd_bus_error_setfv</refname>
<refname>sd_bus_error_set_const</refname>
<refname>sd_bus_error_set_errno</refname>
<refname>sd_bus_error_set_errnof</refname>
@@ -74,6 +75,14 @@
<paramdef></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_error_setfv</function></funcdef>
<paramdef>sd_bus_error *<parameter>e</parameter></paramdef>
<paramdef>const char *<parameter>name</parameter></paramdef>
<paramdef>const char *<parameter>format</parameter></paramdef>
<paramdef>va_list <parameter>ap</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_error_set_const</function></funcdef>
<paramdef>sd_bus_error *<parameter>e</parameter></paramdef>
@@ -196,11 +205,15 @@
which case an <constant>SD_BUS_ERROR_NO_MEMORY</constant> error will be set instead and
<constant>-ENOMEM</constant> returned. </para>
<para><function>sd_bus_error_setf()</function> is similar to
<function>sd_bus_error_set()</function>, but takes a <citerefentry
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
format string and corresponding arguments to generate the
<structfield>message</structfield> field.</para>
<para><function>sd_bus_error_setf()</function> and <function>sd_bus_error_setfv()</function> are similar
to <function>sd_bus_error_set()</function>, but take a <citerefentry
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry> format
string and corresponding arguments to generate the <structfield>message</structfield> field.
<function>sd_bus_error_setf()</function> uses variadic arguments, and
<function>sd_bus_error_setfv()</function> accepts the arguments as a
<citerefentry
project='man-pages'><refentrytitle>va_arg</refentrytitle><manvolnum>3</manvolnum></citerefentry>
parameter list.</para>
<para><function>sd_bus_error_set_const()</function> is similar to
<function>sd_bus_error_set()</function>, but the string parameters are not copied internally, and must
@@ -223,17 +236,15 @@
due to lack of memory, in which case an <constant>SD_BUS_ERROR_NO_MEMORY</constant> error is set instead,
and <constant>-ENOMEM</constant> is returned.</para>
<para><function>sd_bus_error_set_errnof()</function> is similar to
<function>sd_bus_error_set_errno()</function>, but in addition to
<parameter>error</parameter>, takes a <citerefentry
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
format string and corresponding arguments. The
<structfield>message</structfield> field will be generated from
<parameter>format</parameter> and the arguments.</para>
<para><function>sd_bus_error_set_errnofv()</function> is similar to
<function>sd_bus_error_set_errnof()</function>, but takes the
format string parameters as <citerefentry
<para><function>sd_bus_error_set_errnof()</function> and <function>sd_bus_error_set_errnof()</function>
are similar to <function>sd_bus_error_set_errno()</function>, but in addition to
<parameter>error</parameter>, take a <citerefentry
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry> format
string and corresponding arguments. The <structfield>message</structfield> field will be generated from
<parameter>format</parameter> and the arguments.
<function>sd_bus_error_set_errnof()</function> uses variadic arguments, and
<function>sd_bus_error_set_errnofv()</function> accepts the arguments as a
<citerefentry
project='man-pages'><refentrytitle>va_arg</refentrytitle><manvolnum>3</manvolnum></citerefentry>
parameter list.</para>

View File

@@ -44,9 +44,10 @@
<title>Description</title>
<para>The <function>sd_bus_message_dump()</function> function writes a textual representation of the
message <parameter>m</parameter> to the stream <parameter>f</parameter>. This function is intended to be
used for debugging purposes, and the output is neither stable nor designed to be machine readable.
</para>
message <parameter>m</parameter> to the stream <parameter>f</parameter>. If <parameter>f</parameter> is
<constant>NULL</constant>, standard output (<constant>stdio</constant>) will be used. This function is
intended to be used for debugging purposes, and the output is neither stable nor designed to be machine
readable.</para>
<para>The <parameter>flags</parameter> parameter may be used to modify the output. With
<constant>SD_BUS_MESSAGE_DUMP_WITH_HEADER</constant>, a header that specifies the message type and flags

View File

@@ -17,6 +17,7 @@
<refnamediv>
<refname>sd_bus_message_read_strv</refname>
<refname>sd_bus_message_read_strv_extend</refname>
<refpurpose>Access an array of strings in a message</refpurpose>
</refnamediv>
@@ -30,26 +31,39 @@
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
<paramdef>char ***<parameter>l</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_message_read_strv_extend</function></funcdef>
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
<paramdef>char ***<parameter>l</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_bus_message_read_strv()</function> gives access to an array of string-like items in
<para><function>sd_bus_message_read_strv()</function> reads an array of string-like items from the
message <parameter>m</parameter>. The "read pointer" in the message must be right before an array of
strings (D-Bus type <literal>as</literal>), object paths (D-Bus type <literal>ao</literal>), or
signatures (D-Bus type <literal>ag</literal>). On success, a pointer to a
<constant>NULL</constant>-terminated array of strings is returned in the output parameter
<constant>NULL</constant>-terminated array of strings (strv) is returned in the output parameter
<parameter>l</parameter>. Note that ownership of this array is transferred to the caller. Hence, the
caller is responsible for freeing this array and its contents.</para>
<para><function>sd_bus_message_read_strv_extend()</function> is similar, but the second parameter is an
input-output parameter. If <parameter>*l</parameter> is <constant>NULL</constant>, if behaves identically
to <function>sd_bus_message_read_strv()</function>. Otherwise, <parameter>*l</parameter> must point to a
strv, which will be reallocated and extended with additional strings. This function is particularly
useful when combining multiple lists of strings in a message or messages into a single array of strings.
</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success, <function>sd_bus_message_read_strv()</function> returns a non-negative integer. On
failure, it returns a negative errno-style error code.</para>
<para>On success, these functions return a non-negative integer. On failure, they return a negative
errno-style error code.</para>
<refsect2>
<title>Errors</title>

View File

@@ -53,28 +53,29 @@
<refsect1>
<title>Description</title>
<para><function>sd_event_source_set_enabled()</function> may be
used to enable or disable the event source object specified as
<parameter>source</parameter>. The <parameter>enabled</parameter>
parameter takes one of <constant>SD_EVENT_ON</constant> (to
enable), <constant>SD_EVENT_OFF</constant> (to disable) or
<constant>SD_EVENT_ONESHOT</constant>. If invoked with
<constant>SD_EVENT_ONESHOT</constant> the event source will be
enabled but automatically reset to
<constant>SD_EVENT_OFF</constant> after the event source was
dispatched once.</para>
<para><function>sd_event_source_set_enabled()</function> may be used to enable or disable the event
source object specified as <parameter>source</parameter>. The <parameter>enabled</parameter> parameter
takes one of <constant>SD_EVENT_ON</constant> (to enable), <constant>SD_EVENT_OFF</constant> (to disable)
or <constant>SD_EVENT_ONESHOT</constant>. If invoked with <constant>SD_EVENT_ONESHOT</constant> the event
source will be enabled but automatically reset to <constant>SD_EVENT_OFF</constant> after one dispatch.
For <constant>SD_EVENT_OFF</constant>, the event source <parameter>source</parameter> may be
<constant>NULL</constant>, in which case the function does nothing. Otherwise,
<parameter>source</parameter> must be a valid pointer to an <structname>sd_event_source</structname>
object.</para>
<para>Event sources that are disabled will not result in event
loop wakeups and will not be dispatched, until they are enabled
again.</para>
<para><function>sd_event_source_get_enabled()</function> may be
used to query whether the event source object
<parameter>source</parameter> is currently enabled or not. It
returns the enablement state (one of <constant>SD_EVENT_ON</constant>,
<constant>SD_EVENT_OFF</constant>, <constant>SD_EVENT_ONESHOT</constant>)
in <parameter>enabled</parameter>, if it is not <constant>NULL</constant>.
It also returns true if the event source is not disabled.</para>
<para><function>sd_event_source_get_enabled()</function> may be used to query whether the event source
object <parameter>source</parameter> is currently enabled or not. If both the
<parameter>source</parameter> and the output parameter <parameter>enabled</parameter> are
<constant>NULL</constant>, this function returns false. Otherwise, <parameter>source</parameter> must be
a valid pointer to an <structname>sd_event_source</structname> object. If the output parameter
<parameter>enabled</parameter> is not <constant>NULL</constant>, it is set to the enablement state (one
of <constant>SD_EVENT_ON</constant>, <constant>SD_EVENT_OFF</constant>,
<constant>SD_EVENT_ONESHOT</constant>). The function also returns true if the event source is not
disabled.</para>
<para>Event source objects are enabled when they are first created
with calls such as

View File

@@ -1928,7 +1928,6 @@ alias_target('devel', libsystemd_pc, libudev_pc)
libsystemd = shared_library(
'systemd',
disable_mempool_c,
version : libsystemd_version,
include_directories : libsystemd_includes,
link_args : ['-shared',
@@ -1953,7 +1952,6 @@ install_libsystemd_static = static_library(
basic_gcrypt_sources,
basic_compress_sources,
fundamental_sources,
disable_mempool_c,
include_directories : libsystemd_includes,
build_by_default : static_libsystemd != 'false',
install : static_libsystemd != 'false',
@@ -1975,7 +1973,6 @@ install_libsystemd_static = static_library(
libudev = shared_library(
'udev',
disable_mempool_c,
version : libudev_version,
include_directories : includes,
link_args : ['-shared',
@@ -1997,7 +1994,6 @@ install_libudev_static = static_library(
shared_sources,
libsystemd_sources,
libudev_sources,
disable_mempool_c,
include_directories : includes,
build_by_default : static_libudev != 'false',
install : static_libudev != 'false',
@@ -2118,7 +2114,6 @@ subdir('test')
test_dlopen = executable(
'test-dlopen',
test_dlopen_c,
disable_mempool_c,
include_directories : includes,
link_with : [libbasic],
dependencies : [libdl],
@@ -2148,7 +2143,6 @@ foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
nss = shared_library(
'nss_' + module,
sources,
disable_mempool_c,
version : '2',
include_directories : incs,
# Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned

View File

@@ -771,16 +771,15 @@ static void shared_hash_key_initialize(void) {
static struct HashmapBase* hashmap_base_new(const struct hash_ops *hash_ops, enum HashmapType type HASHMAP_DEBUG_PARAMS) {
HashmapBase *h;
const struct hashmap_type_info *hi = &hashmap_type_info[type];
bool up;
up = mempool_enabled();
bool use_pool = mempool_enabled && mempool_enabled();
h = up ? mempool_alloc0_tile(hi->mempool) : malloc0(hi->head_size);
h = use_pool ? mempool_alloc0_tile(hi->mempool) : malloc0(hi->head_size);
if (!h)
return NULL;
h->type = type;
h->from_pool = up;
h->from_pool = use_pool;
h->hash_ops = hash_ops ?: &trivial_hash_ops;
if (type == HASHMAP_TYPE_ORDERED) {

View File

@@ -3,12 +3,9 @@
#include <stdint.h>
#include <stdlib.h>
#include "env-util.h"
#include "macro.h"
#include "memory-util.h"
#include "mempool.h"
#include "process-util.h"
#include "util.h"
struct pool {
struct pool *next;
@@ -73,20 +70,6 @@ void mempool_free_tile(struct mempool *mp, void *p) {
mp->freelist = p;
}
bool mempool_enabled(void) {
static int b = -1;
if (!is_main_thread())
return false;
if (!mempool_use_allowed)
b = false;
if (b < 0)
b = getenv_bool("SYSTEMD_MEMPOOL") != 0;
return b;
}
#if VALGRIND
void mempool_drop(struct mempool *mp) {
struct pool *p = mp->first_pool;

View File

@@ -23,8 +23,7 @@ static struct mempool pool_name = { \
.at_least = alloc_at_least, \
}
extern const bool mempool_use_allowed;
bool mempool_enabled(void);
__attribute__((weak)) bool mempool_enabled(void);
#if VALGRIND
void mempool_drop(struct mempool *mp);

View File

@@ -129,7 +129,7 @@ static inline int fd_inc_sndbuf(int fd, size_t n) {
return fd_set_sndbuf(fd, n, true);
}
int fd_set_rcvbuf(int fd, size_t n, bool increase);
static inline int fd_inc_rcvbuf(int fd, size_t n) {
static inline int fd_increase_rxbuf(int fd, size_t n) {
return fd_set_rcvbuf(fd, n, true);
}

View File

@@ -1005,7 +1005,7 @@ static int manager_setup_notify(Manager *m) {
if (fd < 0)
return log_error_errno(errno, "Failed to allocate notification socket: %m");
fd_inc_rcvbuf(fd, NOTIFY_RCVBUF_SIZE);
fd_increase_rxbuf(fd, NOTIFY_RCVBUF_SIZE);
m->notify_socket = path_join(m->prefix[EXEC_DIRECTORY_RUNTIME], "systemd/notify");
if (!m->notify_socket)
@@ -1093,7 +1093,7 @@ static int manager_setup_cgroups_agent(Manager *m) {
if (fd < 0)
return log_error_errno(errno, "Failed to allocate cgroups agent socket: %m");
fd_inc_rcvbuf(fd, CGROUPS_AGENT_RCVBUF_SIZE);
fd_increase_rxbuf(fd, CGROUPS_AGENT_RCVBUF_SIZE);
(void) sockaddr_un_unlink(&sa.un);
@@ -1157,7 +1157,7 @@ static int manager_setup_user_lookup_fd(Manager *m) {
if (socketpair(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, m->user_lookup_fds) < 0)
return log_error_errno(errno, "Failed to allocate user lookup socket: %m");
(void) fd_inc_rcvbuf(m->user_lookup_fds[0], NOTIFY_RCVBUF_SIZE);
(void) fd_increase_rxbuf(m->user_lookup_fds[0], NOTIFY_RCVBUF_SIZE);
}
if (!m->user_lookup_event_source) {

View File

@@ -10,6 +10,8 @@
#include <sys/quota.h>
#include <sys/stat.h>
#include "sd-id128.h"
#include "btrfs-util.h"
#include "bus-common-errors.h"
#include "bus-error.h"
@@ -1239,7 +1241,7 @@ static int manager_add_device(Manager *m, sd_device *d) {
return 0;
if (r < 0)
return log_error_errno(r, "Failed to acquire ID_PART_ENTRY_TYPE device property, ignoring: %m");
if (id128_equal_string(parttype, GPT_USER_HOME) <= 0) {
if (sd_id128_string_equal(parttype, GPT_USER_HOME) <= 0) {
log_debug("Found partition (%s) we don't care about, ignoring.", sysfs);
return 0;
}

View File

@@ -14,6 +14,7 @@
#include "sd-daemon.h"
#include "sd-device.h"
#include "sd-event.h"
#include "sd-id128.h"
#include "blkid-util.h"
#include "blockdev-util.h"
@@ -34,7 +35,6 @@
#include "home-util.h"
#include "homework-luks.h"
#include "homework-mount.h"
#include "id128-util.h"
#include "io-util.h"
#include "keyring-util.h"
#include "memory-util.h"
@@ -704,7 +704,7 @@ static int luks_validate(
if (!pp)
return errno > 0 ? -errno : -EIO;
if (id128_equal_string(blkid_partition_get_type_string(pp), GPT_USER_HOME) <= 0)
if (sd_id128_string_equal(blkid_partition_get_type_string(pp), GPT_USER_HOME) <= 0)
continue;
if (!streq_ptr(blkid_partition_get_name(pp), label))

View File

@@ -375,12 +375,9 @@ ManagedJournalFile* managed_journal_file_close(ManagedJournalFile *f) {
}
#endif
if (f->file->post_change_timer) {
if (sd_event_source_get_enabled(f->file->post_change_timer, NULL) > 0)
journal_file_post_change(f->file);
sd_event_source_disable_unref(f->file->post_change_timer);
}
if (sd_event_source_get_enabled(f->file->post_change_timer, NULL) > 0)
journal_file_post_change(f->file);
sd_event_source_disable_unref(f->file->post_change_timer);
managed_journal_file_set_offline(f, true);

View File

@@ -1,5 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "mempool.h"
const bool mempool_use_allowed = false;

View File

@@ -781,5 +781,165 @@ global:
LIBSYSTEMD_252 {
global:
sd_bus_message_read_strv_extend;
sd_bus_error_setfv;
sd_id128_string_equal;
sd_hwdb_new_from_path;
sd_netlink_new_from_fd;
sd_netlink_open;
sd_netlink_open_fd;
sd_netlink_increase_rxbuf;
sd_netlink_ref;
sd_netlink_unref;
sd_netlink_send;
sd_netlink_call_async;
sd_netlink_call;
sd_netlink_read;
sd_netlink_get_events;
sd_netlink_get_timeout;
sd_netlink_process;
sd_netlink_wait;
sd_netlink_add_match;
sd_netlink_attach_event;
sd_netlink_detach_event;
sd_netlink_attach_filter;
sd_netlink_message_append_string;
sd_netlink_message_append_strv;
sd_netlink_message_append_flag;
sd_netlink_message_append_u8;
sd_netlink_message_append_u16;
sd_netlink_message_append_u32;
sd_netlink_message_append_u64;
sd_netlink_message_append_s8;
sd_netlink_message_append_s16;
sd_netlink_message_append_s32;
sd_netlink_message_append_s64;
sd_netlink_message_append_data;
sd_netlink_message_append_in_addr;
sd_netlink_message_append_in6_addr;
sd_netlink_message_append_sockaddr_in;
sd_netlink_message_append_sockaddr_in6;
sd_netlink_message_append_ether_addr;
sd_netlink_message_append_cache_info;
sd_netlink_message_open_container;
sd_netlink_message_open_container_union;
sd_netlink_message_close_container;
sd_netlink_message_read;
sd_netlink_message_read_data;
sd_netlink_message_read_data_suffix0;
sd_netlink_message_read_string_strdup;
sd_netlink_message_read_string;
sd_netlink_message_read_strv;
sd_netlink_message_read_u8;
sd_netlink_message_read_u16;
sd_netlink_message_read_u32;
sd_netlink_message_read_ether_addr;
sd_netlink_message_read_cache_info;
sd_netlink_message_read_in_addr;
sd_netlink_message_read_in6_addr;
sd_netlink_message_has_flag;
sd_netlink_message_enter_container;
sd_netlink_message_enter_array;
sd_netlink_message_exit_container;
sd_netlink_message_open_array;
sd_netlink_message_cancel_array;
sd_netlink_message_rewind;
sd_netlink_message_next;
sd_netlink_message_ref;
sd_netlink_message_unref;
sd_netlink_message_request_dump;
sd_netlink_message_is_error;
sd_netlink_message_get_errno;
sd_netlink_message_get_type;
sd_netlink_message_set_flags;
sd_netlink_message_is_broadcast;
sd_netlink_message_get_max_attribute;
sd_netlink_slot_ref;
sd_netlink_slot_unref;
sd_netlink_slot_get_netlink;
sd_netlink_slot_get_userdata;
sd_netlink_slot_set_userdata;
sd_netlink_slot_get_destroy_callback;
sd_netlink_slot_set_destroy_callback;
sd_netlink_slot_get_floating;
sd_netlink_slot_set_floating;
sd_netlink_slot_get_description;
sd_netlink_slot_set_description;
sd_rtnl_message_get_family;
sd_rtnl_message_new_addr;
sd_rtnl_message_new_addr_update;
sd_rtnl_message_addr_set_prefixlen;
sd_rtnl_message_addr_set_scope;
sd_rtnl_message_addr_set_flags;
sd_rtnl_message_addr_get_family;
sd_rtnl_message_addr_get_prefixlen;
sd_rtnl_message_addr_get_scope;
sd_rtnl_message_addr_get_flags;
sd_rtnl_message_addr_get_ifindex;
sd_rtnl_message_new_link;
sd_rtnl_message_link_set_flags;
sd_rtnl_message_link_set_type;
sd_rtnl_message_link_set_family;
sd_rtnl_message_link_get_ifindex;
sd_rtnl_message_link_get_flags;
sd_rtnl_message_link_get_type;
sd_rtnl_message_new_route;
sd_rtnl_message_route_set_dst_prefixlen;
sd_rtnl_message_route_set_src_prefixlen;
sd_rtnl_message_route_set_scope;
sd_rtnl_message_route_set_flags;
sd_rtnl_message_route_set_table;
sd_rtnl_message_route_set_type;
sd_rtnl_message_route_get_flags;
sd_rtnl_message_route_get_family;
sd_rtnl_message_route_get_protocol;
sd_rtnl_message_route_get_scope;
sd_rtnl_message_route_get_tos;
sd_rtnl_message_route_get_table;
sd_rtnl_message_route_get_dst_prefixlen;
sd_rtnl_message_route_get_src_prefixlen;
sd_rtnl_message_route_get_type;
sd_rtnl_message_new_nexthop;
sd_rtnl_message_nexthop_set_flags;
sd_rtnl_message_nexthop_get_flags;
sd_rtnl_message_nexthop_get_family;
sd_rtnl_message_nexthop_get_protocol;
sd_rtnl_message_new_neigh;
sd_rtnl_message_neigh_set_flags;
sd_rtnl_message_neigh_set_state;
sd_rtnl_message_neigh_get_family;
sd_rtnl_message_neigh_get_ifindex;
sd_rtnl_message_neigh_get_state;
sd_rtnl_message_neigh_get_flags;
sd_rtnl_message_new_addrlabel;
sd_rtnl_message_addrlabel_set_prefixlen;
sd_rtnl_message_addrlabel_get_prefixlen;
sd_rtnl_message_new_routing_policy_rule;
sd_rtnl_message_routing_policy_rule_set_tos;
sd_rtnl_message_routing_policy_rule_get_tos;
sd_rtnl_message_routing_policy_rule_set_table;
sd_rtnl_message_routing_policy_rule_get_table;
sd_rtnl_message_routing_policy_rule_set_fib_src_prefixlen;
sd_rtnl_message_routing_policy_rule_get_fib_src_prefixlen;
sd_rtnl_message_routing_policy_rule_set_fib_dst_prefixlen;
sd_rtnl_message_routing_policy_rule_get_fib_dst_prefixlen;
sd_rtnl_message_routing_policy_rule_set_fib_type;
sd_rtnl_message_routing_policy_rule_get_fib_type;
sd_rtnl_message_routing_policy_rule_set_flags;
sd_rtnl_message_routing_policy_rule_get_flags;
sd_rtnl_message_new_traffic_control;
sd_rtnl_message_traffic_control_get_ifindex;
sd_rtnl_message_traffic_control_get_handle;
sd_rtnl_message_traffic_control_get_parent;
sd_rtnl_message_new_mdb;
sd_genl_socket_open;
sd_genl_message_new;
sd_genl_message_get_family_name;
sd_genl_message_get_command;
sd_genl_add_match;
} LIBSYSTEMD_251;

View File

@@ -155,10 +155,8 @@ libsystemd_sources = files(
'sd-path/sd-path.c',
'sd-resolve/resolve-private.h',
'sd-resolve/sd-resolve.c',
'sd-utf8/sd-utf8.c',
) + sd_journal_sources + id128_sources + sd_daemon_sources + sd_event_sources + sd_login_sources
disable_mempool_c = files('disable-mempool.c')
libsystemd_c_args = ['-fvisibility=default']

View File

@@ -270,7 +270,7 @@ _public_ int sd_bus_reply_method_errorfv(
if (call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)
return 0;
bus_error_setfv(&error, name, format, ap);
sd_bus_error_setfv(&error, name, format, ap);
return sd_bus_reply_method_error(call, &error);
}

Some files were not shown because too many files have changed in this diff Show More