*
* 30.10.94 - Added support for v2 filesystem
* (Andreas Schwab, schwab@issan.informatik.uni-dortmund.de)
- *
+ *
* 09.11.94 - Added test to prevent overwrite of mounted fs adapted
* from Theodore Ts'o's (tytso@athena.mit.edu) mke2fs
* program. (Daniel Quinlan, quinlan@yggdrasil.com)
#include "all-io.h"
#include "closestream.h"
#include "ismounted.h"
+
+#define XALLOC_EXIT_CODE MKFS_EX_ERROR
#include "xalloc.h"
#define MINIX_ROOT_INO 1
#define mark_zone(x) (setbit(zone_map,(x)-get_first_zone()+1))
#define unmark_zone(x) (clrbit(zone_map,(x)-get_first_zone()+1))
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] /dev/name [blocks]\n"), program_invocation_short_name);
fputs(USAGE_OPTIONS, out);
fputs(_(" -c, --check check the device for bad blocks\n"), out);
fputs(_(" -l, --badblocks <file> list of bad blocks from file\n"), out);
fputs(USAGE_SEPARATOR, out);
- fputs(USAGE_HELP, out);
- fputs(USAGE_VERSION, out);
- fprintf(out, USAGE_MAN_TAIL("mkfs.minix(8)"));
- exit(out == stderr ? MKFS_EX_USAGE : MKFS_EX_OK);
+ printf(USAGE_HELP_OPTIONS(25));
+ printf(USAGE_MAN_TAIL("mkfs.minix(8)"));
+ exit(MKFS_EX_OK);
}
#ifdef TEST_SCRIPT
*/
static size_t do_check(const struct fs_control *ctl, char * buffer, int try, unsigned int current_block) {
ssize_t got;
-
+
/* Seek to the correct loc. */
if (lseek(ctl->device_fd, current_block * MINIX_BLOCK_SIZE, SEEK_SET) !=
current_block * MINIX_BLOCK_SIZE )
/* Try the read */
got = read(ctl->device_fd, buffer, try * MINIX_BLOCK_SIZE);
- if (got < 0) got = 0;
+ if (got < 0) got = 0;
if (got & (MINIX_BLOCK_SIZE - 1 )) {
printf(_("Weird values in do_check: probably bugs\n"));
}
static void determine_device_blocks(struct fs_control *ctl, const struct stat *statbuf)
{
- unsigned long long dev_blocks;
+ unsigned long long dev_blocks = 0;
if (S_ISBLK(statbuf->st_mode)) {
int sectorsize;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
strutils_set_exitcode(MKFS_EX_USAGE);
listfile = optarg;
break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return MKFS_EX_OK;
+ print_version(MKFS_EX_OK);
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(MKFS_EX_USAGE);
}
ctl.fs_blocks = strtoul_or_err(argv[0], _("failed to parse number of blocks"));
if (!ctl.device_name) {
- usage(stderr);
+ warnx(_("no device specified"));
+ errtryhelp(MKFS_EX_USAGE);
}
check_user_instructions(&ctl);
if (is_mounted(ctl.device_name))