mirror of
https://github.com/systemd/systemd
synced 2025-10-01 17:54:45 +02:00
Compare commits
No commits in common. "1f3315b8bdbc9240f70f90373f2b9043f2087ac5" and "0eaee8281d4699903b8b2cce18c836d4a144aee3" have entirely different histories.
1f3315b8bd
...
0eaee8281d
126
NEWS
126
NEWS
@ -28,38 +28,26 @@ CHANGES WITH 248:
|
|||||||
used to configure dm-verity behaviour for the root device.
|
used to configure dm-verity behaviour for the root device.
|
||||||
|
|
||||||
* The key file specified in /etc/crypttab (the third field) may now
|
* The key file specified in /etc/crypttab (the third field) may now
|
||||||
refer to an AF_UNIX/SOCK_STREAM socket in the file system. The key is
|
refer to a UNIX socket path. The key is acquired by connecting to
|
||||||
acquired by connecting to that socket and reading from it. This
|
that socket and reading from it. This allows the implementation of a
|
||||||
allows the implementation of a service to provide key information
|
service to provide key information dynamically, at the moment when it
|
||||||
dynamically, at the moment when it is needed.
|
is needed.
|
||||||
|
|
||||||
* Support has been added to systemd-cryptsetup for extracting the
|
* Support has been added for extracting the PKCS#11 token URI and
|
||||||
PKCS#11 token URI and encrypted key from the LUKS2 JSON embedded
|
encrypted key from the LUKS2 JSON embedded metadata header. This
|
||||||
metadata header. This allows the information how to open the
|
allows the information how to open the encrypted device to be
|
||||||
encrypted device to be embedded directly in the device and obviates
|
embedded directly in the device and obviates the need for
|
||||||
the need for configuration in an external file.
|
configuration in an external file.
|
||||||
|
|
||||||
* systemd-cryptsetup gained support for unlocking LUKS2 volumes using
|
* LUKS devices may now be unlocked using TPM2 hardware.
|
||||||
TPM2 hardware, as well as FIDO2 security tokens.
|
|
||||||
|
|
||||||
* systemd-repart may lock partitions using TPM2 hardware. This may be
|
* systemd-repart may lock partitions using TPM2 hardware. This may be
|
||||||
useful for example to create an encrypted /var partition bound to the
|
useful for example to create an encrypted /var partition bound to the
|
||||||
machine on first boot.
|
machine on first boot.
|
||||||
|
|
||||||
* A new systemd-cryptenroll tool has been added to enroll TPM2, FIDO2
|
* A new systemd-cryptenroll tool has been added to enroll FIDO2+PKCS#11
|
||||||
and PKCS#11 security tokens to LUKS volumes, list and destroy
|
security tokens to LUKS volumes, list and destroy them. See
|
||||||
them. See:
|
https://www.freedesktop.org/software/systemd/man/systemd-cryptenroll.html.
|
||||||
|
|
||||||
http://0pointer.net/blog/unlocking-luks2-volumes-with-tpm2-fido2-pkcs11-security-hardware-on-systemd-248.html
|
|
||||||
|
|
||||||
It also supports enrolling "recovery keys" and regular passphrases.
|
|
||||||
|
|
||||||
* The libfido2 dependency is now based on dlopen(), so that the library
|
|
||||||
is used at runtime when installed, but not if not.
|
|
||||||
|
|
||||||
* systemd-cryptsetup gained support for two new options in
|
|
||||||
/etc/crypttab: no-write-workqueue and no-read-workqueue which request
|
|
||||||
synchronous processing of encryption/decryption IO.
|
|
||||||
|
|
||||||
* The manager may be configured at compile time to use fexecve instead
|
* The manager may be configured at compile time to use fexecve instead
|
||||||
of execve when spawning children. Using fexecve closes a window
|
of execve when spawning children. Using fexecve closes a window
|
||||||
@ -70,8 +58,8 @@ CHANGES WITH 248:
|
|||||||
* The configuration option -Dcompat-gateway-hostname has been dropped.
|
* The configuration option -Dcompat-gateway-hostname has been dropped.
|
||||||
"_gateway" is now the only supported name.
|
"_gateway" is now the only supported name.
|
||||||
|
|
||||||
* The ConditionSecurity=tpm2 unit file setting may be used to check if
|
* The ConditionSecurity=tpm2 unit file setting may be used to check
|
||||||
the system has at least one TPM2 (tpmrm class) device.
|
if the system has at least one TPM2 (tpmrm class) device.
|
||||||
|
|
||||||
* The tables of system calls in seccomps filters are now automatically
|
* The tables of system calls in seccomps filters are now automatically
|
||||||
generated from kernel lists exported on
|
generated from kernel lists exported on
|
||||||
@ -101,25 +89,13 @@ CHANGES WITH 248:
|
|||||||
* The ExecPaths= and NoExecPaths= settings may be used to specify
|
* The ExecPaths= and NoExecPaths= settings may be used to specify
|
||||||
noexec for parts of the file system.
|
noexec for parts of the file system.
|
||||||
|
|
||||||
* sd-bus has a new function sd_bus_open_user_machine() to open a
|
* sd-bus has a new function sd_bus_open_use_machine() to open a
|
||||||
connection to the session bus of a specific user in a local container
|
connection to the session bus of a specific user in a local container
|
||||||
or on the local host. This is exposed in the -M switch to systemctl
|
or on the local host. It also gained a convenience function
|
||||||
and similar tools:
|
sd_bus_reply() to call sd_bus_send() with an existing reply message.
|
||||||
|
|
||||||
systemctl --user -M lennart@foobar start foo
|
* sd-event allows rate limits to be set on event sources. See the new
|
||||||
|
man page sd_event_source_set_ratelimit(3) for details.
|
||||||
This will connect to the user bus of a user "lennart" in container
|
|
||||||
"foobar". If no container name is specified, the specified user on
|
|
||||||
the host itself is connected to
|
|
||||||
|
|
||||||
systemctl --user -M lennart@ start quux
|
|
||||||
|
|
||||||
* sd-bus also gained a convenience function sd_bus_reply() to call
|
|
||||||
sd_bus_send() with an existing reply message.
|
|
||||||
|
|
||||||
* sd-event allows rate limits to be set on event sources, for dealing
|
|
||||||
with high-priority event sources that might starve out others. See
|
|
||||||
the new man page sd_event_source_set_ratelimit(3) for details.
|
|
||||||
|
|
||||||
* systemd.link files gained a [Link] Promiscuous= switch, which allows
|
* systemd.link files gained a [Link] Promiscuous= switch, which allows
|
||||||
the device to be raised in promiscuous mode.
|
the device to be raised in promiscuous mode.
|
||||||
@ -152,11 +128,6 @@ CHANGES WITH 248:
|
|||||||
systemd.network files gained a [DHCPv6PrefixDelegation]
|
systemd.network files gained a [DHCPv6PrefixDelegation]
|
||||||
ManageTemporaryAddress= switch.
|
ManageTemporaryAddress= switch.
|
||||||
|
|
||||||
.network files gained a new ActivationPolicy= setting which allows
|
|
||||||
configuraiton how the UP state of an interface shall be managed,
|
|
||||||
i.e. whether the iterface is always upped, always downed, or may be
|
|
||||||
upped/downed by the user using "ip dev".
|
|
||||||
|
|
||||||
* systemd.netdev files gained a [VLAN] Protocol=, IngressQOSMaps=,
|
* systemd.netdev files gained a [VLAN] Protocol=, IngressQOSMaps=,
|
||||||
EgressQOSMaps=, and [MACVLAN] BroadcastMulticastQueueLength=
|
EgressQOSMaps=, and [MACVLAN] BroadcastMulticastQueueLength=
|
||||||
configuration options for VLAN packet handling.
|
configuration options for VLAN packet handling.
|
||||||
@ -168,10 +139,10 @@ CHANGES WITH 248:
|
|||||||
* udev now exports the VOLUME_ID, LOGICAL_VOLUME_ID, VOLUME_SET_ID, and
|
* udev now exports the VOLUME_ID, LOGICAL_VOLUME_ID, VOLUME_SET_ID, and
|
||||||
DATA_PREPARED_ID attributes for block devices (when available).
|
DATA_PREPARED_ID attributes for block devices (when available).
|
||||||
|
|
||||||
* udev now exports decoded DMI information about used memory slots as
|
* udev now exports decoded DMI information about memory under the
|
||||||
device properties under the /sys/class/dmi/id/ pseudo device.
|
/sys/class/dmi/id/ pseudo device.
|
||||||
|
|
||||||
* /dev/ is not mounted noexec any more. This didn't provide any
|
* /dev is not mounted noexec any more. This didn't provide any
|
||||||
significant security benefits and would conflicts with the executable
|
significant security benefits and would conflicts with the executable
|
||||||
mappings used with /dev/sgx device nodes.
|
mappings used with /dev/sgx device nodes.
|
||||||
|
|
||||||
@ -187,27 +158,12 @@ CHANGES WITH 248:
|
|||||||
DNS query and respond with a mostly unmodified packet received from
|
DNS query and respond with a mostly unmodified packet received from
|
||||||
the upstream server.
|
the upstream server.
|
||||||
|
|
||||||
* systemd-resolved learnt a new boolean option CacheFromLocalhost= in
|
|
||||||
resolved.conf. If true the service will provide caching even for DNS
|
|
||||||
lookups made to an upstream DNS server on the 127.0.0.1/::1
|
|
||||||
addresses. By default (and when the option is false) systemd-resolved
|
|
||||||
will not cache such lookups, in order to avoid duplicate local
|
|
||||||
caching, under the assumption the local upstream server caches
|
|
||||||
anyway.
|
|
||||||
|
|
||||||
* systemd-nspawn gained a new --ambient-capability= setting
|
* systemd-nspawn gained a new --ambient-capability= setting
|
||||||
(AmbientCapability= in .nspawn files) to configure ambient
|
(AmbientCapability= in .nspawn files) to configure ambient
|
||||||
capabilities passed to the container payload.
|
capabilities passed to the container payload.
|
||||||
|
|
||||||
* systemd-nspawn gained the ability to configure the firewall using the
|
* systemd-nspawn gained the ability to configure the firewall using the
|
||||||
nftables subsystem (in addition to the existing iptables
|
nft subsystem (in addition to the existing iptables support).
|
||||||
support). Similar, systemd-networkd's IPMasquerade= option now
|
|
||||||
supports nftables as backend, too. In both cases NAT on IPv6 is now
|
|
||||||
supported too, in addition to IPv4 (the iptables backend still is
|
|
||||||
IPv4-only).
|
|
||||||
|
|
||||||
* systemd-importd will now download .verity and .roothash.p7s files
|
|
||||||
along with the machine image (as exposed via machinectl pull-raw).
|
|
||||||
|
|
||||||
* systemd-oomd now gained a new DefaultMemoryPressureDurationSec=
|
* systemd-oomd now gained a new DefaultMemoryPressureDurationSec=
|
||||||
setting to configure the time a unit's cgroup needs to exceed memory
|
setting to configure the time a unit's cgroup needs to exceed memory
|
||||||
@ -232,20 +188,15 @@ CHANGES WITH 248:
|
|||||||
the configured hostname ("static", "transient", or "fallback") as
|
the configured hostname ("static", "transient", or "fallback") as
|
||||||
D-Bus properties.
|
D-Bus properties.
|
||||||
|
|
||||||
* systemd-hostnamed now exports the "HardwareVendor" and
|
* systemd-hostnamed now exports the HardwareVendor and HardwareModel
|
||||||
"HardwareModel" D-Bus properties, which are supposed to contain a
|
D-Bus properties. hostnamectl shows this in the status output.
|
||||||
pair of cleaned up, human readable strings describing the system
|
|
||||||
vendor and model. It's typically source from the firmware's DMI
|
|
||||||
tables, but may be augmented from a new hwdb database. hostnamectl
|
|
||||||
shows this in the status output.
|
|
||||||
|
|
||||||
* systemd-localed may now call locale-gen to generate missing locales
|
* systemd-localed may now call locale-gen to generate missing locales
|
||||||
on-demand (UTF-8-only). This improves integration with Debian-based
|
on-demand (UTF-8-only). This improves integration with Debian-based
|
||||||
distributions (Debian/Ubuntu/PureOS/Tanglu/...) and Arch Linux.
|
distributions (Debian/Ubuntu/PureOS/Tanglu/...) and Arch Linux.
|
||||||
|
|
||||||
* systemctl --check-inhibitors=true may now be used to obey inhibitors
|
* systemctl --check-inhibitors may now be used to obey inhibitors even
|
||||||
even when invoked non-interactively. The old --ignore-inhibitors
|
when invoked non-interactively.
|
||||||
switch is now deprecated and replaced by --check-inhibitors=false.
|
|
||||||
|
|
||||||
* systemctl import-environment will now emit a warning when called
|
* systemctl import-environment will now emit a warning when called
|
||||||
without any arguments (i.e. to import the full environment block of
|
without any arguments (i.e. to import the full environment block of
|
||||||
@ -260,11 +211,6 @@ CHANGES WITH 248:
|
|||||||
directly calling the D-Bus API of the manager, should also push
|
directly calling the D-Bus API of the manager, should also push
|
||||||
specific variables, and not the full inherited environment.
|
specific variables, and not the full inherited environment.
|
||||||
|
|
||||||
* systemctl's status output now shows unit state with a more careful
|
|
||||||
selection of Unicode characters: units in maintainance show a "○"
|
|
||||||
symbol instead of the usual "●", failed units show "×", and services
|
|
||||||
being reloaded "↻".
|
|
||||||
|
|
||||||
* coredumpctl gained a --debugger-arguments= switch to pass arguments
|
* coredumpctl gained a --debugger-arguments= switch to pass arguments
|
||||||
to the debugger.
|
to the debugger.
|
||||||
|
|
||||||
@ -273,13 +219,12 @@ CHANGES WITH 248:
|
|||||||
* Various tools gained --pager/--no-pager/--json switches to
|
* Various tools gained --pager/--no-pager/--json switches to
|
||||||
enable/disable the pager and provide JSON output.
|
enable/disable the pager and provide JSON output.
|
||||||
|
|
||||||
* Various tools now accept SYSTEMD_COLORS=16|256 to configure how
|
* Various tools now accept SYSTEMD_COLORS=16|256 to configure what
|
||||||
many terminal colours are used in output.
|
colours are used in output.
|
||||||
|
|
||||||
* less 568 or newer is now required. Hyperlink ANSI sequences in
|
* less 568 or newer is now required. Link markup is now always used,
|
||||||
termina output are now used even if a pager is used, and older
|
and older versions will not display it properly. SYSTEMD_URLIFY=0 may
|
||||||
versions of less are not able to display these sequences
|
be used to disable it.
|
||||||
correctly. SYSTEMD_URLIFY=0 may be used to disable it.
|
|
||||||
|
|
||||||
* Builds with support for separate / and /usr hierarchies (split-usr
|
* Builds with support for separate / and /usr hierarchies (split-usr
|
||||||
builds, non-merged-usr builds) are now officially deprecated. A
|
builds, non-merged-usr builds) are now officially deprecated. A
|
||||||
@ -292,11 +237,6 @@ CHANGES WITH 248:
|
|||||||
for partitions, as in the vast majority of cases they contain none
|
for partitions, as in the vast majority of cases they contain none
|
||||||
and are used internally by the bootloader (eg: uboot).
|
and are used internally by the bootloader (eg: uboot).
|
||||||
|
|
||||||
* systemd will now set the $SYSTEMD_EXEC_PID environment variable for
|
|
||||||
spawned processes to the PID of the process itself. This may be used
|
|
||||||
by programs for detecting whether they were forked off by the service
|
|
||||||
manager itself or are a process forked off further down the tree.
|
|
||||||
|
|
||||||
CHANGES WITH 247:
|
CHANGES WITH 247:
|
||||||
|
|
||||||
* KERNEL API INCOMPATIBILITY: Linux 4.14 introduced two new uevents
|
* KERNEL API INCOMPATIBILITY: Linux 4.14 introduced two new uevents
|
||||||
|
12
TODO
12
TODO
@ -20,18 +20,6 @@ Janitorial Clean-ups:
|
|||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
||||||
* add an Open= setting to service unit files that can open arbitrary file
|
|
||||||
system paths at service startup time and pass them to the service process via
|
|
||||||
our usual socket activation protocol. If passed path refers to AF_UNIX
|
|
||||||
socket: connect() to it.
|
|
||||||
|
|
||||||
* add a ConnectSocket= setting to service unit files, that may reference a
|
|
||||||
socket unit, and which will connect to the socket defined therein, and pass
|
|
||||||
the resulting fd to the service program via socket activation proto.
|
|
||||||
|
|
||||||
* Add a concept of ListenStream=anonymous to socket units: listen on a socket
|
|
||||||
that is deleted in the fs. Usecase would be with ConnectSocket= above.
|
|
||||||
|
|
||||||
* Hook up journald's FSS logic with TPM2: seal the verification disk by
|
* Hook up journald's FSS logic with TPM2: seal the verification disk by
|
||||||
time-based policy, so that the verification key can remain on host and ve
|
time-based policy, so that the verification key can remain on host and ve
|
||||||
validated via TPM.
|
validated via TPM.
|
||||||
|
@ -1463,29 +1463,17 @@ evdev:input:b0003v047FpC006*
|
|||||||
# Purism
|
# Purism
|
||||||
###########################################################
|
###########################################################
|
||||||
|
|
||||||
# If you're using an us layout keyboard in one of the below models of
|
# Purism Librem 13 V2
|
||||||
# Purism Librem 13 consider copying this file to /etc/systemd/hwdb.d/
|
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v2*:*
|
||||||
# to enable the following rule acording to your model.
|
KEYBOARD_KEY_56=backslash
|
||||||
#
|
|
||||||
# There's a bug in the keyboards firmware and the additional rule
|
# Purism Librem 13 V3
|
||||||
# will make your keyboard behave as expected.
|
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v3*:*
|
||||||
#
|
KEYBOARD_KEY_56=backslash
|
||||||
# More info:
|
|
||||||
# - https://github.com/systemd/systemd/issues/15360
|
# Purism Librem 13 V4
|
||||||
# - https://github.com/systemd/systemd/pull/11516
|
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v4*:*
|
||||||
# - https://tracker.pureos.net/T888
|
KEYBOARD_KEY_56=backslash
|
||||||
#
|
|
||||||
# # Purism Librem 13 V2
|
|
||||||
# evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v2*:*
|
|
||||||
# KEYBOARD_KEY_56=backslash
|
|
||||||
#
|
|
||||||
# # Purism Librem 13 V3
|
|
||||||
# evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v3*:*
|
|
||||||
# KEYBOARD_KEY_56=backslash
|
|
||||||
#
|
|
||||||
# # Purism Librem 13 V4
|
|
||||||
# evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v4*:*
|
|
||||||
# KEYBOARD_KEY_56=backslash
|
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
# Quanta
|
# Quanta
|
||||||
|
@ -1935,12 +1935,18 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
|
|||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>UseDNS=</varname></term>
|
<term><varname>UseDNS=</varname></term>
|
||||||
<term><varname>UseNTP=</varname></term>
|
<term><varname>UseNTP=</varname></term>
|
||||||
<term><varname>UseHostname=</varname></term>
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>As in the [DHCPv4] section.</para>
|
<para>As in the [DHCPv4] section.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>UseFQDN=</varname></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Equivalent of <varname>UseHostname=</varname> in the [DHCPv4] section.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>RouteMetric=</varname></term>
|
<term><varname>RouteMetric=</varname></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -495,7 +495,7 @@ int random_write_entropy(int fd, const void *seed, size_t size, bool credit) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t random_u64_range(uint64_t m) {
|
int random_u64_range(uint64_t m) {
|
||||||
uint64_t x, remainder;
|
uint64_t x, remainder;
|
||||||
|
|
||||||
/* Generates a random number in the range 0…m-1, unbiased. (Java's algorithm) */
|
/* Generates a random number in the range 0…m-1, unbiased. (Java's algorithm) */
|
||||||
|
@ -41,4 +41,4 @@ size_t random_pool_size(void);
|
|||||||
|
|
||||||
int random_write_entropy(int fd, const void *seed, size_t size, bool credit);
|
int random_write_entropy(int fd, const void *seed, size_t size, bool credit);
|
||||||
|
|
||||||
uint64_t random_u64_range(uint64_t max);
|
int random_u64_range(uint64_t max);
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
#include "dbus-device.h"
|
#include "dbus-device.h"
|
||||||
#include "dbus-unit.h"
|
#include "dbus-unit.h"
|
||||||
|
#include "device-private.h"
|
||||||
#include "device-util.h"
|
#include "device-util.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
@ -915,8 +916,8 @@ static int device_remove_old(Manager *m, sd_device *dev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int device_dispatch_io(sd_device_monitor *monitor, sd_device *dev, void *userdata) {
|
static int device_dispatch_io(sd_device_monitor *monitor, sd_device *dev, void *userdata) {
|
||||||
sd_device_action_t action;
|
|
||||||
Manager *m = userdata;
|
Manager *m = userdata;
|
||||||
|
DeviceAction action;
|
||||||
const char *sysfs;
|
const char *sysfs;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -929,22 +930,22 @@ static int device_dispatch_io(sd_device_monitor *monitor, sd_device *dev, void *
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_device_get_action(dev, &action);
|
r = device_get_action(dev, &action);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_device_error_errno(dev, r, "Failed to get udev action: %m");
|
log_device_error_errno(dev, r, "Failed to get udev action: %m");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IN_SET(action, SD_DEVICE_ADD, SD_DEVICE_REMOVE, SD_DEVICE_MOVE))
|
if (!IN_SET(action, DEVICE_ACTION_ADD, DEVICE_ACTION_REMOVE, DEVICE_ACTION_MOVE))
|
||||||
device_propagate_reload_by_sysfs(m, sysfs);
|
device_propagate_reload_by_sysfs(m, sysfs);
|
||||||
|
|
||||||
if (action == SD_DEVICE_MOVE)
|
if (action == DEVICE_ACTION_MOVE)
|
||||||
(void) device_remove_old(m, dev);
|
(void) device_remove_old(m, dev);
|
||||||
|
|
||||||
/* A change event can signal that a device is becoming ready, in particular if the device is using
|
/* A change event can signal that a device is becoming ready, in particular if the device is using
|
||||||
* the SYSTEMD_READY logic in udev so we need to reach the else block of the following if, even for
|
* the SYSTEMD_READY logic in udev so we need to reach the else block of the following if, even for
|
||||||
* change events */
|
* change events */
|
||||||
if (action == SD_DEVICE_REMOVE) {
|
if (action == DEVICE_ACTION_REMOVE) {
|
||||||
r = swap_process_device_remove(m, dev);
|
r = swap_process_device_remove(m, dev);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_device_warning_errno(dev, r, "Failed to process swap device remove event, ignoring: %m");
|
log_device_warning_errno(dev, r, "Failed to process swap device remove event, ignoring: %m");
|
||||||
@ -1012,7 +1013,7 @@ static int validate_node(Manager *m, const char *node, sd_device **ret) {
|
|||||||
} else {
|
} else {
|
||||||
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
|
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
|
||||||
|
|
||||||
r = sd_device_new_from_stat_rdev(&dev, &st);
|
r = device_new_from_stat_rdev(&dev, &st);
|
||||||
if (r == -ENOENT) {
|
if (r == -ENOENT) {
|
||||||
*ret = NULL;
|
*ret = NULL;
|
||||||
return 1; /* good! (though missing) */
|
return 1; /* good! (though missing) */
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "dbus-swap.h"
|
#include "dbus-swap.h"
|
||||||
#include "dbus-unit.h"
|
#include "dbus-unit.h"
|
||||||
|
#include "device-private.h"
|
||||||
#include "device-util.h"
|
#include "device-util.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "escape.h"
|
#include "escape.h"
|
||||||
@ -306,7 +307,7 @@ static int swap_load_devnode(Swap *s) {
|
|||||||
if (stat(s->what, &st) < 0 || !S_ISBLK(st.st_mode))
|
if (stat(s->what, &st) < 0 || !S_ISBLK(st.st_mode))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = sd_device_new_from_stat_rdev(&d, &st);
|
r = device_new_from_stat_rdev(&d, &st);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_unit_full_errno(UNIT(s), r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
|
log_unit_full_errno(UNIT(s), r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
|
||||||
"Failed to allocate device for swap %s: %m", s->what);
|
"Failed to allocate device for swap %s: %m", s->what);
|
||||||
@ -509,7 +510,7 @@ static int swap_process_new(Manager *m, const char *device, int prio, bool set_f
|
|||||||
if (stat(device, &st) < 0 || !S_ISBLK(st.st_mode))
|
if (stat(device, &st) < 0 || !S_ISBLK(st.st_mode))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = sd_device_new_from_stat_rdev(&d, &st);
|
r = device_new_from_stat_rdev(&d, &st);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
|
log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
|
||||||
"Failed to allocate device for swap %s: %m", device);
|
"Failed to allocate device for swap %s: %m", device);
|
||||||
|
@ -1234,7 +1234,7 @@ static int manager_on_device(sd_device_monitor *monitor, sd_device *d, void *use
|
|||||||
assert(m);
|
assert(m);
|
||||||
assert(d);
|
assert(d);
|
||||||
|
|
||||||
if (device_for_action(d, SD_DEVICE_REMOVE)) {
|
if (device_for_action(d, DEVICE_ACTION_REMOVE)) {
|
||||||
const char *sysfs;
|
const char *sysfs;
|
||||||
Home *h;
|
Home *h;
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
#include "chattr-util.h"
|
#include "chattr-util.h"
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
#include "device-private.h"
|
||||||
#include "dissect-image.h"
|
#include "dissect-image.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
@ -206,7 +207,7 @@ static int add_matches_for_device(sd_journal *j, const char *devpath) {
|
|||||||
if (stat(devpath, &st) < 0)
|
if (stat(devpath, &st) < 0)
|
||||||
return log_error_errno(errno, "Couldn't stat file: %m");
|
return log_error_errno(errno, "Couldn't stat file: %m");
|
||||||
|
|
||||||
r = sd_device_new_from_stat_rdev(&device, &st);
|
r = device_new_from_stat_rdev(&device, &st);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to get device from devnum %u:%u: %m", major(st.st_rdev), minor(st.st_rdev));
|
return log_error_errno(r, "Failed to get device from devnum %u:%u: %m", major(st.st_rdev), minor(st.st_rdev));
|
||||||
|
|
||||||
|
@ -35,5 +35,5 @@ struct sd_lldp {
|
|||||||
#define log_lldp_errno(error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "LLDP: " fmt, ##__VA_ARGS__)
|
#define log_lldp_errno(error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "LLDP: " fmt, ##__VA_ARGS__)
|
||||||
#define log_lldp(fmt, ...) log_lldp_errno(0, fmt, ##__VA_ARGS__)
|
#define log_lldp(fmt, ...) log_lldp_errno(0, fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
const char* lldp_event_to_string(sd_lldp_event_t e) _const_;
|
const char* lldp_event_to_string(sd_lldp_event e) _const_;
|
||||||
sd_lldp_event_t lldp_event_from_string(const char *s) _pure_;
|
sd_lldp_event lldp_event_from_string(const char *s) _pure_;
|
||||||
|
@ -40,5 +40,5 @@ struct sd_ndisc {
|
|||||||
#define log_ndisc_errno(error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "NDISC: " fmt, ##__VA_ARGS__)
|
#define log_ndisc_errno(error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "NDISC: " fmt, ##__VA_ARGS__)
|
||||||
#define log_ndisc(fmt, ...) log_ndisc_errno(0, fmt, ##__VA_ARGS__)
|
#define log_ndisc(fmt, ...) log_ndisc_errno(0, fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
const char* ndisc_event_to_string(sd_ndisc_event_t e) _const_;
|
const char* ndisc_event_to_string(sd_ndisc_event e) _const_;
|
||||||
sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_;
|
sd_ndisc_event ndisc_event_from_string(const char *s) _pure_;
|
||||||
|
@ -99,7 +99,7 @@ int sd_dhcp_lease_get_mtu(sd_dhcp_lease *lease, uint16_t *mtu) {
|
|||||||
|
|
||||||
int sd_dhcp_lease_get_servers(
|
int sd_dhcp_lease_get_servers(
|
||||||
sd_dhcp_lease *lease,
|
sd_dhcp_lease *lease,
|
||||||
sd_dhcp_lease_server_type_t what,
|
sd_dhcp_lease_server_type what,
|
||||||
const struct in_addr **addr) {
|
const struct in_addr **addr) {
|
||||||
|
|
||||||
assert_return(lease, -EINVAL);
|
assert_return(lease, -EINVAL);
|
||||||
@ -281,7 +281,7 @@ static sd_dhcp_lease *dhcp_lease_free(sd_dhcp_lease *lease) {
|
|||||||
free(lease->hostname);
|
free(lease->hostname);
|
||||||
free(lease->domainname);
|
free(lease->domainname);
|
||||||
|
|
||||||
for (sd_dhcp_lease_server_type_t i = 0; i < _SD_DHCP_LEASE_SERVER_TYPE_MAX; i++)
|
for (sd_dhcp_lease_server_type i = 0; i < _SD_DHCP_LEASE_SERVER_TYPE_MAX; i++)
|
||||||
free(lease->servers[i].addr);
|
free(lease->servers[i].addr);
|
||||||
|
|
||||||
free(lease->static_route);
|
free(lease->static_route);
|
||||||
|
@ -149,7 +149,7 @@ static sd_dhcp_server *dhcp_server_free(sd_dhcp_server *server) {
|
|||||||
|
|
||||||
free(server->timezone);
|
free(server->timezone);
|
||||||
|
|
||||||
for (sd_dhcp_lease_server_type_t i = 0; i < _SD_DHCP_LEASE_SERVER_TYPE_MAX; i++)
|
for (sd_dhcp_lease_server_type i = 0; i < _SD_DHCP_LEASE_SERVER_TYPE_MAX; i++)
|
||||||
free(server->servers[i].addr);
|
free(server->servers[i].addr);
|
||||||
|
|
||||||
hashmap_free(server->leases_by_client_id);
|
hashmap_free(server->leases_by_client_id);
|
||||||
@ -509,7 +509,7 @@ static int server_send_ack(
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (sd_dhcp_lease_server_type_t k = 0; k < _SD_DHCP_LEASE_SERVER_TYPE_MAX; k++) {
|
for (sd_dhcp_lease_server_type k = 0; k < _SD_DHCP_LEASE_SERVER_TYPE_MAX; k++) {
|
||||||
|
|
||||||
if (server->servers[k].size <= 0)
|
if (server->servers[k].size <= 0)
|
||||||
continue;
|
continue;
|
||||||
@ -1118,7 +1118,7 @@ int sd_dhcp_server_set_default_lease_time(sd_dhcp_server *server, uint32_t t) {
|
|||||||
|
|
||||||
int sd_dhcp_server_set_servers(
|
int sd_dhcp_server_set_servers(
|
||||||
sd_dhcp_server *server,
|
sd_dhcp_server *server,
|
||||||
sd_dhcp_lease_server_type_t what,
|
sd_dhcp_lease_server_type what,
|
||||||
const struct in_addr addresses[],
|
const struct in_addr addresses[],
|
||||||
size_t n_addresses) {
|
size_t n_addresses) {
|
||||||
|
|
||||||
|
@ -21,13 +21,13 @@
|
|||||||
#define LLDP_DEFAULT_NEIGHBORS_MAX 128U
|
#define LLDP_DEFAULT_NEIGHBORS_MAX 128U
|
||||||
|
|
||||||
static const char * const lldp_event_table[_SD_LLDP_EVENT_MAX] = {
|
static const char * const lldp_event_table[_SD_LLDP_EVENT_MAX] = {
|
||||||
[SD_LLDP_EVENT_ADDED] = "added",
|
[SD_LLDP_EVENT_ADDED] = "added",
|
||||||
[SD_LLDP_EVENT_REMOVED] = "removed",
|
[SD_LLDP_EVENT_REMOVED] = "removed",
|
||||||
[SD_LLDP_EVENT_UPDATED] = "updated",
|
[SD_LLDP_EVENT_UPDATED] = "updated",
|
||||||
[SD_LLDP_EVENT_REFRESHED] = "refreshed",
|
[SD_LLDP_EVENT_REFRESHED] = "refreshed",
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_STRING_TABLE_LOOKUP(lldp_event, sd_lldp_event_t);
|
DEFINE_STRING_TABLE_LOOKUP(lldp_event, sd_lldp_event);
|
||||||
|
|
||||||
static void lldp_flush_neighbors(sd_lldp *lldp) {
|
static void lldp_flush_neighbors(sd_lldp *lldp) {
|
||||||
assert(lldp);
|
assert(lldp);
|
||||||
@ -35,7 +35,7 @@ static void lldp_flush_neighbors(sd_lldp *lldp) {
|
|||||||
hashmap_clear(lldp->neighbor_by_id);
|
hashmap_clear(lldp->neighbor_by_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lldp_callback(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor *n) {
|
static void lldp_callback(sd_lldp *lldp, sd_lldp_event event, sd_lldp_neighbor *n) {
|
||||||
assert(lldp);
|
assert(lldp);
|
||||||
assert(event >= 0 && event < _SD_LLDP_EVENT_MAX);
|
assert(event >= 0 && event < _SD_LLDP_EVENT_MAX);
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ static const char * const ndisc_event_table[_SD_NDISC_EVENT_MAX] = {
|
|||||||
[SD_NDISC_EVENT_ROUTER] = "router",
|
[SD_NDISC_EVENT_ROUTER] = "router",
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_STRING_TABLE_LOOKUP(ndisc_event, sd_ndisc_event_t);
|
DEFINE_STRING_TABLE_LOOKUP(ndisc_event, sd_ndisc_event);
|
||||||
|
|
||||||
static void ndisc_callback(sd_ndisc *ndisc, sd_ndisc_event_t event, sd_ndisc_router *rt) {
|
static void ndisc_callback(sd_ndisc *ndisc, sd_ndisc_event event, sd_ndisc_router *rt) {
|
||||||
assert(ndisc);
|
assert(ndisc);
|
||||||
assert(event >= 0 && event < _SD_NDISC_EVENT_MAX);
|
assert(event >= 0 && event < _SD_NDISC_EVENT_MAX);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ int lldp_network_bind_raw_socket(int ifindex) {
|
|||||||
return test_fd[0];
|
return test_fd[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lldp_handler(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor *n, void *userdata) {
|
static void lldp_handler(sd_lldp *lldp, sd_lldp_event event, sd_lldp_neighbor *n, void *userdata) {
|
||||||
lldp_handler_calls++;
|
lldp_handler_calls++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ int icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr) {
|
|||||||
return send_ra_function(0);
|
return send_ra_function(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_callback(sd_ndisc *nd, sd_ndisc_event_t event, sd_ndisc_router *rt, void *userdata) {
|
static void test_callback(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *rt, void *userdata) {
|
||||||
sd_event *e = userdata;
|
sd_event *e = userdata;
|
||||||
static unsigned idx = 0;
|
static unsigned idx = 0;
|
||||||
uint64_t flags_array[] = {
|
uint64_t flags_array[] = {
|
||||||
|
@ -745,8 +745,4 @@ global:
|
|||||||
sd_event_source_set_ratelimit;
|
sd_event_source_set_ratelimit;
|
||||||
sd_event_source_get_ratelimit;
|
sd_event_source_get_ratelimit;
|
||||||
sd_event_source_is_ratelimited;
|
sd_event_source_is_ratelimited;
|
||||||
|
|
||||||
sd_device_get_action;
|
|
||||||
sd_device_get_seqnum;
|
|
||||||
sd_device_new_from_stat_rdev;
|
|
||||||
} LIBSYSTEMD_247;
|
} LIBSYSTEMD_247;
|
||||||
|
@ -76,7 +76,7 @@ struct sd_device {
|
|||||||
gid_t devgid;
|
gid_t devgid;
|
||||||
|
|
||||||
/* only set when device is passed through netlink */
|
/* only set when device is passed through netlink */
|
||||||
sd_device_action_t action;
|
DeviceAction action;
|
||||||
uint64_t seqnum;
|
uint64_t seqnum;
|
||||||
|
|
||||||
bool parent_set:1; /* no need to try to reload parent */
|
bool parent_set:1; /* no need to try to reload parent */
|
||||||
|
@ -183,8 +183,20 @@ static int device_set_devgid(sd_device *device, const char *gid) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int device_get_action(sd_device *device, DeviceAction *action) {
|
||||||
|
assert(device);
|
||||||
|
|
||||||
|
if (device->action < 0)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
if (action)
|
||||||
|
*action = device->action;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int device_set_action(sd_device *device, const char *action) {
|
static int device_set_action(sd_device *device, const char *action) {
|
||||||
sd_device_action_t a;
|
DeviceAction a;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(device);
|
assert(device);
|
||||||
@ -194,7 +206,7 @@ static int device_set_action(sd_device *device, const char *action) {
|
|||||||
if (a < 0)
|
if (a < 0)
|
||||||
return a;
|
return a;
|
||||||
|
|
||||||
r = device_add_property_internal(device, "ACTION", device_action_to_string(a));
|
r = device_add_property_internal(device, "ACTION", action);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
@ -203,6 +215,18 @@ static int device_set_action(sd_device *device, const char *action) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int device_get_seqnum(sd_device *device, uint64_t *seqnum) {
|
||||||
|
assert(device);
|
||||||
|
|
||||||
|
if (device->seqnum == 0)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
if (seqnum)
|
||||||
|
*seqnum = device->seqnum;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int device_set_seqnum(sd_device *device, const char *str) {
|
static int device_set_seqnum(sd_device *device, const char *str) {
|
||||||
uint64_t seqnum;
|
uint64_t seqnum;
|
||||||
int r;
|
int r;
|
||||||
@ -331,12 +355,7 @@ static int device_amend(sd_device *device, const char *key, const char *value) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int device_append(
|
static int device_append(sd_device *device, char *key, const char **_major, const char **_minor) {
|
||||||
sd_device *device,
|
|
||||||
char *key,
|
|
||||||
const char **_major,
|
|
||||||
const char **_minor) {
|
|
||||||
|
|
||||||
const char *major = NULL, *minor = NULL;
|
const char *major = NULL, *minor = NULL;
|
||||||
char *value;
|
char *value;
|
||||||
int r;
|
int r;
|
||||||
@ -365,10 +384,10 @@ static int device_append(
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (major)
|
if (major != 0)
|
||||||
*_major = major;
|
*_major = major;
|
||||||
|
|
||||||
if (minor)
|
if (minor != 0)
|
||||||
*_minor = minor;
|
*_minor = minor;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -700,6 +719,22 @@ int device_new_from_synthetic_event(sd_device **new_device, const char *syspath,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int device_new_from_stat_rdev(sd_device **ret, const struct stat *st) {
|
||||||
|
char type;
|
||||||
|
|
||||||
|
assert(ret);
|
||||||
|
assert(st);
|
||||||
|
|
||||||
|
if (S_ISBLK(st->st_mode))
|
||||||
|
type = 'b';
|
||||||
|
else if (S_ISCHR(st->st_mode))
|
||||||
|
type = 'c';
|
||||||
|
else
|
||||||
|
return -ENOTTY;
|
||||||
|
|
||||||
|
return sd_device_new_from_devnum(ret, type, st->st_rdev);
|
||||||
|
}
|
||||||
|
|
||||||
int device_copy_properties(sd_device *device_dst, sd_device *device_src) {
|
int device_copy_properties(sd_device *device_dst, sd_device *device_src) {
|
||||||
const char *property, *value;
|
const char *property, *value;
|
||||||
int r;
|
int r;
|
||||||
@ -963,19 +998,19 @@ int device_delete_db(sd_device *device) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* const device_action_table[_SD_DEVICE_ACTION_MAX] = {
|
static const char* const device_action_table[_DEVICE_ACTION_MAX] = {
|
||||||
[SD_DEVICE_ADD] = "add",
|
[DEVICE_ACTION_ADD] = "add",
|
||||||
[SD_DEVICE_REMOVE] = "remove",
|
[DEVICE_ACTION_REMOVE] = "remove",
|
||||||
[SD_DEVICE_CHANGE] = "change",
|
[DEVICE_ACTION_CHANGE] = "change",
|
||||||
[SD_DEVICE_MOVE] = "move",
|
[DEVICE_ACTION_MOVE] = "move",
|
||||||
[SD_DEVICE_ONLINE] = "online",
|
[DEVICE_ACTION_ONLINE] = "online",
|
||||||
[SD_DEVICE_OFFLINE] = "offline",
|
[DEVICE_ACTION_OFFLINE] = "offline",
|
||||||
[SD_DEVICE_BIND] = "bind",
|
[DEVICE_ACTION_BIND] = "bind",
|
||||||
[SD_DEVICE_UNBIND] = "unbind",
|
[DEVICE_ACTION_UNBIND] = "unbind",
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_STRING_TABLE_LOOKUP(device_action, sd_device_action_t);
|
DEFINE_STRING_TABLE_LOOKUP(device_action, DeviceAction);
|
||||||
|
|
||||||
void dump_device_action_table(void) {
|
void dump_device_action_table(void) {
|
||||||
DUMP_STRING_TABLE(device_action, sd_device_action_t, _SD_DEVICE_ACTION_MAX);
|
DUMP_STRING_TABLE(device_action, DeviceAction, _DEVICE_ACTION_MAX);
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,22 @@
|
|||||||
|
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
|
|
||||||
|
typedef enum DeviceAction {
|
||||||
|
DEVICE_ACTION_ADD,
|
||||||
|
DEVICE_ACTION_REMOVE,
|
||||||
|
DEVICE_ACTION_CHANGE,
|
||||||
|
DEVICE_ACTION_MOVE,
|
||||||
|
DEVICE_ACTION_ONLINE,
|
||||||
|
DEVICE_ACTION_OFFLINE,
|
||||||
|
DEVICE_ACTION_BIND,
|
||||||
|
DEVICE_ACTION_UNBIND,
|
||||||
|
_DEVICE_ACTION_MAX,
|
||||||
|
_DEVICE_ACTION_INVALID = -EINVAL,
|
||||||
|
} DeviceAction;
|
||||||
|
|
||||||
int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len);
|
int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len);
|
||||||
int device_new_from_strv(sd_device **ret, char **strv);
|
int device_new_from_strv(sd_device **ret, char **strv);
|
||||||
|
int device_new_from_stat_rdev(sd_device **ret, const struct stat *st);
|
||||||
|
|
||||||
int device_get_id_filename(sd_device *device, const char **ret);
|
int device_get_id_filename(sd_device *device, const char **ret);
|
||||||
|
|
||||||
@ -20,6 +34,8 @@ int device_get_watch_handle(sd_device *device, int *handle);
|
|||||||
int device_get_devnode_mode(sd_device *device, mode_t *mode);
|
int device_get_devnode_mode(sd_device *device, mode_t *mode);
|
||||||
int device_get_devnode_uid(sd_device *device, uid_t *uid);
|
int device_get_devnode_uid(sd_device *device, uid_t *uid);
|
||||||
int device_get_devnode_gid(sd_device *device, gid_t *gid);
|
int device_get_devnode_gid(sd_device *device, gid_t *gid);
|
||||||
|
int device_get_action(sd_device *device, DeviceAction *action);
|
||||||
|
int device_get_seqnum(sd_device *device, uint64_t *seqnum);
|
||||||
|
|
||||||
void device_seal(sd_device *device);
|
void device_seal(sd_device *device);
|
||||||
void device_set_is_initialized(sd_device *device);
|
void device_set_is_initialized(sd_device *device);
|
||||||
@ -57,6 +73,6 @@ static inline int device_read_db(sd_device *device) {
|
|||||||
return device_read_db_internal(device, false);
|
return device_read_db_internal(device, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
sd_device_action_t device_action_from_string(const char *s) _pure_;
|
DeviceAction device_action_from_string(const char *s) _pure_;
|
||||||
const char *device_action_to_string(sd_device_action_t a) _const_;
|
const char *device_action_to_string(DeviceAction a) _const_;
|
||||||
void dump_device_action_table(void);
|
void dump_device_action_table(void);
|
||||||
|
@ -43,7 +43,7 @@ int device_new_aux(sd_device **ret) {
|
|||||||
.devmode = (mode_t) -1,
|
.devmode = (mode_t) -1,
|
||||||
.devuid = (uid_t) -1,
|
.devuid = (uid_t) -1,
|
||||||
.devgid = (gid_t) -1,
|
.devgid = (gid_t) -1,
|
||||||
.action = _SD_DEVICE_ACTION_INVALID,
|
.action = _DEVICE_ACTION_INVALID,
|
||||||
};
|
};
|
||||||
|
|
||||||
*ret = device;
|
*ret = device;
|
||||||
@ -316,22 +316,6 @@ _public_ int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *s
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
_public_ int sd_device_new_from_stat_rdev(sd_device **ret, const struct stat *st) {
|
|
||||||
char type;
|
|
||||||
|
|
||||||
assert_return(ret, -EINVAL);
|
|
||||||
assert_return(st, -EINVAL);
|
|
||||||
|
|
||||||
if (S_ISBLK(st->st_mode))
|
|
||||||
type = 'b';
|
|
||||||
else if (S_ISCHR(st->st_mode))
|
|
||||||
type = 'c';
|
|
||||||
else
|
|
||||||
return -ENOTTY;
|
|
||||||
|
|
||||||
return sd_device_new_from_devnum(ret, type, st->st_rdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
int device_set_devtype(sd_device *device, const char *devtype) {
|
int device_set_devtype(sd_device *device, const char *devtype) {
|
||||||
_cleanup_free_ char *t = NULL;
|
_cleanup_free_ char *t = NULL;
|
||||||
int r;
|
int r;
|
||||||
@ -1068,30 +1052,6 @@ _public_ int sd_device_get_sysnum(sd_device *device, const char **ret) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_public_ int sd_device_get_action(sd_device *device, sd_device_action_t *ret) {
|
|
||||||
assert_return(device, -EINVAL);
|
|
||||||
|
|
||||||
if (device->action < 0)
|
|
||||||
return -ENOENT;
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
*ret = device->action;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
_public_ int sd_device_get_seqnum(sd_device *device, uint64_t *ret) {
|
|
||||||
assert_return(device, -EINVAL);
|
|
||||||
|
|
||||||
if (device->seqnum == 0)
|
|
||||||
return -ENOENT;
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
*ret = device->seqnum;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool is_valid_tag(const char *tag) {
|
static bool is_valid_tag(const char *tag) {
|
||||||
assert(tag);
|
assert(tag);
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ static const genl_family genl_families[] = {
|
|||||||
int sd_genl_socket_open(sd_netlink **ret) {
|
int sd_genl_socket_open(sd_netlink **ret) {
|
||||||
return netlink_open_family(ret, NETLINK_GENERIC);
|
return netlink_open_family(ret, NETLINK_GENERIC);
|
||||||
}
|
}
|
||||||
static int lookup_id(sd_netlink *nl, sd_genl_family_t family, uint16_t *id);
|
static int lookup_id(sd_netlink *nl, sd_genl_family family, uint16_t *id);
|
||||||
|
|
||||||
static int genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint16_t nlmsg_type, uint8_t cmd, sd_netlink_message **ret) {
|
static int genl_message_new(sd_netlink *nl, sd_genl_family family, uint16_t nlmsg_type, uint8_t cmd, sd_netlink_message **ret) {
|
||||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
|
||||||
const NLType *genl_cmd_type, *nl_type;
|
const NLType *genl_cmd_type, *nl_type;
|
||||||
const NLTypeSystem *type_system;
|
const NLTypeSystem *type_system;
|
||||||
@ -71,7 +71,7 @@ static int genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint16_t nl
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sd_genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint8_t cmd, sd_netlink_message **ret) {
|
int sd_genl_message_new(sd_netlink *nl, sd_genl_family family, uint8_t cmd, sd_netlink_message **ret) {
|
||||||
uint16_t id;
|
uint16_t id;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ int sd_genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint8_t cmd, sd
|
|||||||
return genl_message_new(nl, family, id, cmd, ret);
|
return genl_message_new(nl, family, id, cmd, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lookup_id(sd_netlink *nl, sd_genl_family_t family, uint16_t *id) {
|
static int lookup_id(sd_netlink *nl, sd_genl_family family, uint16_t *id) {
|
||||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL, *reply = NULL;
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL, *reply = NULL;
|
||||||
uint16_t u;
|
uint16_t u;
|
||||||
void *v;
|
void *v;
|
||||||
@ -127,7 +127,7 @@ static int lookup_id(sd_netlink *nl, sd_genl_family_t family, uint16_t *id) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nlmsg_type_to_genl_family(const sd_netlink *nl, uint16_t type, sd_genl_family_t *ret) {
|
int nlmsg_type_to_genl_family(const sd_netlink *nl, uint16_t type, sd_genl_family *ret) {
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
assert_return(nl, -EINVAL);
|
assert_return(nl, -EINVAL);
|
||||||
@ -151,7 +151,7 @@ int nlmsg_type_to_genl_family(const sd_netlink *nl, uint16_t type, sd_genl_famil
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sd_genl_message_get_family(const sd_netlink *nl, const sd_netlink_message *m, sd_genl_family_t *family) {
|
int sd_genl_message_get_family(const sd_netlink *nl, const sd_netlink_message *m, sd_genl_family *family) {
|
||||||
uint16_t type;
|
uint16_t type;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
#include "sd-netlink.h"
|
#include "sd-netlink.h"
|
||||||
|
|
||||||
int nlmsg_type_to_genl_family(const sd_netlink *nl, uint16_t type, sd_genl_family_t *ret);
|
int nlmsg_type_to_genl_family(const sd_netlink *nl, uint16_t type, sd_genl_family *ret);
|
||||||
|
@ -1636,7 +1636,7 @@ const NLTypeSystem *type_system_get_root(int protocol) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int type_system_root_get_type(sd_netlink *nl, const NLType **ret, uint16_t type) {
|
int type_system_root_get_type(sd_netlink *nl, const NLType **ret, uint16_t type) {
|
||||||
sd_genl_family_t family;
|
sd_genl_family family;
|
||||||
const NLType *nl_type;
|
const NLType *nl_type;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ _public_ unsigned long long udev_device_get_seqnum(struct udev_device *udev_devi
|
|||||||
|
|
||||||
assert_return_errno(udev_device, 0, EINVAL);
|
assert_return_errno(udev_device, 0, EINVAL);
|
||||||
|
|
||||||
if (sd_device_get_seqnum(udev_device->device, &seqnum) < 0)
|
if (device_get_seqnum(udev_device->device, &seqnum) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return seqnum;
|
return seqnum;
|
||||||
@ -693,11 +693,11 @@ _public_ struct udev_list_entry *udev_device_get_properties_list_entry(struct ud
|
|||||||
* Returns: the kernel action value, or #NULL if there is no action value available.
|
* Returns: the kernel action value, or #NULL if there is no action value available.
|
||||||
**/
|
**/
|
||||||
_public_ const char *udev_device_get_action(struct udev_device *udev_device) {
|
_public_ const char *udev_device_get_action(struct udev_device *udev_device) {
|
||||||
sd_device_action_t action;
|
DeviceAction action;
|
||||||
|
|
||||||
assert_return_errno(udev_device, NULL, EINVAL);
|
assert_return_errno(udev_device, NULL, EINVAL);
|
||||||
|
|
||||||
if (sd_device_get_action(udev_device->device, &action) < 0)
|
if (device_get_action(udev_device->device, &action) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return device_action_to_string(action);
|
return device_action_to_string(action);
|
||||||
|
@ -246,7 +246,7 @@ int manager_process_seat_device(Manager *m, sd_device *d) {
|
|||||||
|
|
||||||
assert(m);
|
assert(m);
|
||||||
|
|
||||||
if (device_for_action(d, SD_DEVICE_REMOVE) ||
|
if (device_for_action(d, DEVICE_ACTION_REMOVE) ||
|
||||||
sd_device_has_current_tag(d, "seat") <= 0) {
|
sd_device_has_current_tag(d, "seat") <= 0) {
|
||||||
const char *syspath;
|
const char *syspath;
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ int manager_process_button_device(Manager *m, sd_device *d) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (device_for_action(d, SD_DEVICE_REMOVE) ||
|
if (device_for_action(d, DEVICE_ACTION_REMOVE) ||
|
||||||
sd_device_has_current_tag(d, "power-switch") <= 0) {
|
sd_device_has_current_tag(d, "power-switch") <= 0) {
|
||||||
|
|
||||||
b = hashmap_get(m->buttons, sysname);
|
b = hashmap_get(m->buttons, sysname);
|
||||||
|
@ -578,7 +578,7 @@ static int manager_dispatch_vcsa_udev(sd_device_monitor *monitor, sd_device *dev
|
|||||||
|
|
||||||
if (sd_device_get_sysname(device, &name) >= 0 &&
|
if (sd_device_get_sysname(device, &name) >= 0 &&
|
||||||
startswith(name, "vcsa") &&
|
startswith(name, "vcsa") &&
|
||||||
device_for_action(device, SD_DEVICE_REMOVE))
|
device_for_action(device, DEVICE_ACTION_REMOVE))
|
||||||
seat_preallocate_vts(m->seat0);
|
seat_preallocate_vts(m->seat0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -60,7 +60,7 @@ static Address* link_find_dhcp_server_address(Link *link) {
|
|||||||
|
|
||||||
static int link_push_uplink_to_dhcp_server(
|
static int link_push_uplink_to_dhcp_server(
|
||||||
Link *link,
|
Link *link,
|
||||||
sd_dhcp_lease_server_type_t what,
|
sd_dhcp_lease_server_type what,
|
||||||
sd_dhcp_server *s) {
|
sd_dhcp_server *s) {
|
||||||
|
|
||||||
_cleanup_free_ struct in_addr *addresses = NULL;
|
_cleanup_free_ struct in_addr *addresses = NULL;
|
||||||
@ -307,7 +307,7 @@ int dhcp4_server_configure(Link *link) {
|
|||||||
return log_link_error_errno(link, r, "Failed to set default lease time for DHCPv4 server instance: %m");
|
return log_link_error_errno(link, r, "Failed to set default lease time for DHCPv4 server instance: %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (sd_dhcp_lease_server_type_t type = 0; type < _SD_DHCP_LEASE_SERVER_TYPE_MAX; type ++) {
|
for (sd_dhcp_lease_server_type type = 0; type < _SD_DHCP_LEASE_SERVER_TYPE_MAX; type ++) {
|
||||||
|
|
||||||
if (!link->network->dhcp_server_emit[type].emit)
|
if (!link->network->dhcp_server_emit[type].emit)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1076,10 +1076,9 @@ static int dhcp6_address_acquired(Link *link) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link->network->dhcp6_use_hostname) {
|
if (link->network->dhcp6_use_fqdn) {
|
||||||
const char *dhcpname = NULL;
|
const char *dhcpname = NULL;
|
||||||
_cleanup_free_ char *hostname = NULL;
|
_cleanup_free_ char *hostname = NULL;
|
||||||
|
|
||||||
(void) sd_dhcp6_lease_get_fqdn(link->dhcp6_lease, &dhcpname);
|
(void) sd_dhcp6_lease_get_fqdn(link->dhcp6_lease, &dhcpname);
|
||||||
|
|
||||||
if (dhcpname) {
|
if (dhcpname) {
|
||||||
|
@ -2823,7 +2823,7 @@ static void serialize_addresses(
|
|||||||
char **addresses,
|
char **addresses,
|
||||||
sd_dhcp_lease *lease,
|
sd_dhcp_lease *lease,
|
||||||
bool conditional,
|
bool conditional,
|
||||||
sd_dhcp_lease_server_type_t what,
|
sd_dhcp_lease_server_type what,
|
||||||
sd_dhcp6_lease *lease6,
|
sd_dhcp6_lease *lease6,
|
||||||
bool conditional6,
|
bool conditional6,
|
||||||
int (*lease6_get_addr)(sd_dhcp6_lease*, const struct in6_addr**),
|
int (*lease6_get_addr)(sd_dhcp6_lease*, const struct in6_addr**),
|
||||||
|
@ -47,7 +47,7 @@ static bool link_lldp_rx_enabled(Link *link) {
|
|||||||
return link->network->lldp_mode != LLDP_MODE_NO;
|
return link->network->lldp_mode != LLDP_MODE_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lldp_handler(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor *n, void *userdata) {
|
static void lldp_handler(sd_lldp *lldp, sd_lldp_event event, sd_lldp_neighbor *n, void *userdata) {
|
||||||
Link *link = userdata;
|
Link *link = userdata;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -182,15 +182,15 @@ int manager_connect_bus(Manager *m) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int manager_udev_process_link(sd_device_monitor *monitor, sd_device *device, void *userdata) {
|
static int manager_udev_process_link(sd_device_monitor *monitor, sd_device *device, void *userdata) {
|
||||||
sd_device_action_t action;
|
|
||||||
Manager *m = userdata;
|
Manager *m = userdata;
|
||||||
|
DeviceAction action;
|
||||||
Link *link = NULL;
|
Link *link = NULL;
|
||||||
int r, ifindex;
|
int r, ifindex;
|
||||||
|
|
||||||
assert(m);
|
assert(m);
|
||||||
assert(device);
|
assert(device);
|
||||||
|
|
||||||
r = sd_device_get_action(device, &action);
|
r = device_get_action(device, &action);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_device_debug_errno(device, r, "Failed to get udev action, ignoring device: %m");
|
log_device_debug_errno(device, r, "Failed to get udev action, ignoring device: %m");
|
||||||
return 0;
|
return 0;
|
||||||
@ -199,7 +199,7 @@ static int manager_udev_process_link(sd_device_monitor *monitor, sd_device *devi
|
|||||||
/* Ignore the "remove" uevent — let's remove a device only if rtnetlink says so. All other uevents
|
/* Ignore the "remove" uevent — let's remove a device only if rtnetlink says so. All other uevents
|
||||||
* are "positive" events in some form, i.e. inform us about a changed or new network interface, that
|
* are "positive" events in some form, i.e. inform us about a changed or new network interface, that
|
||||||
* still exists — and we are interested in that. */
|
* still exists — and we are interested in that. */
|
||||||
if (action == SD_DEVICE_REMOVE)
|
if (action == DEVICE_ACTION_REMOVE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = sd_device_get_ifindex(device, &ifindex);
|
r = sd_device_get_ifindex(device, &ifindex);
|
||||||
|
@ -1274,7 +1274,7 @@ static int ndisc_router_handler(Link *link, sd_ndisc_router *rt) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ndisc_handler(sd_ndisc *nd, sd_ndisc_event_t event, sd_ndisc_router *rt, void *userdata) {
|
static void ndisc_handler(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *rt, void *userdata) {
|
||||||
Link *link = userdata;
|
Link *link = userdata;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ DHCPv4.RouteMTUBytes, config_parse_mtu,
|
|||||||
DHCPv4.FallbackLeaseLifetimeSec, config_parse_dhcp_fallback_lease_lifetime, 0, 0
|
DHCPv4.FallbackLeaseLifetimeSec, config_parse_dhcp_fallback_lease_lifetime, 0, 0
|
||||||
DHCPv6.UseAddress, config_parse_bool, 0, offsetof(Network, dhcp6_use_address)
|
DHCPv6.UseAddress, config_parse_bool, 0, offsetof(Network, dhcp6_use_address)
|
||||||
DHCPv6.UseDNS, config_parse_dhcp_use_dns, 0, 0
|
DHCPv6.UseDNS, config_parse_dhcp_use_dns, 0, 0
|
||||||
DHCPv6.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp6_use_hostname)
|
DHCPv6.UseFQDN, config_parse_bool, 0, offsetof(Network, dhcp6_use_fqdn)
|
||||||
DHCPv6.UseNTP, config_parse_dhcp_use_ntp, 0, 0
|
DHCPv6.UseNTP, config_parse_dhcp_use_ntp, 0, 0
|
||||||
DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_rapid_commit)
|
DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_rapid_commit)
|
||||||
DHCPv6.MUDURL, config_parse_dhcp6_mud_url, 0, 0
|
DHCPv6.MUDURL, config_parse_dhcp6_mud_url, 0, 0
|
||||||
|
@ -373,7 +373,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
|||||||
|
|
||||||
.dhcp6_use_address = true,
|
.dhcp6_use_address = true,
|
||||||
.dhcp6_use_dns = true,
|
.dhcp6_use_dns = true,
|
||||||
.dhcp6_use_hostname = true,
|
.dhcp6_use_fqdn = true,
|
||||||
.dhcp6_use_ntp = true,
|
.dhcp6_use_ntp = true,
|
||||||
.dhcp6_rapid_commit = true,
|
.dhcp6_rapid_commit = true,
|
||||||
.dhcp6_route_metric = DHCP_ROUTE_METRIC,
|
.dhcp6_route_metric = DHCP_ROUTE_METRIC,
|
||||||
@ -664,7 +664,7 @@ static Network *network_free(Network *network) {
|
|||||||
|
|
||||||
free(network->dhcp_server_timezone);
|
free(network->dhcp_server_timezone);
|
||||||
|
|
||||||
for (sd_dhcp_lease_server_type_t t = 0; t < _SD_DHCP_LEASE_SERVER_TYPE_MAX; t++)
|
for (sd_dhcp_lease_server_type t = 0; t < _SD_DHCP_LEASE_SERVER_TYPE_MAX; t++)
|
||||||
free(network->dhcp_server_emit[t].addresses);
|
free(network->dhcp_server_emit[t].addresses);
|
||||||
|
|
||||||
set_free_free(network->dnssec_negative_trust_anchors);
|
set_free_free(network->dnssec_negative_trust_anchors);
|
||||||
|
@ -159,7 +159,7 @@ struct Network {
|
|||||||
bool dhcp6_use_address;
|
bool dhcp6_use_address;
|
||||||
bool dhcp6_use_dns;
|
bool dhcp6_use_dns;
|
||||||
bool dhcp6_use_dns_set;
|
bool dhcp6_use_dns_set;
|
||||||
bool dhcp6_use_hostname;
|
bool dhcp6_use_fqdn;
|
||||||
bool dhcp6_use_ntp;
|
bool dhcp6_use_ntp;
|
||||||
bool dhcp6_use_ntp_set;
|
bool dhcp6_use_ntp_set;
|
||||||
bool dhcp6_rapid_commit;
|
bool dhcp6_rapid_commit;
|
||||||
|
@ -9,35 +9,35 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static const char* const address_family_table[_ADDRESS_FAMILY_MAX] = {
|
static const char* const address_family_table[_ADDRESS_FAMILY_MAX] = {
|
||||||
[ADDRESS_FAMILY_NO] = "no",
|
[ADDRESS_FAMILY_NO] = "no",
|
||||||
[ADDRESS_FAMILY_YES] = "yes",
|
[ADDRESS_FAMILY_YES] = "yes",
|
||||||
[ADDRESS_FAMILY_IPV4] = "ipv4",
|
[ADDRESS_FAMILY_IPV4] = "ipv4",
|
||||||
[ADDRESS_FAMILY_IPV6] = "ipv6",
|
[ADDRESS_FAMILY_IPV6] = "ipv6",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* const routing_policy_rule_address_family_table[_ADDRESS_FAMILY_MAX] = {
|
static const char* const routing_policy_rule_address_family_table[_ADDRESS_FAMILY_MAX] = {
|
||||||
[ADDRESS_FAMILY_YES] = "both",
|
[ADDRESS_FAMILY_YES] = "both",
|
||||||
[ADDRESS_FAMILY_IPV4] = "ipv4",
|
[ADDRESS_FAMILY_IPV4] = "ipv4",
|
||||||
[ADDRESS_FAMILY_IPV6] = "ipv6",
|
[ADDRESS_FAMILY_IPV6] = "ipv6",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* const nexthop_address_family_table[_ADDRESS_FAMILY_MAX] = {
|
static const char* const nexthop_address_family_table[_ADDRESS_FAMILY_MAX] = {
|
||||||
[ADDRESS_FAMILY_IPV4] = "ipv4",
|
[ADDRESS_FAMILY_IPV4] = "ipv4",
|
||||||
[ADDRESS_FAMILY_IPV6] = "ipv6",
|
[ADDRESS_FAMILY_IPV6] = "ipv6",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* const duplicate_address_detection_address_family_table[_ADDRESS_FAMILY_MAX] = {
|
static const char* const duplicate_address_detection_address_family_table[_ADDRESS_FAMILY_MAX] = {
|
||||||
[ADDRESS_FAMILY_NO] = "none",
|
[ADDRESS_FAMILY_NO] = "none",
|
||||||
[ADDRESS_FAMILY_YES] = "both",
|
[ADDRESS_FAMILY_YES] = "both",
|
||||||
[ADDRESS_FAMILY_IPV4] = "ipv4",
|
[ADDRESS_FAMILY_IPV4] = "ipv4",
|
||||||
[ADDRESS_FAMILY_IPV6] = "ipv6",
|
[ADDRESS_FAMILY_IPV6] = "ipv6",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* const dhcp_deprecated_address_family_table[_ADDRESS_FAMILY_MAX] = {
|
static const char* const dhcp_deprecated_address_family_table[_ADDRESS_FAMILY_MAX] = {
|
||||||
[ADDRESS_FAMILY_NO] = "none",
|
[ADDRESS_FAMILY_NO] = "none",
|
||||||
[ADDRESS_FAMILY_YES] = "both",
|
[ADDRESS_FAMILY_YES] = "both",
|
||||||
[ADDRESS_FAMILY_IPV4] = "v4",
|
[ADDRESS_FAMILY_IPV4] = "v4",
|
||||||
[ADDRESS_FAMILY_IPV6] = "v6",
|
[ADDRESS_FAMILY_IPV6] = "v6",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* const dhcp_lease_server_type_table[_SD_DHCP_LEASE_SERVER_TYPE_MAX] = {
|
static const char* const dhcp_lease_server_type_table[_SD_DHCP_LEASE_SERVER_TYPE_MAX] = {
|
||||||
@ -65,7 +65,7 @@ DEFINE_STRING_TABLE_LOOKUP(duplicate_address_detection_address_family, AddressFa
|
|||||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_link_local_address_family, link_local_address_family,
|
DEFINE_CONFIG_PARSE_ENUM(config_parse_link_local_address_family, link_local_address_family,
|
||||||
AddressFamily, "Failed to parse option");
|
AddressFamily, "Failed to parse option");
|
||||||
DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(dhcp_deprecated_address_family, AddressFamily);
|
DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(dhcp_deprecated_address_family, AddressFamily);
|
||||||
DEFINE_STRING_TABLE_LOOKUP(dhcp_lease_server_type, sd_dhcp_lease_server_type_t);
|
DEFINE_STRING_TABLE_LOOKUP(dhcp_lease_server_type, sd_dhcp_lease_server_type);
|
||||||
|
|
||||||
static AddressFamily address_family_compat_from_string(const char *s) {
|
static AddressFamily address_family_compat_from_string(const char *s) {
|
||||||
if (streq_ptr(s, "yes")) /* compat name */
|
if (streq_ptr(s, "yes")) /* compat name */
|
||||||
|
@ -46,8 +46,8 @@ AddressFamily duplicate_address_detection_address_family_from_string(const char
|
|||||||
|
|
||||||
AddressFamily dhcp_deprecated_address_family_from_string(const char *s) _pure_;
|
AddressFamily dhcp_deprecated_address_family_from_string(const char *s) _pure_;
|
||||||
|
|
||||||
const char *dhcp_lease_server_type_to_string(sd_dhcp_lease_server_type_t t) _const_;
|
const char *dhcp_lease_server_type_to_string(sd_dhcp_lease_server_type t) _const_;
|
||||||
sd_dhcp_lease_server_type_t dhcp_lease_server_type_from_string(const char *s) _pure_;
|
sd_dhcp_lease_server_type dhcp_lease_server_type_from_string(const char *s) _pure_;
|
||||||
|
|
||||||
int kernel_route_expiration_supported(void);
|
int kernel_route_expiration_supported(void);
|
||||||
|
|
||||||
|
@ -46,10 +46,10 @@ int main(int argc, char **argv) {
|
|||||||
test_table_sparse(macvlan_mode, NETDEV_MACVLAN_MODE);
|
test_table_sparse(macvlan_mode, NETDEV_MACVLAN_MODE);
|
||||||
test_table_sparse(address_family, ADDRESS_FAMILY);
|
test_table_sparse(address_family, ADDRESS_FAMILY);
|
||||||
|
|
||||||
assert_cc(sizeof(sd_lldp_event_t) == sizeof(int64_t));
|
assert_cc(sizeof(sd_lldp_event) == sizeof(int64_t));
|
||||||
assert_cc(sizeof(sd_ndisc_event_t) == sizeof(int64_t));
|
assert_cc(sizeof(sd_ndisc_event) == sizeof(int64_t));
|
||||||
assert_cc(sizeof(sd_dhcp_lease_server_type_t) == sizeof(int64_t));
|
assert_cc(sizeof(sd_dhcp_lease_server_type) == sizeof(int64_t));
|
||||||
assert_cc(sizeof(sd_genl_family_t) == sizeof(int64_t));
|
assert_cc(sizeof(sd_genl_family) == sizeof(int64_t));
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1046,8 +1046,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
|
|||||||
* should hence not attempt to access the query or transaction
|
* should hence not attempt to access the query or transaction
|
||||||
* after calling this function. */
|
* after calling this function. */
|
||||||
|
|
||||||
log_debug("Processing incoming packet of size %zu on transaction %" PRIu16" (rcode=%s).",
|
log_debug("Processing incoming packet on transaction %" PRIu16" (rcode=%s).",
|
||||||
p->size,
|
|
||||||
t->id, dns_rcode_to_string(DNS_PACKET_RCODE(p)));
|
t->id, dns_rcode_to_string(DNS_PACKET_RCODE(p)));
|
||||||
|
|
||||||
switch (t->scope->protocol) {
|
switch (t->scope->protocol) {
|
||||||
@ -1212,8 +1211,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
|
|||||||
* servers often do not implement TCP, hence falling back to TCP on fragmentation is
|
* servers often do not implement TCP, hence falling back to TCP on fragmentation is
|
||||||
* counter-productive there.) */
|
* counter-productive there.) */
|
||||||
|
|
||||||
log_debug("Reply fragmented, retrying via TCP. (Largest fragment size: %zu; Datagram size: %zu)",
|
log_debug("Reply fragmented, retrying via TCP.");
|
||||||
p->fragsize, p->size);
|
|
||||||
retry_with_tcp = true;
|
retry_with_tcp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -926,10 +926,8 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
|
|||||||
p->ifindex = manager_find_ifindex(m, p->family, &p->destination);
|
p->ifindex = manager_find_ifindex(m, p->family, &p->destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_debug("Received %s UDP packet of size %zu, ifindex=%i, ttl=%i, fragsize=%zu",
|
|
||||||
dns_protocol_to_string(protocol), p->size, p->ifindex, p->ttl, p->fragsize);
|
|
||||||
|
|
||||||
*ret = TAKE_PTR(p);
|
*ret = TAKE_PTR(p);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +135,8 @@ static int determine_state_file(
|
|||||||
|
|
||||||
static int load_state(Context *c, const struct rfkill_event *event) {
|
static int load_state(Context *c, const struct rfkill_event *event) {
|
||||||
_cleanup_free_ char *state_file = NULL, *value = NULL;
|
_cleanup_free_ char *state_file = NULL, *value = NULL;
|
||||||
|
struct rfkill_event we;
|
||||||
|
ssize_t l;
|
||||||
int b, r;
|
int b, r;
|
||||||
|
|
||||||
assert(c);
|
assert(c);
|
||||||
@ -166,22 +168,18 @@ static int load_state(Context *c, const struct rfkill_event *event) {
|
|||||||
if (b < 0)
|
if (b < 0)
|
||||||
return log_error_errno(b, "Failed to parse state file %s: %m", state_file);
|
return log_error_errno(b, "Failed to parse state file %s: %m", state_file);
|
||||||
|
|
||||||
struct rfkill_event we = {
|
we = (struct rfkill_event) {
|
||||||
.idx = event->idx,
|
|
||||||
.op = RFKILL_OP_CHANGE,
|
.op = RFKILL_OP_CHANGE,
|
||||||
|
.idx = event->idx,
|
||||||
.soft = b,
|
.soft = b,
|
||||||
};
|
};
|
||||||
assert_cc(offsetof(struct rfkill_event, op) < RFKILL_EVENT_SIZE_V1);
|
|
||||||
assert_cc(offsetof(struct rfkill_event, soft) < RFKILL_EVENT_SIZE_V1);
|
|
||||||
|
|
||||||
ssize_t l = write(c->rfkill_fd, &we, sizeof we);
|
l = write(c->rfkill_fd, &we, sizeof(we));
|
||||||
if (l < 0)
|
if (l < 0)
|
||||||
return log_error_errno(errno, "Failed to restore rfkill state for %i: %m", event->idx);
|
return log_error_errno(errno, "Failed to restore rfkill state for %i: %m", event->idx);
|
||||||
if (l < RFKILL_EVENT_SIZE_V1)
|
if (l != sizeof(we))
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EIO),
|
return log_error_errno(SYNTHETIC_ERRNO(EIO),
|
||||||
"Couldn't write rfkill event structure, too short (wrote %zd of %zu bytes).",
|
"Couldn't write rfkill event structure, too short.");
|
||||||
l, sizeof we);
|
|
||||||
log_debug("Writing struct rfkill_event successful (%zd of %zu bytes).", l, sizeof we);
|
|
||||||
|
|
||||||
log_debug("Loaded state '%s' from %s.", one_zero(b), state_file);
|
log_debug("Loaded state '%s' from %s.", one_zero(b), state_file);
|
||||||
return 0;
|
return 0;
|
||||||
@ -307,45 +305,44 @@ static int run(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
struct rfkill_event event = {};
|
struct rfkill_event event;
|
||||||
|
const char *type;
|
||||||
|
ssize_t l;
|
||||||
|
|
||||||
ssize_t l = read(c.rfkill_fd, &event, sizeof event);
|
l = read(c.rfkill_fd, &event, sizeof(event));
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
if (errno != EAGAIN)
|
if (errno == EAGAIN) {
|
||||||
return log_error_errno(errno, "Failed to read from /dev/rfkill: %m");
|
|
||||||
|
|
||||||
if (!ready) {
|
if (!ready) {
|
||||||
/* Notify manager that we are now finished with processing whatever was
|
/* Notify manager that we are
|
||||||
* queued */
|
* now finished with
|
||||||
(void) sd_notify(false, "READY=1");
|
* processing whatever was
|
||||||
ready = true;
|
* queued */
|
||||||
|
(void) sd_notify(false, "READY=1");
|
||||||
|
ready = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hang around for a bit, maybe there's more coming */
|
||||||
|
|
||||||
|
r = fd_wait_for_event(c.rfkill_fd, POLLIN, EXIT_USEC);
|
||||||
|
if (r == -EINTR)
|
||||||
|
continue;
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to poll() on device: %m");
|
||||||
|
if (r > 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
log_debug("All events read and idle, exiting.");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hang around for a bit, maybe there's more coming */
|
log_error_errno(errno, "Failed to read from /dev/rfkill: %m");
|
||||||
|
|
||||||
r = fd_wait_for_event(c.rfkill_fd, POLLIN, EXIT_USEC);
|
|
||||||
if (r == -EINTR)
|
|
||||||
continue;
|
|
||||||
if (r < 0)
|
|
||||||
return log_error_errno(r, "Failed to poll() on device: %m");
|
|
||||||
if (r > 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
log_debug("All events read and idle, exiting.");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l < RFKILL_EVENT_SIZE_V1)
|
if (l != RFKILL_EVENT_SIZE_V1)
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read of struct rfkill_event: (%zd < %d)",
|
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Read event structure of invalid size.");
|
||||||
l, RFKILL_EVENT_SIZE_V1);
|
|
||||||
log_debug("Reading struct rfkill_event: got %zd bytes.", l);
|
|
||||||
|
|
||||||
/* The event structure has more fields. We only care about the first few, so it's OK if we
|
type = rfkill_type_to_string(event.type);
|
||||||
* don't read the full structure. */
|
|
||||||
assert_cc(offsetof(struct rfkill_event, op) < RFKILL_EVENT_SIZE_V1);
|
|
||||||
assert_cc(offsetof(struct rfkill_event, type) < RFKILL_EVENT_SIZE_V1);
|
|
||||||
|
|
||||||
const char *type = rfkill_type_to_string(event.type);
|
|
||||||
if (!type) {
|
if (!type) {
|
||||||
log_debug("An rfkill device of unknown type %i discovered, ignoring.", event.type);
|
log_debug("An rfkill device of unknown type %i discovered, ignoring.", event.type);
|
||||||
continue;
|
continue;
|
||||||
|
@ -247,7 +247,7 @@ static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device,
|
|||||||
|
|
||||||
assert(w);
|
assert(w);
|
||||||
|
|
||||||
if (device_for_action(device, SD_DEVICE_REMOVE))
|
if (device_for_action(device, DEVICE_ACTION_REMOVE))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = sd_device_get_parent(device, &pp);
|
r = sd_device_get_parent(device, &pp);
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "device-nodes.h"
|
#include "device-nodes.h"
|
||||||
#include "device-private.h"
|
|
||||||
#include "device-util.h"
|
#include "device-util.h"
|
||||||
#include "env-file.h"
|
#include "env-file.h"
|
||||||
#include "escape.h"
|
#include "escape.h"
|
||||||
@ -176,7 +175,7 @@ static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device,
|
|||||||
* (And yes, we only need to special case REMOVE. It's the only "negative" event type, where a device
|
* (And yes, we only need to special case REMOVE. It's the only "negative" event type, where a device
|
||||||
* ceases to exist. All other event types are "positive": the device exists and is registered in the
|
* ceases to exist. All other event types are "positive": the device exists and is registered in the
|
||||||
* udev database, thus whenever we see the event, we can consider it initialized.) */
|
* udev database, thus whenever we see the event, we can consider it initialized.) */
|
||||||
if (device_for_action(device, SD_DEVICE_REMOVE))
|
if (device_for_action(device, DEVICE_ACTION_REMOVE))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (data->sysname && sd_device_get_sysname(device, &sysname) >= 0 && streq(sysname, data->sysname))
|
if (data->sysname && sd_device_get_sysname(device, &sysname) >= 0 && streq(sysname, data->sysname))
|
||||||
@ -319,29 +318,26 @@ int device_is_renaming(sd_device *dev) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool device_for_action(sd_device *dev, sd_device_action_t a) {
|
bool device_for_action(sd_device *dev, DeviceAction action) {
|
||||||
sd_device_action_t b;
|
DeviceAction a;
|
||||||
|
|
||||||
assert(dev);
|
assert(dev);
|
||||||
|
|
||||||
if (a < 0)
|
if (device_get_action(dev, &a) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (sd_device_get_action(dev, &b) < 0)
|
return a == action;
|
||||||
return false;
|
|
||||||
|
|
||||||
return a == b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_device_uevent(sd_device *device, const char *str) {
|
void log_device_uevent(sd_device *device, const char *str) {
|
||||||
sd_device_action_t action = _SD_DEVICE_ACTION_INVALID;
|
DeviceAction action = _DEVICE_ACTION_INVALID;
|
||||||
uint64_t seqnum = 0;
|
uint64_t seqnum = 0;
|
||||||
|
|
||||||
if (!DEBUG_LOGGING)
|
if (!DEBUG_LOGGING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(void) sd_device_get_seqnum(device, &seqnum);
|
(void) device_get_seqnum(device, &seqnum);
|
||||||
(void) sd_device_get_action(device, &action);
|
(void) device_get_action(device, &action);
|
||||||
log_device_debug(device, "%s%s(SEQNUM=%"PRIu64", ACTION=%s)",
|
log_device_debug(device, "%s%s(SEQNUM=%"PRIu64", ACTION=%s)",
|
||||||
strempty(str), isempty(str) ? "" : " ",
|
strempty(str), isempty(str) ? "" : " ",
|
||||||
seqnum, strna(device_action_to_string(action)));
|
seqnum, strna(device_action_to_string(action)));
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "sd-device.h"
|
#include "sd-device.h"
|
||||||
|
|
||||||
|
#include "device-private.h"
|
||||||
#include "time-util.h"
|
#include "time-util.h"
|
||||||
|
|
||||||
#define UDEV_NAME_SIZE 512
|
#define UDEV_NAME_SIZE 512
|
||||||
@ -34,8 +35,7 @@ static inline int udev_parse_config(void) {
|
|||||||
int device_wait_for_initialization(sd_device *device, const char *subsystem, usec_t deadline, sd_device **ret);
|
int device_wait_for_initialization(sd_device *device, const char *subsystem, usec_t deadline, sd_device **ret);
|
||||||
int device_wait_for_devlink(const char *path, const char *subsystem, usec_t deadline, sd_device **ret);
|
int device_wait_for_devlink(const char *path, const char *subsystem, usec_t deadline, sd_device **ret);
|
||||||
int device_is_renaming(sd_device *dev);
|
int device_is_renaming(sd_device *dev);
|
||||||
|
bool device_for_action(sd_device *dev, DeviceAction action);
|
||||||
bool device_for_action(sd_device *dev, sd_device_action_t action);
|
|
||||||
|
|
||||||
void log_device_uevent(sd_device *device, const char *str);
|
void log_device_uevent(sd_device *device, const char *str);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftype, char **ssid) {
|
int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftype, char **ssid) {
|
||||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL, *reply = NULL;
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL, *reply = NULL;
|
||||||
sd_genl_family_t family;
|
sd_genl_family family;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(genl);
|
assert(genl);
|
||||||
@ -75,7 +75,7 @@ nodata:
|
|||||||
|
|
||||||
int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid) {
|
int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid) {
|
||||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL, *reply = NULL;
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL, *reply = NULL;
|
||||||
sd_genl_family_t family;
|
sd_genl_family family;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(genl);
|
assert(genl);
|
||||||
|
@ -17,9 +17,7 @@
|
|||||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/sysmacros.h>
|
#include <sys/sysmacros.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
@ -33,20 +31,6 @@ typedef struct sd_device sd_device;
|
|||||||
typedef struct sd_device_enumerator sd_device_enumerator;
|
typedef struct sd_device_enumerator sd_device_enumerator;
|
||||||
typedef struct sd_device_monitor sd_device_monitor;
|
typedef struct sd_device_monitor sd_device_monitor;
|
||||||
|
|
||||||
typedef enum sd_device_action_t {
|
|
||||||
SD_DEVICE_ADD,
|
|
||||||
SD_DEVICE_REMOVE,
|
|
||||||
SD_DEVICE_CHANGE,
|
|
||||||
SD_DEVICE_MOVE,
|
|
||||||
SD_DEVICE_ONLINE,
|
|
||||||
SD_DEVICE_OFFLINE,
|
|
||||||
SD_DEVICE_BIND,
|
|
||||||
SD_DEVICE_UNBIND,
|
|
||||||
_SD_DEVICE_ACTION_MAX,
|
|
||||||
_SD_DEVICE_ACTION_INVALID = -EINVAL,
|
|
||||||
_SD_ENUM_FORCE_S64(DEVICE_ACTION),
|
|
||||||
} sd_device_action_t;
|
|
||||||
|
|
||||||
/* callback */
|
/* callback */
|
||||||
|
|
||||||
typedef int (*sd_device_monitor_handler_t)(sd_device_monitor *m, sd_device *device, void *userdata);
|
typedef int (*sd_device_monitor_handler_t)(sd_device_monitor *m, sd_device *device, void *userdata);
|
||||||
@ -60,7 +44,6 @@ int sd_device_new_from_syspath(sd_device **ret, const char *syspath);
|
|||||||
int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum);
|
int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum);
|
||||||
int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *subsystem, const char *sysname);
|
int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *subsystem, const char *sysname);
|
||||||
int sd_device_new_from_device_id(sd_device **ret, const char *id);
|
int sd_device_new_from_device_id(sd_device **ret, const char *id);
|
||||||
int sd_device_new_from_stat_rdev(sd_device **ret, const struct stat *st);
|
|
||||||
|
|
||||||
int sd_device_get_parent(sd_device *child, sd_device **ret);
|
int sd_device_get_parent(sd_device *child, sd_device **ret);
|
||||||
int sd_device_get_parent_with_subsystem_devtype(sd_device *child, const char *subsystem, const char *devtype, sd_device **ret);
|
int sd_device_get_parent_with_subsystem_devtype(sd_device *child, const char *subsystem, const char *devtype, sd_device **ret);
|
||||||
@ -75,8 +58,6 @@ int sd_device_get_devpath(sd_device *device, const char **ret);
|
|||||||
int sd_device_get_devname(sd_device *device, const char **ret);
|
int sd_device_get_devname(sd_device *device, const char **ret);
|
||||||
int sd_device_get_sysname(sd_device *device, const char **ret);
|
int sd_device_get_sysname(sd_device *device, const char **ret);
|
||||||
int sd_device_get_sysnum(sd_device *device, const char **ret);
|
int sd_device_get_sysnum(sd_device *device, const char **ret);
|
||||||
int sd_device_get_action(sd_device *device, sd_device_action_t *ret);
|
|
||||||
int sd_device_get_seqnum(sd_device *device, uint64_t *ret);
|
|
||||||
|
|
||||||
int sd_device_get_is_initialized(sd_device *device);
|
int sd_device_get_is_initialized(sd_device *device);
|
||||||
int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec);
|
int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec);
|
||||||
|
@ -34,7 +34,7 @@ typedef struct sd_dhcp_route sd_dhcp_route;
|
|||||||
sd_dhcp_lease *sd_dhcp_lease_ref(sd_dhcp_lease *lease);
|
sd_dhcp_lease *sd_dhcp_lease_ref(sd_dhcp_lease *lease);
|
||||||
sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease);
|
sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease);
|
||||||
|
|
||||||
typedef enum sd_dhcp_lease_server_type_t {
|
typedef enum sd_dhcp_lease_server_type {
|
||||||
SD_DHCP_LEASE_DNS,
|
SD_DHCP_LEASE_DNS,
|
||||||
SD_DHCP_LEASE_NTP,
|
SD_DHCP_LEASE_NTP,
|
||||||
SD_DHCP_LEASE_SIP,
|
SD_DHCP_LEASE_SIP,
|
||||||
@ -44,7 +44,7 @@ typedef enum sd_dhcp_lease_server_type_t {
|
|||||||
_SD_DHCP_LEASE_SERVER_TYPE_MAX,
|
_SD_DHCP_LEASE_SERVER_TYPE_MAX,
|
||||||
_SD_DHCP_LEASE_SERVER_TYPE_INVALID = -EINVAL,
|
_SD_DHCP_LEASE_SERVER_TYPE_INVALID = -EINVAL,
|
||||||
_SD_ENUM_FORCE_S64(DHCP_LEASE_SERVER_TYPE),
|
_SD_ENUM_FORCE_S64(DHCP_LEASE_SERVER_TYPE),
|
||||||
} sd_dhcp_lease_server_type_t;
|
} sd_dhcp_lease_server_type;
|
||||||
|
|
||||||
int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct in_addr *addr);
|
int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct in_addr *addr);
|
||||||
int sd_dhcp_lease_get_lifetime(sd_dhcp_lease *lease, uint32_t *lifetime);
|
int sd_dhcp_lease_get_lifetime(sd_dhcp_lease *lease, uint32_t *lifetime);
|
||||||
@ -55,7 +55,7 @@ int sd_dhcp_lease_get_netmask(sd_dhcp_lease *lease, struct in_addr *addr);
|
|||||||
int sd_dhcp_lease_get_router(sd_dhcp_lease *lease, const struct in_addr **addr);
|
int sd_dhcp_lease_get_router(sd_dhcp_lease *lease, const struct in_addr **addr);
|
||||||
int sd_dhcp_lease_get_next_server(sd_dhcp_lease *lease, struct in_addr *addr);
|
int sd_dhcp_lease_get_next_server(sd_dhcp_lease *lease, struct in_addr *addr);
|
||||||
int sd_dhcp_lease_get_server_identifier(sd_dhcp_lease *lease, struct in_addr *addr);
|
int sd_dhcp_lease_get_server_identifier(sd_dhcp_lease *lease, struct in_addr *addr);
|
||||||
int sd_dhcp_lease_get_servers(sd_dhcp_lease *lease, sd_dhcp_lease_server_type_t what, const struct in_addr **addr);
|
int sd_dhcp_lease_get_servers(sd_dhcp_lease *lease, sd_dhcp_lease_server_type what, const struct in_addr **addr);
|
||||||
int sd_dhcp_lease_get_dns(sd_dhcp_lease *lease, const struct in_addr **addr);
|
int sd_dhcp_lease_get_dns(sd_dhcp_lease *lease, const struct in_addr **addr);
|
||||||
int sd_dhcp_lease_get_ntp(sd_dhcp_lease *lease, const struct in_addr **addr);
|
int sd_dhcp_lease_get_ntp(sd_dhcp_lease *lease, const struct in_addr **addr);
|
||||||
int sd_dhcp_lease_get_sip(sd_dhcp_lease *lease, const struct in_addr **addr);
|
int sd_dhcp_lease_get_sip(sd_dhcp_lease *lease, const struct in_addr **addr);
|
||||||
|
@ -60,7 +60,7 @@ int sd_dhcp_server_set_emit_router(sd_dhcp_server *server, int enabled);
|
|||||||
|
|
||||||
int sd_dhcp_server_set_servers(
|
int sd_dhcp_server_set_servers(
|
||||||
sd_dhcp_server *server,
|
sd_dhcp_server *server,
|
||||||
sd_dhcp_lease_server_type_t what,
|
sd_dhcp_lease_server_type what,
|
||||||
const struct in_addr addresses[],
|
const struct in_addr addresses[],
|
||||||
size_t n_addresses);
|
size_t n_addresses);
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ enum {
|
|||||||
typedef struct sd_lldp sd_lldp;
|
typedef struct sd_lldp sd_lldp;
|
||||||
typedef struct sd_lldp_neighbor sd_lldp_neighbor;
|
typedef struct sd_lldp_neighbor sd_lldp_neighbor;
|
||||||
|
|
||||||
typedef enum sd_lldp_event_t {
|
typedef enum sd_lldp_event {
|
||||||
SD_LLDP_EVENT_ADDED,
|
SD_LLDP_EVENT_ADDED,
|
||||||
SD_LLDP_EVENT_REMOVED,
|
SD_LLDP_EVENT_REMOVED,
|
||||||
SD_LLDP_EVENT_UPDATED,
|
SD_LLDP_EVENT_UPDATED,
|
||||||
@ -130,9 +130,9 @@ typedef enum sd_lldp_event_t {
|
|||||||
_SD_LLDP_EVENT_MAX,
|
_SD_LLDP_EVENT_MAX,
|
||||||
_SD_LLDP_EVENT_INVALID = -EINVAL,
|
_SD_LLDP_EVENT_INVALID = -EINVAL,
|
||||||
_SD_ENUM_FORCE_S64(LLDP_EVENT),
|
_SD_ENUM_FORCE_S64(LLDP_EVENT),
|
||||||
} sd_lldp_event_t;
|
} sd_lldp_event;
|
||||||
|
|
||||||
typedef void (*sd_lldp_callback_t)(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor *n, void *userdata);
|
typedef void (*sd_lldp_callback_t)(sd_lldp *lldp, sd_lldp_event event, sd_lldp_neighbor *n, void *userdata);
|
||||||
|
|
||||||
int sd_lldp_new(sd_lldp **ret);
|
int sd_lldp_new(sd_lldp **ret);
|
||||||
sd_lldp* sd_lldp_ref(sd_lldp *lldp);
|
sd_lldp* sd_lldp_ref(sd_lldp *lldp);
|
||||||
|
@ -55,15 +55,15 @@ enum {
|
|||||||
typedef struct sd_ndisc sd_ndisc;
|
typedef struct sd_ndisc sd_ndisc;
|
||||||
typedef struct sd_ndisc_router sd_ndisc_router;
|
typedef struct sd_ndisc_router sd_ndisc_router;
|
||||||
|
|
||||||
typedef enum sd_ndisc_event_t {
|
typedef enum sd_ndisc_event {
|
||||||
SD_NDISC_EVENT_TIMEOUT,
|
SD_NDISC_EVENT_TIMEOUT,
|
||||||
SD_NDISC_EVENT_ROUTER,
|
SD_NDISC_EVENT_ROUTER,
|
||||||
_SD_NDISC_EVENT_MAX,
|
_SD_NDISC_EVENT_MAX,
|
||||||
_SD_NDISC_EVENT_INVALID = -EINVAL,
|
_SD_NDISC_EVENT_INVALID = -EINVAL,
|
||||||
_SD_ENUM_FORCE_S64(NDISC_EVENT),
|
_SD_ENUM_FORCE_S64(NDISC_EVENT),
|
||||||
} sd_ndisc_event_t;
|
} sd_ndisc_event;
|
||||||
|
|
||||||
typedef void (*sd_ndisc_callback_t)(sd_ndisc *nd, sd_ndisc_event_t event, sd_ndisc_router *rt, void *userdata);
|
typedef void (*sd_ndisc_callback_t)(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *rt, void *userdata);
|
||||||
|
|
||||||
int sd_ndisc_new(sd_ndisc **ret);
|
int sd_ndisc_new(sd_ndisc **ret);
|
||||||
sd_ndisc *sd_ndisc_ref(sd_ndisc *nd);
|
sd_ndisc *sd_ndisc_ref(sd_ndisc *nd);
|
||||||
|
@ -35,7 +35,7 @@ typedef struct sd_genl_socket sd_genl_socket;
|
|||||||
typedef struct sd_netlink_message sd_netlink_message;
|
typedef struct sd_netlink_message sd_netlink_message;
|
||||||
typedef struct sd_netlink_slot sd_netlink_slot;
|
typedef struct sd_netlink_slot sd_netlink_slot;
|
||||||
|
|
||||||
typedef enum sd_genl_family_t {
|
typedef enum sd_genl_family {
|
||||||
SD_GENL_ERROR,
|
SD_GENL_ERROR,
|
||||||
SD_GENL_DONE,
|
SD_GENL_DONE,
|
||||||
SD_GENL_ID_CTRL,
|
SD_GENL_ID_CTRL,
|
||||||
@ -47,7 +47,7 @@ typedef enum sd_genl_family_t {
|
|||||||
_SD_GENL_FAMILY_MAX,
|
_SD_GENL_FAMILY_MAX,
|
||||||
_SD_GENL_FAMILY_INVALID = -EINVAL,
|
_SD_GENL_FAMILY_INVALID = -EINVAL,
|
||||||
_SD_ENUM_FORCE_S64(GENL_FAMILY)
|
_SD_ENUM_FORCE_S64(GENL_FAMILY)
|
||||||
} sd_genl_family_t;
|
} sd_genl_family;
|
||||||
|
|
||||||
/* callback */
|
/* callback */
|
||||||
|
|
||||||
@ -249,8 +249,8 @@ int sd_nfnl_nft_message_add_setelem_end(sd_netlink_message *m);
|
|||||||
|
|
||||||
/* genl */
|
/* genl */
|
||||||
int sd_genl_socket_open(sd_netlink **nl);
|
int sd_genl_socket_open(sd_netlink **nl);
|
||||||
int sd_genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint8_t cmd, sd_netlink_message **m);
|
int sd_genl_message_new(sd_netlink *nl, sd_genl_family family, uint8_t cmd, sd_netlink_message **m);
|
||||||
int sd_genl_message_get_family(const sd_netlink *nl, const sd_netlink_message *m, sd_genl_family_t *family);
|
int sd_genl_message_get_family(const sd_netlink *nl, const sd_netlink_message *m, sd_genl_family *family);
|
||||||
|
|
||||||
/* slot */
|
/* slot */
|
||||||
sd_netlink_slot *sd_netlink_slot_ref(sd_netlink_slot *nl);
|
sd_netlink_slot *sd_netlink_slot_ref(sd_netlink_slot *nl);
|
||||||
|
@ -50,7 +50,7 @@ int main(int argc, char **argv) {
|
|||||||
test_table(collect_mode, COLLECT_MODE);
|
test_table(collect_mode, COLLECT_MODE);
|
||||||
test_table(condition_result, CONDITION_RESULT);
|
test_table(condition_result, CONDITION_RESULT);
|
||||||
test_table(condition_type, CONDITION_TYPE);
|
test_table(condition_type, CONDITION_TYPE);
|
||||||
test_table(device_action, SD_DEVICE_ACTION);
|
test_table(device_action, DEVICE_ACTION);
|
||||||
test_table(device_state, DEVICE_STATE);
|
test_table(device_state, DEVICE_STATE);
|
||||||
test_table(dns_over_tls_mode, DNS_OVER_TLS_MODE);
|
test_table(dns_over_tls_mode, DNS_OVER_TLS_MODE);
|
||||||
test_table(dnssec_mode, DNSSEC_MODE);
|
test_table(dnssec_mode, DNSSEC_MODE);
|
||||||
@ -125,7 +125,5 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
test_table_sparse(object_compressed, OBJECT_COMPRESSED);
|
test_table_sparse(object_compressed, OBJECT_COMPRESSED);
|
||||||
|
|
||||||
assert_cc(sizeof(sd_device_action_t) == sizeof(int64_t));
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "device-internal.h"
|
||||||
#include "device-private.h"
|
#include "device-private.h"
|
||||||
#include "device-util.h"
|
#include "device-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
|
@ -594,7 +594,7 @@ static int link_config_apply_alternative_names(sd_netlink **rtnl, const link_con
|
|||||||
|
|
||||||
int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device *device, const char **ret_name) {
|
int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device *device, const char **ret_name) {
|
||||||
const char *new_name;
|
const char *new_name;
|
||||||
sd_device_action_t a;
|
DeviceAction a;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(ctx);
|
assert(ctx);
|
||||||
@ -602,11 +602,11 @@ int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device
|
|||||||
assert(device);
|
assert(device);
|
||||||
assert(ret_name);
|
assert(ret_name);
|
||||||
|
|
||||||
r = sd_device_get_action(device, &a);
|
r = device_get_action(device, &a);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_device_error_errno(device, r, "Failed to get ACTION= property: %m");
|
return log_device_error_errno(device, r, "Failed to get ACTION= property: %m");
|
||||||
|
|
||||||
if (!IN_SET(a, SD_DEVICE_ADD, SD_DEVICE_BIND, SD_DEVICE_MOVE)) {
|
if (!IN_SET(a, DEVICE_ACTION_ADD, DEVICE_ACTION_BIND, DEVICE_ACTION_MOVE)) {
|
||||||
log_device_debug(device, "Skipping to apply .link settings on '%s' uevent.", device_action_to_string(a));
|
log_device_debug(device, "Skipping to apply .link settings on '%s' uevent.", device_action_to_string(a));
|
||||||
|
|
||||||
r = sd_device_get_sysname(device, ret_name);
|
r = sd_device_get_sysname(device, ret_name);
|
||||||
@ -624,7 +624,7 @@ int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (a == SD_DEVICE_MOVE) {
|
if (a == DEVICE_ACTION_MOVE) {
|
||||||
log_device_debug(device, "Skipping to apply Name= and NamePolicy= on '%s' uevent.", device_action_to_string(a));
|
log_device_debug(device, "Skipping to apply Name= and NamePolicy= on '%s' uevent.", device_action_to_string(a));
|
||||||
|
|
||||||
r = sd_device_get_sysname(device, &new_name);
|
r = sd_device_get_sysname(device, &new_name);
|
||||||
|
@ -831,7 +831,7 @@ static int rename_netif(UdevEvent *event) {
|
|||||||
if (streq(event->name, oldname))
|
if (streq(event->name, oldname))
|
||||||
return 0; /* The interface name is already requested name. */
|
return 0; /* The interface name is already requested name. */
|
||||||
|
|
||||||
if (!device_for_action(dev, SD_DEVICE_ADD))
|
if (!device_for_action(dev, DEVICE_ACTION_ADD))
|
||||||
return 0; /* Rename the interface only when it is added. */
|
return 0; /* Rename the interface only when it is added. */
|
||||||
|
|
||||||
r = sd_device_get_ifindex(dev, &ifindex);
|
r = sd_device_get_ifindex(dev, &ifindex);
|
||||||
@ -904,7 +904,7 @@ static int update_devnode(UdevEvent *event) {
|
|||||||
/* If group is set, but mode is not set, "upgrade" mode for the group. */
|
/* If group is set, but mode is not set, "upgrade" mode for the group. */
|
||||||
event->mode = 0660;
|
event->mode = 0660;
|
||||||
|
|
||||||
bool apply_mac = device_for_action(dev, SD_DEVICE_ADD);
|
bool apply_mac = device_for_action(dev, DEVICE_ACTION_ADD);
|
||||||
|
|
||||||
return udev_node_add(dev, apply_mac, event->mode, event->uid, event->gid, event->seclabel_list);
|
return udev_node_add(dev, apply_mac, event->mode, event->uid, event->gid, event->seclabel_list);
|
||||||
}
|
}
|
||||||
@ -975,7 +975,7 @@ int udev_event_execute_rules(UdevEvent *event,
|
|||||||
Hashmap *properties_list,
|
Hashmap *properties_list,
|
||||||
UdevRules *rules) {
|
UdevRules *rules) {
|
||||||
const char *subsystem;
|
const char *subsystem;
|
||||||
sd_device_action_t action;
|
DeviceAction action;
|
||||||
sd_device *dev;
|
sd_device *dev;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -988,11 +988,11 @@ int udev_event_execute_rules(UdevEvent *event,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_device_error_errno(dev, r, "Failed to get subsystem: %m");
|
return log_device_error_errno(dev, r, "Failed to get subsystem: %m");
|
||||||
|
|
||||||
r = sd_device_get_action(dev, &action);
|
r = device_get_action(dev, &action);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_device_error_errno(dev, r, "Failed to get ACTION: %m");
|
return log_device_error_errno(dev, r, "Failed to get ACTION: %m");
|
||||||
|
|
||||||
if (action == SD_DEVICE_REMOVE) {
|
if (action == DEVICE_ACTION_REMOVE) {
|
||||||
event_execute_rules_on_remove(event, timeout_usec, timeout_signal, properties_list, rules);
|
event_execute_rules_on_remove(event, timeout_usec, timeout_signal, properties_list, rules);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1009,7 +1009,7 @@ int udev_event_execute_rules(UdevEvent *event,
|
|||||||
/* Disable watch during event processing. */
|
/* Disable watch during event processing. */
|
||||||
(void) udev_watch_end(event->dev_db_clone);
|
(void) udev_watch_end(event->dev_db_clone);
|
||||||
|
|
||||||
if (action == SD_DEVICE_MOVE) {
|
if (action == DEVICE_ACTION_MOVE) {
|
||||||
r = udev_event_on_move(event->dev);
|
r = udev_event_on_move(event->dev);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include "architecture.h"
|
#include "architecture.h"
|
||||||
#include "conf-files.h"
|
#include "conf-files.h"
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
#include "device-private.h"
|
|
||||||
#include "device-util.h"
|
#include "device-util.h"
|
||||||
#include "dirent-util.h"
|
#include "dirent-util.h"
|
||||||
#include "escape.h"
|
#include "escape.h"
|
||||||
@ -1546,9 +1545,9 @@ static int udev_rule_apply_token_to_event(
|
|||||||
|
|
||||||
switch (token->type) {
|
switch (token->type) {
|
||||||
case TK_M_ACTION: {
|
case TK_M_ACTION: {
|
||||||
sd_device_action_t a;
|
DeviceAction a;
|
||||||
|
|
||||||
r = sd_device_get_action(dev, &a);
|
r = device_get_action(dev, &a);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_rule_error_errno(dev, rules, r, "Failed to get uevent action type: %m");
|
return log_rule_error_errno(dev, rules, r, "Failed to get uevent action type: %m");
|
||||||
|
|
||||||
@ -2227,14 +2226,14 @@ static int udev_rule_apply_line_to_event(
|
|||||||
UdevRuleLineType mask = LINE_HAS_GOTO | LINE_UPDATE_SOMETHING;
|
UdevRuleLineType mask = LINE_HAS_GOTO | LINE_UPDATE_SOMETHING;
|
||||||
UdevRuleToken *token, *next_token;
|
UdevRuleToken *token, *next_token;
|
||||||
bool parents_done = false;
|
bool parents_done = false;
|
||||||
sd_device_action_t action;
|
DeviceAction action;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = sd_device_get_action(event->dev, &action);
|
r = device_get_action(event->dev, &action);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (action != SD_DEVICE_REMOVE) {
|
if (action != DEVICE_ACTION_REMOVE) {
|
||||||
if (sd_device_get_devnum(event->dev, NULL) >= 0)
|
if (sd_device_get_devnum(event->dev, NULL) >= 0)
|
||||||
mask |= LINE_HAS_DEVLINK;
|
mask |= LINE_HAS_DEVLINK;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ static Set *arg_tag_filter = NULL;
|
|||||||
static Hashmap *arg_subsystem_filter = NULL;
|
static Hashmap *arg_subsystem_filter = NULL;
|
||||||
|
|
||||||
static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device, void *userdata) {
|
static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device, void *userdata) {
|
||||||
sd_device_action_t action = _SD_DEVICE_ACTION_INVALID;
|
DeviceAction action = _DEVICE_ACTION_INVALID;
|
||||||
const char *devpath = NULL, *subsystem = NULL;
|
const char *devpath = NULL, *subsystem = NULL;
|
||||||
MonitorNetlinkGroup group = PTR_TO_INT(userdata);
|
MonitorNetlinkGroup group = PTR_TO_INT(userdata);
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
@ -35,7 +35,7 @@ static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device,
|
|||||||
assert(device);
|
assert(device);
|
||||||
assert(IN_SET(group, MONITOR_GROUP_UDEV, MONITOR_GROUP_KERNEL));
|
assert(IN_SET(group, MONITOR_GROUP_UDEV, MONITOR_GROUP_KERNEL));
|
||||||
|
|
||||||
(void) sd_device_get_action(device, &action);
|
(void) device_get_action(device, &action);
|
||||||
(void) sd_device_get_devpath(device, &devpath);
|
(void) sd_device_get_devpath(device, &devpath);
|
||||||
(void) sd_device_get_subsystem(device, &subsystem);
|
(void) sd_device_get_subsystem(device, &subsystem);
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
while ((c = getopt_long(argc, argv, "a:N:Vh", options, NULL)) >= 0)
|
while ((c = getopt_long(argc, argv, "a:N:Vh", options, NULL)) >= 0)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a': {
|
case 'a': {
|
||||||
sd_device_action_t a;
|
DeviceAction a;
|
||||||
|
|
||||||
if (streq(optarg, "help")) {
|
if (streq(optarg, "help")) {
|
||||||
dump_device_action_table();
|
dump_device_action_table();
|
||||||
@ -63,9 +63,10 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
|
|
||||||
a = device_action_from_string(optarg);
|
a = device_action_from_string(optarg);
|
||||||
if (a < 0)
|
if (a < 0)
|
||||||
return log_error_errno(a, "Invalid action '%s'", optarg);
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||||
|
"Invalid action '%s'", optarg);
|
||||||
|
|
||||||
arg_action = device_action_to_string(a);
|
arg_action = optarg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'N':
|
case 'N':
|
||||||
|
@ -211,7 +211,7 @@ int trigger_main(int argc, char *argv[], void *userdata) {
|
|||||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown type --type=%s", optarg);
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown type --type=%s", optarg);
|
||||||
break;
|
break;
|
||||||
case 'c': {
|
case 'c': {
|
||||||
sd_device_action_t a;
|
DeviceAction a;
|
||||||
|
|
||||||
if (streq(optarg, "help")) {
|
if (streq(optarg, "help")) {
|
||||||
dump_device_action_table();
|
dump_device_action_table();
|
||||||
@ -222,7 +222,7 @@ int trigger_main(int argc, char *argv[], void *userdata) {
|
|||||||
if (a < 0)
|
if (a < 0)
|
||||||
return log_error_errno(a, "Unknown action '%s'", optarg);
|
return log_error_errno(a, "Unknown action '%s'", optarg);
|
||||||
|
|
||||||
action = device_action_to_string(a);
|
action = optarg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 's':
|
case 's':
|
||||||
|
@ -20,7 +20,7 @@ static int find_device_from_path(const char *path, sd_device **ret) {
|
|||||||
if (stat(path, &st) < 0)
|
if (stat(path, &st) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
return sd_device_new_from_stat_rdev(ret, &st);
|
return device_new_from_stat_rdev(ret, &st);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -325,12 +325,16 @@ static int worker_lock_block_device(sd_device *dev, int *ret_fd) {
|
|||||||
assert(dev);
|
assert(dev);
|
||||||
assert(ret_fd);
|
assert(ret_fd);
|
||||||
|
|
||||||
/* Take a shared lock on the device node; this establishes a concept of device "ownership" to
|
/*
|
||||||
* serialize device access. External processes holding an exclusive lock will cause udev to skip the
|
* Take a shared lock on the device node; this establishes
|
||||||
* event handling; in the case udev acquired the lock, the external process can block until udev has
|
* a concept of device "ownership" to serialize device
|
||||||
* finished its event handling. */
|
* access. External processes holding an exclusive lock will
|
||||||
|
* cause udev to skip the event handling; in the case udev
|
||||||
|
* acquired the lock, the external process can block until
|
||||||
|
* udev has finished its event handling.
|
||||||
|
*/
|
||||||
|
|
||||||
if (device_for_action(dev, SD_DEVICE_REMOVE))
|
if (device_for_action(dev, DEVICE_ACTION_REMOVE))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = sd_device_get_subsystem(dev, &val);
|
r = sd_device_get_subsystem(dev, &val);
|
||||||
@ -388,7 +392,7 @@ static int worker_mark_block_device_read_only(sd_device *dev) {
|
|||||||
/* Do this only once, when the block device is new. If the device is later retriggered let's not
|
/* Do this only once, when the block device is new. If the device is later retriggered let's not
|
||||||
* toggle the bit again, so that people can boot up with full read-only mode and then unset the bit
|
* toggle the bit again, so that people can boot up with full read-only mode and then unset the bit
|
||||||
* for specific devices only. */
|
* for specific devices only. */
|
||||||
if (!device_for_action(dev, SD_DEVICE_ADD))
|
if (!device_for_action(dev, DEVICE_ACTION_ADD))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = sd_device_get_subsystem(dev, &val);
|
r = sd_device_get_subsystem(dev, &val);
|
||||||
@ -690,7 +694,7 @@ static int event_queue_insert(Manager *manager, sd_device *dev) {
|
|||||||
assert(manager->pid == getpid_cached());
|
assert(manager->pid == getpid_cached());
|
||||||
|
|
||||||
/* We only accepts devices received by device monitor. */
|
/* We only accepts devices received by device monitor. */
|
||||||
r = sd_device_get_seqnum(dev, &seqnum);
|
r = device_get_seqnum(dev, &seqnum);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ FallbackLeaseLifetimeSec=
|
|||||||
UseAddress=
|
UseAddress=
|
||||||
UseNTP=
|
UseNTP=
|
||||||
UseDNS=
|
UseDNS=
|
||||||
UseHostname=
|
UseFQDN=
|
||||||
RapidCommit=
|
RapidCommit=
|
||||||
ForceDHCPv6PDOtherInformation=
|
ForceDHCPv6PDOtherInformation=
|
||||||
PrefixDelegationHint=
|
PrefixDelegationHint=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user