*
* Mon Jul 1 18:52:58 1996: janl@math.uio.no (Nicolai Langfeldt):
* Incorporated fix by Jonathan Kamens <jik@annex-1-slip-jik.cam.ov.com>
- * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
+ * 1999-02-22 Arkadiusz Miśkiewicz <misiek@pld.ORG.PL>
* - added Native Language Support
- *
+ *
+ */
+
+/*
+ * This command is deprecated. The utility is in maintenance mode,
+ * meaning we keep them in source tree for backward compatibility
+ * only. Do not waste time making this command better, unless the
+ * fix is about security or other very critical issue.
+ *
+ * See Documentation/deprecated.txt for more information.
*/
#include <getopt.h>
#define DEFAULT_FSTYPE "ext2"
#endif
-#define SEARCH_PATH "PATH=" FS_SEARCH_PATH
-#define PROGNAME "mkfs.%s"
-
-
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
- fprintf(out,
- _("Usage: %s [options] [-t type fs-options] device [size]\n"),
- program_invocation_short_name);
-
- fprintf(out, _("\nOptions:\n"
- " -t, --type=TYPE file system type, when undefined ext2 is used\n"
- " fs-options parameters to real file system builder\n"
- " device path to a device\n"
- " size number of blocks on the device\n"
- " -V, --verbose explain what is done\n"
- " defining -V more than once will cause a dry-run\n"
- " -V, --version output version information and exit\n"
- " -V as version must be only option\n"
- " -h, --help display this help and exit\n"));
-
- fprintf(out, _("\nFor more information see mkfs(8).\n"));
-
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-static void __attribute__ ((__noreturn__)) print_version(void)
-{
- printf(UTIL_LINUX_VERSION);
+ FILE *out = stdout;
+ fputs(USAGE_HEADER, out);
+ fprintf(out, _(" %s [options] [-t <type>] [fs-options] <device> [<size>]\n"),
+ program_invocation_short_name);
+
+ fputs(USAGE_SEPARATOR, out);
+ fputs(_("Make a Linux filesystem.\n"), out);
+
+ fputs(USAGE_OPTIONS, out);
+ fprintf(out, _(" -t, --type=<type> filesystem type; when unspecified, ext2 is used\n"));
+ fprintf(out, _(" fs-options parameters for the real filesystem builder\n"));
+ fprintf(out, _(" <device> path to the device to be used\n"));
+ fprintf(out, _(" <size> number of blocks to be used on the device\n"));
+ fprintf(out, _(" -V, --verbose explain what is being done;\n"
+ " specifying -V more than once will cause a dry-run\n"));
+ printf(USAGE_HELP_OPTIONS(20));
+
+ printf(USAGE_MAN_TAIL("mkfs(8)"));
exit(EXIT_SUCCESS);
}
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 };
static const struct option longopts[] = {
{"type", required_argument, NULL, 't'},
{"version", no_argument, NULL, VERSION_OPTION},
+ {"verbose", no_argument, NULL, 'V'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
if (argc == 2 && !strcmp(argv[1], "-V"))
- print_version();
+ print_version(EXIT_SUCCESS);
/* Check commandline options. */
opterr = 0;
fstype = optarg;
break;
case 'h':
- usage(stdout);
+ usage();
case VERSION_OPTION:
- print_version();
+ print_version(EXIT_SUCCESS);
default:
optind--;
more = 1;
break; /* start of specific arguments */
}
- if (optind == argc)
- usage(stderr);
+ if (optind == argc) {
+ warnx(_("no device specified"));
+ errtryhelp(EXIT_FAILURE);
+ }
/* If -t wasn't specified, use the default */
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) {
/* Execute the program */
execvp(progname, argv + optind);
- perror(progname);
- return EXIT_FAILURE;
+ err(EXIT_FAILURE, _("failed to execute %s"), progname);
}