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>
13 * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
14 * - added Native Language Support
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 of executable to be called */
38 int i, more = 0, verbose = 0;
39 char *oldpath, *newpath;
40 char *program_name, *p;
42 program_name = argv[0];
43 if ((p = strrchr(program_name, '/')) != NULL)
46 setlocale(LC_ALL, "");
47 bindtextdomain(PACKAGE, LOCALEDIR);
51 (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version"))) {
52 printf(_("%s (%s)\n"), program_name, PACKAGE_STRING);
56 /* Check commandline options. */
58 while ((more == 0) && ((i = getopt(argc, argv, "Vt:")) != -1))
69 break; /* start of specific arguments */
73 _("Usage: mkfs [-V] [-t fstype] [fs-options] device [size]\n"));
77 /* If -t wasn't specified, use the default */
79 fstype = DEFAULT_FSTYPE;
81 /* Set PATH and program name */
82 oldpath = getenv("PATH");
86 newpath = (char *) malloc(strlen(oldpath) + sizeof(SEARCH_PATH) + 3);
88 fprintf(stderr, _("%s: Out of memory!\n"), "mkfs");
91 sprintf(newpath, "%s:%s\n", SEARCH_PATH, oldpath);
94 progname = (char *) malloc(sizeof(PROGNAME) + strlen(fstype) + 1);
96 fprintf(stderr, _("%s: Out of memory!\n"), "mkfs");
99 sprintf(progname, PROGNAME, fstype);
100 argv[--optind] = progname;
103 printf(_("mkfs (%s)\n"), PACKAGE_STRING);
106 printf("%s ", argv[i++]);
112 /* Execute the program */
113 execvp(progname, argv+optind);