This is useful for systems which don't have any fsck.
We already skip emitting the fsck dependency when the fsck.$fstype helper
is missing, but fstab-generator doesn't necessarily know the fstype when
handling the root= parameter.
Previously, systemd-fsck was started for these mounts and then exited
immediately because it couldn't find the fsck.$fstype helper.
"/dev/null");
}
-int fsck_exists(const char *fstype) {
+int fsck_exists(void) {
+ return executable_is_good("fsck");
+}
+
+int fsck_exists_for_fstype(const char *fstype) {
const char *checker;
+ int r;
assert(fstype);
if (streq(fstype, "auto"))
return -EINVAL;
+ r = fsck_exists();
+ if (r <= 0)
+ return r;
+
checker = strjoina("fsck.", fstype);
return executable_is_good(checker);
}
bool paths_check_timestamp(const char* const* paths, usec_t *paths_ts_usec, bool update);
-int fsck_exists(const char *fstype);
+int fsck_exists(void);
+int fsck_exists_for_fstype(const char *fstype);
/* Iterates through the path prefixes of the specified path, going up
* the tree, to root. Also returns "" (and not "/"!) for the root
}
if (sd_device_get_property_value(dev, "ID_FS_TYPE", &type) >= 0) {
- r = fsck_exists(type);
+ r = fsck_exists_for_fstype(type);
if (r < 0)
log_device_warning_errno(dev, r, "Couldn't detect if fsck.%s may be used, proceeding: %m", type);
else if (r == 0) {
log_device_info(dev, "fsck.%s doesn't exist, not checking file system.", type);
return 0;
}
+ } else {
+ r = fsck_exists();
+ if (r < 0)
+ log_device_warning_errno(dev, r, "Couldn't detect if the fsck command may be used, proceeding: %m");
+ else if (r == 0) {
+ log_device_info(dev, "The fsck command does not exist, not checking file system.");
+ return 0;
+ }
}
console = fopen("/dev/console", "we");
assert(node);
assert(fstype);
- r = fsck_exists(fstype);
+ r = fsck_exists_for_fstype(fstype);
if (r < 0)
return log_error_errno(r, "Failed to check if fsck for file system %s exists: %m", fstype);
if (r == 0) {
arg_fsck = false;
if (arg_fsck && arg_mount_type && arg_transport == BUS_TRANSPORT_LOCAL) {
- r = fsck_exists(arg_mount_type);
+ r = fsck_exists_for_fstype(arg_mount_type);
if (r < 0)
log_warning_errno(r, "Couldn't determine whether fsck for %s exists, proceeding anyway.", arg_mount_type);
else if (r == 0) {
assert(node);
assert(fstype);
- r = fsck_exists(fstype);
+ r = fsck_exists_for_fstype(fstype);
if (r < 0) {
log_debug_errno(r, "Couldn't determine whether fsck for %s exists, proceeding anyway.", fstype);
return 0;
}
if (!isempty(fstype) && !streq(fstype, "auto")) {
- r = fsck_exists(fstype);
+ r = fsck_exists_for_fstype(fstype);
if (r < 0)
log_warning_errno(r, "Checking was requested for %s, but couldn't detect if fsck.%s may be used, proceeding: %m", what, fstype);
else if (r == 0) {
log_debug("Checking was requested for %s, but fsck.%s does not exist.", what, fstype);
return 0;
}
+ } else {
+ r = fsck_exists();
+ if (r < 0)
+ log_warning_errno(r, "Checking was requested for %s, but couldn't detect if the fsck command may be used, proceeding: %m", what);
+ else if (r == 0) {
+ /* treat missing fsck as essentially OK */
+ log_debug("Checking was requested for %s, but the fsck command does not exist.", what);
+ return 0;
+ }
}
if (path_equal(where, "/")) {
assert_se(unsetenv("PATH") == 0);
/* fsck.minix is provided by util-linux and will probably exist. */
- assert_se(fsck_exists("minix") == 1);
+ assert_se(fsck_exists_for_fstype("minix") == 1);
- assert_se(fsck_exists("AbCdE") == 0);
- assert_se(fsck_exists("/../bin/") == 0);
+ assert_se(fsck_exists_for_fstype("AbCdE") == 0);
+ assert_se(fsck_exists_for_fstype("/../bin/") == 0);
}
static void test_path_make_relative_one(const char *from, const char *to, const char *expected) {