]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/test/test-path-util.c
path-util: rework find_binary(), fsck_exists() and mkfs_exists()
authorLennart Poettering <lennart@poettering.net>
Thu, 22 Oct 2015 16:24:59 +0000 (18:24 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 24 Oct 2015 21:03:49 +0000 (23:03 +0200)
commit85eca92e2061043d733991b386d8dc10fad0fc30
treebc3c54d34f95bc8b34d7834d63e5c5f168afad73
parent7f66eb931d20cfdb7e1123673f2d6d08c2589bdf
path-util: rework find_binary(), fsck_exists() and mkfs_exists()

Modernize the code a bit:

- Get rid of FOREACH_WORD_SEPARATOR() loop in favour of a
  extract_first_word() loop.

- Remove find_binary()'s "local" flag. It's not reasonably possible to
  look for binaries on remote systems, we hence should not pretend we
  could.

- When we cannot find a suitable binary, return the last error returned
  from access() rather than ENOENT unconditionally.

- Rework fsck_exists() and mkfs_exists() to return 1 on success, 0 if
  the implementation is missing and negative on real errors. This is
  more like we do it in other functions.

- Make sure we also detect direct fsck symlinks to "true", rather than
  just absolute ones to /bin/true.
src/basic/path-util.c
src/basic/path-util.h
src/fsck/fsck.c
src/run/run.c
src/shared/generator.c
src/test/test-path-util.c