1
0
mirror of https://github.com/systemd/systemd synced 2026-03-12 16:14:47 +01:00

Compare commits

...

30 Commits

Author SHA1 Message Date
Lennart Poettering
bc32241e6a core: use UNIT_TRIGGER at more places
Just some minor simplification.
2021-04-15 20:38:20 +01:00
Luca Boccassi
672e9aec1b
Merge pull request #19326 from keszybz/reorder-meson-status-output
Reorder meson status output
2021-04-15 20:37:29 +01:00
Luca Boccassi
2969369130
Merge pull request #19318 from yuwata/udev-ignore-additional-newline-on-verify-19314
udev: ignore additional newline at the end on verify
2021-04-15 20:36:55 +01:00
Luca Boccassi
2d8c8549ab
Merge pull request #19317 from keszybz/check-return-values-from-log_errno-functions
Check return values from log_errno functions
2021-04-15 20:33:54 +01:00
Zbigniew Jędrzejewski-Szmek
8d1c9489ef Assert zero is not passed to log_{device,rule,token}_*_errno() 2021-04-15 11:56:22 +02:00
Zbigniew Jędrzejewski-Szmek
9d9fed9ef4 Voidify log_{device,token,rule}_debug()
See analogous change for log_debug() for discussion.
2021-04-15 11:45:44 +02:00
Zbigniew Jędrzejewski-Szmek
2669c66614 core/selinux: fix wrong assertion when 0 is passed to log_debug
https://github.com/systemd/systemd/pull/19317#issuecomment-820245680
2021-04-15 11:18:37 +02:00
Zbigniew Jędrzejewski-Szmek
237f2da9d4 meson: output one "item" for DNS-over-TLS 2021-04-15 11:04:40 +02:00
Zbigniew Jędrzejewski-Szmek
56d68e715b meson: reorder the "features" list
Try to make this more manageable by reording:
- dependencies / inputs
  (with subcategory of compression libraries)
- major components / outputs
- optional features / conditionals that don't fit into the two above categories

The division isn't well defined, because libraries often correspond one-to-one
to feature, but not always.
2021-04-15 11:04:40 +02:00
Zbigniew Jędrzejewski-Szmek
c716c2537f meson: fold static libsystemd and libudev into the generic status line
It's a very specialized feature and we don't need to devote a separate line to it.
2021-04-15 11:04:40 +02:00
Zbigniew Jędrzejewski-Szmek
ba081955fc meson: reindent 2021-04-15 11:04:40 +02:00
Zbigniew Jędrzejewski-Szmek
3d346b8106 udev/cdrom_id: drop unnecessary cleanup and simplify loop 2021-04-15 07:51:58 +02:00
Zbigniew Jędrzejewski-Szmek
ec77d1ab3b udev/cdrom_id: do not pass ioctl return value to log_debug_errno()
While at it, let's print the tray status in human readable form.
2021-04-15 07:49:31 +02:00
Zbigniew Jędrzejewski-Szmek
00dd6d7770 libsystemd-network: check that errno==0 is not passed to log functions 2021-04-14 23:32:10 +02:00
Zbigniew Jędrzejewski-Szmek
a0c2541b6b libsystemd-network: use macro for definitions of log_{lldp,dhcp,…}_errno
No functional change.
2021-04-14 23:32:07 +02:00
Zbigniew Jędrzejewski-Szmek
f407219cd1 Check that errno passed log_{interface,link}_*_errno() is non-zero 2021-04-14 22:53:49 +02:00
Zbigniew Jędrzejewski-Szmek
e89f6ed476 Voidify log_link_debug
See analogous change for log_debug() for discussion.
2021-04-14 22:20:20 +02:00
Zbigniew Jędrzejewski-Szmek
cf5a2ee825 journald: fix %m usage 2021-04-14 22:06:02 +02:00
Yu Watanabe
6fb61918cc udev: ignore additional newline in sysfs attribute on verify
Some driver may automatically add additional newline at the end.
E.g., portno attribute for qeth driver.

Fixes #19314.
2021-04-15 01:46:58 +09:00
Yu Watanabe
6873d20392 fileio: introduce a new flag to make write_string_file() ignore trailing newline
When writing a sysfs attribute, kernel may automatically append newline
at the end, e.g., 'portno' attribute for qeth driver.
2021-04-15 01:40:52 +09:00
Zbigniew Jędrzejewski-Szmek
75029e150b Do not try to return 0 from log_debug()
As @yuwata correctly points out, this became broken when log_debug()
started returning -EIO. I wanted to preserve this pattern, but it turns
out it is not very widely used, and preserving it would make the whole
thing, already quite complicated, even more complex.

log_debug() is made like log_info() and friends, and returns void.
2021-04-14 17:45:11 +02:00
Zbigniew Jędrzejewski-Szmek
a2eb2267e4 shared/module-util: fix errno value passed to log function
If r == 0, no harm done. But if r > 0, this would be interpreted as an
errno value, wrongly.
2021-04-14 17:10:36 +02:00
Zbigniew Jędrzejewski-Szmek
a626cb15c0 basic/log: assert that 0 is not passed as errno, except in test code
Let's assert if we ever happen to pass 0 to one of the log functions.
With the preceding commit to return -EIO from log_*(), passing 0 wouldn't
affect the return value any more, but it is still most likely an error.
The unit test code is an exception: we fairly often pass the return value
to print it, before checking what it is. So let's assert that we're not
passing 0 in non-test code. As with the previous check for %m, this is only
done in developer mode. We are depending on external code setting
errno correctly for us, which might not always be true, and which we can't
test, so we shouldn't assert, but just handle this gracefully.

I did a bunch of greps to try to figure out if there are any places where
we're passing 0 on purpose, and couldn't find any.
The one place that failed in tests is adjusted.

About "zerook" in the name: I wanted the suffix to be unambiguous. It's a
single "word" because each of the words in log_full_errno is also meaningful,
and having one term use two words would be confusing.
2021-04-14 17:07:06 +02:00
Zbigniew Jędrzejewski-Szmek
63275a7032 basic/log: assert that %m is not used when error is not set
This is only done in developer mode. It is a pretty rare occurence that we
make this kind of mistake. And even if it happens, the result is just a misleading
error message. So let's only do the check in non-release builds.
2021-04-14 16:19:54 +02:00
Zbigniew Jędrzejewski-Szmek
cbe97b9c92 basic/log: force log_*_errno() to return negative
This silences some warnigns where gcc thinks that some variables are
unitialized. One particular case:

../src/journal/journald-server.c: In function 'ache_space_refresh':
../src/journal/journald-server.c:136:28: error: 'vfs_avail' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  136 |         uint64_t vfs_used, vfs_avail, avail;
      |                            ^~~~~~~~~
../src/journal/journald-server.c:136:18: error: 'vfs_used' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  136 |         uint64_t vfs_used, vfs_avail, avail;
      |                  ^~~~~~~~
cc1: all warnings being treated as errors

which is caused by

   d = opendir(path);
   if (!d)
           return log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR,
                                 errno, "Failed to open %s: %m", path);
   if (fstatvfs(dirfd(d), &ss) < 0)
           return log_error_errno(errno, "Failed to fstatvfs(%s): %m", path);

