chiark / gitweb /
tmpfiles: add new "C" line for copying files or directories
[elogind.git] / src / shared / generator.c
index 49647c1ab6b55857ff687ae350fb1dd27ad14cbc..5ac7b5f02f379fae03a7ff5392b77f6d6ee6a8e1 100644 (file)
@@ -19,6 +19,7 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include <string.h>
 #include <unistd.h>
 
 #include "util.h"
 #include "mkdir.h"
 #include "unit-name.h"
 #include "generator.h"
+#include "path-util.h"
 
 int generator_write_fsck_deps(
                 FILE *f,
                 const char *dest,
                 const char *what,
                 const char *where,
-                const char *type) {
+                const char *fstype) {
 
         assert(f);
+        assert(dest);
+        assert(what);
+        assert(where);
 
         if (!is_device_path(what)) {
                 log_warning("Checking was requested for \"%s\", but it is not a device.", what);
                 return 0;
         }
 
-        if (type && !streq(type, "auto")) {
-                const char *checker;
+        if (!isempty(fstype) && !streq(fstype, "auto")) {
                 int r;
-
-                checker = strappenda("/sbin/fsck.", type);
-                r = access(checker, X_OK);
+                r = fsck_exists(fstype);
                 if (r < 0) {
-                        log_warning("Checking was requested for %s, but %s cannot be used: %m", what, checker);
-
+                        log_warning("Checking was requested for %s, but fsck.%s cannot be used: %s", what, fstype, strerror(-r));
                         /* treat missing check as essentially OK */
-                        return errno == ENOENT ? 0 : -errno;
+                        return r == -ENOENT ? 0 : r;
                 }
         }