*
* Busybox'ed (2009) by Vladimir Dronnikov <dronnikov@gmail.com>
*
- * Licensed under GPLv2, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2, see file LICENSE in this source tree.
*/
+//config:config MKDOSFS
+//config: bool "mkdosfs (6.8 kb)"
+//config: default y
+//config: select PLATFORM_LINUX
+//config: help
+//config: Utility to create FAT32 filesystems.
+//config:
+//config:config MKFS_VFAT
+//config: bool "mkfs.vfat (6.8 kb)"
+//config: default y
+//config: select PLATFORM_LINUX
+//config: help
+//config: Alias to "mkdosfs".
+
+// APPLET_ODDNAME:name main location suid_type help
+//applet:IF_MKDOSFS( APPLET_ODDNAME(mkdosfs, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat))
+//applet:IF_MKFS_VFAT(APPLET_ODDNAME(mkfs.vfat, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat))
+
+//kbuild:lib-$(CONFIG_MKDOSFS) += mkfs_vfat.o
+//kbuild:lib-$(CONFIG_MKFS_VFAT) += mkfs_vfat.o
+
+//usage:#define mkfs_vfat_trivial_usage
+//usage: "[-v] [-n LABEL] BLOCKDEV [KBYTES]"
+/* Accepted but ignored:
+ "[-c] [-C] [-I] [-l bad-block-file] [-b backup-boot-sector] "
+ "[-m boot-msg-file] [-i volume-id] "
+ "[-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs] "
+ "[-h hidden-sectors] [-F fat-size] [-r root-dir-entries] [-R reserved-sectors] "
+*/
+//usage:#define mkfs_vfat_full_usage "\n\n"
+//usage: "Make a FAT32 filesystem\n"
+/* //usage: "\n -c Check device for bad blocks" */
+//usage: "\n -v Verbose"
+/* //usage: "\n -I Allow to use entire disk device (e.g. /dev/hda)" */
+//usage: "\n -n LBL Volume label"
+
#include "libbb.h"
#include <linux/hdreg.h> /* HDIO_GETGEO */
#define ATTR_VOLUME 8
-#define NUM_FATS 2
+#define NUM_FATS 2
/* FAT32 filesystem looks like this:
* sector -nn...-1: "hidden" sectors, all sectors before this partition
OPT_v = 1 << 16, // verbose
};
- opt_complementary = "-1";//:b+:f+:F+:h+:r+:R+:s+:S+:vv:c--l:l--c";
- opts = getopt32(argv, "Ab:cCf:F:h:Ii:l:m:n:r:R:s:S:v",
+ opts = getopt32(argv, "^"
+ "Ab:cCf:F:h:Ii:l:m:n:r:R:s:S:v"
+ "\0" "-1", //:b+:f+:F+:h+:r+:R+:s+:S+:vv:c--l:l--c
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, &volume_label, NULL, NULL, NULL, NULL);
argv += optind;
volume_id = time(NULL);
dev = xopen(device_name, O_RDWR);
- if (fstat(dev, &st) < 0)
- bb_simple_perror_msg_and_die(device_name);
+ xfstat(dev, &st, device_name);
//
// Get image size and sector size
start_data_sector = (reserved_sect + NUM_FATS * sect_per_fat) * (bytes_per_sect / SECTOR_SIZE);
start_data_block = (start_data_sector + SECTORS_PER_BLOCK - 1) / SECTORS_PER_BLOCK;
- bb_info_msg("searching for bad blocks ");
+ bb_error_msg("searching for bad blocks");
currently_testing = 0;
try = TEST_BUFFER_BLOCKS;
while (currently_testing < volume_size_blocks) {
}
free(blkbuf);
if (badblocks)
- bb_info_msg("%d bad block(s)", badblocks);
+ bb_error_msg("%d bad block(s)", badblocks);
}
#endif