summaryrefslogtreecommitdiff
blob: 84576cc521939de187251116fc877ac45c65be4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
https://bugs.gentoo.org/403073

From 1653dd95c3babbf7011d9732069af919e493bac4 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Thu, 16 Feb 2012 14:56:38 -0500
Subject: [PATCH] umount: respect fs search path

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 |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/mount/umount.c b/mount/umount.c
index ad93e75..a6fcd33 100644
--- a/mount/umount.c
+++ b/mount/umount.c
@@ -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 */
-- 
1.7.8.4