]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
umount: respect fs search path
authorMike Frysinger <vapier@gentoo.org>
Thu, 16 Feb 2012 19:59:26 +0000 (14:59 -0500)
committerKarel Zak <kzak@redhat.com>
Fri, 24 Feb 2012 09:54:07 +0000 (10:54 +0100)
This brings search path support to umount to match existing behavior
in fsck and mount.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
mount/umount.c

index ad93e757b0c0b121d1c1a212fb5e0b7c4a80cbfe..a6fcd333ccc32c203f62ad1c9a4b79840591a25c 100644 (file)
@@ -100,7 +100,8 @@ static int fake = 0;
 static int
 check_special_umountprog(const char *node,
                         const char *type, int *status) {
-       char umountprog[120];
+       char search_path[] = FS_SEARCH_PATH;
+       char *path, umountprog[150];
        struct stat statbuf;
        int res;
 
@@ -110,10 +111,16 @@ check_special_umountprog(const char *node,
        if (type == NULL || strcmp(type, "none") == 0)
                return 0;
 
-       if (strlen(type) < 100) {
+       path = strtok(search_path, ":");
+       while (path) {
                int type_opt = 0;
 
-               sprintf(umountprog, "/sbin/umount.%s", type);
+               res = snprintf(umountprog, sizeof(umountprog), "%s/umount.%s",
+                              path, type);
+               path = strtok(NULL, ":");
+               if (res < 0 || (size_t) res >= sizeof(umountprog))
+                       continue;
+
                res = stat(umountprog, &statbuf);
                if (res == -1 && errno == ENOENT && strchr(type, '.')) {
                        /* If type ends with ".subtype" try without it */