summaryrefslogtreecommitdiffstats
path: root/disk-utils/mkfs.c
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:35 +0100
committerKarel Zak2006-12-07 00:25:35 +0100
commit2b6fc908bc368b540845a313c3b8a867c5ad9a42 (patch)
tree6fad48a239bc90515a5dc4084d6e3c3ee1f41e29 /disk-utils/mkfs.c
parentImported from util-linux-2.7.1 tarball. (diff)
downloadkernel-qcow2-util-linux-2b6fc908bc368b540845a313c3b8a867c5ad9a42.tar.gz
kernel-qcow2-util-linux-2b6fc908bc368b540845a313c3b8a867c5ad9a42.tar.xz
kernel-qcow2-util-linux-2b6fc908bc368b540845a313c3b8a867c5ad9a42.zip
Imported from util-linux-2.8 tarball.
Diffstat (limited to 'disk-utils/mkfs.c')
-rw-r--r--disk-utils/mkfs.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/disk-utils/mkfs.c b/disk-utils/mkfs.c
index 8d4671915..ba293e939 100644
--- a/disk-utils/mkfs.c
+++ b/disk-utils/mkfs.c
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <string.h>
#include <getopt.h>
#include <limits.h>
@@ -26,7 +27,7 @@
# define DEFAULT_FSTYPE "ext2"
#endif
-#define SEARCH_PATH "PATH=/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc"
+#define SEARCH_PATH "PATH=/sbin:/sbin/fs:/sbin/fs.d:/etc/fs:/etc"
#define PROGNAME "mkfs.%s"
@@ -35,6 +36,7 @@ int main(int argc, char *argv[])
char progname[NAME_MAX];
char *fstype = NULL;
int i, more = 0, verbose = 0;
+ char *oldpath, *newpath;
/* Check commandline options. */
opterr = 0;
@@ -62,7 +64,16 @@ int main(int argc, char *argv[])
fstype = DEFAULT_FSTYPE;
/* Set PATH and program name */
- putenv(SEARCH_PATH);
+ oldpath = getenv("PATH");
+ if (!oldpath)
+ oldpath = "/bin";
+ newpath = (char *) malloc(strlen(oldpath) + sizeof(SEARCH_PATH) + 2);
+ if (!newpath) {
+ fputs("mkfs: out of memory\n", stderr);
+ exit(1);
+ }
+ sprintf(newpath, "%s:%s\n", SEARCH_PATH, oldpath);
+ putenv(newpath);
sprintf(progname, PROGNAME, fstype);
argv[--optind] = progname;