57 #include <sys/types.h>
79 #define TEST_BUFFER_BLOCKS 16
80 #define BLOCK_SIZE 1024
81 #define HARD_SECTOR_SIZE 512
82 #define SECTORS_PER_BLOCK ( BLOCK_SIZE / HARD_SECTOR_SIZE )
84 #define NO_NAME "NO NAME "
90 #define mark_sector_bad( sector ) mark_FAT_sector( sector, FAT_BAD )
94 static inline int cdiv(
int a,
int b)
96 return (a + b - 1) / b;
100 #define FAT_EOF (atari_format ? 0x0fffffff : 0x0ffffff8)
101 #define FAT_BAD 0x0ffffff7
103 #define MSDOS_EXT_SIGN 0x29
104 #define MSDOS_FAT12_SIGN "FAT12 "
105 #define MSDOS_FAT16_SIGN "FAT16 "
106 #define MSDOS_FAT32_SIGN "FAT32 "
108 #define BOOT_SIGN 0xAA55
116 #define MAX_CLUST_12 4084
117 #define MIN_CLUST_16 4087
124 #define MAX_CLUST_16 65524
125 #define MIN_CLUST_32 65525
129 #define MAX_CLUST_32 268435446
131 #define OLDGEMDOS_MAX_SECTORS 32765
132 #define GEMDOS_MAX_SECTORS 65531
133 #define GEMDOS_MAX_SECTOR_SIZE (16*1024)
135 #define BOOTCODE_SIZE 448
136 #define BOOTCODE_FAT32_SIZE 420
148 } __attribute__ ((packed));
184 } __attribute__ ((packed));
185 #define fat32 fstype._fat32
186 #define oldfat fstype._oldfat
195 } __attribute__ ((packed));
204 #define MSG_OFFSET_OFFSET 3
224 "This is not a bootable disk. Please insert a bootable floppy and\r\n"
225 "press any key to try again ... \r\n";
227 #define MESSAGE_OFFSET 29
257 static unsigned char *
fat;
285 static long do_check(
char *buffer,
int try, off_t current_block);
302 die(
"Internal error: out of range cluster number in mark_FAT_cluster");
307 if (((cluster * 3) & 0x1) == 0) {
308 fat[3 * cluster / 2] = (
unsigned char)(value & 0x00ff);
309 fat[(3 * cluster / 2) + 1] =
310 (
unsigned char)((
fat[(3 * cluster / 2) + 1] & 0x00f0)
311 | ((value & 0x0f00) >> 8));
313 fat[3 * cluster / 2] =
314 (
unsigned char)((
fat[3 * cluster / 2] & 0x000f) |
315 ((value & 0x000f) << 4));
316 fat[(3 * cluster / 2) + 1] = (
unsigned char)((value & 0x0ff0) >> 4);
322 fat[2 * cluster] = (
unsigned char)(value & 0x00ff);
323 fat[(2 * cluster) + 1] = (
unsigned char)(value >> 8);
328 fat[4 * cluster] = (
unsigned char)(value & 0x000000ff);
329 fat[(4 * cluster) + 1] = (
unsigned char)((value & 0x0000ff00) >> 8);
330 fat[(4 * cluster) + 2] = (
unsigned char)((value & 0x00ff0000) >> 16);
331 fat[(4 * cluster) + 3] = (
unsigned char)((value & 0xff000000) >> 24);
335 die(
"Bad FAT size (not 12, 16, or 32)");
346 if (sector < start_data_sector || sector >=
num_sectors)
347 die(
"Internal error: out of range sector number in mark_FAT_sector");
354 static long do_check(
char *buffer,
int try, off_t current_block)
360 die(
"seek failed during testing for blocks");
367 printf(
"Unexpected values in do_check: probably bugs\n");
399 printf(
"Searching for bad blocks ");
419 die(
"bad blocks before data-area: cannot make fs");
444 listfile = fopen(filename,
"r");
445 if (listfile == (FILE *) NULL)
446 die(
"Can't open file of bad blocks");
450 ssize_t length = getline(&line, &linesize, listfile);
456 die(
"Error while reading bad blocks file");
460 blockno = strtoll(line, &end, 10);
462 if (errno || blockno < 0) {
464 "While converting bad block number in line %d: %s\n",
465 lineno, strerror(errno));
466 die(
"Error in bad blocks file");
471 if (!isspace(*
check)) {
473 "Badly formed number in bad blocks file line %d\n",
475 die(
"Error in bad blocks file");
490 fprintf(stderr,
"Block number %lld is before data area\n",
492 die(
"Error in bad blocks file");
496 fprintf(stderr,
"Block number %lld is behind end of filesystem\n",
498 die(
"Error in bad blocks file");
524 unsigned int sec_per_track;
526 unsigned int media = 0xf8;
527 unsigned int cluster_size = 4;
528 int def_root_dir_entries = 512;
534 unsigned long long int total_sectors;
543 if (total_sectors <= 524288) {
545 heads = total_sectors <= 32768 ? 2 :
546 total_sectors <= 65536 ? 4 :
547 total_sectors <= 262144 ? 8 : 16;
548 sec_per_track = total_sectors <= 4096 ? 16 : 32;
551 heads = total_sectors <= 16*63*1024 ? 16 :
552 total_sectors <= 32*63*1024 ? 32 :
553 total_sectors <= 64*63*1024 ? 64 :
554 total_sectors <= 128*63*1024 ? 128 : 255;
561 switch (info->
size / 1024) {
567 def_root_dir_entries = 112;
575 def_root_dir_entries = 112;
583 def_root_dir_entries = 224;
591 def_root_dir_entries = 224;
599 def_root_dir_entries = 224;
606 printf(
"Auto-selecting FAT32 for large filesystem\n");
620 cluster_size = sectors > 32*1024*1024*2 ? 64 :
621 sectors > 16*1024*1024*2 ? 32 :
622 sectors > 8*1024*1024*2 ? 16 :
623 sectors > 260*1024*2 ? 8 : 1;
644 static unsigned int align_object(
unsigned int sectors,
unsigned int clustsize)
647 return (sectors + clustsize - 1) & ~(clustsize - 1);
656 unsigned cluster_count = 0, fat_length;
660 char label[12] = { 0 };
670 memcpy((
char *)
bs.
system_id,
"kdosf", strlen(
"kdosf"));
672 memcpy((
char *)
bs.
system_id,
"mkfs.fat", strlen(
"mkfs.fat"));
691 fprintf(stderr,
"Warning: root directory entries specified with -r have no effect on FAT32\n");
707 if (len != (
size_t)-1 && len > 11)
708 die(
"Label can be no longer than 11 characters");
711 die(
"Error when processing label");
713 for (i = strlen(label); i < 11; ++i)
723 "mkfs.fat: Warning: lowercase labels might not work properly on some systems\n");
725 die(
"Labels with characters below 0x20 are not allowed\n");
727 die(
"Labels with characters *?.,;:/\\|+=<>[]\" are not allowed\n");
729 die(
"Label can't start with a space character");
744 printf(
"Warning: message too long; truncated\n");
757 printf(
"Boot jump code is %02x %02x\n",
764 die(
"On FAT32 at least 2 reserved sectors are needed.");
776 die(
"#hidden doesn't fit in 16bit field of Atari format\n");
782 printf(
"Warning: target too large, space at end will be left unused\n");
796 unsigned fatdata1216;
798 unsigned fatlength12, fatlength16, fatlength32;
799 unsigned maxclust12, maxclust16, maxclust32;
800 unsigned clust12, clust16, clust32;
810 printf(
"Disabling alignment due to tiny filesystem\n");
824 fatdata1216 = fatdata32
844 printf(
"Trying FAT12: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n",
846 if (clust12 > maxclust12) {
849 printf(
"Trying FAT12: too much clusters\n");
864 printf(
"Trying FAT16: #clu=%u, fatlen=%u, maxclu=%u, limit=%u/%u\n",
866 if (clust16 > maxclust16) {
868 printf(
"Trying FAT16: too much clusters\n");
875 printf(
"Trying FAT16: not enough clusters, would be misdetected as FAT12\n");
891 printf(
"Trying FAT32: #clu=%u, fatlen=%u, maxclu=%u, limit=%u/%u\n",
893 if (clust32 > maxclust32) {
895 printf(
"Trying FAT32: too much clusters\n");
902 printf(
"Trying FAT32: not enough clusters\n");
918 size_fat = (clust16 > clust12) ? 16 : 12;
920 printf(
"Choosing %d bits for FAT\n",
size_fat);
925 cluster_count = clust12;
926 fat_length = fatlength12;
932 cluster_count = clust16;
933 fat_length = fatlength16;
940 fprintf(stderr,
"WARNING: Number of clusters for 32 bit FAT is less then suggested minimum.\n");
941 cluster_count = clust32;
942 fat_length = fatlength32;
950 die(
"FAT not 12, 16 or 32 bits");
963 unsigned clusters, maxclust, fatdata;
974 printf(
"Choosing %d bits for FAT\n",
size_fat);
988 printf(
"Sector size must be %d to have less than %d log. sectors\n",
1012 printf(
"ss=%d: #clu=%d, fat_len=%d, maxclu=%d\n",
1019 && clusters <= maxclust - 2)
1022 printf(clusters > maxclust - 2 ?
1023 "Too many clusters\n" :
"FAT too big\n");
1027 die(
"With this sector size, the maximum number of FAT entries "
1028 "would be exceeded.");
1034 die(
"Would need a sector size > 16k, which GEMDOS can't work with");
1036 cluster_count = clusters;
1047 uint8_t *disk_sig_ptr;
1053 printf(
"Adding MBR table\n");
1060 if (*(disk_sig_ptr-1)) {
1061 printf(
"Warning: message too long; truncated\n");
1062 *(disk_sig_ptr-1) = 0;
1066 memset(disk_sig_ptr, 0, 16*4 + 6);
1071 if (read(
fd, buf,
sizeof(buf)) ==
sizeof(buf) && buf[510] == 0x55 && buf[511] == 0xAA)
1072 disk_sig = (uint32_t)buf[440] | ((uint32_t)buf[441] << 8) | ((uint32_t)buf[442] << 16) | ((uint32_t)buf[443] << 24);
1082 disk_sig_ptr[0] = (disk_sig >> 0) & 0xFF;
1083 disk_sig_ptr[1] = (disk_sig >> 8) & 0xFF;
1084 disk_sig_ptr[2] = (disk_sig >> 16) & 0xFF;
1085 disk_sig_ptr[3] = (disk_sig >> 24) & 0xFF;
1087 partition = disk_sig_ptr + 6;
1090 partition[0] = 0x80;
1100 partition[4] = 0x0E;
1102 partition[4] = 0x0C;
1104 partition[4] = 0x01;
1106 partition[4] = 0x04;
1108 partition[4] = 0x06;
1110 partition[4] = 0x0E;
1112 partition[4] = 0x0C;
1163 die(
"Backup boot sector must not be same as info sector (%d)",
info_sector);
1165 die(
"Backup boot sector must be a reserved sector");
1168 printf(
"Using sector %d as backup boot sector (0 = none)\n",
1177 die(
"GEMDOS can't handle more than 65531 sectors");
1179 printf(
"Warning: More than 32765 sector need TOS 1.04 "
1196 if (!cluster_count) {
1198 die(
"Not enough or too many clusters for filesystem - try less or more sectors per cluster");
1200 die(
"Attempting to create a too small or a too large filesystem");
1212 die(
"Too few blocks for viable filesystem");
1215 printf(
"%s has %d head%s and %d sector%s per track,\n",
1220 printf(
"logical sector size is %d,\n",
sector_size);
1221 printf(
"using 0x%02x media descriptor, with %u sectors;\n",
1223 printf(
"drive number 0x%02x;\n", (
int) (vi->
drive_number));
1224 printf(
"filesystem has %d %d-bit FAT%s and %d sector%s per cluster.\n",
1227 printf(
"FAT size is %d sector%s, and provides %d cluster%s.\n",
1228 fat_length, (fat_length != 1) ?
"s" :
"",
1229 cluster_count, (cluster_count != 1) ?
"s" :
"");
1230 printf(
"There %s %u reserved sector%s.\n",
1237 unsigned root_dir_sectors =
1239 printf(
"Root directory contains %u slots and uses %u sectors.\n",
1242 printf(
"Volume ID is %08lx, ",
volume_id &
1247 printf(
"no volume label.\n");
1259 die(
"unable to allocate space for FAT image in memory");
1279 die(
"unable to allocate space for root directory in memory");
1286 if (de->
name[0] == 0xe5)
1298 de->
time = htole16((
unsigned short)((
ctime->tm_sec >> 1) +
1299 (
ctime->tm_min << 5) +
1300 (
ctime->tm_hour << 11)));
1301 de->
date = htole16((
unsigned short)(
ctime->tm_mday +
1302 ((
ctime->tm_mon + 1) << 5) +
1303 ((
ctime->tm_year - 80) << 9)));
1306 de->
time = htole16(0);
1307 de->
date = htole16(1 + (1 << 5));
1314 de->
start = htole16(0);
1315 de->
size = htole32(0);
1323 die(
"Out of memory");
1345 die(
"Out of memory");
1351 #define error(str) \
1354 free (info_sector_buffer); \
1359 #define seekto(pos,errstr) \
1361 off_t __pos = (pos); \
1362 if (lseek (dev, part_sector * sector_size + __pos, SEEK_SET) != part_sector * sector_size + __pos) \
1363 error ("seek to " errstr " failed whilst writing tables"); \
1366 #define writebuf(buf,size,errstr) \
1368 int __size = (size); \
1369 if (write (dev, buf, __size) != __size) \
1370 error ("failed whilst writing " errstr); \
1381 seekto(0,
"start of device");
1386 seekto(0,
"boot sector");
1395 "backup boot sector");
1405 for (x = 1; x <=
nr_fats; x++) {
1409 for (y = 0; y < blank_fat_length; y++)
1425 static void usage(
const char *name,
int exitval)
1427 fprintf(stderr,
"Usage: %s [OPTIONS] TARGET [BLOCKS]\n", name);
1428 fprintf(stderr,
"Create FAT filesystem in TARGET, which can be a block device or file. Use only\n");
1429 fprintf(stderr,
"up to BLOCKS 1024 byte blocks if specified. With the -C option, file TARGET will be\n");
1430 fprintf(stderr,
"created with a size of 1024 bytes times BLOCKS, which must be specified.\n");
1431 fprintf(stderr,
"\n");
1432 fprintf(stderr,
"Options:\n");
1433 fprintf(stderr,
" -a Disable alignment of data structures\n");
1434 fprintf(stderr,
" -A Toggle Atari variant of the filesystem\n");
1435 fprintf(stderr,
" -b SECTOR Select SECTOR as location of the FAT32 backup boot sector\n");
1436 fprintf(stderr,
" -c Check device for bad blocks before creating the filesystem\n");
1437 fprintf(stderr,
" -C Create file TARGET then create filesystem in it\n");
1438 fprintf(stderr,
" -D NUMBER Write BIOS drive number NUMBER to boot sector\n");
1439 fprintf(stderr,
" -f COUNT Create COUNT file allocation tables\n");
1440 fprintf(stderr,
" -F SIZE Select FAT size SIZE (12, 16 or 32)\n");
1441 fprintf(stderr,
" -g GEOM Select disk geometry: heads/sectors_per_track\n");
1442 fprintf(stderr,
" -h NUMBER Write hidden sectors NUMBER to boot sector\n");
1443 fprintf(stderr,
" -i VOLID Set volume ID to VOLID (a 32 bit hexadecimal number)\n");
1444 fprintf(stderr,
" -I Ignore and disable safety checks\n");
1445 fprintf(stderr,
" -l FILENAME Read bad blocks list from FILENAME\n");
1446 fprintf(stderr,
" -m FILENAME Replace default error message in boot block with contents of FILENAME\n");
1447 fprintf(stderr,
" -M TYPE Set media type in boot sector to TYPE\n");
1448 fprintf(stderr,
" --mbr[=y|n|a] Fill (fake) MBR table with one partition which spans whole disk\n");
1449 fprintf(stderr,
" -n LABEL Set volume name to LABEL (up to 11 characters long)\n");
1450 fprintf(stderr,
" --codepage=N use DOS codepage N to encode label (default: %d)\n",
DEFAULT_DOS_CODEPAGE);
1451 fprintf(stderr,
" -r COUNT Make room for at least COUNT entries in the root directory\n");
1452 fprintf(stderr,
" -R COUNT Set minimal number of reserved sectors to COUNT\n");
1453 fprintf(stderr,
" -s COUNT Set number of sectors per cluster to COUNT\n");
1454 fprintf(stderr,
" -S SIZE Select a sector size of SIZE (a power of two, at least 512)\n");
1455 fprintf(stderr,
" -v Verbose execution\n");
1456 fprintf(stderr,
" --variant=TYPE Select variant TYPE of filesystem (standard or Atari)\n");
1457 fprintf(stderr,
"\n");
1458 fprintf(stderr,
" --invariant Use constants for randomly generated or time based values\n");
1459 fprintf(stderr,
" --offset=SECTOR Write the filesystem at a specific sector into the device file.\n");
1460 fprintf(stderr,
" --help Show this help message and exit\n");
1471 char *listfile = NULL;
1476 unsigned long long cblocks = 0;
1477 int blocks_specified = 0;
1478 struct timeval create_timeval;
1479 long long conversion;
1481 enum {OPT_HELP=1000, OPT_INVARIANT, OPT_MBR, OPT_VARIANT, OPT_CODEPAGE, OPT_OFFSET};
1482 const struct option long_options[] = {
1483 {
"codepage", required_argument, NULL, OPT_CODEPAGE},
1484 {
"invariant", no_argument, NULL, OPT_INVARIANT},
1485 {
"mbr", optional_argument, NULL, OPT_MBR},
1486 {
"variant", required_argument, NULL, OPT_VARIANT},
1487 {
"offset", required_argument, NULL, OPT_OFFSET},
1488 {
"help", no_argument, NULL, OPT_HELP},
1493 if (argc && *argv) {
1500 if (gettimeofday(&create_timeval, NULL) == 0 && create_timeval.tv_sec != (time_t)-1)
1505 printf(
"mkfs.fat " VERSION
" (" VERSION_DATE
")\n");
1507 while ((c = getopt_long(argc, argv,
"aAb:cCf:D:F:g:Ii:l:m:M:n:r:R:s:S:h:v",
1508 long_options, NULL)) != -1)
1521 conversion = strtol(optarg, &tmp, 0);
1522 if (!*optarg || isspace(*optarg) || *tmp || errno || conversion < 0 || conversion > 0xffff) {
1523 printf(
"Bad location for backup boot sector : %s\n", optarg);
1541 conversion = strtol(optarg, &tmp, 0);
1542 if (!*optarg || isspace(*optarg) || *tmp || errno || conversion < 0x00 || conversion > 0xFF) {
1543 printf (
"Bad drive number: %s\n", optarg);
1552 conversion = strtol(optarg, &tmp, 0);
1553 if (!*optarg || isspace(*optarg) || *tmp || errno || conversion < 1 || conversion > 4) {
1554 printf(
"Bad number of FATs : %s\n", optarg);
1562 conversion = strtol(optarg, &tmp, 0);
1563 if (!*optarg || isspace(*optarg) || *tmp || errno || (conversion != 12 && conversion != 16 && conversion != 32)) {
1564 printf(
"Bad FAT type : %s\n", optarg);
1573 conversion = strtol(optarg, &tmp, 0);
1574 if (!*optarg || isspace(*optarg) || tmp[0] !=
'/' || !tmp[1] || isspace(tmp[1]) || errno || conversion <= 0 || conversion > UINT16_MAX) {
1575 printf(
"Bad format of geometry : %s\n", optarg);
1578 bs.
heads = htole16(conversion);
1579 conversion = strtol(tmp+1, &tmp, 0);
1580 if (*tmp || errno || conversion <= 0 || conversion > UINT16_MAX) {
1581 printf(
"Bad format of geometry : %s\n", optarg);
1589 conversion = strtoll(optarg, &tmp, 0);
1590 if (!*optarg || isspace(*optarg) || *tmp || errno || conversion < 0 || conversion > UINT32_MAX) {
1591 printf(
"Bad number of hidden sectors : %s\n", optarg);
1604 conversion = strtoll(optarg, &tmp, 16);
1606 if (!*optarg || isspace(*optarg) || *tmp || conversion < 0) {
1607 printf(
"Volume ID must be a hexadecimal number\n");
1610 if (conversion > UINT32_MAX) {
1611 printf(
"Volume ID does not fit in 32 bit\n");
1615 printf(
"Parsing volume ID failed (%s)\n", strerror(errno));
1628 if (strcmp(optarg,
"-")) {
1629 msgfile = fopen(optarg,
"r");
1680 printf(
"Warning: message too long; truncated\n");
1682 if (msgfile != stdin)
1689 conversion = strtol(optarg, &tmp, 0);
1690 if (!*optarg || isspace(*optarg) || *tmp || errno) {
1691 printf(
"Bad number for media descriptor : %s\n", optarg);
1694 if (conversion != 0xf0 && (conversion < 0xf8 || conversion > 0xff)) {
1695 printf(
"FAT Media byte must either be between 0xF8 and 0xFF or be 0xF0 : %s\n", optarg);
1707 conversion = strtol(optarg, &tmp, 10);
1708 if (!*optarg || isspace(*optarg) || *tmp || errno || conversion < 0 || conversion > INT_MAX) {
1709 fprintf(stderr,
"Invalid codepage : %s\n", optarg);
1718 conversion = strtol(optarg, &tmp, 0);
1719 if (!*optarg || isspace(*optarg) || *tmp || errno || conversion < 16 || conversion > 32768) {
1720 printf(
"Bad number of root directory entries : %s\n", optarg);
1729 conversion = strtol(optarg, &tmp, 0);
1730 if (!*optarg || isspace(*optarg) || *tmp || errno || conversion < 1 || conversion > 0xffff) {
1731 printf(
"Bad number of reserved sectors : %s\n", optarg);
1739 conversion = strtol(optarg, &tmp, 0);
1740 if (!*optarg || isspace(*optarg) || *tmp || errno || (conversion != 1 && conversion != 2
1741 && conversion != 4 && conversion != 8 && conversion != 16
1742 && conversion != 32 && conversion != 64 && conversion != 128)) {
1743 printf(
"Bad number of sectors per cluster : %s\n", optarg);
1751 conversion = strtol(optarg, &tmp, 0);
1752 if (!*optarg || isspace(*optarg) || *tmp || errno || (conversion != 512 && conversion != 1024 &&
1753 conversion != 2048 && conversion != 4096 && conversion != 8192 &&
1754 conversion != 16384 && conversion != 32768)) {
1755 printf(
"Bad logical sector size : %s\n", optarg);
1777 if (!optarg || !strcasecmp(optarg,
"y") || !strcasecmp(optarg,
"yes"))
1779 else if (!strcasecmp(optarg,
"n") || !strcasecmp(optarg,
"no"))
1781 else if (!strcasecmp(optarg,
"a") || !strcasecmp(optarg,
"auto"))
1784 printf(
"Unknown option for --mbr: '%s'\n", optarg);
1790 if (!strcasecmp(optarg,
"standard")) {
1792 }
else if (!strcasecmp(optarg,
"atari")) {
1795 printf(
"Unknown variant: %s\n", optarg);
1802 conversion = strtoll(optarg, &tmp, 0);
1803 if (!*optarg || isspace(*optarg) || *tmp || errno) {
1804 printf(
"Bad number for offset : %s\n", optarg);
1808 if (conversion < 0 || conversion >
OFF_MAX) {
1809 printf(
"FAT offset must be between 0 and %lld: %s\n", (
long long)
OFF_MAX, optarg);
1822 "Internal error: getopt_long() returned unexpected value %d\n", c);
1829 if (optind == argc || !argv[optind]) {
1830 printf(
"No device specified.\n");
1836 if (optind != argc) {
1837 blocks_specified = 1;
1839 conversion = strtoll(argv[optind], &tmp, 0);
1841 if (!*argv[optind] || isspace(*argv[optind]) || *tmp || errno || conversion < 0) {
1842 printf(
"Bad block count : %s\n", argv[optind]);
1850 if (optind != argc) {
1851 fprintf(stderr,
"Excess arguments on command line\n");
1855 if (create && !blocks_specified)
1856 die(
"Need intended size with -C.");
1858 if (
check && listfile)
1859 die(
"-c and -l are incompatible");
1865 fprintf(stderr,
"%s: unable to open %s: %s\n",
program_name,
1873 if (errno == EEXIST)
1886 if (devinfo.
size <= 0)
1894 "Warning: sector size was set to %d (minimal for this device)\n",
1903 die(
"The device %s size %llu is less then the offset %llu",
1909 "Warning: sector size %d > 4096 is non-standard, filesystem may not be usable\n",
1915 if (blocks_specified) {
1917 fprintf(stderr,
"Warning: block count mismatch: ");
1918 fprintf(stderr,
"found %llu but assuming %llu.\n",
1929 die(
"Partitions or virtual mappings on device '%s', not making filesystem (use -I to override)",
int local_string_to_dos_string(char *out, char *in, unsigned int out_size)
int set_dos_codepage(int codepage)
#define DEFAULT_DOS_CODEPAGE
void pdie(const char *msg,...)
void die(const char *msg,...)
int validate_volume_label(char *doslabel)
uint32_t generate_volume_id(void)
const char * program_name
int is_device_mounted(const char *path)
int get_device_info(int fd, struct device_info *info)
static int size_fat_by_user
static int start_data_block
static unsigned alloced_fat_length
static void setup_tables(void)
static int sectors_per_cluster
static time_t create_time
static char initial_volume_name[]
unsigned char dummy_boot_jump_m68k[2]
static int drive_number_by_user
#define TEST_BUFFER_BLOCKS
#define SECTORS_PER_BLOCK
static uint32_t num_sectors
static unsigned hidden_sectors
int main(int argc, char **argv)
static off_t currently_testing
static int reserved_sectors
#define mark_sector_bad(sector)
static void mark_FAT_cluster(int cluster, unsigned int value)
static int root_dir_entries_set
static void establish_params(struct device_info *info)
static char * device_name
#define seekto(pos, errstr)
#define GEMDOS_MAX_SECTORS
static int start_data_sector
static unsigned long long blocks
static int ignore_safety_checks
char dummy_boot_code[448]
static unsigned int align_object(unsigned int sectors, unsigned int clustsize)
static char * volume_name
static int backup_boot_set
static int fill_mbr_partition
static struct msdos_boot_sector bs
static int fat_media_byte
static unsigned sector_size
static void mark_FAT_sector(int sector, unsigned int value)
static struct msdos_dir_entry * root_dir
static void write_tables(void)
#define MSG_OFFSET_OFFSET
static unsigned fat_entries
static int drive_number_option
static void get_list_blocks(char *filename)
#define BOOTCODE_FAT32_SIZE
static void check_mount(char *device_name)
#define GEMDOS_MAX_SECTOR_SIZE
static void usage(const char *name, int exitval)
static void check_blocks(void)
#define writebuf(buf, size, errstr)
static long do_check(char *buffer, int try, off_t current_block)
static int root_dir_entries
static unsigned char * fat
static int malloc_entire_fat
#define OLDGEMDOS_MAX_SECTORS
static int sector_size_set
static char * blank_sector
static int orphaned_sectors
static void alarm_intr(int alnum)
static int cdiv(int a, int b)
static unsigned char * info_sector_buffer
unsigned char dummy_boot_jump[3]
static int align_structures
static int hidden_sectors_by_user
struct msdos_boot_sector::@1::@3 _fat32
struct msdos_volume_info vi
union msdos_boot_sector::@1 fstype
struct msdos_boot_sector::@1::@2 _oldfat