]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/basic/fs-util.c
process-util: refactor APIs for reading /proc/self/xyz symlinks
authorLennart Poettering <lennart@poettering.net>
Fri, 1 Apr 2022 08:43:49 +0000 (10:43 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 1 Apr 2022 13:22:27 +0000 (15:22 +0200)
commitaed3c5eca3f2ccc98e724c1f7f7460b8bd77738f
tree72893bc9a538fa825e5fa92d7627cd588d163221
parentb8529cf376ed537419074eb8f8dfa66e4162e482
process-util: refactor APIs for reading /proc/self/xyz symlinks

The three functions for reading cwd, exe and root symlinks of processes
already share a common core: get_process_link_contents(). Let's refactor
that a bit, and move formatting of the /proc/self/ path into this helper
function instead of doing that in the caller, thus sharing more code.

While we are at it, make the return parameters optional, in case the
information if the links are readable is interesting, but the contents
is not. (This also means safe_getcwd() and readlinkat_malloc() are
updated to make the return parameter optional, as these are called by
the relevant three functions)
src/basic/fs-util.c
src/basic/path-util.c
src/basic/process-util.c