1
0
mirror of https://github.com/systemd/systemd synced 2026-03-17 10:34:46 +01:00

Compare commits

..

27 Commits

Author SHA1 Message Date
Yu Watanabe
2255e8adee sd-device: do not use ::subsystem member directly
The value is set dynamically when sd_device_get_subsystem() is called
first time.

Fixes the following issue:
```
$ build/udevadm test /sys/class/block/dm-1
...
Assertion '_subsystem' failed at src/libsystemd/sd-device/sd-device.c:767, function device_set_subsystem(). Aborting.
Program received signal SIGABRT, Aborted.
```
2021-06-03 05:59:03 +09:00
Yu Watanabe
f0273cba25
Merge pull request #19798 from bluca/todo_landlock
Add new item to TODO list
2021-06-03 03:37:33 +09:00
Yu Watanabe
a884774635
Merge pull request #19792 from keszybz/more-logging-stuff
More logging tweaks
2021-06-03 03:36:28 +09:00
Luca Boccassi
88511a3712 TODO: mention the new Landlock LSM as a way to implement sandboxing for systemd --user 2021-06-02 19:13:28 +01:00
Luca Boccassi
e91035abf0 TODO: remove some features that have been implemented 2021-06-02 18:57:31 +01:00
Yu Watanabe
63b8a781b6
Merge pull request #19791 from yuwata/udev-node-logs
udev: update several log messages
2021-06-03 01:32:29 +09:00
scootergrisen
a22bcf503b po: Translated using Weblate (Danish)
Currently translated at 100.0% (189 of 189 strings)

Co-authored-by: scootergrisen <scootergrisen@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/da/
Translation: systemd/main
2021-06-03 01:31:51 +09:00
Luca Boccassi
c17b4f4b0e
Merge pull request #19783 from yuwata/efi-build-options
efi: constify several functions and enable more warnings
2021-06-02 17:02:57 +01:00
Zbigniew Jędrzejewski-Szmek
0d5a24beae various: don't say that the timestamp 'changed' on initial load
I always found this a bit annoying.
With the patch:

$ SYSTEMD_LOG_LEVEL=debug build/udevadm test /sys/class/block/dm-1
...
Loaded timestamp for '/etc/systemd/network'.
Loaded timestamp for '/usr/lib/systemd/network'.
Parsed configuration file /usr/lib/systemd/network/99-default.link
Parsed configuration file /etc/systemd/network/10-eth0.link
Created link configuration context.
Loaded timestamp for '/etc/udev/rules.d'.
Loaded timestamp for '/usr/lib/udev/rules.d'.
...
2021-06-02 16:23:54 +02:00
Yu Watanabe
7b80829575 udev: upgrade log level about failure in updating devlinks 2021-06-02 21:00:45 +09:00
Yu Watanabe
cd8bcff507 udev: check that passed symbolic link path starts with /dev 2021-06-02 21:00:22 +09:00
Yu Watanabe
d46969072a udev: explicitly mention that the error will be ignored
See #19788.
2021-06-02 19:15:02 +09:00
Yu Watanabe
6be1feb1d7 udev: ignore the case that the device is already removed
See #19788.
2021-06-02 19:10:52 +09:00
Zbigniew Jędrzejewski-Szmek
0517ececff core: show manager version in dump
This makes it easier to not get lost which one is which when
comparing two dumps.
2021-06-02 09:22:08 +02:00
Zbigniew Jędrzejewski-Szmek
2a341bb9d2 core: split out core/manager-dump.[ch]
This is a fairly specialized topic, let's create a separate file for it.
2021-06-02 09:22:08 +02:00
Zbigniew Jędrzejewski-Szmek
5b326dee29 TODO: add entry about alias logging 2021-06-02 09:22:08 +02:00
Zbigniew Jędrzejewski-Szmek
953394e3bb varlink: remove duplicated "varlink:" prefix
We had:

systemd[1]: varlink-36: New incoming message: {"method":"io.systemd.UserDatabase.GetMemberships","parameters":{"userName":"gdm","service":"io.systemd.DynamicUser"},"more":true}
systemd[1]: varlink-36: varlink: changing state idle-server → processing-method-more
systemd[1]: varlink-36: Sending message: {"error":"io.systemd.UserDatabase.NoRecordFound","parameters":{}}
systemd[1]: varlink-36: varlink: changing state processing-method-more → processed-method
systemd[1]: varlink-36: varlink: changing state processed-method → idle-server
systemd[1]: varlink-36: Got POLLHUP from socket.
systemd[1]: varlink-36: varlink: changing state idle-server → pending-disconnect
systemd[1]: varlink-36: varlink: changing state pending-disconnect → processing-disconnect
systemd[1]: varlink-36: varlink: changing state processing-disconnect → disconnected

So let's drop the "varlink:" prefix and use capitalized sentences like in other messages.
2021-06-02 09:22:08 +02:00
Zbigniew Jędrzejewski-Szmek
f35e9b101d varlink: say "varlink:" instead of "n/a:" when no description is available
For new connections, we log something like this:

systemd[1]: n/a: New incoming connection.
systemd[1]: n/a: Connections of user 997: 0 (of 1024 max)
systemd[1]: varlink-22: varlink: setting state idle-server
systemd[1]: varlink-22: New incoming message: ...

