Commit graph

55 commits

Author SHA1 Message Date
Michal Schmidt d5099efc47 hashmap: introduce hash_ops to make struct Hashmap smaller
It is redundant to store 'hash' and 'compare' function pointers in
struct Hashmap separately. The functions always comprise a pair.
Store a single pointer to struct hash_ops instead.

systemd keeps hundreds of hashmaps, so this saves a little bit of
memory.
2014-09-15 16:08:50 +02:00
Philippe De Swert 48d4c7468f journal: do not dereference already freed patterns
In case set_consume goes wrong, the pattern name has already been
freed. So we do not try to print it in the logs, assuming the pattern
addition print will be printed just before the failure anyway. Found
with coverity. Fixes: CID#1237798
2014-09-11 17:13:59 +02:00
Zbigniew Jędrzejewski-Szmek 601185b43d Unify parse_argv style
getopt is usually good at printing out a nice error message when
commandline options are invalid. It distinguishes between an unknown
option and a known option with a missing arg. It is better to let it
do its job and not use opterr=0 unless we actually want to suppress
messages. So remove opterr=0 in the few places where it wasn't really
useful.

When an error in options is encountered, we should not print a lengthy
help() and overwhelm the user, when we know precisely what is wrong
with the commandline. In addition, since help() prints to stdout, it
should not be used except when requested with -h or --help.

Also, simplify things here and there.
2014-08-03 21:46:07 -04:00
Zbigniew Jędrzejewski-Szmek 73f860db98 Always prefer our headers to system headers
In practice this shouldn't make much difference, but
sometimes our headers might be newer, and we want to
test them.
2014-07-31 08:56:03 -04:00
Zbigniew Jędrzejewski-Szmek f7a5bb2842 Small modernizations 2014-07-18 21:45:27 -04:00
Zbigniew Jędrzejewski-Szmek 31cda3d175 coredumpctl: show a useful error on permission problems 2014-07-06 19:06:03 -04:00
Zbigniew Jędrzejewski-Szmek d89c8fdf48 journal: add LZ4 as optional compressor
Add liblz4 as an optional dependency when requested with --enable-lz4,
and use it in preference to liblzma for journal blob and coredump
compression. To retain backwards compatibility, XZ is used to
decompress old blobs.

Things will function correctly only with lz4-119.

Based on the benchmarks found on the web, lz4 seems to be the best
choice for "quick" compressors atm.

For pkg-config status, see http://code.google.com/p/lz4/issues/detail?id=135.
2014-07-06 19:06:03 -04:00
Thomas Hindoe Paaboel Andersen d0c8806d4a coredumpctl: fix potential deref of null pointer 2014-06-27 00:17:58 +02:00
Thomas Hindoe Paaboel Andersen de8f6e5463 coredumpctl: remove unused variable 2014-06-26 23:16:58 +02:00
Daniel Mack 8ac8c5817f coredumpctl: fix HAVE_XZ check 2014-06-26 10:35:52 +02:00
Daniel Mack 2fb8159fb3 coredumpctl: fix build with !HAVE_XZ
Fixes the following build error:

  CCLD     coredumpctl
src/journal/coredumpctl.o: In function `save_core':
/src/systemd-master/src/journal/coredumpctl.c:656:
undefined reference to `decompress_stream'
collect2: error: ld returned 1 exit status
make[2]: *** [coredumpctl] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
2014-06-26 10:31:23 +02:00
Zbigniew Jędrzejewski-Szmek 9fe13294a9 coredump+coredumpctl: add COREDUMP_FILENAME, use in coredumpctl 2014-06-26 01:41:04 -04:00
Lennart Poettering 93240d3aba coredump: never write more than the configured processing size limit to disk 2014-06-23 16:28:05 +02:00
Lennart Poettering 81cef14fce coredumpctl: show comm name next to PID 2014-06-23 15:55:24 +02:00
Lennart Poettering 4b8cbe9a71 coredumpctl: include timestamp information in "coredumpctl info" output 2014-06-23 15:51:09 +02:00
Lennart Poettering b0b21dce0e coredump: also escape spaces in comm fields when formatting file names 2014-06-23 12:40:38 +02:00
Lennart Poettering 31a020ced3 coredumpctl: add missing entries to --help 2014-06-19 17:36:22 +02:00
Lennart Poettering c3f841063d coredumpctl: fix columns sizing for timestamp 2014-06-19 17:29:39 +02:00
Lennart Poettering 0c51aada56 coredumpctl: introduce new -1 switch for showing a single, most recent entry only
"coredumpctl info -1" is now incredibly useful for showing the most recent
stacktrace.
2014-06-19 12:38:45 +02:00
Lennart Poettering 8d4e028f18 coredump: include stacktrace of coredumps in the log message
elfutils' libdw is maintained, can read DWARF debug data and appears to
be the library of choice for generating backtraces today.
2014-06-19 12:38:45 +02:00
Lennart Poettering a035f8191a coredump: add 3 more metadata fields to coredump entries 2014-06-19 00:00:24 +02:00
Lennart Poettering e15758cce3 coredump: add new "info" verb to coredumpctl showing detailed information about a coredump 2014-06-19 00:00:24 +02:00
Lennart Poettering a276ae7429 coredump: make sure coredumpctl can handle externally stored coredumps 2014-06-19 00:00:24 +02:00
Lennart Poettering 03e334a1c7 util: replace close_nointr_nofail() by a more useful safe_close()
safe_close() automatically becomes a NOP when a negative fd is passed,
and returns -1 unconditionally. This makes it easy to write lines like
this:

        fd = safe_close(fd);

