Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH 1/3] mkfs: drop hardcoded search path
@ 2015-04-12  9:06 Mike Frysinger
  2015-04-12  9:06 ` [PATCH 2/3] swapon: search for mkswap via PATH Mike Frysinger
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mike Frysinger @ 2015-04-12  9:06 UTC (permalink / raw)
  To: util-linux

Rather than maintain a hardcoded search path for looking up tools and
override the user's PATH env setting, respect whatever the user has.
This matches the convention of just about every other tool out there.

It might break on systems that don't have /sbin in their PATH and they
try to run /sbin/mkfs directly, but so be it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 disk-utils/mkfs.8 | 16 ++--------------
 disk-utils/mkfs.c | 17 +----------------
 2 files changed, 3 insertions(+), 30 deletions(-)

diff --git a/disk-utils/mkfs.8 b/disk-utils/mkfs.8
index 9a5cdc0..0279260 100644
--- a/disk-utils/mkfs.8
+++ b/disk-utils/mkfs.8
@@ -29,20 +29,8 @@ In actuality,
 is simply a front-end for the various filesystem builders
 (\fBmkfs.\fIfstype\fR)
 available under Linux.
-The filesystem-specific builder is searched for in a number
-of directories, like perhaps
-.IR /sbin ,
-.IR /sbin/fs ,
-.IR /sbin/fs.d ,
-.IR /etc/fs ,
-.I /etc
-(the precise list is defined at compile time but at least
-contains
-.I /sbin
-and
-.IR /sbin/fs ),
-and finally in the directories
-listed in the PATH environment variable.
+The filesystem-specific builder is searched for via your PATH
+environment setting only.
 Please see the filesystem-specific builder manual pages for
 further details.
 .SH OPTIONS
diff --git a/disk-utils/mkfs.c b/disk-utils/mkfs.c
index 08c4ef0..cf1a312 100644
--- a/disk-utils/mkfs.c
+++ b/disk-utils/mkfs.c
@@ -38,10 +38,6 @@
 #define DEFAULT_FSTYPE	"ext2"
 #endif
 
-#define SEARCH_PATH	"PATH=" FS_SEARCH_PATH
-#define PROGNAME	"mkfs.%s"
-
-
 static void __attribute__ ((__noreturn__)) usage(FILE * out)
 {
 	fputs(USAGE_HEADER, out);
@@ -78,7 +74,6 @@ int main(int argc, char **argv)
 	char *progname;		/* name of executable to be called */
 	char *fstype = NULL;
 	int i, more = 0, verbose = 0;
-	char *oldpath, *newpath;
 
 	enum { VERSION_OPTION = CHAR_MAX + 1 };
 
@@ -126,17 +121,7 @@ int main(int argc, char **argv)
 	if (fstype == NULL)
 		fstype = DEFAULT_FSTYPE;
 
-	/* Set PATH and program name */
-	oldpath = getenv("PATH");
-	if (!oldpath)
-		oldpath = "/bin";
-
-	newpath = xmalloc(strlen(oldpath) + sizeof(SEARCH_PATH) + 3);
-	sprintf(newpath, "%s:%s\n", SEARCH_PATH, oldpath);
-	putenv(newpath);
-
-	progname = xmalloc(sizeof(PROGNAME) + strlen(fstype) + 1);
-	sprintf(progname, PROGNAME, fstype);
+	xasprintf(&progname, "mkfs.%s", fstype);
 	argv[--optind] = progname;
 
 	if (verbose) {
-- 
2.3.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-04-27  9:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-12  9:06 [PATCH 1/3] mkfs: drop hardcoded search path Mike Frysinger
2015-04-12  9:06 ` [PATCH 2/3] swapon: search for mkswap via PATH Mike Frysinger
2015-04-27  8:59   ` Karel Zak
2015-04-12  9:06 ` [PATCH 3/3] fsck: drop hardcoded search path Mike Frysinger
2015-04-13 10:27   ` Karel Zak
2015-04-27  9:03   ` Karel Zak
2015-04-27  8:58 ` [PATCH 1/3] mkfs: " Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox