X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fsystemctl%2Fsystemctl.c;h=b44c6d78ba581757d32a22249407f3267c031384;hp=9c4b9ed277395c0d530f39d5fe23097645ab40ae;hb=8b0cc9a36c8f92f010f2e8465942d2cd7c580d78;hpb=a39b4bdd10fc15654db37459fe8235a3de1ad817 diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 9c4b9ed27..b44c6d78b 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -194,6 +194,15 @@ static void polkit_agent_open_if_enabled(void) { } #endif +static OutputFlags get_output_flags(void) { + return + arg_all * OUTPUT_SHOW_ALL | + arg_full * OUTPUT_FULL_WIDTH | + (!on_tty() || pager_have()) * OUTPUT_FULL_WIDTH | + on_tty() * OUTPUT_COLOR | + !arg_quiet * OUTPUT_WARN_CUTOFF; +} + static int translate_bus_error_to_exit_status(int r, const sd_bus_error *error) { assert(error); @@ -3224,12 +3233,6 @@ static void print_status_info( char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1; char since2[FORMAT_TIMESTAMP_MAX], *s2; const char *path; - int flags = - arg_all * OUTPUT_SHOW_ALL | - (!on_tty() || pager_have()) * OUTPUT_FULL_WIDTH | - on_tty() * OUTPUT_COLOR | - !arg_quiet * OUTPUT_WARN_CUTOFF | - arg_full * OUTPUT_FULL_WIDTH; char **t, **t2; assert(i); @@ -3499,21 +3502,23 @@ static void print_status_info( if (i->control_pid > 0) extra[k++] = i->control_pid; - show_cgroup_and_extra(SYSTEMD_CGROUP_CONTROLLER, i->control_group, prefix, c, false, extra, k, flags); + show_cgroup_and_extra(SYSTEMD_CGROUP_CONTROLLER, i->control_group, prefix, c, false, extra, k, get_output_flags()); } } if (i->id && arg_transport == BUS_TRANSPORT_LOCAL) { - show_journal_by_unit(stdout, - i->id, - arg_output, - 0, - i->inactive_exit_timestamp_monotonic, - arg_lines, - getuid(), - flags | OUTPUT_BEGIN_NEWLINE, - arg_scope == UNIT_FILE_SYSTEM, - ellipsized); + show_journal_by_unit( + stdout, + i->id, + arg_output, + 0, + i->inactive_exit_timestamp_monotonic, + arg_lines, + getuid(), + get_output_flags() | OUTPUT_BEGIN_NEWLINE, + SD_JOURNAL_LOCAL_ONLY, + arg_scope == UNIT_FILE_SYSTEM, + ellipsized); } if (i->need_daemon_reload) @@ -4377,13 +4382,6 @@ static int show_system_status(sd_bus *bus) { printf(" CGroup: %s\n", mi.control_group ?: "/"); if (arg_transport == BUS_TRANSPORT_LOCAL || arg_transport == BUS_TRANSPORT_MACHINE) { - int flags = - arg_all * OUTPUT_SHOW_ALL | - (!on_tty() || pager_have()) * OUTPUT_FULL_WIDTH | - on_tty() * OUTPUT_COLOR | - !arg_quiet * OUTPUT_WARN_CUTOFF | - arg_full * OUTPUT_FULL_WIDTH; - static const char prefix[] = " "; unsigned c; @@ -4393,7 +4391,7 @@ static int show_system_status(sd_bus *bus) { else c = 0; - show_cgroup(SYSTEMD_CGROUP_CONTROLLER, strempty(mi.control_group), prefix, c, false, flags); + show_cgroup(SYSTEMD_CGROUP_CONTROLLER, strempty(mi.control_group), prefix, c, false, get_output_flags()); } free(mi.state); @@ -4515,11 +4513,7 @@ static int init_home_and_lookup_paths(char **user_home, char **user_runtime, Loo return log_error_errno(ENOTDIR, "Cannot find units: $XDG_RUNTIME_DIR is not set."); } - r = lookup_paths_init(lp, - arg_scope == UNIT_FILE_SYSTEM ? SYSTEMD_SYSTEM : SYSTEMD_USER, - arg_scope == UNIT_FILE_USER, - arg_root, - NULL, NULL, NULL); + r = lookup_paths_init_from_scope(lp, arg_scope, arg_root); if (r < 0) return log_error_errno(r, "Failed to lookup unit lookup paths: %m"); @@ -5188,8 +5182,10 @@ static int enable_sysv_units(const char *verb, char **args) { return -EPROTO; /* Remove this entry, so that we don't try enabling it as native unit */ - assert(f > 0 && streq(args[f-1], name)); - assert_se(strv_remove(args + f - 1, name)); + assert(f > 0); + f--; + assert(args[f] == name); + strv_remove(args, name); } #endif @@ -7411,6 +7407,11 @@ int main(int argc, char*argv[]) { goto finish; } + /* Increase max number of open files to 16K if we can, we + * might needs this when browsing journal files, which might + * be split up into many files. */ + setrlimit_closest(RLIMIT_NOFILE, &RLIMIT_MAKE_CONST(16384)); + if (!avoid_bus()) r = bus_open_transport_systemd(arg_transport, arg_host, arg_scope != UNIT_FILE_SYSTEM, &bus);