[systemd-devel] [PATCH] fsck: Search for fsck.type in PATH

Mike Gilbert floppym at gentoo.org
Wed Apr 9 07:07:00 PDT 2014


Matches default behavior in recent util-linux.
---
 src/fsck/fsck.c        | 6 ++++--
 src/shared/generator.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index 18f2aca..24c8890 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -36,6 +36,7 @@
 #include "bus-error.h"
 #include "bus-errors.h"
 #include "fileio.h"
+#include "path-util.h"
 #include "udev-util.h"
 
 static bool arg_skip = false;
@@ -285,8 +286,9 @@ int main(int argc, char *argv[]) {
 
         type = udev_device_get_property_value(udev_device, "ID_FS_TYPE");
         if (type) {
-                const char *checker = strappenda("/sbin/fsck.", type);
-                r = access(checker, X_OK);
+                const char *checker = strappenda("fsck.", type);
+                _cleanup_free_ char *command = NULL;
+                r = find_binary(checker, &command);
                 if (r < 0) {
                         if (errno == ENOENT) {
                                 log_info("%s doesn't exist, not checking file system.", checker);
diff --git a/src/shared/generator.c b/src/shared/generator.c
index 6110303..6f4eaae 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -24,6 +24,7 @@
 #include "util.h"
 #include "special.h"
 #include "mkdir.h"
+#include "path-util.h"
 #include "unit-name.h"
 #include "generator.h"
 
@@ -46,10 +47,11 @@ int generator_write_fsck_deps(
 
         if (!isempty(fstype) && !streq(fstype, "auto")) {
                 const char *checker;
+                _cleanup_free_ char *command = NULL;
                 int r;
 
-                checker = strappenda("/sbin/fsck.", fstype);
-                r = access(checker, X_OK);
+                checker = strappenda("fsck.", fstype);
+                r = find_binary(checker, &command);
                 if (r < 0) {
                         log_warning("Checking was requested for %s, but %s cannot be used: %m", what, checker);
 
-- 
1.9.1



More information about the systemd-devel mailing list