]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - disk-utils/mkfs.c
2 * mkfs A simple generic frontend for the for the mkfs program
3 * under Linux. See the manual page for details.
5 * Usage: mkfs [-V] [-t fstype] [fs-options] device [size]
7 * Authors: David Engel, <david@ods.com>
8 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
9 * Ron Sommeling, <sommel@sci.kun.nl>
11 * Mon Jul 1 18:52:58 1996: janl@math.uio.no (Nicolai Langfeldt):
12 * Incorporated fix by Jonathan Kamens <jik@annex-1-slip-jik.cam.ov.com>
24 #define VERSION "1.10"
26 #ifndef DEFAULT_FSTYPE
27 # define DEFAULT_FSTYPE "ext2"
30 #define SEARCH_PATH "PATH=/sbin:/sbin/fs:/sbin/fs.d:/etc/fs:/etc"
31 #define PROGNAME "mkfs.%s"
34 int main(int argc
, char *argv
[])
36 char progname
[NAME_MAX
];
38 int i
, more
= 0, verbose
= 0;
39 char *oldpath
, *newpath
;
41 /* Check commandline options. */
43 while ((more
== 0) && ((i
= getopt(argc
, argv
, "Vt:")) != EOF
))
54 break; /* start of specific arguments */
58 "Usage: mkfs [-V] [-t fstype] [fs-options] device [size]\n");
62 /* If -t wasn't specified, use the default */
64 fstype
= DEFAULT_FSTYPE
;
66 /* Set PATH and program name */
67 oldpath
= getenv("PATH");
70 newpath
= (char *) malloc(strlen(oldpath
) + sizeof(SEARCH_PATH
) + 2);
72 fputs("mkfs: out of memory\n", stderr
);
75 sprintf(newpath
, "%s:%s\n", SEARCH_PATH
, oldpath
);
77 sprintf(progname
, PROGNAME
, fstype
);
78 argv
[--optind
] = progname
;
81 puts("mkfs version " VERSION
" (" __DATE__
")");
84 printf("%s ", argv
[i
++]);
90 /* Execute the program */
91 execvp(progname
, argv
+optind
);