diff options
49 files changed, 396 insertions, 212 deletions
@@ -169,7 +169,7 @@ CHANGES WITH 233 in spe LUKS and Verity partitions) to a local host directory, in order to inspect them. This tool is not considered public API (yet), and is thus not installed into /usr/bin. Please do not rely on its - existance, since it might go away or be changed in later systemd + existence, since it might go away or be changed in later systemd versions. * A new generator "systemd-verity-generator" has been added, similar in @@ -50,6 +50,11 @@ REQUIREMENTS: CONFIG_PROC_FS CONFIG_FHANDLE (libudev, mount and bind mount handling) + Kernel crypto/hash API + CONFIG_CRYPTO_USER_API_HASH + CONFIG_CRYPTO_HMAC + CONFIG_CRYPTO_SHA256 + udev will fail to work with the legacy sysfs layout: CONFIG_SYSFS_DEPRECATED=n diff --git a/configure.ac b/configure.ac index d98cc4d9ba..3835413ad5 100644 --- a/configure.ac +++ b/configure.ac @@ -167,6 +167,7 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\ -Werror=implicit-function-declaration \ -Werror=missing-declarations \ -Werror=return-type \ + -Werror=incompatible-pointer-types \ -Werror=format=2 \ -Wstrict-prototypes \ -Wredundant-decls \ diff --git a/hwdb/60-keyboard.hwdb b/hwdb/60-keyboard.hwdb index 4201ad76fc..1aa729f047 100644 --- a/hwdb/60-keyboard.hwdb +++ b/hwdb/60-keyboard.hwdb @@ -133,6 +133,9 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pnAspire*8930:* KEYBOARD_KEY_89=fastforward KEYBOARD_KEY_9e=back +evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pnAspire*7750G:pvr* + KEYBOARD_KEY_e0=!pageup + # Travelmate C300 evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pnTravelMate*C3[01]0*:pvr* KEYBOARD_KEY_67=f24 # FIXME: rotate screen diff --git a/man/coredumpctl.xml b/man/coredumpctl.xml index 72a244d2eb..5204db4073 100644 --- a/man/coredumpctl.xml +++ b/man/coredumpctl.xml @@ -92,6 +92,20 @@ </varlistentry> <varlistentry> + <term><option>-S</option></term> + <term><option>--since</option></term> + + <listitem><para>Only print entries which are since the specified date.</para></listitem> + </varlistentry> + + <varlistentry> + <term><option>-U</option></term> + <term><option>--until</option></term> + + <listitem><para>Only print entries which are until the specified date.</para></listitem> + </varlistentry> + + <varlistentry> <term><option>-r</option></term> <term><option>--reverse</option></term> diff --git a/man/systemctl.xml b/man/systemctl.xml index d0b39d771b..7e1864c4f1 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -712,8 +712,23 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service <listitem> <para>List timer units currently in memory, ordered by the time they elapse next. If one or more <replaceable>PATTERN</replaceable>s are specified, only units matching one of them are shown. + Produces output similar to + <programlisting> +NEXT LEFT LAST PASSED UNIT ACTIVATES +n/a n/a Thu 2017-02-23 13:40:29 EST 3 days ago ureadahead-stop.timer ureadahead-stop.service +Sun 2017-02-26 18:55:42 EST 1min 14s left Thu 2017-02-23 13:54:44 EST 3 days ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service +Sun 2017-02-26 20:37:16 EST 1h 42min left Sun 2017-02-26 11:56:36 EST 6h ago apt-daily.timer apt-daily.service +Sun 2017-02-26 20:57:49 EST 2h 3min left Sun 2017-02-26 11:56:36 EST 6h ago snapd.refresh.timer snapd.refresh.service + </programlisting> </para> + <para><emphasis>NEXT</emphasis> shows the next time the timer will run.</para> + <para><emphasis>LEFT</emphasis> shows how long till the next time the timer runs.</para> + <para><emphasis>LAST</emphasis> shows the last time the timer ran.</para> + <para><emphasis>PASSED</emphasis> shows has long as passed since the timer laset ran.</para> + <para><emphasis>UNIT</emphasis> shows the name of the timer</para> + <para><emphasis>ACTIVATES</emphasis> shows the the name the service the timer activates when it runs.</para> + <para>Also see <option>--all</option> and <option>--state=</option>.</para> </listitem> </varlistentry> diff --git a/shell-completion/bash/coredumpctl b/shell-completion/bash/coredumpctl index d34f89e2bb..87fe473e09 100644 --- a/shell-completion/bash/coredumpctl +++ b/shell-completion/bash/coredumpctl @@ -38,7 +38,7 @@ _coredumpctl() { local i verb comps local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field -1 - -r --reverse' + -r --reverse -S --since -U --until' local -A VERBS=( [LIST]='list' diff --git a/shell-completion/zsh/_coredumpctl b/shell-completion/zsh/_coredumpctl index 64b44c1214..e469bca958 100644 --- a/shell-completion/zsh/_coredumpctl +++ b/shell-completion/zsh/_coredumpctl @@ -32,6 +32,8 @@ _arguments \ {-o+,--output=}'[Write output to FILE]:output file:_files' \ {-F+,--field=}'[Show field in list output]:field' \ '-1[Show information about most recent entry only]' \ + {-S,--since}'[Print entries since the specified date]' \ + {-U,--until}'[Print entries until the specified date]' \ {-r,--reverse}'[Show the newest entries first]' \ '--no-pager[Do not pipe output into a pager]' \ '--no-legend[Do not print the column headers]' \ diff --git a/src/basic/architecture.h b/src/basic/architecture.h index d6b8603b06..46883719d1 100644 --- a/src/basic/architecture.h +++ b/src/basic/architecture.h @@ -124,13 +124,21 @@ int uname_architecture(void); #elif defined(__sparc__) # define native_architecture() ARCHITECTURE_SPARC # define LIB_ARCH_TUPLE "sparc-linux-gnu" -#elif defined(__mips64__) +#elif defined(__mips64) && defined(__LP64__) # if __BYTE_ORDER == __BIG_ENDIAN # define native_architecture() ARCHITECTURE_MIPS64 -# error "Missing LIB_ARCH_TUPLE for MIPS64" +# define LIB_ARCH_TUPLE "mips64-linux-gnuabi64" # else # define native_architecture() ARCHITECTURE_MIPS64_LE -# error "Missing LIB_ARCH_TUPLE for MIPS64_LE" +# define LIB_ARCH_TUPLE "mips64el-linux-gnuabi64" +# endif +#elif defined(__mips64) +# if __BYTE_ORDER == __BIG_ENDIAN +# define native_architecture() ARCHITECTURE_MIPS64 +# define LIB_ARCH_TUPLE "mips64-linux-gnuabin32" +# else +# define native_architecture() ARCHITECTURE_MIPS64_LE +# define LIB_ARCH_TUPLE "mips64el-linux-gnuabin32" # endif #elif defined(__mips__) # if __BYTE_ORDER == __BIG_ENDIAN @@ -187,7 +195,7 @@ int uname_architecture(void); # define LIB_ARCH_TUPLE "m68k-linux-gnu" #elif defined(__tilegx__) # define native_architecture() ARCHITECTURE_TILEGX -# error "Missing LIB_ARCH_TUPLE for TILEGX" +# define LIB_ARCH_TUPLE "tilegx-linux-gnu" #elif defined(__cris__) # define native_architecture() ARCHITECTURE_CRIS # error "Missing LIB_ARCH_TUPLE for CRIS" diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index f76b7f47e5..bda5c555ad 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -208,7 +208,13 @@ int cg_rmdir(const char *controller, const char *path) { if (r < 0 && errno != ENOENT) return -errno; - if (streq(controller, SYSTEMD_CGROUP_CONTROLLER) && cg_hybrid_unified()) { + r = cg_hybrid_unified(); + if (r < 0) + return r; + if (r == 0) + return 0; + + if (streq(controller, SYSTEMD_CGROUP_CONTROLLER)) { r = cg_rmdir(SYSTEMD_CGROUP_CONTROLLER_LEGACY, path); if (r < 0) log_warning_errno(r, "Failed to remove compat systemd cgroup %s: %m", path); @@ -549,7 +555,7 @@ static const char *controller_to_dirname(const char *controller) { * hierarchies, if it is specified. */ if (streq(controller, SYSTEMD_CGROUP_CONTROLLER)) { - if (cg_hybrid_unified()) + if (cg_hybrid_unified() > 0) controller = SYSTEMD_CGROUP_CONTROLLER_HYBRID; else controller = SYSTEMD_CGROUP_CONTROLLER_LEGACY; @@ -636,7 +642,10 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch if (!cg_controller_is_valid(controller)) return -EINVAL; - if (cg_all_unified()) + r = cg_all_unified(); + if (r < 0) + return r; + if (r > 0) r = join_path_unified(path, suffix, fs); else r = join_path_legacy(controller, path, suffix, fs); @@ -648,6 +657,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch } static int controller_is_accessible(const char *controller) { + int r; assert(controller); @@ -659,7 +669,10 @@ static int controller_is_accessible(const char *controller) { if (!cg_controller_is_valid(controller)) return -EINVAL; - if (cg_all_unified()) { + r = cg_all_unified(); + if (r < 0) + return r; + if (r > 0) { /* We don't support named hierarchies if we are using * the unified hierarchy. */ @@ -736,7 +749,10 @@ int cg_trim(const char *controller, const char *path, bool delete_root) { return -errno; } - if (streq(controller, SYSTEMD_CGROUP_CONTROLLER) && cg_hybrid_unified()) { + q = cg_hybrid_unified(); + if (q < 0) + return q; + if (q > 0 && streq(controller, SYSTEMD_CGROUP_CONTROLLER)) { q = cg_trim(SYSTEMD_CGROUP_CONTROLLER_LEGACY, path, delete_root); if (q < 0) log_warning_errno(q, "Failed to trim compat systemd cgroup %s: %m", path); @@ -765,7 +781,11 @@ int cg_create(const char *controller, const char *path) { return -errno; } - if (streq(controller, SYSTEMD_CGROUP_CONTROLLER) && cg_hybrid_unified()) { + r = cg_hybrid_unified(); + if (r < 0) + return r; + + if (r > 0 && streq(controller, SYSTEMD_CGROUP_CONTROLLER)) { r = cg_create(SYSTEMD_CGROUP_CONTROLLER_LEGACY, path); if (r < 0) log_warning_errno(r, "Failed to create compat systemd cgroup %s: %m", path); @@ -812,7 +832,11 @@ int cg_attach(const char *controller, const char *path, pid_t pid) { if (r < 0) return r; - if (streq(controller, SYSTEMD_CGROUP_CONTROLLER) && cg_hybrid_unified()) { + r = cg_hybrid_unified(); + if (r < 0) + return r; + + if (r > 0 && streq(controller, SYSTEMD_CGROUP_CONTROLLER)) { r = cg_attach(SYSTEMD_CGROUP_CONTROLLER_LEGACY, path, pid); if (r < 0) log_warning_errno(r, "Failed to attach %d to compat systemd cgroup %s: %m", pid, path); @@ -871,7 +895,10 @@ int cg_set_group_access( if (r < 0) return r; - if (streq(controller, SYSTEMD_CGROUP_CONTROLLER) && cg_hybrid_unified()) { + r = cg_hybrid_unified(); + if (r < 0) + return r; + if (r > 0 && streq(controller, SYSTEMD_CGROUP_CONTROLLER)) { r = cg_set_group_access(SYSTEMD_CGROUP_CONTROLLER_LEGACY, path, mode, uid, gid); if (r < 0) log_warning_errno(r, "Failed to set group access on compat systemd cgroup %s: %m", path); @@ -906,14 +933,20 @@ int cg_set_task_access( if (r < 0) return r; - if (!cg_unified(controller)) { + r = cg_unified_controller(controller); + if (r < 0) + return r; + if (r == 0) { /* Compatibility, Always keep values for "tasks" in sync with * "cgroup.procs" */ if (cg_get_path(controller, path, "tasks", &procs) >= 0) (void) chmod_and_chown(procs, mode, uid, gid); } - if (streq(controller, SYSTEMD_CGROUP_CONTROLLER) && cg_hybrid_unified()) { + r = cg_hybrid_unified(); + if (r < 0) + return r; + if (r > 0 && streq(controller, SYSTEMD_CGROUP_CONTROLLER)) { r = cg_set_task_access(SYSTEMD_CGROUP_CONTROLLER_LEGACY, path, mode, uid, gid); if (r < 0) log_warning_errno(r, "Failed to set task access on compat systemd cgroup %s: %m", path); @@ -964,7 +997,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path) { char line[LINE_MAX]; const char *fs, *controller_str; size_t cs = 0; - bool unified; + int unified; assert(path); assert(pid >= 0); @@ -975,8 +1008,10 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path) { } else controller = SYSTEMD_CGROUP_CONTROLLER; - unified = cg_unified(controller); - if (!unified) { + unified = cg_unified_controller(controller); + if (unified < 0) + return unified; + if (unified == 0) { if (streq(controller, SYSTEMD_CGROUP_CONTROLLER)) controller_str = SYSTEMD_CGROUP_CONTROLLER_LEGACY; else @@ -1048,7 +1083,10 @@ int cg_install_release_agent(const char *controller, const char *agent) { assert(agent); - if (cg_unified(controller)) /* doesn't apply to unified hierarchy */ + r = cg_unified_controller(controller); + if (r < 0) + return r; + if (r > 0) /* doesn't apply to unified hierarchy */ return -EOPNOTSUPP; r = cg_get_path(controller, NULL, "release_agent", &fs); @@ -1096,7 +1134,10 @@ int cg_uninstall_release_agent(const char *controller) { _cleanup_free_ char *fs = NULL; int r; - if (cg_unified(controller)) /* Doesn't apply to unified hierarchy */ + r = cg_unified_controller(controller); + if (r < 0) + return r; + if (r > 0) /* Doesn't apply to unified hierarchy */ return -EOPNOTSUPP; r = cg_get_path(controller, NULL, "notify_on_release", &fs); @@ -1149,7 +1190,10 @@ int cg_is_empty_recursive(const char *controller, const char *path) { if (controller && (isempty(path) || path_equal(path, "/"))) return false; - if (cg_unified(controller)) { + r = cg_unified_controller(controller); + if (r < 0) + return r; + if (r > 0) { _cleanup_free_ char *t = NULL; /* On the unified hierarchy we can check empty state @@ -2034,7 +2078,10 @@ int cg_create_everywhere(CGroupMask supported, CGroupMask mask, const char *path return r; /* If we are in the unified hierarchy, we are done now */ - if (cg_all_unified()) + r = cg_all_unified(); + if (r < 0) + return r; + if (r > 0) return 0; /* Otherwise, do the same in the other hierarchies */ @@ -2061,7 +2108,10 @@ int cg_attach_everywhere(CGroupMask supported, const char *path, pid_t pid, cg_m if (r < 0) return r; - if (cg_all_unified()) + r = cg_all_unified(); + if (r < 0) + return r; + if (r > 0) return 0; for (c = 0; c < _CGROUP_CONTROLLER_MAX; c++) { @@ -2102,7 +2152,7 @@ int cg_attach_many_everywhere(CGroupMask supported, const char *path, Set* pids, int cg_migrate_everywhere(CGroupMask supported, const char *from, const char *to, cg_migrate_callback_t to_callback, void *userdata) { CGroupController c; - int r = 0; + int r = 0, q; if (!path_equal(from, to)) { r = cg_migrate_recursive(SYSTEMD_CGROUP_CONTROLLER, from, SYSTEMD_CGROUP_CONTROLLER, to, CGROUP_REMOVE); @@ -2110,7 +2160,10 @@ int cg_migrate_everywhere(CGroupMask supported, const char *from, const char *to return r; } - if (cg_all_unified()) + q = cg_all_unified(); + if (q < 0) + return q; + if (q > 0) return r; for (c = 0; c < _CGROUP_CONTROLLER_MAX; c++) { @@ -2134,13 +2187,16 @@ int cg_migrate_everywhere(CGroupMask supported, const char *from, const char *to int cg_trim_everywhere(CGroupMask supported, const char *path, bool delete_root) { CGroupController c; - int r; + int r, q; r = cg_trim(SYSTEMD_CGROUP_CONTROLLER, path, delete_root); if (r < 0) return r; - if (cg_all_unified()) + q = cg_all_unified(); + if (q < 0) + return q; + if (q > 0) return r; for (c = 0; c < _CGROUP_CONTROLLER_MAX; c++) { @@ -2163,7 +2219,10 @@ int cg_mask_supported(CGroupMask *ret) { * includes controllers we can make sense of and that are * actually accessible. */ - if (cg_all_unified()) { + r = cg_all_unified(); + if (r < 0) + return r; + if (r > 0) { _cleanup_free_ char *root = NULL, *controllers = NULL, *path = NULL; const char *c; @@ -2283,21 +2342,18 @@ int cg_kernel_controllers(Set *controllers) { static thread_local CGroupUnified unified_cache = CGROUP_UNIFIED_UNKNOWN; -/* The hybrid mode was initially implemented in v232 and simply mounted - * cgroup v2 on /sys/fs/cgroup/systemd. This unfortunately broke other - * tools (such as docker) which expected the v1 "name=systemd" hierarchy - * on /sys/fs/cgroup/systemd. From v233 and on, the hybrid mode mountnbs - * v2 on /sys/fs/cgroup/unified and maintains "name=systemd" hierarchy - * on /sys/fs/cgroup/systemd for compatibility with other tools. +/* The hybrid mode was initially implemented in v232 and simply mounted cgroup v2 on /sys/fs/cgroup/systemd. This + * unfortunately broke other tools (such as docker) which expected the v1 "name=systemd" hierarchy on + * /sys/fs/cgroup/systemd. From v233 and on, the hybrid mode mountnbs v2 on /sys/fs/cgroup/unified and maintains + * "name=systemd" hierarchy on /sys/fs/cgroup/systemd for compatibility with other tools. * - * To keep live upgrade working, we detect and support v232 layout. When - * v232 layout is detected, to keep cgroup v2 process management but - * disable the compat dual layout, we return %true on - * cg_unified(SYSTEMD_CGROUP_CONTROLLER) and %false on cg_hybrid_unified(). + * To keep live upgrade working, we detect and support v232 layout. When v232 layout is detected, to keep cgroup v2 + * process management but disable the compat dual layout, we return %true on + * cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) and %false on cg_hybrid_unified(). */ static thread_local bool unified_systemd_v232; -static int cg_update_unified(void) { +static int cg_unified_update(void) { struct statfs fs; @@ -2336,24 +2392,38 @@ static int cg_update_unified(void) { return 0; } -bool cg_unified(const char *controller) { +int cg_unified_controller(const char *controller) { + int r; + + r = cg_unified_update(); + if (r < 0) + return r; - assert(cg_update_unified() >= 0); + if (unified_cache == CGROUP_UNIFIED_NONE) + return false; - if (streq_ptr(controller, SYSTEMD_CGROUP_CONTROLLER)) - return unified_cache >= CGROUP_UNIFIED_SYSTEMD; - else - return unified_cache >= CGROUP_UNIFIED_ALL; + if (unified_cache >= CGROUP_UNIFIED_ALL) + return true; + + return streq_ptr(controller, SYSTEMD_CGROUP_CONTROLLER); } -bool cg_all_unified(void) { +int cg_all_unified(void) { + int r; - return cg_unified(NULL); + r = cg_unified_update(); + if (r < 0) + return r; + + return unified_cache >= CGROUP_UNIFIED_ALL; } -bool cg_hybrid_unified(void) { +int cg_hybrid_unified(void) { + int r; - assert(cg_update_unified() >= 0); + r = cg_unified_update(); + if (r < 0) + return r; return unified_cache == CGROUP_UNIFIED_SYSTEMD && !unified_systemd_v232; } @@ -2361,7 +2431,7 @@ bool cg_hybrid_unified(void) { int cg_unified_flush(void) { unified_cache = CGROUP_UNIFIED_UNKNOWN; - return cg_update_unified(); + return cg_unified_update(); } int cg_enable_everywhere(CGroupMask supported, CGroupMask mask, const char *p) { @@ -2374,7 +2444,10 @@ int cg_enable_everywhere(CGroupMask supported, CGroupMask mask, const char *p) { if (supported == 0) return 0; - if (!cg_all_unified()) /* on the legacy hiearchy there's no joining of controllers defined */ + r = cg_all_unified(); + if (r < 0) + return r; + if (r == 0) /* on the legacy hiearchy there's no joining of controllers defined */ return 0; r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, p, "cgroup.subtree_control", &fs); @@ -2417,7 +2490,7 @@ bool cg_is_unified_wanted(void) { /* If the hierarchy is already mounted, then follow whatever * was chosen for it. */ if (cg_unified_flush() >= 0) - return (wanted = cg_all_unified()); + return (wanted = unified_cache >= CGROUP_UNIFIED_ALL); /* Otherwise, let's see what the kernel command line has to say. * Since checking is expensive, cache a non-error result. */ diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h index 3d14ec3d9d..a522095d95 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -240,9 +240,9 @@ int cg_kernel_controllers(Set *controllers); bool cg_ns_supported(void); -bool cg_all_unified(void); -bool cg_hybrid_unified(void); -bool cg_unified(const char *controller); +int cg_all_unified(void); +int cg_hybrid_unified(void); +int cg_unified_controller(const char *controller); int cg_unified_flush(void); bool cg_is_unified_wanted(void); diff --git a/src/basic/khash.h b/src/basic/khash.h index f404a68236..410f3020e0 100644 --- a/src/basic/khash.h +++ b/src/basic/khash.h @@ -28,7 +28,7 @@ typedef struct khash khash; /* For plain hash functions. Hash functions commonly supported on today's kernels are: crc32c, crct10dif, crc32, - * sha224, sha256, sha512, sha384, sha1, md5, md4, sha3-224, sha3-256, sha3-384, sha3-512, and more.*/ + * sha224, sha256, sha512, sha384, sha1, md5, md4, sha3-224, sha3-256, sha3-384, sha3-512, and more. */ int khash_new(khash **ret, const char *algorithm); /* For keyed hash functions. Hash functions commonly supported on today's kernels are: hmac(sha256), cmac(aes), diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c index f703e7f145..8592a428d5 100644 --- a/src/basic/proc-cmdline.c +++ b/src/basic/proc-cmdline.c @@ -154,7 +154,7 @@ int proc_cmdline_get_key(const char *key, unsigned flags, char **value) { * * c) The "value" parameter is NULL. In this case a search for the exact "key" parameter is performed. * - * In all three cases, > 0 is returned if the key is found, 0 if not.*/ + * In all three cases, > 0 is returned if the key is found, 0 if not. */ if (isempty(key)) return -EINVAL; diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 87e5586027..0df3fed640 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -311,7 +311,7 @@ int rename_process(const char name[]) { /* Third step, completely replace the argv[] array the kernel maintains for us. This requires privileges, but * has the advantage that the argv[] array is exactly what we want it to be, and not filled up with zeros at - * the end. This is the best option for changing /proc/self/cmdline.*/ + * the end. This is the best option for changing /proc/self/cmdline. */ if (mm_size < l+1) { size_t nn_size; char *nn; diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 116608bbd3..155bf278b2 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -125,12 +125,8 @@ static int verify_esp( errno = 0; b = blkid_new_probe_from_filename(t); - if (!b) { - if (errno == 0) - return log_oom(); - - return log_error_errno(errno, "Failed to open file system \"%s\": %m", p); - } + if (!b) + return log_error_errno(errno ?: ENOMEM, "Failed to open file system \"%s\": %m", p); blkid_probe_enable_superblocks(b, 1); blkid_probe_set_superblocks_flags(b, BLKID_SUBLKS_TYPE); @@ -145,17 +141,13 @@ static int verify_esp( } else if (r == 1) { log_error("File system \"%s\" does not contain a label.", p); return -ENODEV; - } else if (r != 0) { - r = errno ? -errno : -EIO; - return log_error_errno(r, "Failed to probe file system \"%s\": %m", p); - } + } else if (r != 0) + return log_error_errno(errno ?: EIO, "Failed to probe file system \"%s\": %m", p); errno = 0; r = blkid_probe_lookup_value(b, "TYPE", &v, NULL); - if (r != 0) { - r = errno ? -errno : -EIO; - return log_error_errno(r, "Failed to probe file system type \"%s\": %m", p); - } + if (r != 0) + return log_error_errno(errno ?: EIO, "Failed to probe file system type \"%s\": %m", p); if (!streq(v, "vfat")) { log_error("File system \"%s\" is not FAT.", p); return -ENODEV; @@ -163,10 +155,8 @@ static int verify_esp( errno = 0; r = blkid_probe_lookup_value(b, "PART_ENTRY_SCHEME", &v, NULL); - if (r != 0) { - r = errno ? -errno : -EIO; - return log_error_errno(r, "Failed to probe partition scheme \"%s\": %m", p); - } + if (r != 0) + return log_error_errno(errno ?: EIO, "Failed to probe partition scheme \"%s\": %m", p); if (!streq(v, "gpt")) { log_error("File system \"%s\" is not on a GPT partition table.", p); return -ENODEV; @@ -174,10 +164,8 @@ static int verify_esp( errno = 0; r = blkid_probe_lookup_value(b, "PART_ENTRY_TYPE", &v, NULL); - if (r != 0) { - r = errno ? -errno : -EIO; - return log_error_errno(r, "Failed to probe partition type UUID \"%s\": %m", p); - } + if (r != 0) + return log_error_errno(errno ?: EIO, "Failed to probe partition type UUID \"%s\": %m", p); if (!streq(v, "c12a7328-f81f-11d2-ba4b-00a0c93ec93b")) { log_error("File system \"%s\" has wrong type for an EFI System Partition (ESP).", p); return -ENODEV; @@ -185,10 +173,8 @@ static int verify_esp( errno = 0; r = blkid_probe_lookup_value(b, "PART_ENTRY_UUID", &v, NULL); - if (r != 0) { - r = errno ? -errno : -EIO; - return log_error_errno(r, "Failed to probe partition entry UUID \"%s\": %m", p); - } + if (r != 0) + return log_error_errno(errno ?: EIO, "Failed to probe partition entry UUID \"%s\": %m", p); r = sd_id128_from_string(v, &uuid); if (r < 0) { log_error("Partition \"%s\" has invalid UUID \"%s\".", p, v); @@ -197,30 +183,24 @@ static int verify_esp( errno = 0; r = blkid_probe_lookup_value(b, "PART_ENTRY_NUMBER", &v, NULL); - if (r != 0) { - r = errno ? -errno : -EIO; - return log_error_errno(r, "Failed to probe partition number \"%s\": m", p); - } + if (r != 0) + return log_error_errno(errno ?: EIO, "Failed to probe partition number \"%s\": m", p); r = safe_atou32(v, &part); if (r < 0) return log_error_errno(r, "Failed to parse PART_ENTRY_NUMBER field."); errno = 0; r = blkid_probe_lookup_value(b, "PART_ENTRY_OFFSET", &v, NULL); - if (r != 0) { - r = errno ? -errno : -EIO; - return log_error_errno(r, "Failed to probe partition offset \"%s\": %m", p); - } + if (r != 0) + return log_error_errno(errno ?: EIO, "Failed to probe partition offset \"%s\": %m", p); r = safe_atou64(v, &pstart); if (r < 0) return log_error_errno(r, "Failed to parse PART_ENTRY_OFFSET field."); errno = 0; r = blkid_probe_lookup_value(b, "PART_ENTRY_SIZE", &v, NULL); - if (r != 0) { - r = errno ? -errno : -EIO; - return log_error_errno(r, "Failed to probe partition size \"%s\": %m", p); - } + if (r != 0) + return log_error_errno(errno ?: EIO, "Failed to probe partition size \"%s\": %m", p); r = safe_atou64(v, &psize); if (r < 0) return log_error_errno(r, "Failed to parse PART_ENTRY_SIZE field."); diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 7cc54a8cdd..681e783f2e 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -1787,7 +1787,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { config_title_generate(&config); - /* select entry by configured pattern or EFI LoaderDefaultEntry= variable*/ + /* select entry by configured pattern or EFI LoaderDefaultEntry= variable */ config_default_entry_select(&config); /* if no configured entry to select from was found, enable the menu */ diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index 7c1ffb1bca..b7d5d3cdae 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -87,7 +87,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { cmdline_len = szs[0]; /* if we are not in secure boot mode, accept a custom command line and replace the built-in one */ - if (!secure && loaded_image->LoadOptionsSize > 0) { + if (!secure && loaded_image->LoadOptionsSize > 0 && *(CHAR16 *)loaded_image->LoadOptions != 0) { CHAR16 *options; CHAR8 *line; UINTN i; diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c index 40db82f9ae..1b746a0e13 100644 --- a/src/cgls/cgls.c +++ b/src/cgls/cgls.c @@ -158,7 +158,7 @@ static int parse_argv(int argc, char *argv[]) { static void show_cg_info(const char *controller, const char *path) { - if (!cg_all_unified() && controller && !streq(controller, SYSTEMD_CGROUP_CONTROLLER)) + if (cg_all_unified() == 0 && controller && !streq(controller, SYSTEMD_CGROUP_CONTROLLER)) printf("Controller %s; ", controller); printf("Control group %s:\n", isempty(path) ? "/" : path); diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index 45c050c9c3..a1c0f48c89 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -133,12 +133,16 @@ static int process( Group **ret) { Group *g; - int r; + int r, all_unified; assert(controller); assert(path); assert(a); + all_unified = cg_all_unified(); + if (all_unified < 0) + return all_unified; + g = hashmap_get(a, path); if (!g) { g = hashmap_get(b, path); @@ -214,7 +218,7 @@ static int process( uint64_t new_usage; nsec_t timestamp; - if (cg_all_unified()) { + if (all_unified) { const char *keys[] = { "usage_usec", NULL }; _cleanup_free_ char *val = NULL; @@ -274,10 +278,10 @@ static int process( } else if (streq(controller, "memory")) { _cleanup_free_ char *p = NULL, *v = NULL; - if (!cg_all_unified()) - r = cg_get_path(controller, path, "memory.usage_in_bytes", &p); - else + if (all_unified) r = cg_get_path(controller, path, "memory.current", &p); + else + r = cg_get_path(controller, path, "memory.usage_in_bytes", &p); if (r < 0) return r; @@ -294,14 +298,14 @@ static int process( if (g->memory > 0) g->memory_valid = true; - } else if ((streq(controller, "io") && cg_all_unified()) || - (streq(controller, "blkio") && !cg_all_unified())) { + } else if ((streq(controller, "io") && all_unified) || + (streq(controller, "blkio") && !all_unified)) { _cleanup_fclose_ FILE *f = NULL; _cleanup_free_ char *p = NULL; uint64_t wr = 0, rd = 0; nsec_t timestamp; - r = cg_get_path(controller, path, cg_all_unified() ? "io.stat" : "blkio.io_service_bytes", &p); + r = cg_get_path(controller, path, all_unified ? "io.stat" : "blkio.io_service_bytes", &p); if (r < 0) return r; @@ -324,7 +328,7 @@ static int process( l += strcspn(l, WHITESPACE); l += strspn(l, WHITESPACE); - if (cg_all_unified()) { + if (all_unified) { while (!isempty(l)) { if (sscanf(l, "rbytes=%" SCNu64, &k)) rd += k; diff --git a/src/core/cgroup.c b/src/core/cgroup.c index fbb711782e..774b832a63 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -678,7 +678,7 @@ static void cgroup_context_apply(Unit *u, CGroupMask mask, ManagerState state) { bool has_weight = cgroup_context_has_cpu_weight(c); bool has_shares = cgroup_context_has_cpu_shares(c); - if (cg_all_unified()) { + if (cg_all_unified() > 0) { uint64_t weight; if (has_weight) @@ -858,9 +858,8 @@ static void cgroup_context_apply(Unit *u, CGroupMask mask, ManagerState state) { } if ((mask & CGROUP_MASK_MEMORY) && !is_root) { - if (cg_all_unified()) { - uint64_t max; - uint64_t swap_max = CGROUP_LIMIT_MAX; + if (cg_all_unified() > 0) { + uint64_t max, swap_max = CGROUP_LIMIT_MAX; if (cgroup_context_has_unified_memory_config(c)) { max = c->memory_max; @@ -1033,7 +1032,7 @@ CGroupMask unit_get_own_mask(Unit *u) { e = unit_get_exec_context(u); if (!e || exec_context_maintains_privileges(e) || - cg_all_unified()) + cg_all_unified() > 0) return _CGROUP_MASK_ALL; } @@ -1260,7 +1259,10 @@ int unit_watch_cgroup(Unit *u) { return 0; /* Only applies to the unified hierarchy */ - if (!cg_unified(SYSTEMD_CGROUP_CONTROLLER)) + r = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER); + if (r < 0) + return log_error_errno(r, "Failed to determine whether the name=systemd hierarchy is unified: %m"); + if (r == 0) return 0; /* Don't watch the root slice, it's pointless. */ @@ -1670,6 +1672,8 @@ static int unit_watch_pids_in_path(Unit *u, const char *path) { } int unit_watch_all_pids(Unit *u) { + int r; + assert(u); /* Adds all PIDs from our cgroup to the set of PIDs we @@ -1680,7 +1684,10 @@ int unit_watch_all_pids(Unit *u) { if (!u->cgroup_path) return -ENOENT; - if (cg_unified(SYSTEMD_CGROUP_CONTROLLER)) /* On unified we can use proper notifications */ + r = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER); + if (r < 0) + return r; + if (r > 0) /* On unified we can use proper notifications */ return 0; return unit_watch_pids_in_path(u, u->cgroup_path); @@ -1753,7 +1760,7 @@ static int on_cgroup_inotify_event(sd_event_source *s, int fd, uint32_t revents, int manager_setup_cgroup(Manager *m) { _cleanup_free_ char *path = NULL; CGroupController c; - int r; + int r, all_unified; char *e; assert(m); @@ -1794,18 +1801,26 @@ int manager_setup_cgroup(Manager *m) { if (r < 0) return log_error_errno(r, "Couldn't determine if we are running in the unified hierarchy: %m"); - if (cg_all_unified()) + all_unified = cg_all_unified(); + if (r < 0) + return log_error_errno(r, "Couldn't determine whether we are in all unified mode: %m"); + if (r > 0) log_debug("Unified cgroup hierarchy is located at %s.", path); - else if (cg_unified(SYSTEMD_CGROUP_CONTROLLER)) - log_debug("Unified cgroup hierarchy is located at %s. Controllers are on legacy hierarchies.", path); - else - log_debug("Using cgroup controller " SYSTEMD_CGROUP_CONTROLLER_LEGACY ". File system hierarchy is at %s.", path); + else { + r = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER); + if (r < 0) + return log_error_errno(r, "Failed to determine whether systemd's own controller is in unified mode: %m"); + if (r > 0) + log_debug("Unified cgroup hierarchy is located at %s. Controllers are on legacy hierarchies.", path); + else + log_debug("Using cgroup controller " SYSTEMD_CGROUP_CONTROLLER_LEGACY ". File system hierarchy is at %s.", path); + } if (!m->test_run) { const char *scope_path; /* 3. Install agent */ - if (cg_unified(SYSTEMD_CGROUP_CONTROLLER)) { + if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) > 0) { /* In the unified hierarchy we can get * cgroup empty notifications via inotify. */ @@ -1865,7 +1880,7 @@ int manager_setup_cgroup(Manager *m) { return log_error_errno(errno, "Failed to open pin file: %m"); /* 6. Always enable hierarchical support if it exists... */ - if (!cg_all_unified()) + if (!all_unified) (void) cg_set_attribute("memory", "/", "memory.use_hierarchy", "1"); } @@ -1991,10 +2006,13 @@ int unit_get_memory_current(Unit *u, uint64_t *ret) { if ((u->cgroup_realized_mask & CGROUP_MASK_MEMORY) == 0) return -ENODATA; - if (!cg_all_unified()) - r = cg_get_attribute("memory", u->cgroup_path, "memory.usage_in_bytes", &v); - else + r = cg_all_unified(); + if (r < 0) + return r; + if (r > 0) r = cg_get_attribute("memory", u->cgroup_path, "memory.current", &v); + else + r = cg_get_attribute("memory", u->cgroup_path, "memory.usage_in_bytes", &v); if (r == -ENOENT) return -ENODATA; if (r < 0) @@ -2036,7 +2054,10 @@ static int unit_get_cpu_usage_raw(Unit *u, nsec_t *ret) { if (!u->cgroup_path) return -ENODATA; - if (cg_all_unified()) { + r = cg_all_unified(); + if (r < 0) + return r; + if (r > 0) { const char *keys[] = { "usage_usec", NULL }; _cleanup_free_ char *val = NULL; uint64_t us; diff --git a/src/core/manager.c b/src/core/manager.c index ea80585329..cff38e28de 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -776,7 +776,10 @@ static int manager_setup_cgroups_agent(Manager *m) { if (!MANAGER_IS_SYSTEM(m)) return 0; - if (cg_unified(SYSTEMD_CGROUP_CONTROLLER)) /* We don't need this anymore on the unified hierarchy */ + r = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER); + if (r < 0) + return log_error_errno(r, "Failed to determine whether unified cgroups hierarchy is used: %m"); + if (r > 0) /* We don't need this anymore on the unified hierarchy */ return 0; if (m->cgroups_agent_fd < 0) { diff --git a/src/core/namespace.c b/src/core/namespace.c index 75dca5b791..4f29217bc4 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -799,7 +799,7 @@ static int make_read_only(MountEntry *m, char **blacklist) { if (mount_entry_read_only(m)) r = bind_remount_recursive(mount_entry_path(m), true, blacklist); - else if (m->mode == PRIVATE_DEV) { /* Superblock can be readonly but the submounts can't*/ + else if (m->mode == PRIVATE_DEV) { /* Superblock can be readonly but the submounts can't */ if (mount(NULL, mount_entry_path(m), NULL, MS_REMOUNT|DEV_MOUNT_OPTIONS|MS_RDONLY, NULL) < 0) r = -errno; } else diff --git a/src/core/scope.c b/src/core/scope.c index 5e068a76d1..a1d5c1cfd5 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -475,7 +475,7 @@ static void scope_sigchld_event(Unit *u, pid_t pid, int code, int status) { /* If the PID set is empty now, then let's finish this off (On unified we use proper notifications) */ - if (!cg_unified(SYSTEMD_CGROUP_CONTROLLER) && set_isempty(u->pids)) + if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) == 0 && set_isempty(u->pids)) scope_notify_cgroup_empty_event(u); } diff --git a/src/core/service.c b/src/core/service.c index 0c2eb18f38..5581ec8b06 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -2938,7 +2938,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { /* If the PID set is empty now, then let's finish this off (On unified we use proper notifications) */ - if (!cg_unified(SYSTEMD_CGROUP_CONTROLLER) && set_isempty(u->pids)) + if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) == 0 && set_isempty(u->pids)) service_notify_cgroup_empty_event(u); } diff --git a/src/core/socket.c b/src/core/socket.c index 84b7a1a82d..c4da227e09 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -1260,7 +1260,7 @@ static int usbffs_address_create(const char *path) { if (fstat(fd, &st) < 0) return -errno; - /* Check whether this is a regular file (ffs endpoint)*/ + /* Check whether this is a regular file (ffs endpoint) */ if (!S_ISREG(st.st_mode)) return -EEXIST; diff --git a/src/core/unit.c b/src/core/unit.c index 685df6f00d..174dd42819 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -3895,9 +3895,9 @@ int unit_kill_context( * should not exist in non-delegated units. On * the unified hierarchy that's different, * there we get proper events. Hence rely on - * them.*/ + * them. */ - if (cg_unified(SYSTEMD_CGROUP_CONTROLLER) || + if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) > 0 || (detect_container() == 0 && !unit_cgroup_delegate(u))) wait_for_exit = true; diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index 43dba82c3a..4ac98d8163 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -50,6 +50,8 @@ #include "user-util.h" #include "util.h" +static usec_t arg_since = USEC_INFINITY, arg_until = USEC_INFINITY; + static enum { ACTION_NONE, ACTION_INFO, @@ -128,11 +130,12 @@ static void help(void) { " --no-pager Do not pipe output into a pager\n" " --no-legend Do not print the column headers.\n" " -1 Show information about most recent entry only\n" + " -S --since=DATE Only print coredumps since the date\n" + " -U --until=DATE Only print coredumps until the date\n" " -r --reverse Show the newest entries first\n" " -F --field=FIELD List all values a certain field takes\n" " -o --output=FILE Write output to FILE\n" " -D --directory=DIR Use journal files from directory\n\n" - "Commands:\n" " list [MATCHES...] List available coredumps (default)\n" " info [MATCHES...] Show detailed information about one or more coredumps\n" @@ -148,7 +151,7 @@ static int parse_argv(int argc, char *argv[]) { ARG_NO_LEGEND, }; - int c; + int c, r; static const struct option options[] = { { "help", no_argument, NULL, 'h' }, @@ -159,15 +162,16 @@ static int parse_argv(int argc, char *argv[]) { { "field", required_argument, NULL, 'F' }, { "directory", required_argument, NULL, 'D' }, { "reverse", no_argument, NULL, 'r' }, + { "since", required_argument, NULL, 'S' }, + { "until", required_argument, NULL, 'U' }, {} }; assert(argc >= 0); assert(argv); - while ((c = getopt_long(argc, argv, "ho:F:1D:r", options, NULL)) >= 0) + while ((c = getopt_long(argc, argv, "ho:F:1D:S:U:r", options, NULL)) >= 0) switch(c) { - case 'h': arg_action = ACTION_NONE; help(); @@ -197,6 +201,18 @@ static int parse_argv(int argc, char *argv[]) { break; + case 'S': + r = parse_timestamp(optarg, &arg_since); + if (r < 0) + return log_error_errno(r, "Failed to parse timestamp: %s", optarg); + break; + + case 'U': + r = parse_timestamp(optarg, &arg_until); + if (r < 0) + return log_error_errno(r, "Failed to parse timestamp: %s", optarg); + break; + case 'F': if (arg_field) { log_error("cannot use --field/-F more than once"); @@ -224,6 +240,12 @@ static int parse_argv(int argc, char *argv[]) { assert_not_reached("Unhandled option"); } + if (arg_since != USEC_INFINITY && arg_until != USEC_INFINITY && + arg_since > arg_until) { + log_error("--since= must be before --until=."); + return -EINVAL; + } + if (optind < argc) { const char *cmd = argv[optind++]; if (streq(cmd, "list")) @@ -610,18 +632,52 @@ static int dump_list(sd_journal *j) { return print_entry(j, 0); } else { - if (!arg_reverse) { - SD_JOURNAL_FOREACH(j) { - r = print_entry(j, n_found++); + if (arg_since != USEC_INFINITY && !arg_reverse) + r = sd_journal_seek_realtime_usec(j, arg_since); + else if (arg_until != USEC_INFINITY && arg_reverse) + r = sd_journal_seek_realtime_usec(j, arg_until); + else if (arg_reverse) + r = sd_journal_seek_tail(j); + else + r = sd_journal_seek_head(j); + if (r < 0) + return log_error_errno(r, "Failed to seek to date: %m"); + + for (;;) { + if (!arg_reverse) + r = sd_journal_next(j); + else + r = sd_journal_previous(j); + + if (r < 0) + return log_error_errno(r, "Failed to iterate through journal: %m"); + + if (r == 0) + break; + + if (arg_until != USEC_INFINITY && !arg_reverse) { + usec_t usec; + + r = sd_journal_get_realtime_usec(j, &usec); if (r < 0) - return r; + return log_error_errno(r, "Failed to determine timestamp: %m"); + if (usec > arg_until) + continue; } - } else { - SD_JOURNAL_FOREACH_BACKWARDS(j) { - r = print_entry(j, n_found++); + + if (arg_since != USEC_INFINITY && arg_reverse) { + usec_t usec; + + r = sd_journal_get_realtime_usec(j, &usec); if (r < 0) - return r; + return log_error_errno(r, "Failed to determine timestamp: %m"); + if (usec < arg_since) + continue; } + + r = print_entry(j, n_found++); + if (r < 0) + return r; } if (!arg_field && n_found <= 0) { diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index b958070c90..80f676e477 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -475,7 +475,7 @@ static int add_esp(DissectedPartition *p) { 120 * USEC_PER_SEC); } #else -static int add_esp(const char *what) { +static int add_esp(DissectedPartition *p) { return 0; } #endif diff --git a/src/import/curl-util.c b/src/import/curl-util.c index 734e1560e6..0e8f3fb918 100644 --- a/src/import/curl-util.c +++ b/src/import/curl-util.c @@ -400,7 +400,7 @@ int curl_header_strdup(const void *contents, size_t sz, const char *field, char sz--; } - /* Truncate trailing whitespace*/ + /* Truncate trailing whitespace */ while (sz > 0 && strchr(WHITESPACE, p[sz-1])) sz--; diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index ef87b176fa..a6ccb679a8 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -3283,7 +3283,7 @@ int journal_file_rotate(JournalFile **f, bool compress, bool seal, Set *deferred return -EINVAL; /* Is this a journal file that was passed to us as fd? If so, we synthesized a path name for it, and we refuse - * rotation, since we don't know the actual path, and couldn't rename the file hence.*/ + * rotation, since we don't know the actual path, and couldn't rename the file hence. */ if (path_startswith(old_file->path, "/proc/self/fd")) return -EINVAL; diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c index 0469393f3b..44a2cf5217 100644 --- a/src/journal/test-compress.c +++ b/src/journal/test-compress.c @@ -109,7 +109,7 @@ static void test_decompress_startswith(int compression, size_t csize, usize = 0, len; int r; - log_info("/* testing decompress_startswith with %s on %.20s text*/", + log_info("/* testing decompress_startswith with %s on %.20s text */", object_compressed_to_string(compression), data); #define BUFSIZE_1 512 diff --git a/src/libsystemd-network/arp-util.c b/src/libsystemd-network/arp-util.c index 02028bf28a..2e02b3fa66 100644 --- a/src/libsystemd-network/arp-util.c +++ b/src/libsystemd-network/arp-util.c @@ -58,7 +58,7 @@ int arp_network_bind_raw_socket(int ifindex, be32_t address, const struct ether_ BPF_STMT(BPF_ALU + BPF_XOR + BPF_X, 0), /* A xor X */ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0, 0, 1), /* A == 0 ? */ BPF_STMT(BPF_RET + BPF_K, 0), /* ignore */ - /* Sender Protocol Address or Target Protocol Address must be equal to the one we care about*/ + /* Sender Protocol Address or Target Protocol Address must be equal to the one we care about */ BPF_STMT(BPF_LD + BPF_IMM, htobe32(address)), /* A <- clients IP */ BPF_STMT(BPF_MISC + BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD + BPF_W + BPF_ABS, offsetof(struct ether_arp, arp_spa)), /* A <- SPA */ diff --git a/src/libsystemd-network/test-lldp.c b/src/libsystemd-network/test-lldp.c index 6bcd65de0a..430c58ae60 100644 --- a/src/libsystemd-network/test-lldp.c +++ b/src/libsystemd-network/test-lldp.c @@ -98,14 +98,14 @@ static void test_receive_basic_packet(sd_event *e) { static const uint8_t frame[] = { /* Ethernet header */ - 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03, /* Destination MAC*/ + 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03, /* Destination MAC */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, /* Source MAC */ 0x88, 0xcc, /* Ethertype */ /* LLDP mandatory TLVs */ 0x02, 0x07, 0x04, 0x00, 0x01, 0x02, /* Chassis: MAC, 00:01:02:03:04:05 */ 0x03, 0x04, 0x05, 0x04, 0x04, 0x05, 0x31, 0x2f, 0x33, /* Port: interface name, "1/3" */ - 0x06, 0x02, 0x00, 0x78, /* TTL: 120 seconds*/ + 0x06, 0x02, 0x00, 0x78, /* TTL: 120 seconds */ /* LLDP optional TLVs */ 0x08, 0x04, 0x50, 0x6f, 0x72, 0x74, /* Port Description: "Port" */ 0x0a, 0x03, 0x53, 0x59, 0x53, /* System Name: "SYS" */ @@ -162,7 +162,7 @@ static void test_receive_incomplete_packet(sd_event *e) { sd_lldp_neighbor **neighbors; uint8_t frame[] = { /* Ethernet header */ - 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03, /* Destination MAC*/ + 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03, /* Destination MAC */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, /* Source MAC */ 0x88, 0xcc, /* Ethertype */ /* LLDP mandatory TLVs */ @@ -189,14 +189,14 @@ static void test_receive_oui_packet(sd_event *e) { sd_lldp_neighbor **neighbors; uint8_t frame[] = { /* Ethernet header */ - 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03, /* Destination MAC*/ + 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03, /* Destination MAC */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, /* Source MAC */ 0x88, 0xcc, /* Ethertype */ /* LLDP mandatory TLVs */ 0x02, 0x07, 0x04, 0x00, 0x01, 0x02, /* Chassis: MAC, 00:01:02:03:04:05 */ 0x03, 0x04, 0x05, 0x04, 0x04, 0x05, 0x31, 0x2f, 0x33, /* Port TLV: interface name, "1/3" */ - 0x06, 0x02, 0x00, 0x78, /* TTL: 120 seconds*/ + 0x06, 0x02, 0x00, 0x78, /* TTL: 120 seconds */ /* LLDP optional TLVs */ 0xfe, 0x06, 0x00, 0x80, 0xc2, 0x01, /* Port VLAN ID: 0x1234 */ 0x12, 0x34, diff --git a/src/libsystemd/sd-device/device-internal.h b/src/libsystemd/sd-device/device-internal.h index 9fad388953..f4783deef8 100644 --- a/src/libsystemd/sd-device/device-internal.h +++ b/src/libsystemd/sd-device/device-internal.h @@ -34,7 +34,7 @@ struct sd_device { uint64_t properties_generation; /* changes whenever the properties are changed */ uint64_t properties_iterator_generation; /* generation when iteration was started */ - /* the subset of the properties that should be written to the db*/ + /* the subset of the properties that should be written to the db */ OrderedHashmap *properties_db; Hashmap *sysattr_values; /* cached sysattr values */ diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index 0d8d99c56d..8b4af5a2c3 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -245,7 +245,7 @@ static int network_link_get_ifindexes(int ifindex, const char *key, int **ret) { } if (ifis) - ifis[c] = 0; /* Let's add a 0 ifindex to the end, to be nice*/ + ifis[c] = 0; /* Let's add a 0 ifindex to the end, to be nice */ *ret = ifis; ifis = NULL; diff --git a/src/network/netdev/tunnel.c b/src/network/netdev/tunnel.c index c11ac0c539..67f4fab400 100644 --- a/src/network/netdev/tunnel.c +++ b/src/network/netdev/tunnel.c @@ -410,10 +410,10 @@ static int netdev_tunnel_verify(NetDev *netdev, const char *filename) { return -EINVAL; } - if (netdev->kind == NETDEV_KIND_VTI6 && + if (IN_SET(netdev->kind, NETDEV_KIND_VTI6, NETDEV_KIND_IP6TNL, NETDEV_KIND_IP6GRE) && (t->family != AF_INET6 || in_addr_is_null(t->family, &t->local))) { log_netdev_error(netdev, - "vti6 tunnel without a local IPv4 address configured in %s. Ignoring", filename); + "vti6/ip6tnl/ip6gre tunnel without a local IPv6 address configured in %s. Ignoring", filename); return -EINVAL; } diff --git a/src/nspawn/nspawn-cgroup.c b/src/nspawn/nspawn-cgroup.c index 4678a7e349..d749756437 100644 --- a/src/nspawn/nspawn-cgroup.c +++ b/src/nspawn/nspawn-cgroup.c @@ -78,9 +78,12 @@ int sync_cgroup(pid_t pid, CGroupUnified unified_requested, uid_t arg_uid_shift) char tree[] = "/tmp/unifiedXXXXXX", pid_string[DECIMAL_STR_MAX(pid) + 1]; bool undo_mount = false; const char *fn; - int r; + int r, unified_controller; - if (cg_unified(SYSTEMD_CGROUP_CONTROLLER) == (unified_requested >= CGROUP_UNIFIED_SYSTEMD)) + unified_controller = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER); + if (unified_controller < 0) + return log_error_errno(unified_controller, "Failed to determine whether the systemd hierarchy is unified: %m"); + if ((unified_controller > 0) == (unified_requested >= CGROUP_UNIFIED_SYSTEMD)) return 0; /* When the host uses the legacy cgroup setup, but the @@ -96,7 +99,7 @@ int sync_cgroup(pid_t pid, CGroupUnified unified_requested, uid_t arg_uid_shift) if (!mkdtemp(tree)) return log_error_errno(errno, "Failed to generate temporary mount point for unified hierarchy: %m"); - if (cg_unified(SYSTEMD_CGROUP_CONTROLLER)) + if (unified_controller > 0) r = mount_verbose(LOG_ERR, "cgroup", tree, "cgroup", MS_NOSUID|MS_NOEXEC|MS_NODEV, "none,name=systemd,xattr"); else @@ -150,7 +153,10 @@ int create_subcgroup(pid_t pid, CGroupUnified unified_requested) { if (unified_requested == CGROUP_UNIFIED_NONE) return 0; - if (!cg_unified(SYSTEMD_CGROUP_CONTROLLER)) + r = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER); + if (r < 0) + return log_error_errno(r, "Failed to determine whether the systemd controller is unified: %m"); + if (r == 0) return 0; r = cg_mask_supported(&supported); diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c index ed4f1f9db8..d276994120 100644 --- a/src/nspawn/nspawn-mount.c +++ b/src/nspawn/nspawn-mount.c @@ -545,10 +545,10 @@ int mount_all(const char *dest, static const MountPoint mount_table[] = { /* inner child mounts */ { "proc", "/proc", "proc", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, MOUNT_FATAL|MOUNT_IN_USERNS }, - { "/proc/sys", "/proc/sys", NULL, NULL, MS_BIND, MOUNT_FATAL|MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO }, /* Bind mount first ...*/ + { "/proc/sys", "/proc/sys", NULL, NULL, MS_BIND, MOUNT_FATAL|MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO }, /* Bind mount first ... */ { "/proc/sys/net", "/proc/sys/net", NULL, NULL, MS_BIND, MOUNT_FATAL|MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO|MOUNT_APPLY_APIVFS_NETNS }, /* (except for this) */ { NULL, "/proc/sys", NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT, MOUNT_FATAL|MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO }, /* ... then, make it r/o */ - { "/proc/sysrq-trigger", "/proc/sysrq-trigger", NULL, NULL, MS_BIND, MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO }, /* Bind mount first ...*/ + { "/proc/sysrq-trigger", "/proc/sysrq-trigger", NULL, NULL, MS_BIND, MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO }, /* Bind mount first ... */ { NULL, "/proc/sysrq-trigger", NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT, MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO }, /* ... then, make it r/o */ /* outer child mounts */ @@ -991,7 +991,10 @@ static int mount_legacy_cgns_supported( return r; } - if (cg_all_unified()) + r = cg_all_unified(); + if (r < 0) + return r; + if (r > 0) goto skip_controllers; controllers = set_new(&string_hash_ops); @@ -1094,7 +1097,10 @@ static int mount_legacy_cgns_unsupported( return r; } - if (cg_all_unified()) + r = cg_all_unified(); + if (r < 0) + return r; + if (r > 0) goto skip_controllers; controllers = set_new(&string_hash_ops); diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 42355115ff..1fc0501c2e 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -333,7 +333,10 @@ static int detect_unified_cgroup_hierarchy(const char *directory) { } /* Otherwise inherit the default from the host system */ - if (cg_all_unified()) { + r = cg_all_unified(); + if (r < 0) + return log_error_errno(r, "Failed to determine whether we are in all unified mode."); + if (r > 0) { /* Unified cgroup hierarchy support was added in 230. Unfortunately the detection * routine only detects 231, so we'll have a false negative here for 230. */ r = systemd_installation_has_version(directory, 230); @@ -343,7 +346,7 @@ static int detect_unified_cgroup_hierarchy(const char *directory) { arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_ALL; else arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_NONE; - } else if (cg_unified(SYSTEMD_CGROUP_CONTROLLER)) { + } else if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) > 0) { /* Mixed cgroup hierarchy support was added in 233 */ r = systemd_installation_has_version(directory, 233); if (r < 0) @@ -2539,7 +2542,7 @@ static int outer_child( * inside the containter that create a new mount namespace. * See https://github.com/systemd/systemd/issues/3860 * Further submounts (such as /dev) done after this will inherit the - * shared propagation mode.*/ + * shared propagation mode. */ r = mount_verbose(LOG_ERR, NULL, directory, NULL, MS_SHARED|MS_REC, NULL); if (r < 0) return r; diff --git a/src/resolve/resolved-dns-answer.c b/src/resolve/resolved-dns-answer.c index ab85754bf7..db86b4dcf6 100644 --- a/src/resolve/resolved-dns-answer.c +++ b/src/resolve/resolved-dns-answer.c @@ -148,7 +148,7 @@ int dns_answer_add(DnsAnswer *a, DnsResourceRecord *rr, int ifindex, DnsAnswerFl * match. We don't really care if they match * precisely, but we do care whether one is 0 * and the other is not. See RFC 2181, Section - * 5.2.*/ + * 5.2. */ if ((rr->ttl == 0) != (a->items[i].rr->ttl == 0)) return -EINVAL; diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c index 46a25c2bee..f8dab01308 100644 --- a/src/resolve/resolved-dns-cache.c +++ b/src/resolve/resolved-dns-cache.c @@ -433,7 +433,7 @@ static int dns_cache_put_positive( return 0; } - /* Entry exists already? Update TTL, timestamp and owner*/ + /* Entry exists already? Update TTL, timestamp and owner */ existing = dns_cache_get(c, rr); if (existing) { dns_cache_item_update_positive( diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c index ecd7068683..ff2ad9c1de 100644 --- a/src/resolve/resolved-dns-transaction.c +++ b/src/resolve/resolved-dns-transaction.c @@ -2458,7 +2458,7 @@ static int dns_transaction_requires_nsec(DnsTransaction *t) { if (r > 0) { /* The lookup is from a TLD that is proven not to * exist, and we are in downgrade mode, hence ignore - * that fact that we didn't get any NSEC RRs.*/ + * that fact that we didn't get any NSEC RRs. */ log_info("Detected a negative query %s in a private DNS zone, permitting unsigned response.", dns_resource_key_to_string(t->key, key_str, sizeof key_str)); @@ -2763,7 +2763,7 @@ static int dnssec_validate_records( const char *source; /* This RRset validated, but as a wildcard. This means we need - * to prove via NSEC/NSEC3 that no matching non-wildcard RR exists.*/ + * to prove via NSEC/NSEC3 that no matching non-wildcard RR exists. */ /* First step, determine the source of synthesis */ r = dns_resource_record_source(rrsig, &source); @@ -2798,7 +2798,7 @@ static int dnssec_validate_records( return r; if (r == 0) { /* Data does not require signing. In that case, just copy it over, - * but remember that this is by no means authenticated.*/ + * but remember that this is by no means authenticated. */ r = dns_answer_move_by_key(validated, &t->answer, rr->key, 0); if (r < 0) return r; diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c index 44c0cd654f..3f7f9035cf 100644 --- a/src/resolve/resolved-link.c +++ b/src/resolve/resolved-link.c @@ -543,7 +543,7 @@ bool link_relevant(Link *l, int family, bool local_multicast) { * beat, can do multicast and has at least one link-local (or better) IP address. * * A link is relevant for non-multicast traffic if it isn't a loopback device, has a link beat, and has at - * least one routable address.*/ + * least one routable address. */ if (l->flags & (IFF_LOOPBACK|IFF_DORMANT)) return false; diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 410a7764ed..39e724c51a 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -61,12 +61,8 @@ static int probe_filesystem(const char *node, char **ret_fstype) { log_debug("Failed to identify any partition type on partition %s", node); goto not_found; } - if (r != 0) { - if (errno == 0) - return -EIO; - - return -errno; - } + if (r != 0) + return -errno ?: -EIO; (void) blkid_probe_lookup_value(b, "TYPE", &fstype, NULL); @@ -146,12 +142,8 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI errno = 0; r = blkid_probe_set_device(b, fd, 0, 0); - if (r != 0) { - if (errno == 0) - return -ENOMEM; - - return -errno; - } + if (r != 0) + return -errno ?: -ENOMEM; if ((flags & DISSECT_IMAGE_GPT_ONLY) == 0) { /* Look for file system superblocks, unless we only shall look for GPT partition tables */ @@ -168,12 +160,8 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI log_debug("Failed to identify any partition table."); return -ENOPKG; } - if (r != 0) { - if (errno == 0) - return -EIO; - - return -errno; - } + if (r != 0) + return -errno ?: -EIO; m = new0(DissectedImage, 1); if (!m) @@ -232,12 +220,8 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI errno = 0; pl = blkid_probe_get_partitions(b); - if (!pl) { - if (errno == 0) - return -ENOMEM; - - return -errno; - } + if (!pl) + return -errno ?: -ENOMEM; udev = udev_new(); if (!udev) diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c index 87b520b540..c3106f1ae9 100644 --- a/src/shared/fstab-util.c +++ b/src/shared/fstab-util.c @@ -213,7 +213,7 @@ static char *unquote(const char *s, const char* quotes) { * trailing quotes if there is one. Doesn't care about * escaping or anything. * - * DON'T USE THIS FOR NEW CODE ANYMORE!*/ + * DON'T USE THIS FOR NEW CODE ANYMORE! */ l = strlen(s); if (l < 2) diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c index d96ff44e66..32a4c67590 100644 --- a/src/shared/machine-image.c +++ b/src/shared/machine-image.c @@ -636,7 +636,7 @@ int image_clone(Image *i, const char *new_name, bool read_only) { case IMAGE_SUBVOLUME: case IMAGE_DIRECTORY: /* If we can we'll always try to create a new btrfs subvolume here, even if the source is a plain - * directory.*/ + * directory. */ new_path = strjoina("/var/lib/machines/", new_name); @@ -712,7 +712,7 @@ int image_read_only(Image *i, bool b) { use the "immutable" flag, to at least make the top-level directory read-only. It's not as good as a read-only subvolume, but at least something, and - we can read the value back.*/ + we can read the value back. */ r = chattr_path(i->path, b ? FS_IMMUTABLE_FL : 0, FS_IMMUTABLE_FL); if (r < 0) diff --git a/src/test/test-dns-domain.c b/src/test/test-dns-domain.c index b4db4a6702..a7cd8e4b51 100644 --- a/src/test/test-dns-domain.c +++ b/src/test/test-dns-domain.c @@ -373,16 +373,16 @@ static void test_dns_name_is_valid(void) { test_dns_name_is_valid_one("รค", 1); test_dns_name_is_valid_one("\n", 0); - /* 256 characters*/ + /* 256 characters */ test_dns_name_is_valid_one("a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345", 0); - /* 255 characters*/ + /* 255 characters */ test_dns_name_is_valid_one("a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a1234", 0); - /* 254 characters*/ + /* 254 characters */ test_dns_name_is_valid_one("a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a123", 0); - /* 253 characters*/ + /* 253 characters */ test_dns_name_is_valid_one("a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12345678.a12", 1); /* label of 64 chars length */ diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 08a138b1b2..7326597b8c 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -872,7 +872,7 @@ static int parse_attribute_from_arg(Item *item) { { 's', FS_SECRM_FL }, /* Secure deletion */ { 'u', FS_UNRM_FL }, /* Undelete */ { 't', FS_NOTAIL_FL }, /* file tail should not be merged */ - { 'T', FS_TOPDIR_FL }, /* Top of directory hierarchies*/ + { 'T', FS_TOPDIR_FL }, /* Top of directory hierarchies */ { 'C', FS_NOCOW_FL }, /* Do not cow file */ }; diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index 3c58445836..9037aa1304 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -122,7 +122,7 @@ static int find_gpt_root(struct udev_device *dev, blkid_probe pr, bool test) { errno = 0; pl = blkid_probe_get_partitions(pr); if (!pl) - return errno > 0 ? -errno : -ENOMEM; + return -errno ?: -ENOMEM; nvals = blkid_partlist_numof_partitions(pl); for (i = 0; i < nvals; i++) { @@ -193,7 +193,7 @@ static int probe_superblocks(blkid_probe pr) { int rc; if (fstat(blkid_probe_get_fd(pr), &st)) - return -1; + return -errno; blkid_probe_enable_partitions(pr, 1); |