X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=util-linux%2Fmkfs_minix.c;h=59d7d23d40a84fc78590a9fac4487331377b1787;hb=66426760beef7e87c4735f433d123daf911b5b4a;hp=8c3991a99a048dfe68bca08db42f90ee57fcd29b;hpb=e1e5174942d4624e3abb8b98fe404afdbb4edad1;p=oweals%2Fbusybox.git diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index 8c3991a99..59d7d23d4 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c @@ -2,8 +2,9 @@ /* * mkfs.c - make a linux (minix) file-system. * - * (C) 1991 Linus Torvalds. This file may be redistributed as per - * the Linux copyright. + * (C) 1991 Linus Torvalds. + * + * Licensed under GPLv2, see file LICENSE in this source tree. */ /* @@ -62,6 +63,16 @@ * removed getopt based parser and added a hand rolled one. */ +//usage:#define mkfs_minix_trivial_usage +//usage: "[-c | -l FILE] [-nXX] [-iXX] BLOCKDEV [KBYTES]" +//usage:#define mkfs_minix_full_usage "\n\n" +//usage: "Make a MINIX filesystem\n" +//usage: "\n -c Check device for bad blocks" +//usage: "\n -n [14|30] Maximum length of filenames" +//usage: "\n -i INODES Number of inodes for the filesystem" +//usage: "\n -l FILE Read bad blocks list from FILE" +//usage: "\n -v Make version 2 filesystem" + #include "libbb.h" #include @@ -160,7 +171,7 @@ static ALWAYS_INLINE unsigned div_roundup(unsigned size, unsigned n) static int minix_bit(const char* a, unsigned i) { - return a[i >> 3] & (1<<(i & 7)); + return a[i >> 3] & (1<<(i & 7)); } static void minix_setbit(char *a, unsigned i) @@ -242,22 +253,22 @@ static void write_tables(void) msg_eol = "seek to 0 failed"; xlseek(dev_fd, 0, SEEK_SET); - msg_eol = "cannot clear boot sector"; + msg_eol = "can't clear boot sector"; xwrite(dev_fd, G.boot_block_buffer, 512); msg_eol = "seek to BLOCK_SIZE failed"; xlseek(dev_fd, BLOCK_SIZE, SEEK_SET); - msg_eol = "cannot write superblock"; + msg_eol = "can't write superblock"; xwrite(dev_fd, G.superblock_buffer, BLOCK_SIZE); - msg_eol = "cannot write inode map"; + msg_eol = "can't write inode map"; xwrite(dev_fd, G.inode_map, SB_IMAPS * BLOCK_SIZE); - msg_eol = "cannot write zone map"; + msg_eol = "can't write zone map"; xwrite(dev_fd, G.zone_map, SB_ZMAPS * BLOCK_SIZE); - msg_eol = "cannot write inodes"; + msg_eol = "can't write inodes"; xwrite(dev_fd, G.inode_buffer, INODE_BUFFER_SIZE); msg_eol = "\n"; @@ -504,7 +515,7 @@ static void alarm_intr(int alnum UNUSED_PARAM) if (!G.currently_testing) return; printf("%d ...", G.currently_testing); - fflush(stdout); + fflush_all(); } static void check_blocks(void) @@ -540,7 +551,7 @@ static void get_list_blocks(char *filename) FILE *listfile; unsigned long blockno; - listfile = xfopen(filename, "r"); + listfile = xfopen_for_read(filename); while (!feof(listfile)) { fscanf(listfile, "%ld\n", &blockno); mark_zone(blockno); @@ -623,7 +634,6 @@ static void setup_tables(void) int mkfs_minix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int mkfs_minix_main(int argc UNUSED_PARAM, char **argv) { - struct mntent *mp; unsigned opt; char *tmp; struct stat statbuf; @@ -682,15 +692,11 @@ int mkfs_minix_main(int argc UNUSED_PARAM, char **argv) G.total_blocks = 65535; /* Check if it is mounted */ - mp = find_mount_point(G.device_name, NULL); - if (mp && strcmp(G.device_name, mp->mnt_fsname) == 0) - bb_error_msg_and_die("%s is mounted on %s; " - "refusing to make a filesystem", - G.device_name, mp->mnt_dir); + if (find_mount_point(G.device_name, 0)) + bb_error_msg_and_die("can't format mounted filesystem"); xmove_fd(xopen(G.device_name, O_RDWR), dev_fd); - if (fstat(dev_fd, &statbuf) < 0) - bb_error_msg_and_die("cannot stat %s", G.device_name); + xfstat(dev_fd, &statbuf, G.device_name); if (!S_ISBLK(statbuf.st_mode)) opt &= ~1; // clear -c (check)