diff -crN dosfstools-2.8/dosfsck/boot.c dosfstools-2.8-patched/dosfsck/boot.c *** dosfstools-2.8/dosfsck/boot.c 2000-11-29 01:20:02.000000000 +0900 --- dosfstools-2.8-patched/dosfsck/boot.c 2004-08-20 10:44:55.000000000 +0900 *************** *** 16,21 **** --- 16,25 ---- #include "io.h" #include "boot.h" + #ifndef MSDOS_FAT12 + #define MSDOS_FAT12 MAX_FAT12 + #endif // !MSDOS_FAT12 + #define ROUND_TO_MULTIPLE(n,m) ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0) /* don't divide by zero */ diff -crN dosfstools-2.8/dosfsck/dosfsck.h dosfstools-2.8-patched/dosfsck/dosfsck.h *** dosfstools-2.8/dosfsck/dosfsck.h 2000-11-29 01:22:18.000000000 +0900 --- dosfstools-2.8-patched/dosfsck/dosfsck.h 2004-08-20 10:28:15.000000000 +0900 *************** *** 14,27 **** #define _LINUX_STRING_H_ /* hack to avoid inclusion of */ #include ! /* 2.1 kernels use le16_to_cpu() type functions for CF_LE_W & Co., but don't ! * export this macros, only __le16_to_cpu(). */ ! #ifndef le16_to_cpu ! #define le16_to_cpu __le16_to_cpu ! #define le32_to_cpu __le32_to_cpu ! #define cpu_to_le16 __cpu_to_le16 ! #define cpu_to_le32 __cpu_to_le32 ! #endif #define VFAT_LN_ATTR (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME) --- 14,35 ---- #define _LINUX_STRING_H_ /* hack to avoid inclusion of */ #include ! #if __BYTE_ORDER == __BIG_ENDIAN ! #include ! ! #define CF_LE_W(v) bswap_16(v) ! #define CF_LE_L(v) bswap_32(v) ! #define CT_LE_W(v) CF_LE_W(v) ! #define CT_LE_L(v) CF_LE_L(v) ! ! #else ! ! #define CF_LE_W(v) (v) ! #define CF_LE_L(v) (v) ! #define CT_LE_W(v) (v) ! #define CT_LE_L(v) (v) ! ! #endif /* __BIG_ENDIAN */ #define VFAT_LN_ATTR (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME) diff -crN dosfstools-2.8/dosfsck/io.c dosfstools-2.8-patched/dosfsck/io.c *** dosfstools-2.8/dosfsck/io.c 2000-11-29 01:22:42.000000000 +0900 --- dosfstools-2.8-patched/dosfsck/io.c 2004-08-20 10:45:20.000000000 +0900 *************** *** 19,24 **** --- 19,25 ---- #include #include #include + #include #include #include "dosfsck.h" *************** *** 39,71 **** unsigned device_no; - /* Use the _llseek system call directly, because there (once?) was a bug in - * the glibc implementation of it. */ - #include - #if defined(__alpha) || defined (__ia64__) - /* On alpha, the syscall is simply lseek, because it's a 64 bit system. */ - static loff_t llseek( int fd, loff_t offset, int whence ) - { - return lseek(fd, offset, whence); - } - #else - # ifndef __NR__llseek - # error _llseek system call not present - # endif - static _syscall5( int, _llseek, uint, fd, ulong, hi, ulong, lo, - loff_t *, res, uint, wh ); - - static loff_t llseek( int fd, loff_t offset, int whence ) - { - loff_t actual; - - if (_llseek(fd, offset>>32, offset&0xffffffff, &actual, whence) != 0) - return (loff_t)-1; - return actual; - } - #endif - - void fs_open(char *path,int rw) { struct stat stbuf; --- 40,45 ---- diff -crN dosfstools-2.8/mkdosfs/mkdosfs.c dosfstools-2.8-patched/mkdosfs/mkdosfs.c *** dosfstools-2.8/mkdosfs/mkdosfs.c 2000-11-29 01:23:58.000000000 +0900 --- dosfstools-2.8-patched/mkdosfs/mkdosfs.c 2004-08-20 10:30:35.000000000 +0900 *************** *** 52,57 **** --- 52,60 ---- #include #include #include + + #include + #include #include #include *************** *** 92,122 **** #endif /* __BIG_ENDIAN */ - /* Use the _llseek system call directly, because there (once?) was a bug in - * the glibc implementation of it. */ - #include - #if defined(__alpha) || defined(__ia64__) - /* On alpha, the syscall is simply lseek, because it's a 64 bit system. */ - static loff_t llseek( int fd, loff_t offset, int whence ) - { - return lseek(fd, offset, whence); - } - #else - # ifndef __NR__llseek - # error _llseek system call not present - # endif - static _syscall5( int, _llseek, uint, fd, ulong, hi, ulong, lo, - loff_t *, res, uint, wh ); - static loff_t llseek( int fd, loff_t offset, int whence ) - { - loff_t actual; - - if (_llseek(fd, offset>>32, offset&0xffffffff, &actual, whence) != 0) - return (loff_t)-1; - return actual; - } - #endif - /* Constant definitions */ #define TRUE 1 /* Boolean constants */ --- 95,100 ---- *************** *** 700,706 **** /* Can we get the loop geometry? This is in 512 byte blocks, always? */ if (ioctl (dev, BLKGETSIZE, &loop_size)) die ("unable to get loop geometry for '%s'"); - loop_size = loop_size >> 1; switch (loop_size) /* Assuming the loop device -> floppy later */ { --- 678,683 ---- *************** *** 770,782 **** bs.media = (char) 0xf8; /* Set up the media descriptor for a hard drive */ bs.dir_entries[0] = (char) 0; /* Default to 512 entries */ bs.dir_entries[1] = (char) 2; ! /* For FAT32, use 4k clusters on sufficiently large file systems, ! * otherwise 1 sector per cluster. This is also what M$'s format ! * command does for FAT32. */ ! bs.cluster_size = (char) ! (size_fat == 32 ? ! ((long long)blocks*SECTORS_PER_BLOCK >= 512*1024 ? 8 : 1) : ! 4); /* FAT12 and FAT16: start at 4 sectors per cluster */ } } --- 747,779 ---- bs.media = (char) 0xf8; /* Set up the media descriptor for a hard drive */ bs.dir_entries[0] = (char) 0; /* Default to 512 entries */ bs.dir_entries[1] = (char) 2; ! /* Check if we should use FAT32 */ ! if (!size_fat) { ! if ((blocks*SECTORS_PER_BLOCK) > 1064960) { ! if (verbose) printf("Selecting FAT32 on large drive\n"); ! size_fat = 32; ! } ! } ! if (size_fat == 32) { ! /* Use this table to find FAT32 default cluster size */ ! int volsize = blocks*SECTORS_PER_BLOCK; ! if (volsize <= 66600) ! die("Volume too small for FAT32\n"); ! else if (volsize <= 532480) ! bs.cluster_size = 1; ! else if (volsize <= 16777216) ! bs.cluster_size = 8; ! else if (volsize <= 33554432) ! bs.cluster_size = 16; ! else if (volsize <= 67108864) ! bs.cluster_size = 32; ! else ! bs.cluster_size = 64; ! if (verbose) printf("Selecting %i sectors per cluster\n",bs.cluster_size); ! } else { ! /* FAT12 and FAT16: start at 4 sectors per cluster */ ! bs.cluster_size = 4; ! } } } *************** *** 1600,1605 **** --- 1597,1608 ---- } device_name = argv[optind]; /* Determine the number of blocks in the FS */ + + if (!device_name) { + printf("No device specified.\n"); + usage(); + } + if (!create) i = count_blocks (device_name); /* Have a look and see! */ if (optind == argc - 2) /* Either check the user specified number */ *************** *** 1628,1634 **** if (check && listfile) /* Auto and specified bad block handling are mutually */ die ("-c and -l are incompatible"); /* exclusive of each other! */ ! if (!create) { check_mount (device_name); /* Is the device already mounted? */ dev = open (device_name, O_RDWR); /* Is it a suitable device to build the FS on? */ --- 1631,1637 ---- if (check && listfile) /* Auto and specified bad block handling are mutually */ die ("-c and -l are incompatible"); /* exclusive of each other! */ ! if (!create) { check_mount (device_name); /* Is the device already mounted? */ dev = open (device_name, O_RDWR); /* Is it a suitable device to build the FS on? */