summaryrefslogtreecommitdiff
path: root/src/pstore
Commit message (Collapse)AuthorAgeFilesLines
* copy: Move chattr arguments to full function signaturesDaan De Meyer2023-03-211-1/+1
| | | | | These are almost never used, so let's move them to the _full() functions signatures.
* conf: replace config_parse_many_nulstr() with config_parse_config_file()Franck Bui2023-03-141-8/+3
| | | | | | | | | | | | | | | | | All daemons use a similar scheme to read their main config files and theirs drop-ins. The main config files are always stored in /etc/systemd directory and it's easy enough to construct the name of the drop-in directories based on the name of the main config file. Hence the new helper does that internally, which allows to reduce and simplify the args passed previously to config_parse_many_nulstr(). Besides the overall code simplification it results: 16 files changed, 87 insertions(+), 159 deletions(-) it allows to identify clearly the locations in the code where configuration files are parsed.
* treewide: fix a few typos in NEWS, docs and commentsDmitry V. Levin2023-02-151-1/+1
|
* tree-wide: fix typo and comment style updateYu Watanabe2023-02-151-1/+1
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* pstore: fixes for dmesg.txt reconstructionEric DeVolder2022-12-051-121/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes problems with the re-assembly of the dmesg from the records stored in pstore. The current code simply ignores the last 6 characters of the file name to form a base record id, which then groups any pstore files with this base id into the reconstructed dmesg.txt. This approach fails when the following oops generated the following in pstore: -rw-------. 1 root root 1808 Oct 27 22:07 dmesg-efi-166692286101001 -rw-------. 1 root root 1341 Oct 27 22:07 dmesg-efi-166692286101002 -rw-------. 1 root root 1812 Oct 27 22:07 dmesg-efi-166692286102001 -rw-------. 1 root root 1820 Oct 27 22:07 dmesg-efi-166692286102002 -rw-------. 1 root root 1807 Oct 27 22:07 dmesg-efi-166692286103001 -rw-------. 1 root root 1791 Oct 27 22:07 dmesg-efi-166692286103002 -rw-------. 1 root root 1773 Oct 27 22:07 dmesg-efi-166692286104001 -rw-------. 1 root root 1801 Oct 27 22:07 dmesg-efi-166692286104002 -rw-------. 1 root root 1821 Oct 27 22:07 dmesg-efi-166692286105001 -rw-------. 1 root root 1809 Oct 27 22:07 dmesg-efi-166692286105002 -rw-------. 1 root root 1804 Oct 27 22:07 dmesg-efi-166692286106001 -rw-------. 1 root root 1817 Oct 27 22:07 dmesg-efi-166692286106002 -rw-------. 1 root root 1792 Oct 27 22:07 dmesg-efi-166692286107001 -rw-------. 1 root root 1810 Oct 27 22:07 dmesg-efi-166692286107002 -rw-------. 1 root root 1717 Oct 27 22:07 dmesg-efi-166692286108001 -rw-------. 1 root root 1808 Oct 27 22:07 dmesg-efi-166692286108002 -rw-------. 1 root root 1764 Oct 27 22:07 dmesg-efi-166692286109001 -rw-------. 1 root root 1765 Oct 27 22:07 dmesg-efi-166692286109002 -rw-------. 1 root root 1796 Oct 27 22:07 dmesg-efi-166692286110001 -rw-------. 1 root root 1816 Oct 27 22:07 dmesg-efi-166692286110002 -rw-------. 1 root root 1793 Oct 27 22:07 dmesg-efi-166692286111001 -rw-------. 1 root root 1751 Oct 27 22:07 dmesg-efi-166692286111002 -rw-------. 1 root root 1813 Oct 27 22:07 dmesg-efi-166692286112001 -rw-------. 1 root root 1786 Oct 27 22:07 dmesg-efi-166692286112002 -rw-------. 1 root root 1754 Oct 27 22:07 dmesg-efi-166692286113001 -rw-------. 1 root root 1752 Oct 27 22:07 dmesg-efi-166692286113002 -rw-------. 1 root root 1803 Oct 27 22:07 dmesg-efi-166692286114001 -rw-------. 1 root root 1759 Oct 27 22:07 dmesg-efi-166692286114002 -rw-------. 1 root root 1805 Oct 27 22:07 dmesg-efi-166692286115001 -rw-------. 1 root root 1787 Oct 27 22:07 dmesg-efi-166692286115002 -rw-------. 1 root root 1815 Oct 27 22:07 dmesg-efi-166692286116001 -rw-------. 1 root root 1771 Oct 27 22:07 dmesg-efi-166692286116002 -rw-------. 1 root root 1816 Oct 27 22:07 dmesg-efi-166692286117002 -rw-------. 1 root root 1388 Oct 27 22:07 dmesg-efi-166692286701003 -rw-------. 1 root root 1824 Oct 27 22:07 dmesg-efi-166692286702003 -rw-------. 1 root root 1795 Oct 27 22:07 dmesg-efi-166692286703003 -rw-------. 1 root root 1805 Oct 27 22:07 dmesg-efi-166692286704003 -rw-------. 1 root root 1813 Oct 27 22:07 dmesg-efi-166692286705003 -rw-------. 1 root root 1821 Oct 27 22:07 dmesg-efi-166692286706003 -rw-------. 1 root root 1814 Oct 27 22:07 dmesg-efi-166692286707003 -rw-------. 1 root root 1812 Oct 27 22:07 dmesg-efi-166692286708003 -rw-------. 1 root root 1769 Oct 27 22:07 dmesg-efi-166692286709003 -rw-------. 1 root root 1820 Oct 27 22:07 dmesg-efi-166692286710003 -rw-------. 1 root root 1755 Oct 27 22:07 dmesg-efi-166692286711003 -rw-------. 1 root root 1790 Oct 27 22:07 dmesg-efi-166692286712003 -rw-------. 1 root root 1756 Oct 27 22:07 dmesg-efi-166692286713003 -rw-------. 1 root root 1763 Oct 27 22:07 dmesg-efi-166692286714003 -rw-------. 1 root root 1791 Oct 27 22:07 dmesg-efi-166692286715003 -rw-------. 1 root root 1775 Oct 27 22:07 dmesg-efi-166692286716003 -rw-------. 1 root root 1820 Oct 27 22:07 dmesg-efi-166692286717003 The "reconstructed" dmesg.txt that resulted from the above contained the following (ignoring actual contents, just providing the Part info): Emergency#3 Part17 Emergency#3 Part16 Emergency#3 Part15 Emergency#3 Part14 Emergency#3 Part13 Emergency#3 Part12 Emergency#3 Part11 Emergency#3 Part10 Emergency#3 Part9 Emergency#3 Part8 Emergency#3 Part7 Emergency#3 Part6 Emergency#3 Part5 Emergency#3 Part4 Emergency#3 Part3 Emergency#3 Part2 Emergency#3 Part1 Panic#2 Part17 Panic#2 Part16 Oops#1 Part16 Panic#2 Part15 Oops#1 Part15 Panic#2 Part14 Oops#1 Part14 Panic#2 Part13 Oops#1 Part13 Panic#2 Part12 Oops#1 Part12 Panic#2 Part11 Oops#1 Part11 Panic#2 Part10 Oops#1 Part10 Panic#2 Part9 Oops#1 Part9 Panic#2 Part8 Oops#1 Part8 Panic#2 Part7 Oops#1 Part7 Panic#2 Part6 Oops#1 Part6 Panic#2 Part5 Oops#1 Part5 Panic#2 Part4 Oops#1 Part4 Panic#2 Part3 Oops#1 Part3 Panic#2 Part2 Oops#1 Part2 Panic#2 Part1 Oops#1 Part1 The above is a interleaved mess of three dmesg dumps. This patch fixes the above problems, and simplifies the dmesg reconstruction process. The code now distinguishes between records on EFI vs ERST, which have differently formatted record identifiers. Using knowledge of the format of the record ids allows vastly improved reconstruction process. With this change in place, the above pstore records now result in the following: # ls -alR /var/lib/systemd/pstore 1666922861: total 8 drwxr-xr-x. 4 root root 28 Nov 18 14:58 . drwxr-xr-x. 7 root root 144 Nov 18 14:58 .. drwxr-xr-x. 2 root root 4096 Nov 18 14:58 001 drwxr-xr-x. 2 root root 4096 Nov 18 14:58 002 1666922861/001: total 100 drwxr-xr-x. 2 root root 4096 Nov 18 14:58 . drwxr-xr-x. 4 root root 28 Nov 18 14:58 .. -rw-------. 1 root root 1808 Oct 27 22:07 dmesg-efi-166692286101001 -rw-------. 1 root root 1812 Oct 27 22:07 dmesg-efi-166692286102001 -rw-------. 1 root root 1807 Oct 27 22:07 dmesg-efi-166692286103001 -rw-------. 1 root root 1773 Oct 27 22:07 dmesg-efi-166692286104001 -rw-------. 1 root root 1821 Oct 27 22:07 dmesg-efi-166692286105001 -rw-------. 1 root root 1804 Oct 27 22:07 dmesg-efi-166692286106001 -rw-------. 1 root root 1792 Oct 27 22:07 dmesg-efi-166692286107001 -rw-------. 1 root root 1717 Oct 27 22:07 dmesg-efi-166692286108001 -rw-------. 1 root root 1764 Oct 27 22:07 dmesg-efi-166692286109001 -rw-------. 1 root root 1796 Oct 27 22:07 dmesg-efi-166692286110001 -rw-------. 1 root root 1793 Oct 27 22:07 dmesg-efi-166692286111001 -rw-------. 1 root root 1813 Oct 27 22:07 dmesg-efi-166692286112001 -rw-------. 1 root root 1754 Oct 27 22:07 dmesg-efi-166692286113001 -rw-------. 1 root root 1803 Oct 27 22:07 dmesg-efi-166692286114001 -rw-------. 1 root root 1805 Oct 27 22:07 dmesg-efi-166692286115001 -rw-------. 1 root root 1815 Oct 27 22:07 dmesg-efi-166692286116001 -rw-r-----. 1 root root 28677 Nov 18 14:58 dmesg.txt 1666922861/002: total 104 drwxr-xr-x. 2 root root 4096 Nov 18 14:58 . drwxr-xr-x. 4 root root 28 Nov 18 14:58 .. -rw-------. 1 root root 1341 Oct 27 22:07 dmesg-efi-166692286101002 -rw-------. 1 root root 1820 Oct 27 22:07 dmesg-efi-166692286102002 -rw-------. 1 root root 1791 Oct 27 22:07 dmesg-efi-166692286103002 -rw-------. 1 root root 1801 Oct 27 22:07 dmesg-efi-166692286104002 -rw-------. 1 root root 1809 Oct 27 22:07 dmesg-efi-166692286105002 -rw-------. 1 root root 1817 Oct 27 22:07 dmesg-efi-166692286106002 -rw-------. 1 root root 1810 Oct 27 22:07 dmesg-efi-166692286107002 -rw-------. 1 root root 1808 Oct 27 22:07 dmesg-efi-166692286108002 -rw-------. 1 root root 1765 Oct 27 22:07 dmesg-efi-166692286109002 -rw-------. 1 root root 1816 Oct 27 22:07 dmesg-efi-166692286110002 -rw-------. 1 root root 1751 Oct 27 22:07 dmesg-efi-166692286111002 -rw-------. 1 root root 1786 Oct 27 22:07 dmesg-efi-166692286112002 -rw-------. 1 root root 1752 Oct 27 22:07 dmesg-efi-166692286113002 -rw-------. 1 root root 1759 Oct 27 22:07 dmesg-efi-166692286114002 -rw-------. 1 root root 1787 Oct 27 22:07 dmesg-efi-166692286115002 -rw-------. 1 root root 1771 Oct 27 22:07 dmesg-efi-166692286116002 -rw-------. 1 root root 1816 Oct 27 22:07 dmesg-efi-166692286117002 -rw-r-----. 1 root root 30000 Nov 18 14:58 dmesg.txt 1666922867: total 4 drwxr-xr-x. 3 root root 17 Nov 18 14:58 . drwxr-xr-x. 7 root root 144 Nov 18 14:58 .. drwxr-xr-x. 2 root root 4096 Nov 18 14:58 003 1666922867/003: total 104 drwxr-xr-x. 2 root root 4096 Nov 18 14:58 . drwxr-xr-x. 3 root root 17 Nov 18 14:58 .. -rw-------. 1 root root 1388 Oct 27 22:07 dmesg-efi-166692286701003 -rw-------. 1 root root 1824 Oct 27 22:07 dmesg-efi-166692286702003 -rw-------. 1 root root 1795 Oct 27 22:07 dmesg-efi-166692286703003 -rw-------. 1 root root 1805 Oct 27 22:07 dmesg-efi-166692286704003 -rw-------. 1 root root 1813 Oct 27 22:07 dmesg-efi-166692286705003 -rw-------. 1 root root 1821 Oct 27 22:07 dmesg-efi-166692286706003 -rw-------. 1 root root 1814 Oct 27 22:07 dmesg-efi-166692286707003 -rw-------. 1 root root 1812 Oct 27 22:07 dmesg-efi-166692286708003 -rw-------. 1 root root 1769 Oct 27 22:07 dmesg-efi-166692286709003 -rw-------. 1 root root 1820 Oct 27 22:07 dmesg-efi-166692286710003 -rw-------. 1 root root 1755 Oct 27 22:07 dmesg-efi-166692286711003 -rw-------. 1 root root 1790 Oct 27 22:07 dmesg-efi-166692286712003 -rw-------. 1 root root 1756 Oct 27 22:07 dmesg-efi-166692286713003 -rw-------. 1 root root 1763 Oct 27 22:07 dmesg-efi-166692286714003 -rw-------. 1 root root 1791 Oct 27 22:07 dmesg-efi-166692286715003 -rw-------. 1 root root 1775 Oct 27 22:07 dmesg-efi-166692286716003 -rw-------. 1 root root 1820 Oct 27 22:07 dmesg-efi-166692286717003 -rw-r-----. 1 root root 30111 Nov 18 14:58 dmesg.txt Furthemore, pstore records on ERST are now able to accurately identify the change in timestamp sequence in order to start a new dmesg.txt, as needed.
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* meson: do not use split() in file listsZbigniew Jędrzejewski-Szmek2022-03-021-3/+1
| | | | | | | | | | | The approach to use '''…'''.split() instead of a list of strings was initially used when converting from automake because it allowed identical blocks of lines to be used for both, making the conversion easier. But over the years we have been using normal lists more and more, especially when there were just a few filenames listed. This converts the rest. No functional change.
* Define FOREACH_DIRENT through FOREACH_DIRENT_ALLZbigniew Jędrzejewski-Szmek2021-12-151-1/+0
| | | | As in the previous commit, 'de' is used as the iterator variable name.
* alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-191-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | We recently started making more use of malloc_usable_size() and rely on it (see the string_erase() story). Given that we don't really support sytems where malloc_usable_size() cannot be trusted beyond statistics anyway, let's go fully in and rework GREEDY_REALLOC() on top of it: instead of passing around and maintaining the currenly allocated size everywhere, let's just derive it automatically from malloc_usable_size(). I am mostly after this for the simplicity this brings. It also brings minor efficiency improvements I guess, but things become so much nicer to look at if we can avoid these allocation size variables everywhere. Note that the malloc_usable_size() man page says relying on it wasn't "good programming practice", but I think it does this for reasons that don't apply here: the greedy realloc logic specifically doesn't rely on the returned extra size, beyond the fact that it is equal or larger than what was requested. (This commit was supposed to be a quick patch btw, but apparently we use the greedy realloc stuff quite a bit across the codebase, so this ends up touching *a*lot* of code.)
* fix: point to the correct drop-ins subdirectory for confsJóhann B. Guðmundsson2021-04-221-1/+1
|
* tree-wide: use read_full_virtual_file() where appropriateLennart Poettering2021-03-171-1/+1
| | | | | | | Wherever we read virtual files we better should use read_full_virtual_file(), to make sure we get a consistent response given how weird the kernel's handling with partial read on such file systems is.
* Recommend drop-ins over modifications to the main config fileZbigniew Jędrzejewski-Szmek2021-02-191-7/+8
| | | | As discussed in https://github.com/systemd/systemd/pull/18347.
* tree-wide: use -EINVAL for enum invalid valuesZbigniew Jędrzejewski-Szmek2021-02-101-1/+1
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617. This does not touch anything exposed in src/systemd. Changing the defines there would be a compatibility break. Note that tests are broken after this commit. They will be fixed in the next one.
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-02-011-1/+1
| | | | It may be useful when debugging daemons.
* Add install-sysconfdir=no-samples option for (non-)installation of sample ↵Josh Triplett2021-01-141-1/+1
| | | | | | | | | | | | | configs By default, systemd installs various sample configuration files containing commented-out defaults. Systems seeking to minimize the number of files in /etc may wish to install directories and configuration files that have semantic effects, but not install not commented-out sample configuration files. Turn install-sysconfdir into a multi-valued option, with a "no-samples" value to skip installing sample-only configuration files.
* pstore: use log_oom()Yu Watanabe2020-11-201-1/+1
|
* meson: add option to skip installing to $sysconfdirJörg Thalheim2020-11-121-1/+1
| | | | | | | | | | | | | | | | | | | | | This is useful for development where overwriting files out side the configured prefix will affect the host as well as stateless systems such as NixOS that don't let packages install to /etc but handle configuration on their own. Alternative to https://github.com/systemd/systemd/pull/17501 tested with: $ mkdir inst build && cd build $ meson \ -Dcreate-log-dirs=false \ -Dsysvrcnd-path=$(realpath ../inst)/etc/rc.d \ -Dsysvinit-path=$(realpath ../inst)/etc/init.d \ -Drootprefix=$(realpath ../inst) \ -Dinstall-sysconfdir=false \ --prefix=$(realpath ../inst) .. $ ninja install
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-092-2/+2
|
* Merge pull request #16057 from keszybz/resolvectl-sorted-no-ntaYu Watanabe2020-06-041-5/+4
|\ | | | | Drop NTA lists from resolvectl status and sort output by link number
| * pstore: use typesafe_qsortZbigniew Jędrzejewski-Szmek2020-06-031-5/+4
| | | | | | | | | | Also move "allocated" above "n", since, conceptually, it is modified earlier (and that is the definition order we normally use).
* | conf-parser: return mtime in config_parse() and friendsLennart Poettering2020-06-021-5/+8
|/ | | | | | | | | | | | | This is a follow-up for 9f83091e3cceb646a66fa9df89de6d9a77c21d86. Instead of reading the mtime off the configuration files after reading, let's do so before reading, but with the fd we read the data from. This is not only cleaner (as it allows us to save one stat()), but also has the benefit that we'll detect changes that happen while we read the files. This also reworks unit file drop-ins to use the common code for determining drop-in mtime, instead of reading system clock for that.
* tree-wide: drop missing.hYu Watanabe2019-10-311-1/+0
|
* pstore: rework memory handling for dmesgZbigniew Jędrzejewski-Szmek2019-10-041-17/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Semmle Security Reports report: > The problem occurs on the way realloc is being used. When a size > bigger than the chunk that wants to be reallocated is passed, realloc > try to malloc a bigger size, however in the case that malloc fails > (for example, by forcing a big allocation) realloc will return NULL. > > According to the man page: > "The realloc() function returns a pointer to the newly allocated > memory, which is suitably aligned for any built-in type and may be > different from ptr, or NULL if the request fails. If size was > equal to 0, either NULL or a pointer suitable to be passed to free() > is returned. If realloc() fails, the original block is left > untouched; it is not freed or moved." > > The problem occurs when the memory ptr passed to the first argument of > realloc is the same as the one used for the result, for example in > this case: > > dmesg = realloc(dmesg, dmesg_size + strlen(pe->dirent.d_name) + > strlen(":\n") + pe->content_size + 1); > > https://lgtm.com/projects/g/systemd/systemd/snapshot/f8bcb81955f9e93a4787627e28f43fffb2a84836/files/src/pstore/pstore.c?sort=name&dir=A > SC&mode=heatmap#L300 > > If the malloc inside that realloc fails, then the original memory > chunk will never be free but since realloc will return NULL, the > pointer to that memory chunk will be lost and a memory leak will > occur. > > In case you are curious, this is the query we used to find this problem: > https://lgtm.com/query/8650323308193591473/ Let's use a more standard pattern: allocate memory using greedy_realloc, and instead of freeing it when we wrote out a chunk, let's just move the cursor back to the beginning and reuse the memory we allocated previously. If we fail to allocate the memory for dmesg contents, don't write the dmesg entry, but let's still process the files to move them out of pstore.
* pstore: allow specifying src and dst dirs are argumentsZbigniew Jędrzejewski-Szmek2019-10-041-4/+7
| | | | | | | This makes it much easier to debug the program as a normal user, since we don't need to set up fake input under /sys/fs/pstore/. Also, let's make the debug output a bit nicer.
* pstore: fix use after freeMichael Olbrich2019-09-071-1/+1
| | | | The memory is still needed in the sd_journal_sendv() after the 'if' block.
* pstore: fix typo in error message - directoy -> directorynikolas2019-09-051-1/+1
|
* Merge pull request #13133 from keszybz/pstore-return-valueLennart Poettering2019-07-221-0/+4
|\ | | | | pstore: refuse to run if arguments are specified
| * pstore: refuse to run if arguments are specifiedZbigniew Jędrzejewski-Szmek2019-07-221-0/+4
| | | | | | | | (This is why the --help chech passed.)
* | pstore: use log_setup_service()Yu Watanabe2019-07-221-1/+1
| |
* | pstore: do not add FILE= journal entry if content_size == 0Yu Watanabe2019-07-221-11/+14
| |
* | pstore: remove temporary file on failureYu Watanabe2019-07-221-3/+3
| |
* | pstore: drop commented out lineYu Watanabe2019-07-221-2/+0
| |
* | pstopre: fix return value of list_files()Yu Watanabe2019-07-221-3/+3
| | | | | | | | | | Previously, the return value of the last read_full_file() is returned. This makes the error in read_full_file() is always ignored.
* | pstore: drop unnecessary initializationsYu Watanabe2019-07-221-9/+6
|/
* pstore: Tool to archive contents of pstoreEric DeVolder2019-07-193-0/+419
This patch introduces the systemd pstore service which will archive the contents of the Linux persistent storage filesystem, pstore, to other storage, thus preserving the existing information contained in the pstore, and clearing pstore storage for future error events. Linux provides a persistent storage file system, pstore[1], that can store error records when the kernel dies (or reboots or powers-off). These records in turn can be referenced to debug kernel problems (currently the kernel stuffs the tail of the dmesg, which also contains a stack backtrace, into pstore). The pstore file system supports a variety of backends that map onto persistent storage, such as the ACPI ERST[2, Section 18.5 Error Serialization] and UEFI variables[3 Appendix N Common Platform Error Record]. The pstore backends typically offer a relatively small amount of persistent storage, e.g. 64KiB, which can quickly fill up and thus prevent subsequent kernel crashes from recording errors. Thus there is a need to monitor and extract the pstore contents so that future kernel problems can also record information in the pstore. The pstore service is independent of the kdump service. In cloud environments specifically, host and guest filesystems are on remote filesystems (eg. iSCSI or NFS), thus kdump relies [implicitly and/or explicitly] upon proper operation of networking software *and* hardware *and* infrastructure. Thus it may not be possible to capture a kernel coredump to a file since writes over the network may not be possible. The pstore backend, on the other hand, is completely local and provides a path to store error records which will survive a reboot and aid in post-mortem debugging. Usage Notes: This tool moves files from /sys/fs/pstore into /var/lib/systemd/pstore. To enable kernel recording of error records into pstore, one must either pass crash_kexec_post_notifiers[4] to the kernel command line or enable via 'echo Y > /sys/module/kernel/parameters/crash_kexec_post_notifiers'. This option invokes the recording of errors into pstore *before* an attempt to kexec/kdump on a kernel crash. Optionally, to record reboots and shutdowns in the pstore, one can either pass the printk.always_kmsg_dump[4] to the kernel command line or enable via 'echo Y > /sys/module/printk/parameters/always_kmsg_dump'. This option enables code on the shutdown path to record information via pstore. This pstore service is a oneshot service. When run, the service invokes systemd-pstore which is a tool that performs the following: - reads the pstore.conf configuration file - collects the lists of files in the pstore (eg. /sys/fs/pstore) - for certain file types (eg. dmesg) a handler is invoked - for all other files, the file is moved from pstore - In the case of dmesg handler, final processing occurs as such: - files processed in reverse lexigraphical order to faciliate reconstruction of original dmesg - the filename is examined to determine which dmesg it is a part - the file is appended to the reconstructed dmesg For example, the following pstore contents: root@vm356:~# ls -al /sys/fs/pstore total 0 drwxr-x--- 2 root root 0 May 9 09:50 . drwxr-xr-x 7 root root 0 May 9 09:50 .. -r--r--r-- 1 root root 1610 May 9 09:49 dmesg-efi-155741337601001 -r--r--r-- 1 root root 1778 May 9 09:49 dmesg-efi-155741337602001 -r--r--r-- 1 root root 1726 May 9 09:49 dmesg-efi-155741337603001 -r--r--r-- 1 root root 1746 May 9 09:49 dmesg-efi-155741337604001 -r--r--r-- 1 root root 1686 May 9 09:49 dmesg-efi-155741337605001 -r--r--r-- 1 root root 1690 May 9 09:49 dmesg-efi-155741337606001 -r--r--r-- 1 root root 1775 May 9 09:49 dmesg-efi-155741337607001 -r--r--r-- 1 root root 1811 May 9 09:49 dmesg-efi-155741337608001 -r--r--r-- 1 root root 1817 May 9 09:49 dmesg-efi-155741337609001 -r--r--r-- 1 root root 1795 May 9 09:49 dmesg-efi-155741337710001 -r--r--r-- 1 root root 1770 May 9 09:49 dmesg-efi-155741337711001 -r--r--r-- 1 root root 1796 May 9 09:49 dmesg-efi-155741337712001 -r--r--r-- 1 root root 1787 May 9 09:49 dmesg-efi-155741337713001 -r--r--r-- 1 root root 1808 May 9 09:49 dmesg-efi-155741337714001 -r--r--r-- 1 root root 1754 May 9 09:49 dmesg-efi-155741337715001 results in the following: root@vm356:~# ls -al /var/lib/systemd/pstore/155741337/ total 92 drwxr-xr-x 2 root root 4096 May 9 09:50 . drwxr-xr-x 4 root root 40 May 9 09:50 .. -rw-r--r-- 1 root root 1610 May 9 09:50 dmesg-efi-155741337601001 -rw-r--r-- 1 root root 1778 May 9 09:50 dmesg-efi-155741337602001 -rw-r--r-- 1 root root 1726 May 9 09:50 dmesg-efi-155741337603001 -rw-r--r-- 1 root root 1746 May 9 09:50 dmesg-efi-155741337604001 -rw-r--r-- 1 root root 1686 May 9 09:50 dmesg-efi-155741337605001 -rw-r--r-- 1 root root 1690 May 9 09:50 dmesg-efi-155741337606001 -rw-r--r-- 1 root root 1775 May 9 09:50 dmesg-efi-155741337607001 -rw-r--r-- 1 root root 1811 May 9 09:50 dmesg-efi-155741337608001 -rw-r--r-- 1 root root 1817 May 9 09:50 dmesg-efi-155741337609001 -rw-r--r-- 1 root root 1795 May 9 09:50 dmesg-efi-155741337710001 -rw-r--r-- 1 root root 1770 May 9 09:50 dmesg-efi-155741337711001 -rw-r--r-- 1 root root 1796 May 9 09:50 dmesg-efi-155741337712001 -rw-r--r-- 1 root root 1787 May 9 09:50 dmesg-efi-155741337713001 -rw-r--r-- 1 root root 1808 May 9 09:50 dmesg-efi-155741337714001 -rw-r--r-- 1 root root 1754 May 9 09:50 dmesg-efi-155741337715001 -rw-r--r-- 1 root root 26754 May 9 09:50 dmesg.txt where dmesg.txt is reconstructed from the group of related dmesg-efi-155741337* files. Configuration file: The pstore.conf configuration file has four settings, described below. - Storage : one of "none", "external", or "journal". With "none", this tool leaves the contents of pstore untouched. With "external", the contents of the pstore are moved into the /var/lib/systemd/pstore, as well as logged into the journal. With "journal", the contents of the pstore are recorded only in the systemd journal. The default is "external". - Unlink : is a boolean. When "true", the default, then files in the pstore are removed once processed. When "false", processing of the pstore occurs normally, but the pstore files remain. References: [1] "Persistent storage for a kernel's dying breath", March 23, 2011. https://lwn.net/Articles/434821/ [2] "Advanced Configuration and Power Interface Specification", version 6.2, May 2017. https://www.uefi.org/sites/default/files/resources/ACPI_6_2.pdf [3] "Unified Extensible Firmware Interface Specification", version 2.8, March 2019. https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf [4] "The kernel’s command-line parameters", https://static.lwn.net/kerneldoc/admin-guide/kernel-parameters.html