Which will close an fd if it is open, and reset the fd variable
correctly.

By making use of this new scheme we can drop a > 200 lines of code that
was required to test for non-negative fds or to reset the closed fd
variable afterwards.
2014-03-18 19:31:34 +01:00
Lennart Poettering 2d5bdf5bc0 always use the same code for creating temporary files
Let's unify our code here, and also always specifiy O_CLOEXEC.
2014-01-28 13:47:35 +01:00
Lukas Nykryn 1b2457e16d Revert "Revert "coredumpctl: in case of error free pattern after print""
In the case of the error set_consume will free the pointer 'pattern'
which is later used in log_error. Either we should stop priniting that
or use simple set_put and free pattern manually.

This reverts commit ece6b8fd5b.
2014-01-15 12:46:44 +01:00
Zbigniew Jędrzejewski-Szmek ece6b8fd5b Revert "coredumpctl: in case of error free pattern after print"
This reverts commit cf50a55277.

set_consume frees on error.
2014-01-14 09:49:30 -05:00
Lukas Nykryn cf50a55277 coredumpctl: in case of error free pattern after print 2014-01-14 15:40:16 +01:00
Lennart Poettering 9f6445e34a log: log_error() and friends add a newline after each line anyway, so avoid including it in the log strings 2013-12-24 16:39:37 +01:00
Thomas Hindoe Paaboel Andersen f168c27313 trivial coding style clean ups
- Add space between if/for and the opening parentheses
- Place the opening brace on same line as the function (not for  udev)

From the CODING_STYLE
Try to use this:
    void foo() {
    }
instead of this:
    void foo()
    {
    }
2013-12-03 22:27:45 +01:00
Daniel Buch f5f6d0e255 tree-wide usage of %m specifier instead of strerror(errno)
Also for log_error() except where a specific error is specified

e.g. errno ? strerror(errno) : "Some user specified message"
2013-11-26 21:07:46 +10:00
Lennart Poettering eb9da376d7 clients: unify how we invoke getopt_long()
Among other things this makes sure we always expose a --version command
and show it in the help texts.
2013-11-06 18:28:39 +01:00
Zbigniew Jędrzejewski-Szmek 6c17bf04b9 coredumpctl: add more debug output
It can be quite useful when somebody confuses _PID with COREDUMP_PID :).
2013-08-02 10:49:07 -04:00
Jan Janssen 2927b326cc man: Document missing options 2013-05-21 09:23:51 -04:00
Zbigniew Jędrzejewski-Szmek ef42202ac8 Add set_consume which always takes ownership
Freeing in error path is the common pattern with set_put().
2013-04-24 00:25:04 -04:00
Harald Hoyer 7fd1b19bc9 move _cleanup_ attribute in front of the type
http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
2013-04-18 09:11:22 +02:00
Lennart Poettering dfb33a9737 macro: rework how we define cleanup macros
There's now a generic _cleanup_ macro with an argument. The macros for
specific types are now defined using this macro, and in the header files
where they belong.

All cleanup handlers are now inline functions.
2013-04-16 05:25:57 +02:00
Zbigniew Jędrzejewski-Szmek 763c7aa288 journal,shared: add _cleanup_journal_close_ 2013-03-18 19:49:30 -04:00
Harald Hoyer 1b12a7b589 pager: introduce "jump to end" option
$ journalctl -be

is what you want :)

https://bugzilla.redhat.com/show_bug.cgi?id=867841
2013-03-07 21:16:04 +01:00
Lennart Poettering bc2708414b build-sys: drop all distribution specfic checks
Yay, we now have a completely generic systemd. No distribution specific checks anymore!
2013-01-04 23:26:21 +01:00
Lukas Nykryn 348a25edbb coredumpctl: check return of strndup 2012-12-19 15:27:44 +01:00
Lennart Poettering 93b73b064c journal: by default do not decompress dat objects larger than 64K
This introduces a new data threshold setting for sd_journal objects
which controls the maximum size of objects to decompress. This is
relieves the library from having to decompress full data objects even
if a client program is only interested in the initial part of them.

This speeds up "systemd-coredumpctl" drastically when invoked without
parameters.
2012-11-21 00:28:00 +01:00
Dave Reisner a9cdc94f7f enable localization for common *ctl commands 2012-11-12 14:16:07 -05:00
Dave Reisner ef216ca3d7 coredumpctl: add missing -F, --field option to help 2012-11-09 14:14:53 -05:00
Dave Reisner 584f587295 systemd-coredumpctl: add 'gdb' to usage output 2012-11-09 10:04:08 -05:00
Zbigniew Jędrzejewski-Szmek 4f76ae1b4b coredumpctl: add --field/-F option
Useful for completion generation.
2012-10-30 11:26:49 +01:00
Zbigniew Jędrzejewski-Szmek 9a34088094 coredumpctl: add --no-legend option
Useful for completion generation.
2012-10-30 11:26:49 +01:00
Zbigniew Jędrzejewski-Szmek 2fb7a5ce67 coredumpctl: fix program return code 2012-10-30 11:24:00 +01:00
Zbigniew Jędrzejewski-Szmek 57ce4bd4ea coredumpctl: add guard to options table
It is not nice to segfault on unknown options :(
2012-10-30 11:23:59 +01:00
Michal Sekletar 4a207bb2a5 journal: fix memleak, call set_free before return 2012-10-28 02:14:40 +02:00