This "n/a" is not very pretty, and without context it would be hard to even
figure out this is a varlink connection.
2021-06-02 09:22:08 +02:00
Yu Watanabe
505ab9dda2 meson: sort compiler flags 2021-06-02 15:53:29 +09:00
Yu Watanabe
6526736397 meson: enable more warnings when building efi binary 2021-06-02 15:49:44 +09:00
Yu Watanabe
ca474d5114 efi: constify several arguments of functions which handle loader entries 2021-06-02 15:45:47 +09:00
Yu Watanabe
cfb7fa289d efi: drop const qualifiers from arguments in uefi_call_wrapper() 2021-06-02 15:43:21 +09:00
Yu Watanabe
edad24c61e efi: add const qualifier to EFI variable handling functions 2021-06-02 15:41:39 +09:00
Yu Watanabe
ef53d52b01 efi: add const qualifier to string utils 2021-06-02 15:40:56 +09:00
Yu Watanabe
72dc626b3d efi: include endian.h to handle endian correctly
The macro __BYTE_ORDER__ is defined in endian.h.
2021-06-02 15:38:32 +09:00
Yu Watanabe
959ab90bbc efi: do not use _STRING_ARCH_unaligned macro
It is already removed from glibc. See,
https://sourceware.org/git/?p=glibc.git;a=commit;h=16396c41deab45f715ffd813280d9d685b3b281e
https://sourceware.org/git/?p=glibc.git;a=commit;h=09a596cc2cf4e0f9f8e9f3bba4b1a97efcb13bcb
2021-06-02 15:36:29 +09:00
Yu Watanabe
122dbd92c9 string-util: trivial optimizations for strverscmp_improved() 2021-06-02 14:20:25 +09:00
27 changed files with 276 additions and 215 deletions

9
TODO
View File