For some reason on aarch64 gcc thinks we might return non-negative here. In
principle errno must be set in both cases, but it's hard to say for certain.
So let's make sure that our code flow is correct, even if somebody forgot to
set the global variable somewhere.
2021-04-14 16:19:54 +02:00
Zbigniew Jędrzejewski-Szmek
111a3aae71 partition, random-seed, logind: fix log messages with %m
We would print "...: Success", which is not too terrible, but not pretty
either.
2021-04-14 16:19:54 +02:00
Zbigniew Jędrzejewski-Szmek
aca591ac55 sd-device: improve log message and tweak style
We shouldn't say the attribute is missing right after ruling out ENOENT.
2021-04-14 16:19:54 +02:00
Zbigniew Jędrzejewski-Szmek
2d359acda5 libsystemd-network: fix dhcp option buffer confusion
We were writing to the wrong buffer with a wrong offset :(
Bug present since the original introduction of the code in
04b28be1a306fd2ba454d3ee333d63df71aa3873.
2021-04-14 16:19:54 +02:00
Zbigniew Jędrzejewski-Szmek
47350c5fb6 meson: simplify the BUILD_MODE conditional
Using a enum is all nice and generic, but at this point it seems unlikely that
we'll add further build modes. But having an enum means that we need to include
the header file with the enumeration whenerever the conditional is used. I want
to use the conditional in log.h, which makes it hard to avoid circular imports.
2021-04-14 16:19:54 +02:00
Zbigniew Jędrzejewski-Szmek
5600a26114 bpf-devices: update comment 2021-04-14 15:29:41 +02:00
47 changed files with 396 additions and 298 deletions

View File

@ -38,8 +38,8 @@ relative_source_path = run_command('realpath',
project_source_root).stdout().strip() project_source_root).stdout().strip()
conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
conf.set('BUILD_MODE', 'BUILD_MODE_' + get_option('mode').to_upper(), conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer',
description : 'tailor build to development or release builds') description : 'tailor build to development or release builds')
want_ossfuzz = get_option('oss-fuzz') want_ossfuzz = get_option('oss-fuzz')
want_libfuzzer = get_option('llvm-fuzz') want_libfuzzer = get_option('llvm-fuzz')
@ -1117,7 +1117,7 @@ else
libcurl = [] libcurl = []
endif endif
conf.set10('HAVE_LIBCURL', have) conf.set10('HAVE_LIBCURL', have)
conf.set10('CURL_NO_OLDIES', get_option('mode') == 'developer') conf.set10('CURL_NO_OLDIES', conf.get('BUILD_MODE_DEVELOPER') == 1)
want_libidn = get_option('libidn') want_libidn = get_option('libidn')
want_libidn2 = get_option('libidn2') want_libidn2 = get_option('libidn2')
@ -1232,7 +1232,7 @@ conf.set10('HAVE_LIBFIDO2', have)
want_tpm2 = get_option('tpm2') want_tpm2 = get_option('tpm2')
if want_tpm2 != 'false' and not skip_deps if want_tpm2 != 'false' and not skip_deps
tpm2 = dependency('tss2-esys tss2-rc tss2-mu', tpm2 = dependency('tss2-esys tss2-rc tss2-mu',
required : want_tpm2 == 'true') required : want_tpm2 == 'true')
have = tpm2.found() have = tpm2.found()
else else
have = false have = false
@ -2329,7 +2329,7 @@ if conf.get('ENABLE_HOMED') == 1
endif endif
foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] + foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] +
(conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : [])) (conf.get('HAVE_SYSV_COMPAT') == 1 ? ['runlevel', 'telinit'] : []))
meson.add_install_script(meson_make_symlink, meson.add_install_script(meson_make_symlink,
join_paths(rootbindir, 'systemctl'), join_paths(rootbindir, 'systemctl'),
join_paths(rootsbindir, alias)) join_paths(rootsbindir, alias))
@ -2750,14 +2750,14 @@ if conf.get('ENABLE_OOMD') == 1
install_dir : rootlibexecdir) install_dir : rootlibexecdir)
public_programs += executable( public_programs += executable(
'oomctl', 'oomctl',
oomctl_sources, oomctl_sources,
include_directories : includes, include_directories : includes,
link_with : [libshared], link_with : [libshared],
dependencies : [], dependencies : [],
install_rpath : rootlibexecdir, install_rpath : rootlibexecdir,
install : true, install : true,
install_dir : rootbindir) install_dir : rootbindir)
endif endif
if conf.get('ENABLE_BINFMT') == 1 if conf.get('ENABLE_BINFMT') == 1
@ -3313,16 +3313,20 @@ custom_target(
'systemd-runtest.env', 'systemd-runtest.env',
output : 'systemd-runtest.env', output : 'systemd-runtest.env',
command : ['sh', '-c', '{ ' + command : ['sh', '-c', '{ ' +
'echo SYSTEMD_TEST_DATA=@0@; '.format(join_paths(project_source_root, 'test')) + 'echo SYSTEMD_TEST_DATA=@0@; '.format(join_paths(project_source_root, 'test')) +
'echo SYSTEMD_CATALOG_DIR=@0@; '.format(join_paths(project_build_root, 'catalog')) + 'echo SYSTEMD_CATALOG_DIR=@0@; '.format(join_paths(project_build_root, 'catalog')) +
'} >@OUTPUT@'], '} >@OUTPUT@'],
build_by_default : true) build_by_default : true)
# We intentionally do not do inline initializations with definitions for test_cflags = ['-DTEST_CODE=1']
# a bunch of _cleanup_ variables in tests, to ensure valgrind is triggered. # We intentionally do not do inline initializations with definitions for a
# This triggers a lot of maybe-uninitialized false positives when the # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
# combination of -O2 and -flto is used. Suppress them. # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
no_uninit = '-O2' in get_option('c_args') and '-flto=auto' in get_option('c_args') ? cc.first_supported_argument('-Wno-maybe-uninitialized') : [] # false positives when the combination of -O2 and -flto is used. Suppress them.
if '-O2' in get_option('c_args') and '-flto=auto' in get_option('c_args')
test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
endif
foreach tuple : tests foreach tuple : tests
sources = tuple[0] sources = tuple[0]
link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared] link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
@ -3331,7 +3335,7 @@ foreach tuple : tests
condition = tuple.length() > 4 ? tuple[4] : '' condition = tuple.length() > 4 ? tuple[4] : ''
type = tuple.length() > 5 ? tuple[5] : '' type = tuple.length() > 5 ? tuple[5] : ''
defs = tuple.length() > 6 ? tuple[6] : [] defs = tuple.length() > 6 ? tuple[6] : []
defs += no_uninit defs += test_cflags
parallel = tuple.length() > 7 ? tuple[7] : true parallel = tuple.length() > 7 ? tuple[7] : true
timeout = 30 timeout = 30
@ -3399,7 +3403,7 @@ exe = executable(
'test-libudev-sym', 'test-libudev-sym',
test_libudev_sym_c, test_libudev_sym_c,
include_directories : libudev_includes, include_directories : libudev_includes,
c_args : ['-Wno-deprecated-declarations'] + no_uninit, c_args : ['-Wno-deprecated-declarations'] + test_cflags,
link_with : [libudev], link_with : [libudev],
build_by_default : want_tests != 'false', build_by_default : want_tests != 'false',
install : install_tests, install : install_tests,
@ -3412,7 +3416,7 @@ exe = executable(
'test-libudev-static-sym', 'test-libudev-static-sym',
test_libudev_sym_c, test_libudev_sym_c,
include_directories : libudev_includes, include_directories : libudev_includes,
c_args : ['-Wno-deprecated-declarations'] + no_uninit, c_args : ['-Wno-deprecated-declarations'] + test_cflags,
link_with : [install_libudev_static], link_with : [install_libudev_static],
build_by_default : want_tests != 'false' and static_libudev_pic, build_by_default : want_tests != 'false' and static_libudev_pic,
install : install_tests and static_libudev_pic, install : install_tests and static_libudev_pic,
@ -3453,7 +3457,7 @@ foreach tuple : fuzzers
include_directories : [incs, include_directories('src/fuzz')], include_directories : [incs, include_directories('src/fuzz')],
link_with : link_with, link_with : link_with,
dependencies : dependencies, dependencies : dependencies,
c_args : defs, c_args : defs + test_cflags,
link_args: link_args, link_args: link_args,
install : false, install : false,
build_by_default : fuzz_tests or fuzzer_build) build_by_default : fuzz_tests or fuzzer_build)
@ -3640,7 +3644,7 @@ if dbus_docs.length() > 0
'@INPUT@'], '@INPUT@'],
input : dbus_docs) input : dbus_docs)
if conf.get('BUILD_MODE') == 'BUILD_MODE_DEVELOPER' if conf.get('BUILD_MODE_DEVELOPER') == 1
test('dbus-docs-fresh', test('dbus-docs-fresh',
update_dbus_docs_py, update_dbus_docs_py,
args : ['--build-dir=@0@'.format(project_build_root), args : ['--build-dir=@0@'.format(project_build_root),
@ -3724,10 +3728,6 @@ alt_time_epoch = run_command('date', '-Is', '-u', '-d',
status += [ status += [
'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)] 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
status += [
'static libsystemd: @0@'.format(static_libsystemd),
'static libudev: @0@'.format(static_libudev)]
# TODO: # TODO:
# CFLAGS: ${OUR_CFLAGS} ${CFLAGS} # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
# CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS} # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
@ -3750,107 +3750,112 @@ found = []
missing = [] missing = []
foreach tuple : [ foreach tuple : [
['libcryptsetup'], # dependencies
['PAM'], ['ACL'],
['pwquality'],
['libfdisk'],
['p11kit'],
['libfido2'],
['tpm2'],
['AUDIT'], ['AUDIT'],
['IMA'],
['AppArmor'], ['AppArmor'],
['SELinux'], ['IMA'],
['PAM'],
['SECCOMP'], ['SECCOMP'],
['SELinux'],
['SMACK'], ['SMACK'],
['zlib'], ['blkid'],
['xz'], ['elfutils'],
['gcrypt'],
['gnutls'],
['libcryptsetup'],
['libcurl'],
['libfdisk'],
['libfido2'],
['libidn'],
['libidn2'],
['libiptc'],
['microhttpd'],
['openssl'],
['p11kit'],
['pcre2'],
['pwquality'],
['qrencode'],
['tpm2'],
['xkbcommon'],
# compression libs
['zstd'], ['zstd'],
['lz4'], ['lz4'],
['xz'],
['zlib'],
['bzip2'], ['bzip2'],
['ACL'],
['gcrypt'], # components
['qrencode'],
['microhttpd'],
['gnutls'],
['openssl'],
['libcurl'],
['idn'],
['initrd'],
['compat-mutable-uid-boundaries'],
['nscd'],
['libidn2'],
['libidn'],
['libiptc'],
['elfutils'],
['binfmt'],
['repart'],
['vconsole'],
['quotacheck'],
['tmpfiles'],
['environment.d'],
['sysusers'],
['firstboot'],
['randomseed'],
['backlight'], ['backlight'],
['rfkill'], ['binfmt'],
['xdg-autostart'], ['coredump'],
['environment.d'],
['efi'],
['gnu-efi', have_gnu_efi],
['firstboot'],
['hibernate'],
['homed'],
['hostnamed'],
['hwdb'],
['importd'],
['initrd'],
['kernel-install', get_option('kernel-install')],
['localed'],
['logind'], ['logind'],
['machined'], ['machined'],
['portabled'],
['sysext'],
['userdb'],
['homed'],
['importd'],
['hostnamed'],
['timedated'],
['timesyncd'],
['localed'],
['networkd'], ['networkd'],
['resolve'],
['DNS-over-TLS(gnutls)', conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1],
['DNS-over-TLS(openssl)', conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1],
['coredump'],
['pstore'],
['oomd'],
['polkit'],
['legacy pkla', install_polkit_pkla],
['efi'],
['gnu-efi', have_gnu_efi],
['kmod'],
['xkbcommon'],
['pcre2'],
['blkid'],
['dbus'],
['glib'],
['nss-myhostname'], ['nss-myhostname'],
['nss-mymachines'], ['nss-mymachines'],
['nss-resolve'], ['nss-resolve'],
['nss-systemd'], ['nss-systemd'],
['hwdb'], ['oomd'],
['portabled'],
['pstore'],
['quotacheck'],
['randomseed'],
['repart'],
['resolve'],
['rfkill'],
['sysext'],
['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
['sysusers'],
['timedated'],
['timesyncd'],
['tmpfiles'],
['userdb'],
['vconsole'],
['xdg-autostart'],
# optional features
['idn'],
['polkit'],
['nscd'],
['legacy-pkla', install_polkit_pkla],
['kmod'],
['dbus'],
['glib'],
['tpm'], ['tpm'],
['man pages', want_man], ['man pages', want_man],
['html pages', want_html], ['html pages', want_html],
['man page indices', want_man and have_lxml], ['man page indices', want_man and have_lxml],
['SysV compat'], ['SysV compat'],
['compat-mutable-uid-boundaries'],
['utmp'], ['utmp'],
['ldconfig'], ['ldconfig'],
['hibernate'], ['adm group', get_option('adm-group')],
['adm group', get_option('adm-group')], ['wheel group', get_option('wheel-group')],
['wheel group', get_option('wheel-group')],
['gshadow'], ['gshadow'],
['debug hashmap'], ['debug hashmap'],
['debug mmap cache'], ['debug mmap cache'],
['debug siphash'], ['debug siphash'],
['valgrind', conf.get('VALGRIND') == 1], ['valgrind', conf.get('VALGRIND') == 1],
['trace logging', conf.get('LOG_TRACE') == 1], ['trace logging', conf.get('LOG_TRACE') == 1],
['install tests', install_tests], ['install tests', install_tests],
['link-udev-shared', get_option('link-udev-shared')], ['link-udev-shared', get_option('link-udev-shared')],
['link-systemctl-shared', get_option('link-systemctl-shared')], ['link-systemctl-shared', get_option('link-systemctl-shared')],
['link-networkd-shared', get_option('link-networkd-shared')], ['link-networkd-shared', get_option('link-networkd-shared')],
['link-timesyncd-shared', get_option('link-timesyncd-shared')], ['link-timesyncd-shared', get_option('link-timesyncd-shared')],
['kernel-install', get_option('kernel-install')],
['systemd-analyze', conf.get('ENABLE_ANALYZE') == 1],
['fexecve'], ['fexecve'],
['standalone-binaries', get_option('standalone-binaries')], ['standalone-binaries', get_option('standalone-binaries')],
] ]
@ -3869,6 +3874,26 @@ foreach tuple : [
endif endif
endforeach endforeach
if static_libsystemd == 'false'
missing += 'static-libsystemd'
else
found += 'static-libsystemd(@0@)'.format(static_libsystemd)
endif
if static_libudev == 'false'
missing += 'static-libudev'
else
found += 'static-libudev(@0@)'.format(static_libudev)
endif
if conf.get('DNS_OVER_TLS_USE_GNUTLS') == 1
found += 'DNS-over-TLS(gnutls)'
elif conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1
found += 'DNS-over-TLS(openssl)'
else
missing += 'DNS-over-TLS'
endif
status += [ status += [
'', '',
'enabled features: @0@'.format(', '.join(found)), 'enabled features: @0@'.format(', '.join(found)),

View File

@ -15,7 +15,6 @@
#include "analyze-condition.h" #include "analyze-condition.h"
#include "analyze-security.h" #include "analyze-security.h"
#include "analyze-verify.h" #include "analyze-verify.h"
#include "build.h"
#include "bus-error.h" #include "bus-error.h"
#include "bus-locator.h" #include "bus-locator.h"
#include "bus-map-properties.h" #include "bus-map-properties.h"
@ -53,6 +52,7 @@
#include "unit-name.h" #include "unit-name.h"
#include "util.h" #include "util.h"
#include "verbs.h" #include "verbs.h"
#include "version.h"
#define SCALE_X (0.1 / 1000.0) /* pixels per us */ #define SCALE_X (0.1 / 1000.0) /* pixels per us */
#define SCALE_Y (20.0) #define SCALE_Y (20.0)

View File

@ -4,8 +4,3 @@
#include "version.h" #include "version.h"
extern const char* const systemd_features; extern const char* const systemd_features;
enum {
BUILD_MODE_DEVELOPER,
BUILD_MODE_RELEASE,
};

View File

@ -286,7 +286,7 @@ fail:
/* OK, the operation failed, but let's see if the right /* OK, the operation failed, but let's see if the right
* contents in place already. If so, eat up the error. */ * contents in place already. If so, eat up the error. */
q = verify_file(fn, line, !(flags & WRITE_STRING_FILE_AVOID_NEWLINE)); q = verify_file(fn, line, !(flags & WRITE_STRING_FILE_AVOID_NEWLINE) || (flags & WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE));
if (q <= 0) if (q <= 0)
return r; return r;

View File

@ -15,16 +15,17 @@
#define LONG_LINE_MAX (1U*1024U*1024U) #define LONG_LINE_MAX (1U*1024U*1024U)
typedef enum { typedef enum {
WRITE_STRING_FILE_CREATE = 1 << 0, WRITE_STRING_FILE_CREATE = 1 << 0,
WRITE_STRING_FILE_TRUNCATE = 1 << 1, WRITE_STRING_FILE_TRUNCATE = 1 << 1,
WRITE_STRING_FILE_ATOMIC = 1 << 2, WRITE_STRING_FILE_ATOMIC = 1 << 2,
WRITE_STRING_FILE_AVOID_NEWLINE = 1 << 3, WRITE_STRING_FILE_AVOID_NEWLINE = 1 << 3,
WRITE_STRING_FILE_VERIFY_ON_FAILURE = 1 << 4, WRITE_STRING_FILE_VERIFY_ON_FAILURE = 1 << 4,
WRITE_STRING_FILE_SYNC = 1 << 5, WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE = 1 << 5,
WRITE_STRING_FILE_DISABLE_BUFFER = 1 << 6, WRITE_STRING_FILE_SYNC = 1 << 6,
WRITE_STRING_FILE_NOFOLLOW = 1 << 7, WRITE_STRING_FILE_DISABLE_BUFFER = 1 << 7,
WRITE_STRING_FILE_MKDIR_0755 = 1 << 8, WRITE_STRING_FILE_NOFOLLOW = 1 << 8,
WRITE_STRING_FILE_MODE_0600 = 1 << 9, WRITE_STRING_FILE_MKDIR_0755 = 1 << 9,
WRITE_STRING_FILE_MODE_0600 = 1 << 10,
/* And before you wonder, why write_string_file_atomic_label_ts() is a separate function instead of just one /* And before you wonder, why write_string_file_atomic_label_ts() is a separate function instead of just one
more flag here: it's about linking: we don't want to pull -lselinux into all users of write_string_file() more flag here: it's about linking: we don't want to pull -lselinux into all users of write_string_file()

View File

@ -4,6 +4,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <syslog.h> #include <syslog.h>
#include "macro.h" #include "macro.h"
@ -188,20 +189,39 @@ void log_assert_failed_return(
log_dispatch_internal(level, error, PROJECT_FILE, __LINE__, __func__, NULL, NULL, NULL, NULL, buffer) log_dispatch_internal(level, error, PROJECT_FILE, __LINE__, __func__, NULL, NULL, NULL, NULL, buffer)
/* Logging with level */ /* Logging with level */
#define log_full_errno(level, error, ...) \ #define log_full_errno_zerook(level, error, ...) \
({ \ ({ \
int _level = (level), _e = (error); \ int _level = (level), _e = (error); \
(log_get_max_level() >= LOG_PRI(_level)) \ _e = (log_get_max_level() >= LOG_PRI(_level)) \
? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \ ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
: -ERRNO_VALUE(_e); \ : -ERRNO_VALUE(_e); \
_e < 0 ? _e : -EIO; \
}) })
#define log_full(level, ...) (void) log_full_errno((level), 0, __VA_ARGS__) #if BUILD_MODE_DEVELOPER && !defined(TEST_CODE)
# define ASSERT_NON_ZERO(x) assert((x) != 0)
#else
# define ASSERT_NON_ZERO(x)
#endif
#define log_full_errno(level, error, ...) \
({ \
int _error = (error); \
ASSERT_NON_ZERO(_error); \
log_full_errno_zerook(level, _error, __VA_ARGS__); \
})
#define log_full(level, fmt, ...) \
({ \
if (BUILD_MODE_DEVELOPER) \
assert(!strstr(fmt, "%m")); \
(void) log_full_errno_zerook(level, 0, fmt, ##__VA_ARGS__); \
})
int log_emergency_level(void); int log_emergency_level(void);
/* Normal logging */ /* Normal logging */
#define log_debug(...) log_full_errno(LOG_DEBUG, 0, __VA_ARGS__) #define log_debug(...) log_full(LOG_DEBUG, __VA_ARGS__)
#define log_info(...) log_full(LOG_INFO, __VA_ARGS__) #define log_info(...) log_full(LOG_INFO, __VA_ARGS__)
#define log_notice(...) log_full(LOG_NOTICE, __VA_ARGS__) #define log_notice(...) log_full(LOG_NOTICE, __VA_ARGS__)
#define log_warning(...) log_full(LOG_WARNING, __VA_ARGS__) #define log_warning(...) log_full(LOG_WARNING, __VA_ARGS__)

View File

@ -27,7 +27,7 @@
#ifdef CAP_LAST_CAP #ifdef CAP_LAST_CAP
# if CAP_LAST_CAP > SYSTEMD_CAP_LAST_CAP # if CAP_LAST_CAP > SYSTEMD_CAP_LAST_CAP
# if BUILD_MODE == BUILD_MODE_DEVELOPER && defined(TEST_CAPABILITY_C) # if BUILD_MODE_DEVELOPER && defined(TEST_CAPABILITY_C)
# warning "The capability list here is outdated" # warning "The capability list here is outdated"
# endif # endif
# else # else

View File

@ -216,7 +216,7 @@ int bpf_devices_apply_policy(
_cleanup_free_ char *controller_path = NULL; _cleanup_free_ char *controller_path = NULL;
int r; int r;
/* This will assign *keep_program if everything goes well. */ /* This will assign *prog_installed if everything goes well. */
if (!prog) if (!prog)
goto finish; goto finish;

View File

@ -2015,7 +2015,7 @@ int config_parse_trigger_unit(
assert(rvalue); assert(rvalue);
assert(data); assert(data);
if (!hashmap_isempty(u->dependencies[UNIT_TRIGGERS])) { if (UNIT_TRIGGER(u)) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Multiple units to trigger specified, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Multiple units to trigger specified, ignoring: %s", rvalue);
return 0; return 0;
} }

View File

@ -316,7 +316,7 @@ static int path_add_trigger_dependencies(Path *p) {
assert(p); assert(p);
if (!hashmap_isempty(UNIT(p)->dependencies[UNIT_TRIGGERS])) if (UNIT_TRIGGER(UNIT(p)))
return 0; return 0;
r = unit_load_related_unit(UNIT(p), ".service", &x); r = unit_load_related_unit(UNIT(p), ".service", &x);

View File

@ -273,8 +273,9 @@ int mac_selinux_generic_access_check(
sd_bus_error_set(error, SD_BUS_ERROR_ACCESS_DENIED, "SELinux policy denies access."); sd_bus_error_set(error, SD_BUS_ERROR_ACCESS_DENIED, "SELinux policy denies access.");
} }
log_debug_errno(r, "SELinux access check scon=%s tcon=%s tclass=%s perm=%s state=%s path=%s cmdline=%s: %m", log_full_errno_zerook(LOG_DEBUG, r,
scon, fcon, tclass, permission, enforce ? "enforcing" : "permissive", path, cl); "SELinux access check scon=%s tcon=%s tclass=%s perm=%s state=%s path=%s cmdline=%s: %m",
scon, fcon, tclass, permission, enforce ? "enforcing" : "permissive", path, cl);
return enforce ? r : 0; return enforce ? r : 0;
} }

View File

@ -124,7 +124,7 @@ static int timer_add_trigger_dependencies(Timer *t) {
assert(t); assert(t);
if (!hashmap_isempty(UNIT(t)->dependencies[UNIT_TRIGGERS])) if (UNIT_TRIGGER(UNIT(t)))
return 0; return 0;
r = unit_load_related_unit(UNIT(t), ".service", &x); r = unit_load_related_unit(UNIT(t), ".service", &x);

View File

@ -3,11 +3,11 @@
#include <fcntl.h> #include <fcntl.h>
#include "alloc-util.h" #include "alloc-util.h"
#include "build.h"
#include "curl-util.h" #include "curl-util.h"
#include "fd-util.h" #include "fd-util.h"
#include "locale-util.h" #include "locale-util.h"
#include "string-util.h" #include "string-util.h"
#include "version.h"
static void curl_glue_check_finished(CurlGlue *g) { static void curl_glue_check_finished(CurlGlue *g) {
CURLMsg *msg; CURLMsg *msg;

View File

@ -9,7 +9,6 @@
#include "sd-daemon.h" #include "sd-daemon.h"
#include "alloc-util.h" #include "alloc-util.h"
#include "build.h"
#include "conf-parser.h" #include "conf-parser.h"
#include "daemon-util.h" #include "daemon-util.h"
#include "def.h" #include "def.h"
@ -34,6 +33,7 @@
#include "strv.h" #include "strv.h"
#include "tmpfile-util.h" #include "tmpfile-util.h"
#include "util.h" #include "util.h"
#include "version.h"
#define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-upload.pem" #define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-upload.pem"
#define CERT_FILE CERTIFICATE_ROOT "/certs/journal-upload.pem" #define CERT_FILE CERTIFICATE_ROOT "/certs/journal-upload.pem"

View File

@ -376,8 +376,8 @@ int server_open_dev_kmsg(Server *s) {
s->dev_kmsg_fd = open("/dev/kmsg", mode); s->dev_kmsg_fd = open("/dev/kmsg", mode);
if (s->dev_kmsg_fd < 0) { if (s->dev_kmsg_fd < 0) {
log_full(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
"Failed to open /dev/kmsg, ignoring: %m"); errno, "Failed to open /dev/kmsg, ignoring: %m");
return 0; return 0;
} }

View File

@ -66,15 +66,13 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, ui
#define DHCP_CLIENT_DONT_DESTROY(client) \ #define DHCP_CLIENT_DONT_DESTROY(client) \
_cleanup_(sd_dhcp_client_unrefp) _unused_ sd_dhcp_client *_dont_destroy_##client = sd_dhcp_client_ref(client) _cleanup_(sd_dhcp_client_unrefp) _unused_ sd_dhcp_client *_dont_destroy_##client = sd_dhcp_client_ref(client)
#define log_dhcp_client_errno(client, error, fmt, ...) \ #define log_dhcp_client_errno(client, error, fmt, ...) \
({ \ log_interface_prefix_full_errno( \
int _e = (error); \ "DHCPv4 client: ", \
if (DEBUG_LOGGING) \ sd_dhcp_client_get_ifname(client), \
log_interface_full_errno( \ error, fmt, ##__VA_ARGS__)
sd_dhcp_client_get_ifname(client), \
LOG_DEBUG, _e, "DHCPv4 client: " fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_dhcp_client(client, fmt, ...) \ #define log_dhcp_client(client, fmt, ...) \
log_dhcp_client_errno(client, 0, fmt, ##__VA_ARGS__) log_interface_prefix_full_errno_zerook( \
"DHCPv4 client: ", \
sd_dhcp_client_get_ifname(client), \
0, fmt, ##__VA_ARGS__)

View File

@ -98,15 +98,13 @@ int dhcp_server_send_packet(sd_dhcp_server *server,
void client_id_hash_func(const DHCPClientId *p, struct siphash *state); void client_id_hash_func(const DHCPClientId *p, struct siphash *state);
int client_id_compare_func(const DHCPClientId *a, const DHCPClientId *b); int client_id_compare_func(const DHCPClientId *a, const DHCPClientId *b);
#define log_dhcp_server_errno(server, error, fmt, ...) \ #define log_dhcp_server_errno(server, error, fmt, ...) \
({ \ log_interface_prefix_full_errno( \
int _e = (error); \ "DHCPv4 server: ", \
if (DEBUG_LOGGING) \ sd_dhcp_server_get_ifname(server), \
log_interface_full_errno( \ error, fmt, ##__VA_ARGS__)
sd_dhcp_server_get_ifname(server), \
LOG_DEBUG, _e, "DHCPv4 server: " fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_dhcp_server(server, fmt, ...) \ #define log_dhcp_server(server, fmt, ...) \
log_dhcp_server_errno(server, 0, fmt, ##__VA_ARGS__) log_interface_prefix_full_errno_zerook( \
"DHCPv4 server: ", \
sd_dhcp_server_get_ifname(server), \
0, fmt, ##__VA_ARGS__)

View File

@ -119,15 +119,13 @@ int dhcp6_message_type_from_string(const char *s) _pure_;
const char *dhcp6_message_status_to_string(int s) _const_; const char *dhcp6_message_status_to_string(int s) _const_;
int dhcp6_message_status_from_string(const char *s) _pure_; int dhcp6_message_status_from_string(const char *s) _pure_;
#define log_dhcp6_client_errno(client, error, fmt, ...) \ #define log_dhcp6_client_errno(client, error, fmt, ...) \
({ \ log_interface_prefix_full_errno( \
int _e = (error); \ "DHCPv6 client: ", \
if (DEBUG_LOGGING) \ sd_dhcp6_client_get_ifname(client), \
log_interface_full_errno( \ error, fmt, ##__VA_ARGS__)
sd_dhcp6_client_get_ifname(client), \ #define log_dhcp6_client(client, fmt, ...) \
LOG_DEBUG, _e, "DHCPv6 client: " fmt, \ log_interface_prefix_full_errno_zerook( \
##__VA_ARGS__); \ "DHCPv6 client: ", \
-ERRNO_VALUE(_e); \ sd_dhcp6_client_get_ifname(client), \
}) 0, fmt, ##__VA_ARGS__)
#define log_dhcp6_client(client, fmt, ...) \
log_dhcp6_client_errno(client, 0, fmt, ##__VA_ARGS__)

View File

@ -36,15 +36,13 @@ struct sd_lldp {
const char* lldp_event_to_string(sd_lldp_event_t e) _const_; const char* lldp_event_to_string(sd_lldp_event_t e) _const_;
sd_lldp_event_t lldp_event_from_string(const char *s) _pure_; sd_lldp_event_t lldp_event_from_string(const char *s) _pure_;
#define log_lldp_errno(lldp, error, fmt, ...) \ #define log_lldp_errno(lldp, error, fmt, ...) \
({ \ log_interface_prefix_full_errno( \
int _e = (error); \ "LLDP: ", \
if (DEBUG_LOGGING) \ sd_lldp_get_ifname(lldp), \
log_interface_full_errno( \ error, fmt, ##__VA_ARGS__)
sd_lldp_get_ifname(lldp), \ #define log_lldp(lldp, fmt, ...) \
LOG_DEBUG, _e, "LLDP: " fmt, \ log_interface_prefix_full_errno_zerook( \
##__VA_ARGS__); \ "LLDP: ", \
-ERRNO_VALUE(_e); \ sd_lldp_get_ifname(lldp), \
}) 0, fmt, ##__VA_ARGS__)
#define log_lldp(lldp, fmt, ...) \
log_lldp_errno(lldp, 0, fmt, ##__VA_ARGS__)

View File

@ -41,15 +41,13 @@ struct sd_ndisc {
const char* ndisc_event_to_string(sd_ndisc_event_t e) _const_; const char* ndisc_event_to_string(sd_ndisc_event_t e) _const_;
sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_; sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_;
#define log_ndisc_errno(ndisc, error, fmt, ...) \ #define log_ndisc_errno(ndisc, error, fmt, ...) \
({ \ log_interface_prefix_full_errno( \
int _e = (error); \ "NDISC: ", \
if (DEBUG_LOGGING) \ sd_ndisc_get_ifname(ndisc), \
log_interface_full_errno( \ error, fmt, ##__VA_ARGS__)
sd_ndisc_get_ifname(ndisc), \ #define log_ndisc(ndisc, fmt, ...) \
LOG_DEBUG, _e, "NDISC: " fmt, \ log_interface_prefix_full_errno_zerook( \
##__VA_ARGS__); \ "NDISC: ", \
-ERRNO_VALUE(_e); \ sd_ndisc_get_ifname(ndisc), \
}) 0, fmt, ##__VA_ARGS__)
#define log_ndisc(ndisc, fmt, ...) \
log_ndisc_errno(ndisc, 0, fmt, ##__VA_ARGS__)

View File

@ -125,15 +125,13 @@ struct sd_radv_route_prefix {
LIST_FIELDS(struct sd_radv_route_prefix, prefix); LIST_FIELDS(struct sd_radv_route_prefix, prefix);
}; };
#define log_radv_errno(radv, error, fmt, ...) \ #define log_radv_errno(radv, error, fmt, ...) \
({ \ log_interface_prefix_full_errno( \
int _e = (error); \ "RADV: ", \
if (DEBUG_LOGGING) \ sd_radv_get_ifname(radv), \
log_interface_full_errno( \ error, fmt, ##__VA_ARGS__)
sd_radv_get_ifname(radv), \ #define log_radv(radv, fmt, ...) \
LOG_DEBUG, _e, "RADV: " fmt, \ log_interface_prefix_full_errno_zerook( \
##__VA_ARGS__); \ "RADV: ", \
-ERRNO_VALUE(_e); \ sd_radv_get_ifname(radv), \
}) 0, fmt, ##__VA_ARGS__)
#define log_radv(radv, fmt, ...) \
log_radv_errno(radv, 0, fmt, ##__VA_ARGS__)

View File

@ -75,18 +75,16 @@ struct sd_ipv4acd {
void* userdata; void* userdata;
}; };
#define log_ipv4acd_errno(acd, error, fmt, ...) \ #define log_ipv4acd_errno(acd, error, fmt, ...) \
({ \ log_interface_prefix_full_errno( \
int _e = (error); \ "IPv4ACD: ", \
if (DEBUG_LOGGING) \ sd_ipv4acd_get_ifname(acd), \
log_interface_full_errno( \ error, fmt, ##__VA_ARGS__)
sd_ipv4acd_get_ifname(acd), \
LOG_DEBUG, _e, "IPv4ACD: " fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_ipv4acd(acd, fmt, ...) \ #define log_ipv4acd(acd, fmt, ...) \
log_ipv4acd_errno(acd, 0, fmt, ##__VA_ARGS__) log_interface_prefix_full_errno_zerook( \
"IPv4ACD: ", \
sd_ipv4acd_get_ifname(acd), \
0, fmt, ##__VA_ARGS__)
static const char * const ipv4acd_state_table[_IPV4ACD_STATE_MAX] = { static const char * const ipv4acd_state_table[_IPV4ACD_STATE_MAX] = {
[IPV4ACD_STATE_INIT] = "init", [IPV4ACD_STATE_INIT] = "init",

View File

@ -49,18 +49,16 @@ struct sd_ipv4ll {
void* userdata; void* userdata;
}; };
#define log_ipv4ll_errno(ll, error, fmt, ...) \ #define log_ipv4ll_errno(ll, error, fmt, ...) \
({ \ log_interface_prefix_full_errno( \
int _e = (error); \ "IPv4LL: ", \
if (DEBUG_LOGGING) \ sd_ipv4ll_get_ifname(ll), \
log_interface_full_errno( \ error, fmt, ##__VA_ARGS__)
sd_ipv4ll_get_ifname(ll), \
LOG_DEBUG, _e, "IPv4LL: " fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_ipv4ll(ll, fmt, ...) \ #define log_ipv4ll(ll, fmt, ...) \
log_ipv4ll_errno(ll, 0, fmt, ##__VA_ARGS__) log_interface_prefix_full_errno_zerook( \
"IPv4LL: ", \
sd_ipv4ll_get_ifname(ll), \
0, fmt, ##__VA_ARGS__)
static void ipv4ll_on_acd(sd_ipv4acd *ll, int event, void *userdata); static void ipv4ll_on_acd(sd_ipv4acd *ll, int event, void *userdata);

View File

@ -45,22 +45,29 @@
device; \ device; \
device = sd_device_enumerator_get_subsystem_next(enumerator)) device = sd_device_enumerator_get_subsystem_next(enumerator))
#define log_device_full_errno(device, level, error, ...) \ #define log_device_full_errno_zerook(device, level, error, ...) \
({ \ ({ \
const char *_sysname = NULL; \ const char *_sysname = NULL; \
sd_device *_d = (device); \ sd_device *_d = (device); \
int _level = (level), _error = (error); \ int _level = (level), _e = (error); \
\ \
if (_d && _unlikely_(log_get_max_level() >= LOG_PRI(_level))) \ if (_d && _unlikely_(log_get_max_level() >= LOG_PRI(_level))) \
(void) sd_device_get_sysname(_d, &_sysname); \ (void) sd_device_get_sysname(_d, &_sysname); \
log_object_internal(_level, _error, PROJECT_FILE, __LINE__, __func__, \ log_object_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, \
_sysname ? "DEVICE=" : NULL, _sysname, \ _sysname ? "DEVICE=" : NULL, _sysname, \
NULL, NULL, __VA_ARGS__); \ NULL, NULL, __VA_ARGS__); \
}) })
#define log_device_full(device, level, ...) (void) log_device_full_errno(device, level, 0, __VA_ARGS__) #define log_device_full_errno(device, level, error, ...) \
({ \
int _error = (error); \
ASSERT_NON_ZERO(_error); \
log_device_full_errno_zerook(device, level, _error, __VA_ARGS__); \
})
#define log_device_debug(device, ...) log_device_full_errno(device, LOG_DEBUG, 0, __VA_ARGS__) #define log_device_full(device, level, ...) (void) log_device_full_errno_zerook(device, level, 0, __VA_ARGS__)
#define log_device_debug(device, ...) log_device_full(device, LOG_DEBUG, __VA_ARGS__)
#define log_device_info(device, ...) log_device_full(device, LOG_INFO, __VA_ARGS__) #define log_device_info(device, ...) log_device_full(device, LOG_INFO, __VA_ARGS__)
#define log_device_notice(device, ...) log_device_full(device, LOG_NOTICE, __VA_ARGS__) #define log_device_notice(device, ...) log_device_full(device, LOG_NOTICE, __VA_ARGS__)
#define log_device_warning(device, ...) log_device_full(device, LOG_WARNING, __VA_ARGS__) #define log_device_warning(device, ...) log_device_full(device, LOG_WARNING, __VA_ARGS__)

View File

@ -178,13 +178,12 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
/* all 'devices' require an 'uevent' file */ /* all 'devices' require an 'uevent' file */
path = strjoina(syspath, "/uevent"); path = strjoina(syspath, "/uevent");
r = access(path, F_OK); if (access(path, F_OK) < 0) {
if (r < 0) {
if (errno == ENOENT) if (errno == ENOENT)
/* this is not a valid device */ /* this is not a valid device */
return -ENODEV; return -ENODEV;
return log_debug_errno(errno, "sd-device: %s does not have an uevent file: %m", syspath); return log_debug_errno(errno, "sd-device: cannot access uevent file for %s: %m", syspath);
} }
} else { } else {
/* everything else just needs to be a directory */ /* everything else just needs to be a directory */

View File

@ -6,7 +6,6 @@
#include <unistd.h> #include <unistd.h>
#include "alloc-util.h" #include "alloc-util.h"
#include "build.h"
#include "fd-util.h" #include "fd-util.h"
#include "libudev-list-internal.h" #include "libudev-list-internal.h"
#include "libudev-util.h" #include "libudev-util.h"
@ -15,6 +14,7 @@
#include "stdio-util.h" #include "stdio-util.h"
#include "string-util.h" #include "string-util.h"
#include "tests.h" #include "tests.h"
#include "version.h"
static bool arg_monitor = false; static bool arg_monitor = false;

View File

@ -268,8 +268,8 @@ static int manager_enumerate_seats(Manager *m) {
s = hashmap_get(m->seats, de->d_name); s = hashmap_get(m->seats, de->d_name);
if (!s) { if (!s) {
if (unlinkat(dirfd(d), de->d_name, 0) < 0) if (unlinkat(dirfd(d), de->d_name, 0) < 0)
log_warning("Failed to remove /run/systemd/seats/%s: %m", log_warning_errno(errno, "Failed to remove /run/systemd/seats/%s: %m",
de->d_name); de->d_name);
continue; continue;
} }

View File

@ -208,8 +208,10 @@ int link_set_bridge_mdb(Link *link) {
if (hashmap_isempty(link->network->mdb_entries_by_section)) if (hashmap_isempty(link->network->mdb_entries_by_section))
goto finish; goto finish;
if (!link_has_carrier(link)) if (!link_has_carrier(link)) {
return log_link_debug(link, "Link does not have carrier yet, setting MDB entries later."); log_link_debug(link, "Link does not have carrier yet, setting MDB entries later.");
return 0;
}
if (link->network->bridge) { if (link->network->bridge) {
Link *master; Link *master;
@ -218,8 +220,10 @@ int link_set_bridge_mdb(Link *link) {
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Failed to get Link object for Bridge=%s", link->network->bridge->ifname); return log_link_error_errno(link, r, "Failed to get Link object for Bridge=%s", link->network->bridge->ifname);
if (!link_has_carrier(master)) if (!link_has_carrier(master)) {
return log_link_debug(link, "Bridge interface %s does not have carrier yet, setting MDB entries later.", link->network->bridge->ifname); log_link_debug(link, "Bridge interface %s does not have carrier yet, setting MDB entries later.", link->network->bridge->ifname);
return 0;
}
} else if (!streq_ptr(link->kind, "bridge")) { } else if (!streq_ptr(link->kind, "bridge")) {
log_link_warning(link, "Link is neither a bridge master nor a bridge port, ignoring [BridgeMDB] sections."); log_link_warning(link, "Link is neither a bridge master nor a bridge port, ignoring [BridgeMDB] sections.");

View File

@ -711,8 +711,10 @@ int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message,
if (r < 0) { if (r < 0) {
log_link_warning_errno(link, r, "rtnl: could not get nexthop family, ignoring: %m"); log_link_warning_errno(link, r, "rtnl: could not get nexthop family, ignoring: %m");
return 0; return 0;
} else if (!IN_SET(tmp->family, AF_INET, AF_INET6)) } else if (!IN_SET(tmp->family, AF_INET, AF_INET6)) {
return log_link_debug(link, "rtnl: received nexthop message with invalid family %d, ignoring.", tmp->family); log_link_debug(link, "rtnl: received nexthop message with invalid family %d, ignoring.", tmp->family);
return 0;
}
r = sd_rtnl_message_nexthop_get_protocol(message, &tmp->protocol); r = sd_rtnl_message_nexthop_get_protocol(message, &tmp->protocol);
if (r < 0) { if (r < 0) {

View File

@ -3830,7 +3830,7 @@ static int parse_efi_variable_factory_reset(void) {
arg_factory_reset = r; arg_factory_reset = r;
if (r) if (r)
log_notice("Honouring factory reset requested via EFI variable FactoryReset: %m"); log_notice("Factory reset requested via EFI variable FactoryReset.");
return 0; return 0;
} }

View File

@ -262,7 +262,7 @@ static int run(int argc, char *argv[]) {
if (k < 0) if (k < 0)
log_debug_errno(errno, "Failed to read random data with getrandom(), falling back to /dev/urandom: %m"); log_debug_errno(errno, "Failed to read random data with getrandom(), falling back to /dev/urandom: %m");
else if ((size_t) k < buf_size) else if ((size_t) k < buf_size)
log_debug("Short read from getrandom(), falling back to /dev/urandom: %m"); log_debug("Short read from getrandom(), falling back to /dev/urandom.");
else else
getrandom_worked = true; getrandom_worked = true;

View File

@ -306,7 +306,8 @@ int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char* const* extra_ar
if (q < 0 && r == 0) if (q < 0 && r == 0)
r = q; r = q;
log_debug_errno(q, "Got result %s/%m for job %s", d->result, d->name); log_full_errno_zerook(LOG_DEBUG, q,
"Got result %s/%m for job %s", d->result, d->name);
} }
d->name = mfree(d->name); d->name = mfree(d->name);

View File

@ -3,13 +3,38 @@
#include "log.h" #include "log.h"
#define log_interface_full_errno(ifname, level, error, ...) \ #define log_interface_full_errno_zerook(ifname, level, error, ...) \
({ \ ({ \
const char *_ifname = (ifname); \ const char *_ifname = (ifname); \
_ifname ? log_object_internal(level, error, PROJECT_FILE, __LINE__, __func__, "INTERFACE=", _ifname, NULL, NULL, ##__VA_ARGS__) : \ _ifname ? log_object_internal(level, error, PROJECT_FILE, __LINE__, __func__, "INTERFACE=", _ifname, NULL, NULL, ##__VA_ARGS__) : \
log_internal(level, error, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \ log_internal(level, error, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \
}) })
#define log_interface_full_errno(ifname, level, error, ...) \
({ \
int _error = (error); \
ASSERT_NON_ZERO(_error); \
log_interface_full_errno_zerook(ifname, level, _error, __VA_ARGS__); \
})
#define log_interface_prefix_full_errno_zerook(prefix, ifname_expr, error, fmt, ...) \
({ \
int _e = (error); \
if (DEBUG_LOGGING) \
log_interface_full_errno_zerook( \
ifname_expr, \
LOG_DEBUG, _e, prefix fmt, \
##__VA_ARGS__); \
-ERRNO_VALUE(_e); \
})
#define log_interface_prefix_full_errno(prefix, ifname_expr, error, fmt, ...) \
({ \
int _error = (error); \
ASSERT_NON_ZERO(_error); \
log_interface_prefix_full_errno_zerook(prefix, ifname_expr, _error, fmt, ##__VA_ARGS__); \
})
/* /*
* The following macros append INTERFACE= to the message. * The following macros append INTERFACE= to the message.
* The macros require a struct named 'Link' which contains 'char *ifname': * The macros require a struct named 'Link' which contains 'char *ifname':
@ -21,15 +46,22 @@
* See, network/networkd-link.h for example. * See, network/networkd-link.h for example.
*/ */
#define log_link_full_errno(link, level, error, ...) \ #define log_link_full_errno_zerook(link, level, error, ...) \
({ \ ({ \
const Link *_l = (link); \ const Link *_l = (link); \
log_interface_full_errno(_l ? _l->ifname : NULL, level, error, ##__VA_ARGS__); \ log_interface_full_errno_zerook(_l ? _l->ifname : NULL, level, error, __VA_ARGS__); \
}) })
#define log_link_full(link, level, ...) (void) log_link_full_errno(link, level, 0, __VA_ARGS__) #define log_link_full_errno(link, level, error, ...) \
({ \
int _error = (error); \
ASSERT_NON_ZERO(_error); \
log_link_full_errno_zerook(link, level, _error, __VA_ARGS__); \
})
#define log_link_debug(link, ...) log_link_full_errno(link, LOG_DEBUG, 0, __VA_ARGS__) #define log_link_full(link, level, ...) (void) log_link_full_errno_zerook(link, level, 0, __VA_ARGS__)
#define log_link_debug(link, ...) log_link_full(link, LOG_DEBUG, __VA_ARGS__)
#define log_link_info(link, ...) log_link_full(link, LOG_INFO, __VA_ARGS__) #define log_link_info(link, ...) log_link_full(link, LOG_INFO, __VA_ARGS__)
#define log_link_notice(link, ...) log_link_full(link, LOG_NOTICE, __VA_ARGS__) #define log_link_notice(link, ...) log_link_full(link, LOG_NOTICE, __VA_ARGS__)
#define log_link_warning(link, ...) log_link_full(link, LOG_WARNING, __VA_ARGS__) #define log_link_warning(link, ...) log_link_full(link, LOG_WARNING, __VA_ARGS__)

View File

@ -20,11 +20,10 @@ int module_load_and_warn(struct kmod_ctx *ctx, const char *module, bool verbose)
return log_full_errno(verbose ? LOG_ERR : LOG_DEBUG, r, return log_full_errno(verbose ? LOG_ERR : LOG_DEBUG, r,
"Failed to look up module alias '%s': %m", module); "Failed to look up module alias '%s': %m", module);
if (!modlist) { if (!modlist)
log_full_errno(verbose ? LOG_ERR : LOG_DEBUG, r, return log_full_errno(verbose ? LOG_ERR : LOG_DEBUG,
"Failed to find module '%s'", module); SYNTHETIC_ERRNO(ENOENT),
return -ENOENT; "Failed to find module '%s'", module);
}
kmod_list_foreach(itr, modlist) { kmod_list_foreach(itr, modlist) {
_cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL; _cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL;

View File

@ -163,10 +163,10 @@ static int lock_all_homes(void) {
if (!bus_error_is_unknown_service(&error)) if (!bus_error_is_unknown_service(&error))
return log_error_errno(r, "Failed to lock home directories: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to lock home directories: %s", bus_error_message(&error, r));
return log_debug("systemd-homed is not running, locking of home directories skipped."); log_debug("systemd-homed is not running, locking of home directories skipped.");
} } else
log_debug("Successfully requested locking of all home directories.");
return log_debug("Successfully requested locking of all home directories."); return 0;
} }
static int execute(char **modes, char **states, const char *action) { static int execute(char **modes, char **states, const char *action) {

View File

@ -10,7 +10,6 @@
#include "sd-daemon.h" #include "sd-daemon.h"
#include "alloc-util.h" #include "alloc-util.h"
#include "build.h"
#include "bus-internal.h" #include "bus-internal.h"
#include "bus-util.h" #include "bus-util.h"
#include "errno-util.h" #include "errno-util.h"
@ -18,6 +17,7 @@
#include "log.h" #include "log.h"
#include "main-func.h" #include "main-func.h"
#include "util.h" #include "util.h"
#include "version.h"
#define DEFAULT_BUS_PATH "unix:path=/run/dbus/system_bus_socket" #define DEFAULT_BUS_PATH "unix:path=/run/dbus/system_bus_socket"

View File

@ -293,7 +293,7 @@ int main(int argc, char *argv[]) {
r = cg_all_unified(); r = cg_all_unified();
if (r <= 0) if (r <= 0)
return log_tests_skipped_errno(r, "Unified hierarchy is required, skipping."); return log_tests_skipped("Unified hierarchy is required, skipping.");
r = enter_cgroup_subroot(NULL); r = enter_cgroup_subroot(NULL);
if (r == -ENOMEDIUM) if (r == -ENOMEDIUM)

View File

@ -3,13 +3,13 @@
#include <unistd.h> #include <unistd.h>
#include "alloc-util.h" #include "alloc-util.h"
#include "build.h"
#include "cgroup-setup.h" #include "cgroup-setup.h"
#include "errno-util.h" #include "errno-util.h"
#include "log.h" #include "log.h"
#include "proc-cmdline.h" #include "proc-cmdline.h"
#include "string-util.h" #include "string-util.h"
#include "tests.h" #include "tests.h"
#include "version.h"
static void test_is_wanted_print(bool header) { static void test_is_wanted_print(bool header) {
_cleanup_free_ char *cmdline = NULL; _cleanup_free_ char *cmdline = NULL;

View File

@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h" #include "alloc-util.h"
#include "build.h"
#include "cgroup-util.h" #include "cgroup-util.h"
#include "dirent-util.h" #include "dirent-util.h"
#include "errno-util.h" #include "errno-util.h"
@ -17,6 +16,7 @@
#include "tests.h" #include "tests.h"
#include "user-util.h" #include "user-util.h"
#include "util.h" #include "util.h"
#include "version.h"
static void check_p_d_u(const char *path, int code, const char *result) { static void check_p_d_u(const char *path, int code, const char *result) {
_cleanup_free_ char *unit = NULL; _cleanup_free_ char *unit = NULL;

View File

@ -11,7 +11,6 @@
#include <sys/signalfd.h> #include <sys/signalfd.h>
#include <unistd.h> #include <unistd.h>
#include "build.h"
#include "device-private.h" #include "device-private.h"
#include "fs-util.h" #include "fs-util.h"
#include "log.h" #include "log.h"
@ -24,6 +23,7 @@
#include "string-util.h" #include "string-util.h"
#include "tests.h" #include "tests.h"
#include "udev-event.h" #include "udev-event.h"
#include "version.h"
static int fake_filesystems(void) { static int fake_filesystems(void) {
static const struct fakefs { static const struct fakefs {

View File

@ -302,10 +302,23 @@ static int cd_capability_compat(Context *c) {
} }
static int cd_media_compat(Context *c) { static int cd_media_compat(Context *c) {
int r;
assert(c); assert(c);
if (ioctl(c->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) != CDS_DISC_OK) r = ioctl(c->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
return log_debug_errno(errno, "CDROM_DRIVE_STATUS != CDS_DISC_OK"); if (r < 0)
return log_debug_errno(errno, "ioctl(CDROM_DRIVE_STATUS) failed: m");
if (r != CDS_DISC_OK) {
log_debug("ioctl(CDROM_DRIVE_STATUS) → %d (%s), ignoring",
r,
r == CDS_NO_INFO ? "no info" :
r == CDS_NO_DISC ? "no disc" :
r == CDS_TRAY_OPEN ? "tray open" :
r == CDS_DRIVE_NOT_READY ? "drive not ready" :
"unkown status");
return -ENOMEDIUM;
}
c->has_media = true; c->has_media = true;
return 0; return 0;
@ -730,25 +743,23 @@ static int cd_media_toc(Context *c) {
} }
static int open_drive(Context *c) { static int open_drive(Context *c) {
_cleanup_close_ int fd = -1; int fd;
assert(c); assert(c);
assert(c->fd < 0); assert(c->fd < 0);
for (int cnt = 0; cnt < 20; cnt++) { for (int cnt = 0;; cnt++) {
if (cnt != 0)
(void) usleep(100 * USEC_PER_MSEC + random_u64() % (100 * USEC_PER_MSEC));
fd = open(arg_node, O_RDONLY|O_NONBLOCK|O_CLOEXEC); fd = open(arg_node, O_RDONLY|O_NONBLOCK|O_CLOEXEC);
if (fd >= 0 || errno != EBUSY) if (fd >= 0)
break; break;
if (++cnt >= 20 || errno != EBUSY)
return log_debug_errno(errno, "Unable to open '%s': %m", arg_node);
(void) usleep(100 * USEC_PER_MSEC + random_u64() % (100 * USEC_PER_MSEC));
} }
if (fd < 0)
return log_debug_errno(errno, "Unable to open '%s'", arg_node);
log_debug("probing: '%s'", arg_node); log_debug("probing: '%s'", arg_node);
c->fd = fd;
c->fd = TAKE_FD(fd);
return 0; return 0;
} }
@ -939,7 +950,7 @@ static int parse_argv(int argc, char *argv[]) {
arg_node = argv[optind]; arg_node = argv[optind];
if (!arg_node) if (!arg_node)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No device is specified."); return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No device specified.");
return 1; return 1;
} }

View File

@ -45,12 +45,12 @@
#include <getopt.h> #include <getopt.h>
#include "alloc-util.h" #include "alloc-util.h"
#include "build.h"
#include "fileio.h" #include "fileio.h"
#include "main-func.h" #include "main-func.h"
#include "string-util.h" #include "string-util.h"
#include "udev-util.h" #include "udev-util.h"
#include "unaligned.h" #include "unaligned.h"
#include "version.h"
#define SUPPORTED_SMBIOS_VER 0x030300 #define SUPPORTED_SMBIOS_VER 0x030300

View File

@ -364,9 +364,11 @@ static int get_mac(sd_device *device, MACAddressPolicy policy, struct ether_addr
return r; return r;
switch (addr_type) { switch (addr_type) {
case NET_ADDR_SET: case NET_ADDR_SET:
return log_device_debug(device, "MAC on the device already set by userspace"); log_device_debug(device, "MAC on the device already set by userspace");
return 0;
case NET_ADDR_STOLEN: case NET_ADDR_STOLEN:
return log_device_debug(device, "MAC on the device already set based on another device"); log_device_debug(device, "MAC on the device already set based on another device");
return 0;
case NET_ADDR_RANDOM: case NET_ADDR_RANDOM:
case NET_ADDR_PERM: case NET_ADDR_PERM:
break; break;
@ -375,9 +377,11 @@ static int get_mac(sd_device *device, MACAddressPolicy policy, struct ether_addr
return 0; return 0;
} }
if (want_random == (addr_type == NET_ADDR_RANDOM)) if (want_random == (addr_type == NET_ADDR_RANDOM)) {
return log_device_debug(device, "MAC on the device already matches policy *%s*", log_device_debug(device, "MAC on the device already matches policy *%s*",
mac_address_policy_to_string(policy)); mac_address_policy_to_string(policy));
return 0;
}
if (want_random) { if (want_random) {
log_device_debug(device, "Using random bytes to generate MAC"); log_device_debug(device, "Using random bytes to generate MAC");

View File

@ -17,7 +17,6 @@
#include <unistd.h> #include <unistd.h>
#include "alloc-util.h" #include "alloc-util.h"
#include "build.h"
#include "device-nodes.h" #include "device-nodes.h"
#include "extract-word.h" #include "extract-word.h"
#include "fd-util.h" #include "fd-util.h"
@ -27,6 +26,7 @@
#include "strv.h" #include "strv.h"
#include "strxcpyx.h" #include "strxcpyx.h"
#include "udev-util.h" #include "udev-util.h"
#include "version.h"
static const struct option options[] = { static const struct option options[] = {
{ "device", required_argument, NULL, 'd' }, { "device", required_argument, NULL, 'd' },

View File

@ -184,21 +184,30 @@ struct UdevRules {
/*** Logging helpers ***/ /*** Logging helpers ***/
#define log_rule_full_errno(device, rules, level, error, fmt, ...) \ #define log_rule_full_errno_zerook(device, rules, level, error, fmt, ...) \
({ \ ({ \
UdevRules *_r = (rules); \ UdevRules *_r = (rules); \
UdevRuleFile *_f = _r ? _r->current_file : NULL; \ UdevRuleFile *_f = _r ? _r->current_file : NULL; \
UdevRuleLine *_l = _f ? _f->current_line : NULL; \ UdevRuleLine *_l = _f ? _f->current_line : NULL; \
const char *_n = _f ? _f->filename : NULL; \ const char *_n = _f ? _f->filename : NULL; \
\ \
log_device_full_errno(device, level, error, "%s:%u " fmt, \ log_device_full_errno_zerook( \
strna(_n), _l ? _l->line_number : 0, \ device, level, error, "%s:%u " fmt, \
##__VA_ARGS__); \ strna(_n), _l ? _l->line_number : 0, \
##__VA_ARGS__); \
}) })
#define log_rule_full(device, rules, level, ...) (void) log_rule_full_errno(device, rules, level, 0, __VA_ARGS__) #define log_rule_full_errno(device, rules, level, error, fmt, ...) \
({ \
int _error = (error); \
ASSERT_NON_ZERO(_error); \
log_rule_full_errno_zerook( \
device, rules, level, _error, fmt, ##__VA_ARGS__); \
})
#define log_rule_debug(device, rules, ...) log_rule_full_errno(device, rules, LOG_DEBUG, 0, __VA_ARGS__) #define log_rule_full(device, rules, level, ...) (void) log_rule_full_errno_zerook(device, rules, level, 0, __VA_ARGS__)
#define log_rule_debug(device, rules, ...) log_rule_full(device, rules, LOG_DEBUG, __VA_ARGS__)
#define log_rule_info(device, rules, ...) log_rule_full(device, rules, LOG_INFO, __VA_ARGS__) #define log_rule_info(device, rules, ...) log_rule_full(device, rules, LOG_INFO, __VA_ARGS__)
#define log_rule_notice(device, rules, ...) log_rule_full(device, rules, LOG_NOTICE, __VA_ARGS__) #define log_rule_notice(device, rules, ...) log_rule_full(device, rules, LOG_NOTICE, __VA_ARGS__)
#define log_rule_warning(device, rules, ...) log_rule_full(device, rules, LOG_WARNING, __VA_ARGS__) #define log_rule_warning(device, rules, ...) log_rule_full(device, rules, LOG_WARNING, __VA_ARGS__)
@ -210,10 +219,11 @@ struct UdevRules {
#define log_rule_warning_errno(device, rules, error, ...) log_rule_full_errno(device, rules, LOG_WARNING, error, __VA_ARGS__) #define log_rule_warning_errno(device, rules, error, ...) log_rule_full_errno(device, rules, LOG_WARNING, error, __VA_ARGS__)
#define log_rule_error_errno(device, rules, error, ...) log_rule_full_errno(device, rules, LOG_ERR, error, __VA_ARGS__) #define log_rule_error_errno(device, rules, error, ...) log_rule_full_errno(device, rules, LOG_ERR, error, __VA_ARGS__)
#define log_token_full_errno_zerook(rules, level, error, ...) log_rule_full_errno_zerook(NULL, rules, level, error, __VA_ARGS__)
#define log_token_full_errno(rules, level, error, ...) log_rule_full_errno(NULL, rules, level, error, __VA_ARGS__) #define log_token_full_errno(rules, level, error, ...) log_rule_full_errno(NULL, rules, level, error, __VA_ARGS__)
#define log_token_full(rules, level, ...) (void) log_token_full_errno(rules, level, 0, __VA_ARGS__) #define log_token_full(rules, level, ...) (void) log_token_full_errno_zerook(rules, level, 0, __VA_ARGS__)
#define log_token_debug(rules, ...) log_token_full_errno(rules, LOG_DEBUG, 0, __VA_ARGS__) #define log_token_debug(rules, ...) log_token_full(rules, LOG_DEBUG, __VA_ARGS__)
#define log_token_info(rules, ...) log_token_full(rules, LOG_INFO, __VA_ARGS__) #define log_token_info(rules, ...) log_token_full(rules, LOG_INFO, __VA_ARGS__)
#define log_token_notice(rules, ...) log_token_full(rules, LOG_NOTICE, __VA_ARGS__) #define log_token_notice(rules, ...) log_token_full(rules, LOG_NOTICE, __VA_ARGS__)
#define log_token_warning(rules, ...) log_token_full(rules, LOG_WARNING, __VA_ARGS__) #define log_token_warning(rules, ...) log_token_full(rules, LOG_WARNING, __VA_ARGS__)
@ -2123,7 +2133,11 @@ static int udev_rule_apply_token_to_event(
(void) udev_event_apply_format(event, token->value, value, sizeof(value), false); (void) udev_event_apply_format(event, token->value, value, sizeof(value), false);
log_rule_debug(dev, rules, "ATTR '%s' writing '%s'", buf, value); log_rule_debug(dev, rules, "ATTR '%s' writing '%s'", buf, value);
r = write_string_file(buf, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_AVOID_NEWLINE); r = write_string_file(buf, value,
WRITE_STRING_FILE_VERIFY_ON_FAILURE |
WRITE_STRING_FILE_DISABLE_BUFFER |
WRITE_STRING_FILE_AVOID_NEWLINE |
WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE);
if (r < 0) if (r < 0)
log_rule_error_errno(dev, rules, r, "Failed to write ATTR{%s}, ignoring: %m", buf); log_rule_error_errno(dev, rules, r, "Failed to write ATTR{%s}, ignoring: %m", buf);
break; break;

View File

@ -3,7 +3,6 @@
#include <stdio.h> #include <stdio.h>
#include "build.h"
#include "macro.h" #include "macro.h"
int info_main(int argc, char *argv[], void *userdata); int info_main(int argc, char *argv[], void *userdata);

View File

@ -28,7 +28,6 @@
#include "sd-event.h" #include "sd-event.h"
#include "alloc-util.h" #include "alloc-util.h"
#include "build.h"
#include "cgroup-util.h" #include "cgroup-util.h"
#include "cpu-set-util.h" #include "cpu-set-util.h"
#include "dev-setup.h" #include "dev-setup.h"
@ -65,6 +64,7 @@
#include "udev-util.h" #include "udev-util.h"
#include "udev-watch.h" #include "udev-watch.h"
#include "user-util.h" #include "user-util.h"
#include "version.h"
#define WORKER_NUM_MAX 2048U #define WORKER_NUM_MAX 2048U