mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
Merge pull request #34097 from YHNdnzj/journal-browse-prepare
shared/logs-show: introduce journal_browse_prepare()
This commit is contained in:
commit
ce4c4f4c32
@ -29,10 +29,10 @@ static void sigbus_push(void *addr) {
|
||||
assert(addr);
|
||||
|
||||
/* Find a free place, increase the number of entries and leave, if we can */
|
||||
for (size_t u = 0; u < SIGBUS_QUEUE_MAX; u++) {
|
||||
FOREACH_ELEMENT(u, sigbus_queue) {
|
||||
/* OK to initialize this here since we haven't started the atomic ops yet */
|
||||
void *tmp = NULL;
|
||||
if (__atomic_compare_exchange_n(&sigbus_queue[u], &tmp, addr, false,
|
||||
if (__atomic_compare_exchange_n(u, &tmp, addr, false,
|
||||
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
|
||||
__atomic_fetch_add(&n_sigbus_queue, 1, __ATOMIC_SEQ_CST);
|
||||
return;
|
||||
@ -102,7 +102,7 @@ static void sigbus_handler(int sn, siginfo_t *si, void *data) {
|
||||
assert(si);
|
||||
|
||||
if (si->si_code != BUS_ADRERR || !si->si_addr) {
|
||||
assert_se(sigaction(SIGBUS, &old_sigaction, NULL) == 0);
|
||||
assert_se(sigaction(SIGBUS, &old_sigaction, NULL) >= 0);
|
||||
propagate_signal(sn, si);
|
||||
return;
|
||||
}
|
||||
@ -133,7 +133,7 @@ void sigbus_install(void) {
|
||||
n_installed++;
|
||||
|
||||
if (n_installed == 1)
|
||||
assert_se(sigaction(SIGBUS, &sa, &old_sigaction) == 0);
|
||||
assert_se(sigaction(SIGBUS, &sa, &old_sigaction) >= 0);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -146,7 +146,7 @@ void sigbus_reset(void) {
|
||||
n_installed--;
|
||||
|
||||
if (n_installed == 0)
|
||||
assert_se(sigaction(SIGBUS, &old_sigaction, NULL) == 0);
|
||||
assert_se(sigaction(SIGBUS, &old_sigaction, NULL) >= 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "journal-util.h"
|
||||
#include "json-util.h"
|
||||
#include "log.h"
|
||||
#include "logs-show.h"
|
||||
#include "macro.h"
|
||||
#include "main-func.h"
|
||||
#include "mount-util.h"
|
||||
@ -39,7 +40,6 @@
|
||||
#include "pretty-print.h"
|
||||
#include "process-util.h"
|
||||
#include "rlimit-util.h"
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
@ -1378,14 +1378,11 @@ static int run(int argc, char *argv[]) {
|
||||
setlocale(LC_ALL, "");
|
||||
log_setup();
|
||||
|
||||
/* The journal merging logic potentially needs a lot of fds. */
|
||||
(void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
|
||||
|
||||
r = parse_argv(argc, argv);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
sigbus_install();
|
||||
journal_browse_prepare();
|
||||
|
||||
units_active = check_units_active(); /* error is treated the same as 0 */
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "os-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "pretty-print.h"
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "time-util.h"
|
||||
#include "tmpfile-util.h"
|
||||
@ -1134,7 +1133,8 @@ static int run(int argc, char *argv[]) {
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
sigbus_install();
|
||||
journal_browse_prepare();
|
||||
|
||||
assert_se(sigaction(SIGTERM, &sigterm, NULL) >= 0);
|
||||
|
||||
r = setup_gnutls_logger(NULL);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "fileio.h"
|
||||
#include "journal-remote-write.h"
|
||||
#include "journal-remote.h"
|
||||
#include "logs-show.h"
|
||||
#include "main-func.h"
|
||||
#include "memory-util.h"
|
||||
#include "parse-argument.h"
|
||||
@ -20,7 +21,6 @@
|
||||
#include "pretty-print.h"
|
||||
#include "process-util.h"
|
||||
#include "rlimit-util.h"
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "socket-netlink.h"
|
||||
#include "socket-util.h"
|
||||
@ -1072,11 +1072,6 @@ static int run(int argc, char **argv) {
|
||||
|
||||
log_setup();
|
||||
|
||||
/* The journal merging logic potentially needs a lot of fds. */
|
||||
(void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
|
||||
|
||||
sigbus_install();
|
||||
|
||||
r = parse_config();
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -1085,6 +1080,8 @@ static int run(int argc, char **argv) {
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
journal_browse_prepare();
|
||||
|
||||
if (arg_listen_http || arg_listen_https) {
|
||||
r = setup_gnutls_logger(arg_gnutls_log);
|
||||
if (r < 0)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "journal-upload.h"
|
||||
#include "journal-util.h"
|
||||
#include "log.h"
|
||||
#include "logs-show.h"
|
||||
#include "main-func.h"
|
||||
#include "mkdir.h"
|
||||
#include "parse-argument.h"
|
||||
@ -30,7 +31,6 @@
|
||||
#include "pretty-print.h"
|
||||
#include "process-util.h"
|
||||
#include "rlimit-util.h"
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
@ -766,9 +766,6 @@ static int run(int argc, char **argv) {
|
||||
|
||||
log_setup();
|
||||
|
||||
/* The journal merging logic potentially needs a lot of fds. */
|
||||
(void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
|
||||
|
||||
r = parse_config();
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -777,7 +774,7 @@ static int run(int argc, char **argv) {
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
sigbus_install();
|
||||
journal_browse_prepare();
|
||||
|
||||
r = setup_uploader(&u, arg_url, arg_save_state);
|
||||
if (r < 0)
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "parse-argument.h"
|
||||
#include "pretty-print.h"
|
||||
#include "qrcode-util.h"
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "sysctl-util.h"
|
||||
#include "terminal-util.h"
|
||||
@ -307,12 +306,12 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
log_setup();
|
||||
|
||||
sigbus_install();
|
||||
|
||||
r = parse_argv(argc, argv);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
journal_browse_prepare();
|
||||
|
||||
r = acquire_first_emergency_log_message(&message);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "journalctl-util.h"
|
||||
#include "logs-show.h"
|
||||
#include "rlimit-util.h"
|
||||
#include "sigbus.h"
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
|
||||
@ -27,11 +26,7 @@ int acquire_journal(sd_journal **ret) {
|
||||
|
||||
assert(ret);
|
||||
|
||||
/* Increase max number of open files if we can, we might needs this when browsing journal files, which might be
|
||||
* split up into many files. */
|
||||
(void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
|
||||
|
||||
sigbus_install();
|
||||
journal_browse_prepare();
|
||||
|
||||
if (arg_directory)
|
||||
r = sd_journal_open_directory(&j, arg_directory, arg_journal_type | arg_journal_additional_open_flags);
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "pretty-print.h"
|
||||
#include "process-util.h"
|
||||
#include "rlimit-util.h"
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "string-table.h"
|
||||
#include "strv.h"
|
||||
@ -1716,15 +1715,12 @@ static int run(int argc, char *argv[]) {
|
||||
setlocale(LC_ALL, "");
|
||||
log_setup();
|
||||
|
||||
/* The journal merging logic potentially needs a lot of fds. */
|
||||
(void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
|
||||
|
||||
sigbus_install();
|
||||
|
||||
r = parse_argv(argc, argv);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
journal_browse_prepare();
|
||||
|
||||
r = bus_connect_transport(arg_transport, arg_host, RUNTIME_SCOPE_SYSTEM, &bus);
|
||||
if (r < 0)
|
||||
return bus_log_connect_error(r, arg_transport);
|
||||
|
@ -53,7 +53,6 @@
|
||||
#include "process-util.h"
|
||||
#include "ptyfwd.h"
|
||||
#include "rlimit-util.h"
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "sort-util.h"
|
||||
#include "stdio-util.h"
|
||||
@ -2430,14 +2429,12 @@ static int run(int argc, char *argv[]) {
|
||||
setlocale(LC_ALL, "");
|
||||
log_setup();
|
||||
|
||||
/* The journal merging logic potentially needs a lot of fds. */
|
||||
(void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
|
||||
sigbus_install();
|
||||
|
||||
r = parse_argv(argc, argv);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
journal_browse_prepare();
|
||||
|
||||
if (STRPTR_IN_SET(argv[optind],
|
||||
"import-tar", "import-raw", "import-fs",
|
||||
"export-tar", "export-raw",
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "build.h"
|
||||
#include "logs-show.h"
|
||||
#include "main-func.h"
|
||||
#include "networkctl.h"
|
||||
#include "networkctl-address-label.h"
|
||||
@ -16,7 +17,6 @@
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "pretty-print.h"
|
||||
#include "sigbus.h"
|
||||
#include "verbs.h"
|
||||
|
||||
PagerFlags arg_pager_flags = 0;
|
||||
@ -246,12 +246,12 @@ static int run(int argc, char* argv[]) {
|
||||
|
||||
log_setup();
|
||||
|
||||
sigbus_install();
|
||||
|
||||
r = parse_argv(argc, argv);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
journal_browse_prepare();
|
||||
|
||||
return networkctl_main(argc, argv);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,9 @@
|
||||
|
||||
#include "macro.h"
|
||||
#include "output-mode.h"
|
||||
#include "rlimit-util.h"
|
||||
#include "set.h"
|
||||
#include "sigbus.h"
|
||||
#include "time-util.h"
|
||||
|
||||
typedef struct LogId {
|
||||
@ -124,3 +126,11 @@ static inline int journal_get_boots(
|
||||
advance_older, max_ids,
|
||||
ret_ids, ret_n_ids);
|
||||
}
|
||||
|
||||
static inline void journal_browse_prepare(void) {
|
||||
/* Increase max number of open files if we can, we might needs this when browsing journal files,
|
||||
* which might be split up into many files. */
|
||||
(void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
|
||||
|
||||
sigbus_install();
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "capsule-util.h"
|
||||
#include "dissect-image.h"
|
||||
#include "install.h"
|
||||
#include "logs-show.h"
|
||||
#include "main-func.h"
|
||||
#include "mount-util.h"
|
||||
#include "output-mode.h"
|
||||
@ -21,7 +22,6 @@
|
||||
#include "process-util.h"
|
||||
#include "reboot-util.h"
|
||||
#include "rlimit-util.h"
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "stat-util.h"
|
||||
#include "string-table.h"
|
||||
@ -1263,15 +1263,12 @@ static int run(int argc, char *argv[]) {
|
||||
setlocale(LC_ALL, "");
|
||||
log_setup();
|
||||
|
||||
/* The journal merging logic potentially needs a lot of fds. */
|
||||
(void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
|
||||
|
||||
sigbus_install();
|
||||
|
||||
r = systemctl_dispatch_parse_argv(argc, argv);
|
||||
if (r <= 0)
|
||||
goto finish;
|
||||
|
||||
journal_browse_prepare();
|
||||
|
||||
if (proc_mounted() == 0)
|
||||
log_full(arg_no_warn ? LOG_DEBUG : LOG_WARNING,
|
||||
"%s%s/proc/ is not mounted. This is not a supported mode of operation. Please fix\n"
|
||||
|
Loading…
Reference in New Issue
Block a user