Commit Graph

5277 Commits

Author SHA1 Message Date
Yu Watanabe
538d878dbd os-util: introduce several _at() variants of os-release parsers 2023-04-11 18:49:45 +09:00
Yu Watanabe
5cf69e709e os-util: make $SYSTEMD_OS_RELEASE prefixed with the root directory
To make it consistent with other env vars, e.g. $SYSTEMD_ESP_PATH or
$SYSTEMD_XBOOTLDR_PATH.

This is useful when the root is specified by a file descriptor, instead
of a path.
2023-04-11 18:49:23 +09:00
Yu Watanabe
f4a1d32c82 os-util: merge parse_{extension,os}_release() 2023-04-11 18:49:23 +09:00
Yu Watanabe
7ef43c78df os-util: invert order of arguments in extension release parser
For consistency with other functions.
Unfortunately, va_start() requires that the previous argument is a
pointer, hence the order of the arguments in the internal function
cannot be changed.
2023-04-11 18:49:23 +09:00
Yu Watanabe
61acfd8311 os-util: shorten temporal variable names
No functional change, just refactoring.
2023-04-11 18:49:20 +09:00
Yu Watanabe
59c4707594 os-util: log one more error cause 2023-04-11 18:48:58 +09:00
Yu Watanabe
c9d64f8a2c os-util: do not use 'r' for storing loop status
The variable 'r' is usually used for storing return value of functional
call. Let's introduce another boolean to store the current loop status.

No functional change, just refactoring.
2023-04-11 18:48:58 +09:00
Yu Watanabe
7421f20c7e os-util: return earlier when unsupported image class is specified 2023-04-11 18:47:15 +09:00
Yu Watanabe
7213c75045 os-util: return earlier when extension release file is found
No functional change, just refactoring.
2023-04-11 18:44:50 +09:00
Yu Watanabe
a84677e0f4 os-util: split-out open_os_release() from open_extension_release()
The logics of opening os-release and extension-release are completely
different.
No functional change, just refactoring.
2023-04-11 18:44:50 +09:00
Yu Watanabe
6f0f4d1488 os-util: fix fd leak on failure 2023-04-11 18:44:50 +09:00
Yu Watanabe
396ec9587c os-util: make open_extension_release() return O_PATH fd 2023-04-11 18:44:50 +09:00
Yu Watanabe
53cbf5f9a6 os-util: drop fopen_extension_release() 2023-04-11 18:44:50 +09:00
Yu Watanabe
bfeaa62dbc compress: replace compress_blob() with compress_blob_explicit()
And make compress_xyz() return 0 on success, as we know which compression
algorithm is used when calling compress_blob().

Follow-up for 2360352ef0.
2023-04-11 09:14:34 +02:00
Yu Watanabe
0d68cd72b6 chase: drop redundant call of delete_trailing_chars()
In that branch, 'root' is a non-root and absolute path.
Hence, delete_trailing_chars() does not make the path empty.
And, if the path contains redundant slashes at the end, that will be
dropped by path_simplify().
2023-04-11 09:06:05 +02:00
Yu Watanabe
2653ded4d1 Merge pull request #27199 from yuwata/find-esp
path-util: introduce path_prefix_root_cwd(), and use it in find_esp() and friends
2023-04-11 12:36:13 +09:00
Yu Watanabe
562f22dbfc Merge pull request #27202 from yuwata/os-release-tiny-cleanups
os-util: tiny cleanups
2023-04-11 12:35:34 +09:00
Yu Watanabe
06692fdb5b env-file: introduce parse_env_file_fdv() 2023-04-11 12:33:14 +09:00
Yu Watanabe
75cc8d7c42 path-util: introduce path_prefix_root_cwd() 2023-04-11 06:27:05 +09:00
Yu Watanabe
8c14d828d4 os-util: drop redundant declaration of load_os_release_pairs() 2023-04-11 05:20:15 +09:00
Yu Watanabe
d67071d2f6 os-util: use _IMAGE_CLASS_INVALID
When extension is not specified, image class is not necessary to be
specified. Let's use _IMAGE_CLASS_INVALID as an indicator that no
extension is specified.
2023-04-11 05:20:15 +09:00
Yu Watanabe
c2cd950817 os-util: move declaration of string table lookup for image class 2023-04-11 05:20:15 +09:00
Daan De Meyer
25d598e144 Merge pull request #27184 from yuwata/xfopenat-full
fileio: introduce xfopenat_full()
2023-04-10 11:50:34 +02:00
Yu Watanabe
b4cb4c5cc6 fd-util: slightly optimize dir_fd_is_root()
When STATX_MNT_ID is not supported, we need to manually obtain mount id.
Let's compare inodes earlier.
2023-04-10 10:04:46 +09:00
Yu Watanabe
a6ef5ef707 chase: use dir_fd_is_root() to check if fd points to the root directory
As commented in dir_fd_is_root(), comparing inode is not enough to
determine if we are at the root directory.
2023-04-10 09:55:29 +09:00
Yu Watanabe
4443e3003a chase: use stat_inode_same() at one more place 2023-04-10 09:45:21 +09:00
Yu Watanabe
3a7ba9f6b9 path-util: make iterator for path_find_last_component() always finish with the beginning of the buffer 2023-04-10 09:30:14 +09:00
Yu Watanabe
a0d3e0ec79 chase: extend comment about CHASE_PARENT 2023-04-10 08:57:01 +09:00
Yu Watanabe
75adfc3b17 chase: drop one redundant call of fstat()
Now, 'st' is always synced with 'fd'. Hence, we can use
stat_verify_directory().
2023-04-10 08:43:31 +09:00
Yu Watanabe
ad66c7f1d3 chase: make struct stat always sync with the opened fd
Previously, struct stat may not be correctly synced with the currently
opened fd, e.g. when a path contains symlink which points to an absolute
path.