@ -9,6 +9,10 @@ Bugfixes:
* Get rid of nftw(). We should refuse to use such useless APIs on principle.
* Jun 01 09:43:02 krowka systemd[1]: Unit user@1000.service has alias user@.service.
Jun 01 09:43:02 krowka systemd[1]: Unit user@6.service has alias user@.service.
Jun 01 09:43:02 krowka systemd[1]: Unit user-runtime-dir@6.service has alias user-runtime-dir@.service.
External:
* Fedora: add an rpmlint check that verifies that all unit files in the RPM are listed in %systemd_post macros.
@ -665,8 +669,6 @@ Features:
* add support for "portablectl attach http://foobar.com/waaa.raw (i.e. importd integration)
* add attach --enable and attach --now (for attach+enable+start)
* sync dynamic uids/gids between host+portable srvice (i.e. if DynamicUser=1 is set for a service, make sure that the
selected user is resolvable in the service even if it ships its own /etc/passwd)
@ -860,6 +862,9 @@ Features:
on PID 1 with the relevant signals, and makes relevant files in /sys and
/proc (such as the sysrq stuff) unavailable
* Support ReadWritePaths/ReadOnlyPaths/InaccessiblePaths in systemd --user instances
via the new unprivileged Landlock LSM (https://landlock.io)
* make sure the ratelimit object can deal with USEC_INFINITY as way to turn off things
* journalctl: make sure -f ends when the container indicated by -M terminates

View File

@ -319,40 +319,38 @@ endif
# Those generate many false positives, and we do not want to change the code to
# avoid them.
basic_disabled_warnings = [
'-Wno-unused-parameter',
'-Wno-missing-field-initializers',
'-Wno-unused-result',
'-Wno-format-signedness',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
'-Wno-unused-result',
]
possible_cc_flags = [
'-Werror=undef',
'-Wlogical-op',
'-Wmissing-include-dirs',
'-Wold-style-definition',
'-Wpointer-arith',
'-Winit-self',
'-Wfloat-equal',
'-Wsuggest-attribute=noreturn',
'-Werror=missing-prototypes',
'-Werror=implicit-function-declaration',
'-Werror=missing-declarations',
'-Werror=return-type',
'-Werror=incompatible-pointer-types',
'-Werror=format=2',
'-Wstrict-prototypes',
'-Wredundant-decls',
'-Wmissing-noreturn',
'-Wimplicit-fallthrough=5',
'-Wshadow',
possible_common_cc_flags = [
'-Wdate-time',
'-Wendif-labels',
'-Wstrict-aliasing=2',
'-Wwrite-strings',
'-Werror=format=2',
'-Werror=implicit-function-declaration',
'-Werror=incompatible-pointer-types',
'-Werror=overflow',
'-Werror=return-type',
'-Werror=shift-count-overflow',
'-Werror=shift-overflow=2',
'-Wdate-time',
'-Werror=undef',
'-Wfloat-equal',
'-Wimplicit-fallthrough=5',
'-Winit-self',
'-Wlogical-op',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wnested-externs',
'-Wold-style-definition',
'-Wpointer-arith',
'-Wredundant-decls',
'-Wshadow',
'-Wstrict-aliasing=2',
'-Wstrict-prototypes',
'-Wsuggest-attribute=noreturn',
'-Wwrite-strings',
# negative arguments are correctly detected starting with meson 0.46.
'-Wno-error=#warnings', # clang
@ -363,8 +361,6 @@ possible_cc_flags = [
'-fdiagnostics-show-option',
'-fno-strict-aliasing',
'-fvisibility=hidden',
'-fstack-protector',
'-fstack-protector-strong',
'--param=ssp-buffer-size=4',
]
@ -374,7 +370,7 @@ possible_cc_flags = [
# busywork. See https://github.com/systemd/systemd/pull/19226.
if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
cc.version().version_compare('<10'))
possible_cc_flags += '-Wno-maybe-uninitialized'
possible_common_cc_flags += '-Wno-maybe-uninitialized'
endif
# --as-needed and --no-undefined are provided by meson by default,
@ -386,14 +382,14 @@ possible_link_flags = [
]
if cc.get_id() == 'clang'
possible_cc_flags += [
possible_common_cc_flags += [
'-Wno-typedef-redefinition',
'-Wno-gnu-variable-sized-type-not-at-end',
]
endif
if get_option('buildtype') != 'debug'
possible_cc_flags += [
possible_common_cc_flags += [
'-ffunction-sections',
'-fdata-sections',
]
@ -401,6 +397,13 @@ if get_option('buildtype') != 'debug'
possible_link_flags += '-Wl,--gc-sections'
endif
possible_cc_flags = possible_common_cc_flags + [
'-Werror=missing-declarations',
'-Werror=missing-prototypes',
'-fstack-protector',
'-fstack-protector-strong',
]
add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')

View File

@ -2,13 +2,13 @@
#
# Danish translation for systemd.
# Daniel Machon <dmachon.dev@gmail.com>, 2015.
# scootergrisen <scootergrisen@gmail.com>, 2020.
# scootergrisen <scootergrisen@gmail.com>, 2020, 2021.
msgid ""
msgstr ""
"Project-Id-Version: systemd master\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-08 17:48+0100\n"
"PO-Revision-Date: 2020-09-19 12:22+0000\n"
"PO-Revision-Date: 2021-06-02 16:03+0000\n"
"Last-Translator: scootergrisen <scootergrisen@gmail.com>\n"
"Language-Team: Danish <https://translate.fedoraproject.org/projects/systemd/"
"master/da/>\n"
@ -17,7 +17,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.2.2\n"
"X-Generator: Weblate 4.6.2\n"
#: src/core/org.freedesktop.systemd1.policy.in:22
msgid "Send passphrase back to system"
@ -296,22 +296,16 @@ msgstr ""
"skærmlukning."
#: src/login/org.freedesktop.login1.policy:117
#, fuzzy
#| msgid "Allow applications to inhibit system handling of the power key"
msgid "Allow applications to inhibit system handling of the reboot key"
msgstr "Tillad programmer at hæmme systemhåndtering af tænd/sluk-knappen"
msgstr "Tillad programmer at hæmme systemhåndtering af genstart-knappen"
#: src/login/org.freedesktop.login1.policy:118
#, fuzzy
#| msgid ""
#| "Authentication is required for an application to inhibit system handling "
#| "of the power key."
msgid ""
"Authentication is required for an application to inhibit system handling of "
"the reboot key."
msgstr ""
"Der kræves godkendelse for at et program kan hæmme systemhåndtering af tænd/"
"sluk-knappen."
"Der kræves godkendelse for at et program kan hæmme systemhåndtering af "
"genstart-knappen."
#: src/login/org.freedesktop.login1.policy:128
msgid "Allow non-logged-in user to run programs"

View File

@ -713,7 +713,7 @@ int find_executable_full(const char *name, bool use_path_envvar, char **ret_file
}
bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool update) {
bool changed = false;
bool changed = false, originally_unset;
const char* const* i;
assert(timestamp);
@ -721,6 +721,8 @@ bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool upd
if (!paths)
return false;
originally_unset = *timestamp == 0;
STRV_FOREACH(i, paths) {
struct stat stats;
usec_t u;
@ -730,11 +732,11 @@ bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool upd
u = timespec_load(&stats.st_mtim);
/* first check */
/* check first */
if (*timestamp >= u)
continue;
log_debug("timestamp of '%s' changed", *i);
log_debug(originally_unset ? "Loaded timestamp for '%s'." : "Timestamp of '%s' changed.", *i);
/* update timestamp */
if (update) {

View File

@ -91,7 +91,7 @@ static VOID cursor_right(
}
static BOOLEAN line_edit(
CHAR16 *line_in,
const CHAR16 *line_in,
CHAR16 **line_out,
UINTN x_max,
UINTN y_pos) {
@ -521,7 +521,7 @@ static BOOLEAN menu_run(
uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK);
/* draw a single character to make ClearScreen work on some firmware */
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L" ");
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, (CHAR16*) L" ");
if (config->console_mode_change != CONSOLE_MODE_KEEP) {
err = console_set_mode(&config->console_mode, config->console_mode_change);
@ -618,7 +618,7 @@ static BOOLEAN menu_run(
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[i]);
if ((INTN)i == config->idx_default_efivar) {
uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, x_start-3, y_start + i - idx_first);
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"=>");
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, (CHAR16*) L"=>");
}
}
refresh = FALSE;
@ -628,7 +628,7 @@ static BOOLEAN menu_run(
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[idx_highlight_prev]);
if ((INTN)idx_highlight_prev == config->idx_default_efivar) {
uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, x_start-3, y_start + idx_highlight_prev - idx_first);
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"=>");
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, (CHAR16*) L"=>");
}
uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_start + idx_highlight - idx_first);
@ -636,7 +636,7 @@ static BOOLEAN menu_run(
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, lines[idx_highlight]);
if ((INTN)idx_highlight == config->idx_default_efivar) {
uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, x_start-3, y_start + idx_highlight - idx_first);
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"=>");
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, (CHAR16*) L"=>");
}
highlight = FALSE;
}
@ -916,14 +916,13 @@ static VOID config_entry_free(ConfigEntry *entry) {
static CHAR8 *line_get_key_value(
CHAR8 *content,
CHAR8 *sep,
const CHAR8 *sep,
UINTN *pos,
CHAR8 **key_ret,
CHAR8 **value_ret) {
CHAR8 *line;
CHAR8 *line, *value;
UINTN linelen;
CHAR8 *value;
skip:
line = content + *pos;
@ -1073,9 +1072,9 @@ static VOID config_defaults_load_from_file(Config *config, CHAR8 *content) {
static VOID config_entry_parse_tries(
ConfigEntry *entry,
CHAR16 *path,
CHAR16 *file,
CHAR16 *suffix) {
const CHAR16 *path,
const CHAR16 *file,
const CHAR16 *suffix) {
UINTN left = UINTN_MAX, done = UINTN_MAX, factor = 1, i, next_left, next_done;
_cleanup_freepool_ CHAR16 *prefix = NULL;
@ -1259,10 +1258,10 @@ static VOID config_entry_add_from_file(
Config *config,
EFI_HANDLE *device,
EFI_FILE *root_dir,
CHAR16 *path,
CHAR16 *file,
const CHAR16 *path,
const CHAR16 *file,
CHAR8 *content,
CHAR16 *loaded_image_path) {
const CHAR16 *loaded_image_path) {
ConfigEntry *entry;
CHAR8 *line;
@ -1437,7 +1436,7 @@ static VOID config_load_entries(
EFI_FILE_HANDLE entries_dir;
EFI_STATUS err;
err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &entries_dir, L"\\loader\\entries", EFI_FILE_MODE_READ, 0ULL);
err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &entries_dir, (CHAR16*) L"\\loader\\entries", EFI_FILE_MODE_READ, 0ULL);
if (!EFI_ERROR(err)) {
for (;;) {
CHAR16 buf[256];
@ -1689,8 +1688,8 @@ static VOID config_title_generate(Config *config) {
static BOOLEAN config_entry_add_call(
Config *config,
CHAR16 *id,
CHAR16 *title,
const CHAR16 *id,
const CHAR16 *title,
EFI_STATUS (*call)(VOID)) {
ConfigEntry *entry;
@ -1713,11 +1712,11 @@ static ConfigEntry *config_entry_add_loader(
Config *config,
EFI_HANDLE *device,
enum loader_type type,
CHAR16 *id,
const CHAR16 *id,
CHAR16 key,
CHAR16 *title,
CHAR16 *loader,
CHAR16 *version) {
const CHAR16 *title,
const CHAR16 *loader,
const CHAR16 *version) {
ConfigEntry *entry;
@ -1744,11 +1743,11 @@ static BOOLEAN config_entry_add_loader_auto(
Config *config,
EFI_HANDLE *device,
EFI_FILE *root_dir,
CHAR16 *loaded_image_path,
CHAR16 *id,
const CHAR16 *loaded_image_path,
const CHAR16 *id,
CHAR16 key,
CHAR16 *title,
CHAR16 *loader) {
const CHAR16 *title,
const CHAR16 *loader) {
EFI_FILE_HANDLE handle;
ConfigEntry *entry;
@ -1774,7 +1773,7 @@ static BOOLEAN config_entry_add_loader_auto(
}
/* check existence */
err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, loader, EFI_FILE_MODE_READ, 0ULL);
err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, (CHAR16*) loader, EFI_FILE_MODE_READ, 0ULL);
if (EFI_ERROR(err))
return FALSE;
uefi_call_wrapper(handle->Close, 1, handle);
@ -1824,7 +1823,7 @@ static VOID config_entry_add_linux(
EFI_STATUS err;
ConfigEntry *entry;
err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &linux_dir, L"\\EFI\\Linux", EFI_FILE_MODE_READ, 0ULL);
err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &linux_dir, (CHAR16*) L"\\EFI\\Linux", EFI_FILE_MODE_READ, 0ULL);
if (EFI_ERROR(err))
return;

View File

@ -175,23 +175,27 @@ if have_gnu_efi
endif
if have_gnu_efi
compile_args = ['-Wall',
'-Wextra',
'-std=gnu99',
'-nostdlib',
compile_args = cc.get_supported_arguments(
basic_disabled_warnings +
possible_common_cc_flags + [
'-ffreestanding',
'-fno-stack-protector',
'-fpic',
'-fshort-wchar',
'-ffreestanding',
'-fno-strict-aliasing',
'-fno-stack-protector',
'-Wall',
'-Wextra',
'-Wsign-compare',
'-Wno-missing-field-initializers',
]
) + [
'-nostdlib',
'-std=gnu99',
'-isystem', efi_incdir,
'-isystem', join_paths(efi_incdir, gnu_efi_path_arch),
'-I', fundamental_path,
'-DSD_BOOT',
'-include', efi_config_h,
'-include', version_h]
'-include', version_h,
]
if efi_arch == 'x86_64'
compile_args += ['-mno-red-zone',
'-mno-sse',

View File

@ -243,7 +243,7 @@ EFI_STATUS process_random_seed(EFI_FILE *root_dir, RandomSeedMode mode) {
if (mode != RANDOM_SEED_ALWAYS && EFI_ERROR(err))
return err;
err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, L"\\loader\\random-seed", EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0ULL);
err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, (CHAR16*) L"\\loader\\random-seed", EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0ULL);
if (EFI_ERROR(err)) {
if (err != EFI_NOT_FOUND)
Print(L"Failed to open random seed file: %r\n", err);

View File

@ -143,9 +143,12 @@ void sha256_process_bytes(const void *buffer, UINTN len, struct sha256_ctx *ctx)
/* Process available complete blocks. */
if (len >= 64) {
#if !_STRING_ARCH_unaligned
/* To check alignment gcc has an appropriate operator. Other
compilers don't. */
/* The condition below is from glibc's string/string-inline.c.
* See definition of _STRING_INLINE_unaligned. */
#if !defined(__mc68020__) && !defined(__s390__) && !defined(__i386__)
/* To check alignment gcc has an appropriate operator. Other compilers don't. */
# if __GNUC__ >= 2
# define UNALIGNED_P(p) (((UINTN) p) % __alignof__ (UINT32) != 0)
# else

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <endian.h>
#include <efi.h>
#include <efilib.h>

View File

@ -84,14 +84,14 @@ EFI_STATUS efivar_set(const EFI_GUID *vendor, const CHAR16 *name, const CHAR16 *
return efivar_set_raw(vendor, name, value, value ? (StrLen(value) + 1) * sizeof(CHAR16) : 0, flags);
}
EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, CHAR16 *name, UINTN i, UINT32 flags) {
EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UINTN i, UINT32 flags) {
CHAR16 str[32];
SPrint(str, 32, L"%u", i);
return efivar_set(vendor, name, str, flags);
}
EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, CHAR16 *name, UINT32 value, UINT32 flags) {
EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, const CHAR16 *name, UINT32 value, UINT32 flags) {
UINT8 buf[4];
buf[0] = (UINT8)(value >> 0U & 0xFF);
@ -102,7 +102,7 @@ EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, CHAR16 *name, UINT32 val
return efivar_set_raw(vendor, name, buf, sizeof(buf), flags);
}
EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, CHAR16 *name, UINT64 value, UINT32 flags) {
EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, UINT64 value, UINT32 flags) {
UINT8 buf[8];
buf[0] = (UINT8)(value >> 0U & 0xFF);
@ -233,7 +233,7 @@ EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const CHAR16 *name, BOO
return err;
}
VOID efivar_set_time_usec(const EFI_GUID *vendor, CHAR16 *name, UINT64 usec) {
VOID efivar_set_time_usec(const EFI_GUID *vendor, const CHAR16 *name, UINT64 usec) {
CHAR16 str[32];
if (usec == 0)
@ -245,7 +245,7 @@ VOID efivar_set_time_usec(const EFI_GUID *vendor, CHAR16 *name, UINT64 usec) {
efivar_set(vendor, name, str, 0);
}
static INTN utf8_to_16(CHAR8 *stra, CHAR16 *c) {
static INTN utf8_to_16(const CHAR8 *stra, CHAR16 *c) {
CHAR16 unichar;
UINTN len;
@ -296,7 +296,7 @@ static INTN utf8_to_16(CHAR8 *stra, CHAR16 *c) {
return len;
}
CHAR16 *stra_to_str(CHAR8 *stra) {
CHAR16 *stra_to_str(const CHAR8 *stra) {
UINTN strlen;
UINTN len;
UINTN i;
@ -324,7 +324,7 @@ CHAR16 *stra_to_str(CHAR8 *stra) {
return str;
}
CHAR16 *stra_to_path(CHAR8 *stra) {
CHAR16 *stra_to_path(const CHAR8 *stra) {
CHAR16 *str;
UINTN strlen;
UINTN len;
@ -361,10 +361,10 @@ CHAR16 *stra_to_path(CHAR8 *stra) {
return str;
}
CHAR8 *strchra(CHAR8 *s, CHAR8 c) {
CHAR8 *strchra(const CHAR8 *s, CHAR8 c) {
do {
if (*s == c)
return s;
return (CHAR8*) s;
} while (*s++);
return NULL;
}

View File

@ -20,10 +20,10 @@ UINT64 time_usec(void);
EFI_STATUS efivar_set(const EFI_GUID *vendor, const CHAR16 *name, const CHAR16 *value, UINT32 flags);
EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const CHAR16 *name, const VOID *buf, UINTN size, UINT32 flags);
EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, CHAR16 *name, UINTN i, UINT32 flags);
EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, CHAR16 *NAME, UINT32 value, UINT32 flags);
EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, CHAR16 *name, UINT64 value, UINT32 flags);
VOID efivar_set_time_usec(const EFI_GUID *vendor, CHAR16 *name, UINT64 usec);
EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UINTN i, UINT32 flags);
EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, const CHAR16 *NAME, UINT32 value, UINT32 flags);
EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, UINT64 value, UINT32 flags);
VOID efivar_set_time_usec(const EFI_GUID *vendor, const CHAR16 *name, UINT64 usec);
EFI_STATUS efivar_get(const EFI_GUID *vendor, const CHAR16 *name, CHAR16 **value);
EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const CHAR16 *name, CHAR8 **buffer, UINTN *size);
@ -32,9 +32,9 @@ EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const CHAR16 *name, UINT
EFI_STATUS efivar_get_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, UINT64 *ret);
EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const CHAR16 *name, BOOLEAN *ret);
CHAR8 *strchra(CHAR8 *s, CHAR8 c);
CHAR16 *stra_to_path(CHAR8 *stra);
CHAR16 *stra_to_str(CHAR8 *stra);
CHAR8 *strchra(const CHAR8 *s, CHAR8 c);
CHAR16 *stra_to_path(const CHAR8 *stra);
CHAR16 *stra_to_str(const CHAR8 *stra);
EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN size, CHAR8 **content, UINTN *content_size);

View File

@ -26,6 +26,7 @@
#include "fs-util.h"
#include "install.h"
#include "log.h"
#include "manager-dump.h"
#include "os-util.h"
#include "parse-util.h"
#include "path-util.h"

View File

@ -64,6 +64,7 @@
#include "log.h"
#include "macro.h"
#include "manager.h"
#include "manager-dump.h"
#include "memory-util.h"
#include "missing_fs.h"
#include "mkdir.h"

View File

@ -6,6 +6,7 @@
#include "fuzz.h"
#include "install.h"
#include "load-fragment.h"
#include "manager-dump.h"
#include "string-util.h"
#include "unit-serialize.h"
#include "utf8.h"

View File

@ -54,6 +54,7 @@
#include "loopback-setup.h"
#include "machine-id-setup.h"
#include "manager.h"
#include "manager-dump.h"
#include "mkdir.h"
#include "mount-setup.h"
#include "os-util.h"
@ -2500,16 +2501,6 @@ static int initialize_security(
return 0;
}
static void test_summary(Manager *m) {
assert(m);
printf("-> By units:\n");
manager_dump_units(m, stdout, "\t");
printf("-> By jobs:\n");
manager_dump_jobs(m, stdout, "\t");
}
static int collect_fds(FDSet **ret_fds, const char **ret_error_message) {
int r;
@ -2882,7 +2873,7 @@ int main(int argc, char *argv[]) {
format_timespan(timespan, sizeof(timespan), after_startup - before_startup, 100 * USEC_PER_MSEC));
if (arg_action == ACTION_TEST) {
test_summary(m);
manager_test_summary(m);
retval = EXIT_SUCCESS;
goto finish;
}

89
src/core/manager-dump.c Normal file
View File

@ -0,0 +1,89 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "build.h"
#include "fd-util.h"
#include "fileio.h"
#include "hashmap.h"
#include "manager-dump.h"
#include "unit-serialize.h"
void manager_dump_jobs(Manager *s, FILE *f, const char *prefix) {
Job *j;
assert(s);
assert(f);
HASHMAP_FOREACH(j, s->jobs)
job_dump(j, f, prefix);
}
void manager_dump_units(Manager *s, FILE *f, const char *prefix) {
Unit *u;
const char *t;
assert(s);
assert(f);
HASHMAP_FOREACH_KEY(u, t, s->units)
if (u->id == t)
unit_dump(u, f, prefix);
}
void manager_dump(Manager *m, FILE *f, const char *prefix) {
assert(m);
assert(f);
fprintf(f, "%sManager: systemd " STRINGIFY(PROJECT_VERSION) " (" GIT_VERSION ")\n", strempty(prefix));
fprintf(f, "%sFeatures: %s\n", strempty(prefix), systemd_features);
for (ManagerTimestamp q = 0; q < _MANAGER_TIMESTAMP_MAX; q++) {
const dual_timestamp *t = m->timestamps + q;
char buf[CONST_MAX(FORMAT_TIMESPAN_MAX, FORMAT_TIMESTAMP_MAX)];
if (dual_timestamp_is_set(t))
fprintf(f, "%sTimestamp %s: %s\n",
strempty(prefix),
manager_timestamp_to_string(q),
timestamp_is_set(t->realtime) ? format_timestamp(buf, sizeof buf, t->realtime) :
format_timespan(buf, sizeof buf, t->monotonic, 1));
}
manager_dump_units(m, f, prefix);
manager_dump_jobs(m, f, prefix);
}
int manager_get_dump_string(Manager *m, char **ret) {
_cleanup_free_ char *dump = NULL;
_cleanup_fclose_ FILE *f = NULL;
size_t size;
int r;
assert(m);
assert(ret);
f = open_memstream_unlocked(&dump, &size);
if (!f)
return -errno;
manager_dump(m, f, NULL);
r = fflush_and_check(f);
if (r < 0)
return r;
f = safe_fclose(f);
*ret = TAKE_PTR(dump);
return 0;
}
void manager_test_summary(Manager *m) {
assert(m);
printf("-> By units:\n");
manager_dump_units(m, stdout, "\t");
printf("-> By jobs:\n");
manager_dump_jobs(m, stdout, "\t");
}

12
src/core/manager-dump.h Normal file
View File

@ -0,0 +1,12 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdio.h>
#include "manager.h"
void manager_dump_jobs(Manager *s, FILE *f, const char *prefix);
void manager_dump_units(Manager *s, FILE *f, const char *prefix);
void manager_dump(Manager *s, FILE *f, const char *prefix);
int manager_get_dump_string(Manager *m, char **ret);
void manager_test_summary(Manager *m);

View File

@ -55,6 +55,7 @@
#include "log.h"
#include "macro.h"
#include "manager.h"
#include "manager-dump.h"
#include "memory-util.h"
#include "mkdir.h"
#include "parse-util.h"
@ -2154,74 +2155,6 @@ int manager_load_startable_unit_or_warn(
return 0;
}
void manager_dump_jobs(Manager *s, FILE *f, const char *prefix) {
Job *j;
assert(s);
assert(f);
HASHMAP_FOREACH(j, s->jobs)
job_dump(j, f, prefix);
}
void manager_dump_units(Manager *s, FILE *f, const char *prefix) {
Unit *u;
const char *t;
assert(s);
assert(f);
HASHMAP_FOREACH_KEY(u, t, s->units)
if (u->id == t)
unit_dump(u, f, prefix);
}
void manager_dump(Manager *m, FILE *f, const char *prefix) {
assert(m);
assert(f);
for (ManagerTimestamp q = 0; q < _MANAGER_TIMESTAMP_MAX; q++) {
const dual_timestamp *t = m->timestamps + q;
char buf[CONST_MAX(FORMAT_TIMESPAN_MAX, FORMAT_TIMESTAMP_MAX)];
if (dual_timestamp_is_set(t))
fprintf(f, "%sTimestamp %s: %s\n",
strempty(prefix),
manager_timestamp_to_string(q),
timestamp_is_set(t->realtime) ? format_timestamp(buf, sizeof buf, t->realtime) :
format_timespan(buf, sizeof buf, t->monotonic, 1));
}
manager_dump_units(m, f, prefix);
manager_dump_jobs(m, f, prefix);
}
int manager_get_dump_string(Manager *m, char **ret) {
_cleanup_free_ char *dump = NULL;
_cleanup_fclose_ FILE *f = NULL;
size_t size;
int r;
assert(m);
assert(ret);
f = open_memstream_unlocked(&dump, &size);
if (!f)
return -errno;
manager_dump(m, f, NULL);
r = fflush_and_check(f);
if (r < 0)
return r;
f = safe_fclose(f);
*ret = TAKE_PTR(dump);
return 0;
}
void manager_clear_jobs(Manager *m) {
Job *j;

View File

@ -485,11 +485,6 @@ int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode
int manager_add_job_by_name_and_warn(Manager *m, JobType type, const char *name, JobMode mode, Set *affected_jobs, Job **ret);
int manager_propagate_reload(Manager *m, Unit *unit, JobMode mode, sd_bus_error *e);
void manager_dump_units(Manager *s, FILE *f, const char *prefix);
void manager_dump_jobs(Manager *s, FILE *f, const char *prefix);
void manager_dump(Manager *s, FILE *f, const char *prefix);
int manager_get_dump_string(Manager *m, char **ret);
void manager_clear_jobs(Manager *m);
void manager_unwatch_pid(Manager *m, pid_t pid);

View File

@ -85,6 +85,8 @@ libcore_sources = '''
locale-setup.h
manager.c
manager.h
manager-dump.c
manager-dump.h
mount.c
mount.h
namespace.c

View File

@ -152,7 +152,7 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) {
* Note that except for '~' prefixed segments, a string has more segments is newer.
* So, this check must be after the '~' check. */
if (*a == '\0' || *b == '\0')
return strcmp(a, b);
return CMP(*a, *b);
/* Handle '-', which separates version and release, e.g 123.4-3.1.fc33.x86_64 */
if (*a == '-' || *b == '-') {
@ -194,9 +194,9 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) {
/* Find the leading numeric segments. One may be an empty string. So,
* numeric segments are always newer than alpha segments. */
for (aa = a; *aa != '\0' && isdigit(*aa); aa++)
for (aa = a; isdigit(*aa); aa++)
;
for (bb = b; *bb != '\0' && isdigit(*bb); bb++)
for (bb = b; isdigit(*bb); bb++)
;
/* To compare numeric segments without parsing their values, first compare the
@ -211,9 +211,9 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) {
return r;
} else {
/* Find the leading non-numeric segments. */
for (aa = a; *aa != '\0' && is_alpha(*aa); aa++)
for (aa = a; is_alpha(*aa); aa++)
;
for (bb = b; *bb != '\0' && is_alpha(*bb); bb++)
for (bb = b; is_alpha(*bb); bb++)
;
/* Note that the segments are usually not NUL-terminated. */

View File

@ -743,6 +743,7 @@ int device_rename(sd_device *device, const char *name) {
int device_shallow_clone(sd_device *old_device, sd_device **new_device) {
_cleanup_(sd_device_unrefp) sd_device *ret = NULL;
const char *subsystem;
int r;
assert(old_device);
@ -756,9 +757,12 @@ int device_shallow_clone(sd_device *old_device, sd_device **new_device) {
if (r < 0)
return r;
r = device_set_subsystem(ret, old_device->subsystem);
if (sd_device_get_subsystem(old_device, &subsystem) >= 0) {
r = device_set_subsystem(ret, subsystem);
if (r < 0)
return r;
} else
ret->subsystem_set = true;
ret->devnum = old_device->devnum;

View File

@ -221,11 +221,11 @@ DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(varlink_state, VarlinkState);
log_debug("%s: " fmt, varlink_server_description(s), ##__VA_ARGS__)
static inline const char *varlink_description(Varlink *v) {
return strna(v ? v->description : NULL);
return (v ? v->description : NULL) ?: "varlink";
}
static inline const char *varlink_server_description(VarlinkServer *s) {
return strna(s ? s->description : NULL);
return (s ? s->description : NULL) ?: "varlink";
}
static void varlink_set_state(Varlink *v, VarlinkState state) {
@ -233,10 +233,10 @@ static void varlink_set_state(Varlink *v, VarlinkState state) {
assert(state >= 0 && state < _VARLINK_STATE_MAX);
if (v->state < 0)
varlink_log(v, "varlink: setting state %s",
varlink_log(v, "Setting state %s",
varlink_state_to_string(state));
else
varlink_log(v, "varlink: changing state %s → %s",
varlink_log(v, "Changing state %s → %s",
varlink_state_to_string(v->state),
varlink_state_to_string(state));

View File

@ -5,6 +5,7 @@
#include "bus-util.h"
#include "manager.h"
#include "manager-dump.h"
#include "rm-rf.h"
#include "service.h"
#include "special.h"

View File

@ -298,8 +298,11 @@ static int builtin_blkid(sd_device *dev, int argc, char *argv[], bool test) {
return log_device_debug_errno(dev, r, "Failed to get device name: %m");
fd = open(devnode, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
if (fd < 0)
return log_device_debug_errno(dev, errno, "Failed to open block device %s: %m", devnode);
if (fd < 0) {
log_device_debug_errno(dev, errno, "Failed to open block device %s%s: %m",
devnode, errno == ENOENT ? ", ignoring" : "");
return errno == ENOENT ? 0 : -errno;
}
errno = 0;
r = blkid_probe_set_device(pr, fd, offset, 0);

View File

@ -228,18 +228,23 @@ static size_t escape_path(const char *src, char *dest, size_t size) {
/* manage "stack of names" with possibly specified device priorities */
static int link_update(sd_device *dev, const char *slink, bool add) {
_cleanup_free_ char *filename = NULL, *dirname = NULL;
const char *slink_name, *id;
char name_enc[PATH_MAX];
const char *id;
int i, r, retries;
assert(dev);
assert(slink);
slink_name = path_startswith(slink, "/dev");
if (!slink_name)
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EINVAL),
"Invalid symbolic link of device node: %s", slink);
r = device_get_device_id(dev, &id);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to get device id: %m");
escape_path(slink + STRLEN("/dev"), name_enc, sizeof(name_enc));
escape_path(slink_name, name_enc, sizeof(name_enc));
dirname = path_join("/run/udev/links/", name_enc);
if (!dirname)
return log_oom();
@ -339,7 +344,11 @@ int udev_node_update_old_links(sd_device *dev, sd_device *dev_old) {
log_device_debug(dev, "Updating old name, '%s' no longer belonging to '%s'",
name, devpath);
link_update(dev, name, false);
r = link_update(dev, name, false);
if (r < 0)
log_device_warning_errno(dev, r,
"Failed to update device symlink '%s', ignoring: %m",
name);
}
return 0;
@ -530,7 +539,9 @@ int udev_node_add(sd_device *dev, bool apply,
FOREACH_DEVICE_DEVLINK(dev, devlink) {
r = link_update(dev, devlink, true);
if (r < 0)
log_device_info_errno(dev, r, "Failed to update device symlinks: %m");
log_device_warning_errno(dev, r,
"Failed to update device symlink '%s', ignoring: %m",
devlink);
}
return 0;
@ -547,7 +558,9 @@ int udev_node_remove(sd_device *dev) {
FOREACH_DEVICE_DEVLINK(dev, devlink) {
r = link_update(dev, devlink, false);
if (r < 0)
log_device_info_errno(dev, r, "Failed to update device symlinks: %m");
log_device_warning_errno(dev, r,
"Failed to update device symlink '%s', ignoring: %m",
devlink);
}
r = xsprintf_dev_num_path_from_sd_device(dev, &filename);

View File

@ -83,11 +83,14 @@ int udev_watch_begin(int inotify_fd, sd_device *dev) {
log_device_debug(dev, "Adding watch on '%s'", devnode);
wd = inotify_add_watch(inotify_fd, devnode, IN_CLOSE_WRITE);
if (wd < 0) {
r = log_device_full_errno(dev, errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
errno, "Failed to add device '%s' to watch: %m", devnode);
bool ignore = errno == ENOENT;
r = log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, errno,
"Failed to add device '%s' to watch%s: %m",
devnode, ignore ? ", ignoring" : "");
(void) device_set_watch_handle(dev, -1);
return r;
return ignore ? 0 : r;
}
r = device_set_watch_handle(dev, wd);