diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-11-14 20:09:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-14 20:09:39 +0100 |
commit | 042cad5737917e6964ddddba72b8fcc0cb890877 (patch) | |
tree | 7085fa0272983217e94d5ce8f84cd5056d6ece31 /src | |
parent | 3dafa6bc7636451e49565f6260c531c0304285f6 (diff) | |
parent | 84afbbcf242aef2a7ff5449be84a98e315cd4b10 (diff) | |
download | systemd-042cad5737917e6964ddddba72b8fcc0cb890877.tar.gz |
Merge pull request #10753 from keszybz/pager-no-interrupt
Add mode in journalctl where ^C is handled by the pager
Diffstat (limited to 'src')
53 files changed, 202 insertions, 164 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index b5be346eff..0c53a8e21f 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -66,7 +66,7 @@ static enum dot { static char** arg_dot_from_patterns = NULL; static char** arg_dot_to_patterns = NULL; static usec_t arg_fuzz = 0; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; static const char *arg_host = NULL; static UnitFileScope arg_scope = UNIT_FILE_SYSTEM; @@ -1023,7 +1023,7 @@ static int analyze_critical_chain(int argc, char *argv[], void *userdata) { } unit_times_hashmap = h; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); puts("The time after the unit is active or started is printed after the \"@\" character.\n" "The time the unit takes to start is printed after the \"+\" character.\n"); @@ -1055,7 +1055,7 @@ static int analyze_blame(int argc, char *argv[], void *userdata) { typesafe_qsort(times, n, compare_unit_time); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); for (u = times; u->has_data; u++) { char ts[FORMAT_TIMESPAN_MAX]; @@ -1303,7 +1303,7 @@ static int dump(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to create bus connection: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (!sd_bus_can_send(bus, SD_BUS_TYPE_UNIX_FD)) return dump_fallback(bus); @@ -1337,7 +1337,7 @@ static int cat_config(int argc, char *argv[], void *userdata) { char **arg; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); STRV_FOREACH(arg, argv + 1) { const char *t = NULL; @@ -1509,7 +1509,7 @@ static void dump_syscall_filter(const SyscallFilterSet *set) { static int dump_syscall_filters(int argc, char *argv[], void *userdata) { bool first = true; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (strv_isempty(strv_skip(argv, 1))) { int i; @@ -1696,7 +1696,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = terminal_urlify_man("systemd-analyze", "1", &link); if (r < 0) @@ -1841,7 +1841,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case 'H': diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c index c517c52995..7ca8f06234 100644 --- a/src/backlight/backlight.c +++ b/src/backlight/backlight.c @@ -3,7 +3,6 @@ #include "sd-device.h" #include "alloc-util.h" -#include "def.h" #include "device-util.h" #include "escape.h" #include "fileio.h" diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h index c2bf487ab3..9b410f1f58 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -9,8 +9,6 @@ #include <sys/types.h> #include "def.h" -#include "hashmap.h" -#include "macro.h" #include "set.h" #define SYSTEMD_CGROUP_CONTROLLER_LEGACY "name=systemd" diff --git a/src/basic/clock-util.c b/src/basic/clock-util.c index b77e780bed..1877a81434 100644 --- a/src/basic/clock-util.c +++ b/src/basic/clock-util.c @@ -12,7 +12,6 @@ #include "alloc-util.h" #include "clock-util.h" -#include "def.h" #include "fd-util.h" #include "fileio.h" #include "macro.h" diff --git a/src/basic/def.h b/src/basic/def.h index 005cd8d090..5be018d82e 100644 --- a/src/basic/def.h +++ b/src/basic/def.h @@ -74,6 +74,4 @@ "/usr/lib/" n \ _CONF_PATHS_SPLIT_USR(n)) -#define LONG_LINE_MAX (1U*1024U*1024U) - #define HIGH_RLIMIT_MEMLOCK (1024ULL*1024ULL*64ULL) diff --git a/src/basic/exec-util.c b/src/basic/exec-util.c index 2a96ecf9bb..031a99afc1 100644 --- a/src/basic/exec-util.c +++ b/src/basic/exec-util.c @@ -9,7 +9,6 @@ #include "alloc-util.h" #include "conf-files.h" -#include "def.h" #include "env-util.h" #include "exec-util.h" #include "fd-util.h" diff --git a/src/basic/fileio.c b/src/basic/fileio.c index fa6084e602..dc12d0e07f 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -15,7 +15,6 @@ #include "alloc-util.h" #include "ctype.h" -#include "def.h" #include "env-util.h" #include "escape.h" #include "fd-util.h" diff --git a/src/basic/fileio.h b/src/basic/fileio.h index f809848408..a9e0c2526f 100644 --- a/src/basic/fileio.h +++ b/src/basic/fileio.h @@ -10,6 +10,8 @@ #include "macro.h" #include "time-util.h" +#define LONG_LINE_MAX (1U*1024U*1024U) + typedef enum { WRITE_STRING_FILE_CREATE = 1 << 0, WRITE_STRING_FILE_ATOMIC = 1 << 1, diff --git a/src/basic/hostname-util.c b/src/basic/hostname-util.c index 09fabe077b..3a3479910d 100644 --- a/src/basic/hostname-util.c +++ b/src/basic/hostname-util.c @@ -8,7 +8,6 @@ #include <unistd.h> #include "alloc-util.h" -#include "def.h" #include "fd-util.h" #include "fileio.h" #include "hostname-util.h" diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c index 358c8a9143..ec607c7360 100644 --- a/src/basic/mount-util.c +++ b/src/basic/mount-util.c @@ -13,7 +13,6 @@ #include <libmount.h> #include "alloc-util.h" -#include "def.h" #include "escape.h" #include "extract-word.h" #include "fd-util.h" diff --git a/src/basic/pager.c b/src/basic/pager.c index 7d698666e9..88d9ef349e 100644 --- a/src/basic/pager.c +++ b/src/basic/pager.c @@ -12,6 +12,8 @@ #include "copy.h" #include "fd-util.h" +#include "fileio.h" +#include "io-util.h" #include "locale-util.h" #include "log.h" #include "macro.h" @@ -41,13 +43,50 @@ _noreturn_ static void pager_fallback(void) { _exit(EXIT_SUCCESS); } -int pager_open(bool no_pager, bool jump_to_end) { - _cleanup_close_pair_ int fd[2] = { -1, -1 }; +static int no_quit_on_interrupt(int exe_name_fd, const char *less_opts) { + _cleanup_fclose_ FILE *file = NULL; + _cleanup_free_ char *line = NULL; + int r; + + assert(exe_name_fd >= 0); + assert(less_opts); + + /* This takes ownership of exe_name_fd */ + file = fdopen(exe_name_fd, "r"); + if (!file) { + safe_close(exe_name_fd); + return log_debug_errno(errno, "Failed to create FILE object: %m"); + } + + /* Find the last line */ + for (;;) { + _cleanup_free_ char *t = NULL; + + r = read_line(file, LONG_LINE_MAX, &t); + if (r < 0) + return r; + if (r == 0) + break; + + free_and_replace(line, t); + } + + /* We only treat "less" specially. + * Return true whenever option K is *not* set. */ + r = streq_ptr(line, "less") && !strchr(less_opts, 'K'); + + log_debug("Pager executable is \"%s\", options \"%s\", quit_on_interrupt: %s", + strnull(line), less_opts, yes_no(!r)); + return r; +} + +int pager_open(PagerFlags flags) { + _cleanup_close_pair_ int fd[2] = { -1, -1 }, exe_name_pipe[2] = { -1, -1 }; _cleanup_strv_free_ char **pager_args = NULL; - const char *pager; + const char *pager, *less_opts; int r; - if (no_pager) + if (flags & PAGER_DISABLE) return 0; if (pager_pid > 0) @@ -81,23 +120,28 @@ int pager_open(bool no_pager, bool jump_to_end) { if (pipe2(fd, O_CLOEXEC) < 0) return log_error_errno(errno, "Failed to create pager pipe: %m"); + /* This is a pipe to feed the name of the executed pager binary into the parent */ + if (pipe2(exe_name_pipe, O_CLOEXEC) < 0) + return log_error_errno(errno, "Failed to create exe_name pipe: %m"); + + /* Initialize a good set of less options */ + less_opts = getenv("SYSTEMD_LESS"); + if (!less_opts) + less_opts = "FRSXMK"; + if (flags & PAGER_JUMP_TO_END) + less_opts = strjoina(less_opts, " +G"); + r = safe_fork("(pager)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pager_pid); if (r < 0) return r; if (r == 0) { - const char* less_opts, *less_charset; + const char *less_charset, *exe; /* In the child start the pager */ (void) dup2(fd[0], STDIN_FILENO); safe_close_pair(fd); - /* Initialize a good set of less options */ - less_opts = getenv("SYSTEMD_LESS"); - if (!less_opts) - less_opts = "FRSXMK"; - if (jump_to_end) - less_opts = strjoina(less_opts, " +G"); if (setenv("LESS", less_opts, 1) < 0) _exit(EXIT_FAILURE); @@ -111,8 +155,12 @@ int pager_open(bool no_pager, bool jump_to_end) { setenv("LESSCHARSET", less_charset, 1) < 0) _exit(EXIT_FAILURE); - if (pager_args) + if (pager_args) { + if (loop_write(exe_name_pipe[1], pager_args[0], strlen(pager_args[0]) + 1, false) < 0) + _exit(EXIT_FAILURE); + execvp(pager_args[0], pager_args); + } /* Debian's alternatives command for pagers is * called 'pager'. Note that we do not call @@ -120,11 +168,14 @@ int pager_open(bool no_pager, bool jump_to_end) { * shell script that implements a logic that * is similar to this one anyway, but is * Debian-specific. */ - execlp("pager", "pager", NULL); - - execlp("less", "less", NULL); - execlp("more", "more", NULL); + FOREACH_STRING(exe, "pager", "less", "more") { + if (loop_write(exe_name_pipe[1], exe, strlen(exe) + 1, false) < 0) + _exit(EXIT_FAILURE); + execlp(exe, exe, NULL); + } + if (loop_write(exe_name_pipe[1], "(built-in)", strlen("(built-in") + 1, false) < 0) + _exit(EXIT_FAILURE); pager_fallback(); /* not reached */ } @@ -144,6 +195,14 @@ int pager_open(bool no_pager, bool jump_to_end) { } stderr_redirected = true; + exe_name_pipe[1] = safe_close(exe_name_pipe[1]); + + r = no_quit_on_interrupt(TAKE_FD(exe_name_pipe[0]), less_opts); + if (r < 0) + return r; + if (r > 0) + (void) ignore_signals(SIGINT, -1); + return 1; } diff --git a/src/basic/pager.h b/src/basic/pager.h index e0fd34af97..8299e23856 100644 --- a/src/basic/pager.h +++ b/src/basic/pager.h @@ -5,7 +5,12 @@ #include "macro.h" -int pager_open(bool no_pager, bool jump_to_end); +typedef enum PagerFlags { + PAGER_DISABLE = 1 << 0, + PAGER_JUMP_TO_END = 1 << 1, +} PagerFlags; + +int pager_open(PagerFlags flags); void pager_close(void); bool pager_have(void) _pure_; diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 572d7eb38d..b3f69b2542 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -25,7 +25,6 @@ #include "alloc-util.h" #include "architecture.h" -#include "def.h" #include "escape.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 151ac954ad..30ad83d0a7 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -14,7 +14,6 @@ #include <unistd.h> #include "alloc-util.h" -#include "def.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" diff --git a/src/basic/virt.c b/src/basic/virt.c index e05b3e6d99..f63f15f6c1 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -11,7 +11,6 @@ #include "alloc-util.h" #include "dirent-util.h" -#include "def.h" #include "env-util.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c index 0dd202d086..9cead4a87c 100644 --- a/src/binfmt/binfmt.c +++ b/src/binfmt/binfmt.c @@ -22,7 +22,7 @@ #include "util.h" static bool arg_cat_config = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static int delete_rule(const char *rule) { _cleanup_free_ char *x = NULL, *fn = NULL; @@ -160,7 +160,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case '?': @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) { } if (arg_cat_config) { - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = cat_files(NULL, files, 0); goto finish; diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index d1aee188eb..7a20965b6a 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -45,7 +45,7 @@ static char *arg_path = NULL; static bool arg_print_path = false; static bool arg_touch_variables = true; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static int acquire_esp( bool unprivileged_mode, @@ -923,7 +923,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case '?': @@ -965,7 +965,7 @@ static int verb_status(int argc, char *argv[], void *userdata) { r = 0; /* If we couldn't determine the path, then don't consider that a problem from here on, just show what we * can show */ - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (is_efi_boot()) { _cleanup_free_ char *fw_type = NULL, *fw_info = NULL, *loader = NULL, *loader_path = NULL, *stub = NULL; @@ -1054,7 +1054,7 @@ static int verb_list(int argc, char *argv[], void *userdata) { else { size_t n; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); printf("Boot Loader Entries:\n"); diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 9c872ff0aa..2c0f48c437 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -33,7 +33,7 @@ static enum { JSON_SHORT, JSON_PRETTY, } arg_json = JSON_OFF; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; static const char *arg_address = NULL; static bool arg_unique = false; @@ -155,7 +155,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to list names: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); names = hashmap_new(&string_hash_ops); if (!names) @@ -470,7 +470,7 @@ static int tree_one(sd_bus *bus, const char *service, const char *prefix, bool m p = NULL; } - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); l = set_get_strv(done); if (!l) @@ -504,7 +504,7 @@ static int tree(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to get name list: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); STRV_FOREACH(i, names) { int q; @@ -534,7 +534,7 @@ static int tree(int argc, char **argv, void *userdata) { printf("\n"); if (argv[2]) { - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal()); } @@ -1033,7 +1033,7 @@ static int introspect(int argc, char **argv, void *userdata) { return bus_log_parse_error(r); } - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); name_width = STRLEN("NAME"); type_width = STRLEN("TYPE"); @@ -1967,7 +1967,7 @@ static int call(int argc, char **argv, void *userdata) { _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; if (arg_json != JSON_SHORT) - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = json_transform_message(reply, &v); if (r < 0) @@ -1976,7 +1976,7 @@ static int call(int argc, char **argv, void *userdata) { json_dump_with_flags(v, stdout); } else if (arg_verbose) { - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = bus_message_dump(reply, stdout, 0); if (r < 0) @@ -2028,7 +2028,7 @@ static int get_property(int argc, char **argv, void *userdata) { _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; if (arg_json != JSON_SHORT) - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = json_transform_variant(reply, contents, &v); if (r < 0) @@ -2037,7 +2037,7 @@ static int get_property(int argc, char **argv, void *userdata) { json_dump_with_flags(v, stdout); } else if (arg_verbose) { - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = bus_message_dump(reply, stdout, BUS_MESSAGE_DUMP_SUBTREE_ONLY); if (r < 0) @@ -2240,7 +2240,7 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c index 58d72b51a2..476641c481 100644 --- a/src/cgls/cgls.c +++ b/src/cgls/cgls.c @@ -22,7 +22,7 @@ #include "unit-name.h" #include "util.h" -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_kernel_threads = false; static bool arg_all = false; @@ -99,7 +99,7 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case 'a': @@ -170,7 +170,7 @@ int main(int argc, char *argv[]) { if (r <= 0) goto finish; - r = pager_open(arg_no_pager, false); + r = pager_open(arg_pager_flags); if (r > 0 && arg_full < 0) arg_full = true; diff --git a/src/core/ima-setup.c b/src/core/ima-setup.c index d9e5cf4f05..fd7c5f64af 100644 --- a/src/core/ima-setup.c +++ b/src/core/ima-setup.c @@ -8,7 +8,6 @@ #include <unistd.h> #include "alloc-util.h" -#include "def.h" #include "fd-util.h" #include "fileio.h" #include "ima-setup.h" diff --git a/src/core/main.c b/src/core/main.c index a866160d76..11537c8140 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -98,7 +98,7 @@ static bool arg_crash_reboot = false; static char *arg_confirm_spawn = NULL; static ShowStatus arg_show_status = _SHOW_STATUS_INVALID; static bool arg_switched_root = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_service_watchdogs = true; static char ***arg_join_controllers = NULL; static ExecOutput arg_default_std_output = EXEC_OUTPUT_JOURNAL; @@ -922,7 +922,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_VERSION: @@ -2448,7 +2448,7 @@ int main(int argc, char *argv[]) { goto finish; if (IN_SET(arg_action, ACTION_TEST, ACTION_HELP, ACTION_DUMP_CONFIGURATION_ITEMS, ACTION_DUMP_BUS_PROPERTIES)) - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (arg_action != ACTION_RUN) skip_setup = true; diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c index 4e9506f09c..4bb2051aa3 100644 --- a/src/core/smack-setup.c +++ b/src/core/smack-setup.c @@ -14,7 +14,6 @@ #include <string.h> #include "alloc-util.h" -#include "def.h" #include "dirent-util.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index 49df8656b6..6160b4bf7a 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -43,7 +43,7 @@ static usec_t arg_since = USEC_INFINITY, arg_until = USEC_INFINITY; static const char* arg_field = NULL; static const char *arg_debugger = NULL; static const char *arg_directory = NULL; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static int arg_no_legend = false; static int arg_one = false; static FILE* arg_output = NULL; @@ -211,7 +211,7 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: @@ -659,7 +659,7 @@ static int dump_list(int argc, char **argv, void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); /* The coredumps are likely to compressed, and for just * listing them we don't need to decompress them, so let's diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index 45231bf527..85ace5379c 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -4,7 +4,6 @@ #include <stdio_ext.h> #include "alloc-util.h" -#include "def.h" #include "dropin.h" #include "escape.h" #include "fd-util.h" diff --git a/src/delta/delta.c b/src/delta/delta.c index 0cda1df2a3..399d438667 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -52,7 +52,7 @@ static const char have_dropins[] = "systemd/system\0" "systemd/user\0"; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static int arg_diff = -1; static enum { @@ -596,7 +596,7 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case 't': { @@ -654,7 +654,7 @@ int main(int argc, char *argv[]) { else if (arg_diff) arg_flags |= SHOW_OVERRIDDEN; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (optind < argc) { int i; diff --git a/src/journal/catalog.c b/src/journal/catalog.c index 82c35d1d09..3c8f2f92be 100644 --- a/src/journal/catalog.c +++ b/src/journal/catalog.c @@ -13,7 +13,6 @@ #include "alloc-util.h" #include "catalog.h" #include "conf-files.h" -#include "def.h" #include "fd-util.h" #include "fileio.h" #include "hashmap.h" diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 8c9a6106df..e5a5acde8d 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -104,11 +104,10 @@ enum { static OutputMode arg_output = OUTPUT_SHORT; static bool arg_utc = false; -static bool arg_pager_end = false; static bool arg_follow = false; static bool arg_full = true; static bool arg_all = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static int arg_lines = ARG_LINES_DEFAULT; static bool arg_no_tail = false; static bool arg_quiet = false; @@ -298,7 +297,7 @@ static int help(void) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_no_pager, arg_pager_end); + (void) pager_open(arg_pager_flags); r = terminal_urlify_man("journalctl", "1", &link); if (r < 0) @@ -492,11 +491,11 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case 'e': - arg_pager_end = true; + arg_pager_flags |= PAGER_JUMP_TO_END; if (arg_lines == ARG_LINES_DEFAULT) arg_lines = 1000; @@ -1326,7 +1325,7 @@ static int list_boots(sd_journal *j) { if (count == 0) return count; - (void) pager_open(arg_no_pager, arg_pager_end); + (void) pager_open(arg_pager_flags); /* numbers are one less, but we need an extra char for the sign */ w = DECIMAL_STR_WIDTH(count - 1) + 1; @@ -2127,7 +2126,7 @@ int main(int argc, char *argv[]) { } else { bool oneline = arg_action == ACTION_LIST_CATALOG; - (void) pager_open(arg_no_pager, arg_pager_end); + (void) pager_open(arg_pager_flags); if (optind < argc) r = catalog_list_items(stdout, database, oneline, argv + optind); @@ -2495,7 +2494,7 @@ int main(int argc, char *argv[]) { need_seek = true; if (!arg_follow) - (void) pager_open(arg_no_pager, arg_pager_end); + (void) pager_open(arg_pager_flags); if (!arg_quiet && (arg_lines != 0 || arg_follow)) { usec_t start, end; diff --git a/src/libsystemd/sd-hwdb/hwdb-util.c b/src/libsystemd/sd-hwdb/hwdb-util.c index 140ea6b591..87259daadc 100644 --- a/src/libsystemd/sd-hwdb/hwdb-util.c +++ b/src/libsystemd/sd-hwdb/hwdb-util.c @@ -5,7 +5,6 @@ #include "alloc-util.h" #include "conf-files.h" -#include "def.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" diff --git a/src/libsystemd/sd-path/sd-path.c b/src/libsystemd/sd-path/sd-path.c index d590c90f2e..9949c23802 100644 --- a/src/libsystemd/sd-path/sd-path.c +++ b/src/libsystemd/sd-path/sd-path.c @@ -4,7 +4,6 @@ #include "alloc-util.h" #include "architecture.h" -#include "def.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" diff --git a/src/locale/localectl.c b/src/locale/localectl.c index e2a9415138..44e3f13db8 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -24,7 +24,7 @@ #include "verbs.h" #include "virt.h" -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_ask_password = true; static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; static char *arg_host = NULL; @@ -199,7 +199,7 @@ static int list_locales(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to read list of locales: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); strv_print(l); return 0; @@ -241,7 +241,7 @@ static int list_vconsole_keymaps(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to read list of keymaps: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); strv_print(l); @@ -373,7 +373,7 @@ static int list_x11_keymaps(int argc, char **argv, void *userdata) { strv_sort(list); strv_uniq(list); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); strv_print(list); return 0; @@ -461,7 +461,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_ASK_PASSWORD: diff --git a/src/login/inhibit.c b/src/login/inhibit.c index 8fe64b9184..22fee49a2b 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -26,7 +26,7 @@ static const char* arg_what = "idle:sleep:shutdown"; static const char* arg_who = NULL; static const char* arg_why = "Unknown reason"; static const char* arg_mode = NULL; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; static enum { @@ -68,7 +68,7 @@ static int print_inhibitors(sd_bus *bus) { _cleanup_(table_unrefp) Table *table = NULL; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method( bus, @@ -241,7 +241,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 2a3289951a..d6250253d6 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -38,7 +38,7 @@ static char **arg_property = NULL; static bool arg_all = false; static bool arg_value = false; static bool arg_full = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; static const char *arg_kill_who = NULL; static int arg_signal = SIGTERM; @@ -122,7 +122,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) { assert(bus); assert(argv); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method( bus, @@ -203,7 +203,7 @@ static int list_users(int argc, char *argv[], void *userdata) { assert(bus); assert(argv); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method( bus, @@ -260,7 +260,7 @@ static int list_seats(int argc, char *argv[], void *userdata) { assert(bus); assert(argv); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method( bus, @@ -836,7 +836,7 @@ static int show_session(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (argc <= 1) { const char *session, *p = "/org/freedesktop/login1/session/self"; @@ -885,7 +885,7 @@ static int show_user(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (argc <= 1) { /* If not argument is specified inspect the manager @@ -943,7 +943,7 @@ static int show_seat(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (argc <= 1) { /* If not argument is specified inspect the manager @@ -1284,7 +1284,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = terminal_urlify_man("loginctl", "1", &link); if (r < 0) @@ -1435,7 +1435,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index d408d80c14..5dd46fc4a7 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -57,7 +57,7 @@ static char **arg_property = NULL; static bool arg_all = false; static bool arg_value = false; static bool arg_full = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; static const char *arg_kill_who = NULL; static int arg_signal = SIGTERM; @@ -278,7 +278,7 @@ static int list_machines(int argc, char *argv[], void *userdata) { assert(bus); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method(bus, "org.freedesktop.machine1", @@ -358,7 +358,7 @@ static int list_images(int argc, char *argv[], void *userdata) { assert(bus); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method(bus, "org.freedesktop.machine1", @@ -753,7 +753,7 @@ static int show_machine(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (properties && argc <= 1) { @@ -1091,7 +1091,7 @@ static int show_image(int argc, char *argv[], void *userdata) { properties = !strstr(argv[0], "status"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (argc <= 1) { @@ -2396,7 +2396,7 @@ static int list_transfers(int argc, char *argv[], void *userdata) { double progress; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_call_method(bus, "org.freedesktop.import1", @@ -2612,7 +2612,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = terminal_urlify_man("machinectl", "1", &link); if (r < 0) @@ -2852,7 +2852,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index 988dbc5fbd..62b910b487 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -36,7 +36,7 @@ enum { } arg_action = ACTION_DEFAULT; static bool arg_no_block = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_ask_password = true; static bool arg_quiet = false; static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; @@ -177,7 +177,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_ASK_PASSWORD: @@ -1485,7 +1485,7 @@ static int list_devices(void) { typesafe_qsort(items, n, compare_item); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); fputs(ansi_underline(), stdout); for (c = 0; c < _COLUMN_MAX; c++) { diff --git a/src/network/networkctl.c b/src/network/networkctl.c index c4a8fc8bc4..b557a64e4a 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -34,7 +34,7 @@ #include "util.h" #include "verbs.h" -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; static bool arg_all = false; @@ -248,7 +248,7 @@ static int list_links(int argc, char *argv[], void *userdata) { if (c < 0) return c; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (arg_legend) printf("%3s %-16s %-18s %-11s %-10s\n", @@ -874,7 +874,7 @@ static int link_status(int argc, char *argv[], void *userdata) { _cleanup_free_ LinkInfo *links = NULL; int r, c, i; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_netlink_open(&rtnl); if (r < 0) @@ -970,7 +970,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) { if (c < 0) return c; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (arg_legend) printf("%-16s %-17s %-16s %-11s %-17s %-16s\n", @@ -1121,7 +1121,7 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 621968ef8e..cd986379b6 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -207,7 +207,7 @@ static int help(void) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(false, false); + (void) pager_open(false); r = terminal_urlify_man("systemd-nspawn", "1", &link); if (r < 0) diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 21e66def50..ff402151e9 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -25,7 +25,7 @@ #include "terminal-util.h" #include "verbs.h" -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_legend = true; static bool arg_ask_password = true; static bool arg_quiet = false; @@ -263,7 +263,7 @@ static int inspect_image(int argc, char *argv[], void *userdata) { if (r < 0) return bus_log_parse_error(r); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (arg_cat) { printf("%s-- OS Release: --%s\n", ansi_highlight(), ansi_normal()); @@ -776,7 +776,7 @@ static int help(int argc, char *argv[], void *userdata) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = terminal_urlify_man("portablectl", "1", &link); if (r < 0) @@ -866,7 +866,7 @@ static int parse_argv(int argc, char *argv[]) { return version(); case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_LEGEND: diff --git a/src/reply-password/reply-password.c b/src/reply-password/reply-password.c index 122047ffff..bec754f7be 100644 --- a/src/reply-password/reply-password.c +++ b/src/reply-password/reply-password.c @@ -7,7 +7,6 @@ #include <sys/un.h> #include "alloc-util.h" -#include "def.h" #include "fd-util.h" #include "fileio.h" #include "log.h" diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c index 9792750fbf..44fa8ee62c 100644 --- a/src/resolve/resolvectl.c +++ b/src/resolve/resolvectl.c @@ -34,7 +34,7 @@ static uint16_t arg_type = 0; static uint16_t arg_class = 0; static bool arg_legend = true; static uint64_t arg_flags = 0; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; bool arg_ifindex_permissive = false; /* If true, don't generate an error if the specified interface index doesn't exist */ static const char *arg_service_family = NULL; @@ -1438,7 +1438,7 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode if (r < 0) return log_error_errno(r, "Failed to get link data for %i: %s", ifindex, bus_error_message(&error, r)); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (mode == STATUS_DNS) return status_print_strv_ifindex(ifindex, name, link_info.dns); @@ -1684,7 +1684,7 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) { if (r < 0) return log_error_errno(r, "Failed to get global data: %s", bus_error_message(&error, r)); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); if (mode == STATUS_DNS) return status_print_strv_global(global_info.dns); @@ -2657,7 +2657,7 @@ static int compat_parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_SET_DNS: @@ -2917,7 +2917,7 @@ static int native_parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case '?': diff --git a/src/resolve/resolved-etc-hosts.c b/src/resolve/resolved-etc-hosts.c index 8074612fb4..00ff20d2dc 100644 --- a/src/resolve/resolved-etc-hosts.c +++ b/src/resolve/resolved-etc-hosts.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ -#include "def.h" #include "fd-util.h" #include "fileio.h" #include "hostname-util.h" diff --git a/src/resolve/resolved-resolv-conf.c b/src/resolve/resolved-resolv-conf.c index 6b74daf776..f8b5301c1e 100644 --- a/src/resolve/resolved-resolv-conf.c +++ b/src/resolve/resolved-resolv-conf.c @@ -4,7 +4,6 @@ #include <stdio_ext.h> #include "alloc-util.h" -#include "def.h" #include "dns-domain.h" #include "fd-util.h" #include "fileio-label.h" diff --git a/src/shared/clean-ipc.c b/src/shared/clean-ipc.c index f9b05ff924..46fa68027e 100644 --- a/src/shared/clean-ipc.c +++ b/src/shared/clean-ipc.c @@ -16,7 +16,6 @@ #include <unistd.h> #include "clean-ipc.h" -#include "def.h" #include "dirent-util.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/shared/install.c b/src/shared/install.c index d08d0af7b5..1fd24cb4eb 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -15,7 +15,6 @@ #include "alloc-util.h" #include "conf-files.h" #include "conf-parser.h" -#include "def.h" #include "dirent-util.h" #include "extract-word.h" #include "fd-util.h" diff --git a/src/shared/serialize.c b/src/shared/serialize.c index 3a6f8f60eb..d0f86a83f4 100644 --- a/src/shared/serialize.c +++ b/src/shared/serialize.c @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #include "alloc-util.h" -#include "def.h" #include "env-util.h" #include "escape.h" +#include "fileio.h" #include "parse-util.h" #include "serialize.h" #include "strv.h" diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index 945ae3746b..9419f7bd73 100644 --- a/src/sysctl/sysctl.c +++ b/src/sysctl/sysctl.c @@ -24,7 +24,7 @@ static char **arg_prefixes = NULL; static bool arg_cat_config = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static int apply_all(OrderedHashmap *sysctl_options) { char *property, *value; @@ -243,7 +243,7 @@ static int parse_argv(int argc, char *argv[]) { } case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case '?': @@ -302,7 +302,7 @@ int main(int argc, char *argv[]) { } if (arg_cat_config) { - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = cat_files(NULL, files, 0); goto finish; diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 9d0c40b93c..a18fb598fd 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -113,7 +113,7 @@ static UnitFileScope arg_scope = UNIT_FILE_SYSTEM; static bool arg_wait = false; static bool arg_no_block = false; static bool arg_no_legend = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_no_wtmp = false; static bool arg_no_sync = false; static bool arg_no_wall = false; @@ -391,6 +391,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) { const UnitInfo *u; unsigned n_shown = 0; int job_count = 0; + bool full = arg_full || FLAGS_SET(arg_pager_flags, PAGER_DISABLE); max_id_len = STRLEN("UNIT"); load_len = STRLEN("LOAD"); @@ -476,7 +477,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) { printf("%-*.*s%s\n", desc_len, - !arg_full && arg_no_pager ? (int) desc_len : -1, + full ? -1 : (int) desc_len, "DESCRIPTION", ansi_normal()); } @@ -534,7 +535,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) { printf("%-*.*s%s\n", desc_len, - !arg_full && arg_no_pager ? (int) desc_len : -1, + full ? -1 : (int) desc_len, u->description, off_underline); } @@ -749,7 +750,7 @@ static int list_units(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = get_unit_list_recursive(bus, strv_skip(argv, 1), &unit_infos, &replies, &machines); if (r < 0) @@ -961,7 +962,7 @@ static int list_sockets(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); n = get_unit_list_recursive(bus, strv_skip(argv, 1), &unit_infos, &replies, &machines); if (n < 0) @@ -1266,7 +1267,7 @@ static int list_timers(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); n = get_unit_list_recursive(bus, strv_skip(argv, 1), &unit_infos, &replies, &machines); if (n < 0) @@ -1551,7 +1552,7 @@ static int list_unit_files(int argc, char *argv[], void *userdata) { return bus_log_parse_error(r); } - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); typesafe_qsort(units, c, compare_unit_file_list); output_unit_file_list(units, c); @@ -1785,7 +1786,7 @@ static int list_dependencies(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); puts(u); @@ -2025,7 +2026,7 @@ static int list_machines(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); typesafe_qsort(machine_infos, r, compare_machine_info); output_machines_list(machine_infos, r); @@ -2197,7 +2198,7 @@ static void output_jobs_list(sd_bus *bus, const struct job_info* jobs, unsigned return; } - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); id_len = STRLEN("JOB"); unit_len = STRLEN("UNIT"); @@ -2312,7 +2313,7 @@ static int list_jobs(int argc, char *argv[], void *userdata) { if (r < 0) return bus_log_parse_error(r); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); output_jobs_list(bus, jobs, c, skipped); return 0; @@ -5150,7 +5151,7 @@ static int show_all( if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); c = (unsigned) r; @@ -5262,7 +5263,7 @@ static int show(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); /* If no argument is specified inspect the manager itself */ if (show_mode == SYSTEMCTL_SHOW_PROPERTIES && argc <= 1) @@ -5367,7 +5368,7 @@ static int cat(int argc, char *argv[], void *userdata) { if (r < 0) return log_error_errno(r, "Failed to expand names: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); STRV_FOREACH(name, names) { _cleanup_free_ char *fragment_path = NULL; @@ -5644,7 +5645,7 @@ static int show_environment(int argc, char *argv[], void *userdata) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = sd_bus_get_property( bus, @@ -7095,7 +7096,7 @@ static int systemctl_help(void) { _cleanup_free_ char *link = NULL; int r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = terminal_urlify_man("systemctl", "1", &link); if (r < 0) @@ -7656,7 +7657,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_NO_WALL: diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 0c9902adf6..e23360d437 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -62,7 +62,7 @@ static char *arg_root = NULL; static bool arg_cat_config = false; static const char *arg_replace = NULL; static bool arg_inline = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static OrderedHashmap *users = NULL, *groups = NULL; static OrderedHashmap *todo_uids = NULL, *todo_gids = NULL; @@ -1760,7 +1760,7 @@ static int cat_config(void) { if (r < 0) return r; - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); return cat_files(NULL, files, 0); } @@ -1852,7 +1852,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case '?': diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index 1566895ba3..cffaae1286 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -5,7 +5,6 @@ #include <unistd.h> #include "alloc-util.h" -#include "def.h" #include "dirent-util.h" #include "exit-status.h" #include "fd-util.h" diff --git a/src/test/test-env-util.c b/src/test/test-env-util.c index 4c33c7c13c..f57a26021c 100644 --- a/src/test/test-env-util.c +++ b/src/test/test-env-util.c @@ -2,7 +2,6 @@ #include <string.h> -#include "def.h" #include "env-util.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/test/test-serialize.c b/src/test/test-serialize.c index 9a16688a67..e306b1f1d6 100644 --- a/src/test/test-serialize.c +++ b/src/test/test-serialize.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ -#include "def.h" #include "escape.h" #include "fd-util.h" #include "fileio.h" diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index 156a6aae6a..d148b45b38 100644 --- a/src/timedate/timedatectl.c +++ b/src/timedate/timedatectl.c @@ -21,7 +21,7 @@ #include "util.h" #include "verbs.h" -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static bool arg_ask_password = true; static BusTransport arg_transport = BUS_TRANSPORT_LOCAL; static char *arg_host = NULL; @@ -288,7 +288,7 @@ static int list_timezones(int argc, char **argv, void *userdata) { if (r < 0) return log_error_errno(r, "Failed to read list of time zones: %m"); - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); strv_print(zones); return 0; @@ -791,7 +791,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case ARG_MONITOR: diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 7819d96c67..a81cecd2f9 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -153,7 +153,7 @@ static bool arg_create = false; static bool arg_clean = false; static bool arg_remove = false; static bool arg_boot = false; -static bool arg_no_pager = false; +static PagerFlags arg_pager_flags = 0; static char **arg_include_prefixes = NULL; static char **arg_exclude_prefixes = NULL; @@ -2949,7 +2949,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_NO_PAGER: - arg_no_pager = true; + arg_pager_flags |= PAGER_DISABLE; break; case '?': @@ -3147,7 +3147,7 @@ int main(int argc, char *argv[]) { } if (arg_cat_config) { - (void) pager_open(arg_no_pager, false); + (void) pager_open(arg_pager_flags); r = cat_config(config_dirs, argv + optind); goto finish; diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index d582319cf7..dcde65c8ef 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -15,7 +15,6 @@ #include "alloc-util.h" #include "conf-files.h" -#include "def.h" #include "device-private.h" #include "device-util.h" #include "dirent-util.h" |