This also rename variables for struct stat, to make them consistent with
the corresponding fd.
2023-04-10 08:40:14 +09:00
Yu Watanabe
db0096f2ad chase: drop unnecessary conditions for buffer 2023-04-10 08:17:07 +09:00
Yu Watanabe
46b457e54b fileio: introduce read_one_line_file_at() 2023-04-09 07:08:38 +02:00
Yu Watanabe
61d9982c51 fileio: introduce xfopenat_full()
This unifies call of various xfopenat() variants.
No functional change, just refactoring.
2023-04-08 19:03:46 +09:00
Yu Watanabe
0f585d4116 fileio: use take_fdopen() and friends 2023-04-08 14:34:53 +09:00
Yu Watanabe
b1229544a0 conf-files: introduce _at() variants of conf_files_list() or friends 2023-04-08 05:09:48 +09:00
Yu Watanabe
1a39bddfbb conf-files: split out logic of copy and sort filenames from hashmap
No functional change, preparation for the next commit.
2023-04-08 05:08:51 +09:00
Yu Watanabe
273426750a conf-files: use path_compare_filename() 2023-04-08 05:08:51 +09:00
Yu Watanabe
6808e00463 path-util: introduce path_compare_filename() 2023-04-08 05:08:51 +09:00
Yu Watanabe
a5af5f80ca conf-files: drop redundant call of chase()
Previously, chase() was called twice in files_add() and path_strv_resolve_uniq().
2023-04-08 05:08:48 +09:00
Zbigniew Jędrzejewski-Szmek
ddd43f31e3 Merge pull request #26887 from yuwata/proc-cmdline-filter-arguments
proc-cmdline: filter PID1 arguments on container
2023-04-07 10:55:30 +02:00
Zbigniew Jędrzejewski-Szmek
1e094cb4ba Merge pull request #27126 from yuwata/journal-compress
sd-journal: allow to specify compression algorithm through env
2023-04-07 09:28:27 +02:00
maanyagoenka
b60e0f5777 os-util: add a new confext image type and the ability to parse their release files
Adds a new image type called IMAGE_CONFEXT which is similar to IMAGE_SYSEXT but works
for the /etc/ directory instead of /usr/ and /opt/. This commit also adds the ability to
parse the release file that is present with the confext image in /etc/confext-release.d/
directory.
2023-04-05 21:50:04 +00:00
Yu Watanabe
e212f42279 fd-util: introduce dir_fd_is_root_or_cwd() 2023-04-05 00:52:56 +09:00
Yu Watanabe
83f3d73da8 compress: introduce compression_supported() helper function 2023-04-04 18:32:12 +09:00
Yu Watanabe
21eac258f8 chase: fix error handling
Fixes a bug introduced by 63bfd52f48.
2023-04-04 09:20:09 +02:00
OMOJOLA JOSHUA DAMILOLA
de2820606d src: changed usage of basename() to path_extract_filename().
TODO.
2023-04-04 00:10:22 +01:00
Zbigniew Jędrzejewski-Szmek
2657d5bddc basic/fs-util: typo fix 2023-04-03 15:28:53 +02:00
Zbigniew Jędrzejewski-Szmek
2c71aa77a5 basic/mkdir: simplify error handling
If we created the dir successfully, we let chmod_and_chown_at() do its thing
and shouldn't go into the part where we check if the existing directory has the
right permissions and ownership and possibly adjust them. The code was doing
that, by relying on the fact that chmod_and_chown_at() does not return -EEXIST.
That's probably true, but seems unnecessarilly complicated.

Follow-up for c1b1492a94.
2023-04-03 15:28:00 +02:00
Daan De Meyer
6eec59f9cc stat-util: Add xstatfsat() 2023-04-01 14:25:30 +02:00
Luca Boccassi
ed2a4e8d78 Merge pull request #27075 from mrc0mmand/test-tweaks
test: a couple of coverage-related test tweaks
2023-03-31 01:18:15 +01:00