SHA256
1
0
forked from pool/systemd
systemd/0003-fsck-consider-a-fsck-implementation-linked-to-bin-tr.patch

99 lines
3.7 KiB
Diff

Based on 571d0134bd464444567cf4eb0d2ed8df40045f36 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 24 Jun 2014 19:37:22 +0200
Subject: [PATCH] fsck: consider a fsck implementation linked to /bin/true
non-existant
---
src/fsck/fsck.c | 32 ++++++++++++++++++++++----------
src/shared/path-util.c | 26 +++++++++++++++-----------
2 files changed, 37 insertions(+), 21 deletions(-)
--- src/fsck/fsck.c
+++ src/fsck/fsck.c 2014-06-26 09:19:58.591864710 +0000
@@ -280,16 +280,28 @@ 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);
- if (r < 0) {
- if (errno == ENOENT) {
- log_info("%s doesn't exist, not checking file system on %s",
- checker, device);
- return EXIT_SUCCESS;
- } else
- log_warning("%s cannot be used for %s: %m",
- checker, device);
+ _cleanup_free_ char *p = NULL, *d = NULL;
+ const char *checker = strappenda("fsck.", type);
+ r = find_binary(checker, &p);
+ if (r == -ENOENT) {
+ log_info("fsck.%s doesn't exist, not checking file system on %s",
+ type, device);
+ return EXIT_SUCCESS;
+ } else if (r < 0) {
+ log_warning("fsck.%s cannot be used for %s: %m",
+ type, device);
+ return r;
+ }
+
+ /* An fsck that is linked to /bin/true is a non-existant fsck */
+ r = readlink_malloc(p, &d);
+ if (r >= 0 &&
+ (path_equal(d, "/bin/true") ||
+ path_equal(d, "/usr/bin/true") ||
+ path_equal(d, "/dev/null"))) {
+ log_info("fsck.%s doesn't exist, not checking file system on %s",
+ type, device);
+ return EXIT_SUCCESS;
}
}
--- src/shared/path-util.c
+++ src/shared/path-util.c 2014-06-26 09:14:15.651559638 +0000
@@ -425,19 +425,21 @@ int path_is_os_tree(const char *path) {
int find_binary(const char *name, char **filename) {
assert(name);
- assert(filename);
- if (strchr(name, '/')) {
- char *p;
+ if (is_path(name)) {
+ if (access(name, X_OK) < 0)
+ return -errno;
+
+ if (filename) {
+ char *p;
- if (path_is_absolute(name))
- p = strdup(name);
- else
p = path_make_absolute_cwd(name);
- if (!p)
- return -ENOMEM;
+ if (!p)
+ return -ENOMEM;
+
+ *filename = p;
+ }
- *filename = p;
return 0;
} else {
const char *path;
@@ -463,8 +465,10 @@ int find_binary(const char *name, char *
continue;
}
- path_kill_slashes(p);
- *filename = p;
+ if (filename) {
+ path_kill_slashes(p);
+ *filename = p;
+ }
return 0;
}