From 223468546da753b4d98479de2fc74e5a5d70edb3 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 22 Mar 2015 10:58:04 +0000 Subject: [PATCH] dosfstools: switch back to release tarballs, update patches to the latest sent upstream MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This fixes non applying patches on buildbots. Signed-off-by: Álvaro Fernández Rojas SVN-Revision: 44936 --- tools/dosfstools/Makefile | 7 +- .../patches/0001-Add-OSX-support.patch | 1849 ----------------- ...nd-editor-backup-files-to-.gitignore.patch | 25 + ...tion-of-fix-power-loss-damage-commit.patch | 100 + ....c-Use-unsigned-char-for-binary-data.patch | 33 + ...ll-char-that-may-take-literals-const.patch | 169 ++ ...w-0xF0-to-be-specified-as-media-byte.patch | 122 ++ .../0006-fsck.fat-Make-r-option-default.patch | 603 ++++++ ...7-Makefile-fix-typo-in-uninstall-man.patch | 30 + .../0008-Makefile-avoid-using-install-D.patch | 43 + .../patches/0009-Improve-.gitignore.patch | 28 + .../0010-Remove-non-standard-int-types.patch | 538 +++++ ...011-Remove-linux-msdos_fs.h-includes.patch | 209 ++ ...ix-read-beyond-end-of-array-on-FAT12.patch | 54 + ...ible-ioctl-calls-for-OSX-and-FreeBSD.patch | 217 ++ .../0014-Add-OSX-and-FreeBSD-support.patch | 334 +++ 16 files changed, 2508 insertions(+), 1853 deletions(-) delete mode 100644 tools/dosfstools/patches/0001-Add-OSX-support.patch create mode 100644 tools/dosfstools/patches/0001-Add-tags-and-editor-backup-files-to-.gitignore.patch create mode 100644 tools/dosfstools/patches/0002-Fix-indentation-of-fix-power-loss-damage-commit.patch create mode 100644 tools/dosfstools/patches/0003-mkfs.fat.c-Use-unsigned-char-for-binary-data.patch create mode 100644 tools/dosfstools/patches/0004-Make-all-char-that-may-take-literals-const.patch create mode 100644 tools/dosfstools/patches/0005-mkfs.fat-Allow-0xF0-to-be-specified-as-media-byte.patch create mode 100644 tools/dosfstools/patches/0006-fsck.fat-Make-r-option-default.patch create mode 100644 tools/dosfstools/patches/0007-Makefile-fix-typo-in-uninstall-man.patch create mode 100644 tools/dosfstools/patches/0008-Makefile-avoid-using-install-D.patch create mode 100644 tools/dosfstools/patches/0009-Improve-.gitignore.patch create mode 100644 tools/dosfstools/patches/0010-Remove-non-standard-int-types.patch create mode 100644 tools/dosfstools/patches/0011-Remove-linux-msdos_fs.h-includes.patch create mode 100644 tools/dosfstools/patches/0012-fsck.fat-Fix-read-beyond-end-of-array-on-FAT12.patch create mode 100644 tools/dosfstools/patches/0013-Add-compatible-ioctl-calls-for-OSX-and-FreeBSD.patch create mode 100644 tools/dosfstools/patches/0014-Add-OSX-and-FreeBSD-support.patch diff --git a/tools/dosfstools/Makefile b/tools/dosfstools/Makefile index 5a5bd1d4b9..910e94f722 100644 --- a/tools/dosfstools/Makefile +++ b/tools/dosfstools/Makefile @@ -10,10 +10,9 @@ PKG_NAME:=dosfstools PKG_VERSION:=3.0.27 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=git://github.com/dosfstools/dosfstools.git -PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=266a5fc635135a9ffaa8683da1ec03aae1553b7b -PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_URL:=https://github.com/dosfstools/dosfstools/releases/download/v$(PKG_VERSION)/ \ + http://fossies.org/linux/misc +PKG_MD5SUM:=2e31e7bdf92998e41ed17de505a4a552 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION) diff --git a/tools/dosfstools/patches/0001-Add-OSX-support.patch b/tools/dosfstools/patches/0001-Add-OSX-support.patch deleted file mode 100644 index 71b8a956da..0000000000 --- a/tools/dosfstools/patches/0001-Add-OSX-support.patch +++ /dev/null @@ -1,1849 +0,0 @@ -From 92e55f1d1404e823b0a5fd6d0ea0b962de247e31 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= -Date: Wed, 25 Feb 2015 17:00:32 +0100 -Subject: [PATCH] Add OSX support -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Signed-off-by: Álvaro Fernández Rojas ---- - Makefile | 16 +- - src/boot.c | 1 + - src/common.h | 54 ++++- - src/file.c | 9 +- - src/file.h | 2 + - src/fsck.fat.h | 11 - - src/io.c | 4 +- - src/linux/fd.h | 383 ++++++++++++++++++++++++++++++ - src/linux/fs.h | 206 ++++++++++++++++ - src/linux/hdreg.h | 644 +++++++++++++++++++++++++++++++++++++++++++++++++++ - src/linux/magic.h | 76 ++++++ - src/linux/msdos_fs.h | 201 ++++++++++++++++ - src/mkfs.fat.c | 32 ++- - 13 files changed, 1603 insertions(+), 36 deletions(-) - create mode 100644 src/linux/fd.h - create mode 100644 src/linux/fs.h - create mode 100644 src/linux/hdreg.h - create mode 100644 src/linux/magic.h - create mode 100644 src/linux/msdos_fs.h - -diff --git a/Makefile b/Makefile -index 3cbdb76..b86111d 100644 ---- a/Makefile -+++ b/Makefile -@@ -27,10 +27,16 @@ SBINDIR = $(PREFIX)/sbin - DOCDIR = $(PREFIX)/share/doc - MANDIR = $(PREFIX)/share/man - -+UNAME_S := $(shell uname -s) -+ifeq ($(UNAME_S),Darwin) -+ CFLAGS += -D__osx__ -+ LDLIBS += -liconv -+endif -+ - #OPTFLAGS = -O2 -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 - OPTFLAGS = -O2 -fomit-frame-pointer -D_GNU_SOURCE $(shell getconf LFS_CFLAGS) - #WARNFLAGS = -Wall -pedantic -std=c99 --WARNFLAGS = -Wall -Wextra -Wno-sign-compare -Wno-missing-field-initializers -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -+WARNFLAGS = -Wall -Wextra -Wno-sign-compare -Wno-missing-field-initializers -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wimplicit-function-declaration - DEBUGFLAGS = -g - CFLAGS += $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS) - -@@ -62,7 +68,8 @@ install-man: - for MANPAGE in manpages/en/*; \ - do \ - SECTION="8"; \ -- install -D -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/man$${SECTION}/$$(basename $${MANPAGE}); \ -+ mkdir -p $(DESTDIR)/$(MANDIR)/man$${SECTION}/; \ -+ install -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/man$${SECTION}/$$(basename $${MANPAGE}); \ - done - - for LANGUAGE in $(LANGUAGES); \ -@@ -70,7 +77,8 @@ install-man: - for MANPAGE in manpages/$${LANGUAGE}/*; \ - do \ - SECTION="8"; \ -- install -D -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/$${LANGUAGE}/man$${SECTION}/$$(basename $${MANPAGE} .$${LANGUAGE}.$${SECTION}).$${SECTION}; \ -+ mkdir -p $(DESTDIR)/$(MANDIR)/$${LANGUAGE}/man$${SECTION}/; \ -+ install -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/$${LANGUAGE}/man$${SECTION}/$$(basename $${MANPAGE} .$${LANGUAGE}.$${SECTION}).$${SECTION}; \ - done; \ - done - install-symlinks: install-bin install-man -@@ -127,7 +135,7 @@ uninstall-man: - for MANPAGE in manpages/en/*; \ - do \ - SECTION="8"; \ -- rm -f $(DESTDIR)/$(MANDIR}/man$${SECTION}/$$(basename $${MANPAGE} .en.$${SECTION}).$${SECTION}; \ -+ rm -f $(DESTDIR)/$(MANDIR)/man$${SECTION}/$$(basename $${MANPAGE} .en.$${SECTION}).$${SECTION}; \ - done - - for LANGUAGE in $(LANGUAGES); \ -diff --git a/src/boot.c b/src/boot.c -index be7bfb7..0c8b273 100644 ---- a/src/boot.c -+++ b/src/boot.c -@@ -31,6 +31,7 @@ - #include - - #include "common.h" -+#include "linux/msdos_fs.h" - #include "fsck.fat.h" - #include "fat.h" - #include "io.h" -diff --git a/src/common.h b/src/common.h -index b127f63..e16c00c 100644 ---- a/src/common.h -+++ b/src/common.h -@@ -20,11 +20,61 @@ - can be found in /usr/share/common-licenses/GPL-3 file. - */ - --#include -- - #ifndef _COMMON_H - #define _COMMON_H - -+/* from linux/types.h */ -+#if defined(__linux__) -+ #include -+#elif defined(__osx__) -+ #include -+ -+ typedef uint8_t __u8; -+ typedef uint16_t __u16; -+ typedef uint32_t __u32; -+ typedef uint64_t __u64; -+ -+ typedef int16_t __le16; -+ typedef int32_t __le32; -+ -+ /* from linux stdio.h */ -+ #ifndef loff_t -+ typedef long long loff_t; -+ #endif /* loff_t */ -+ -+ #ifndef off64_t -+ #ifdef _LP64 -+ typedef off_t off64_t; -+ #else -+ typedef __longlong_t off64_t; -+ #endif /* _LP64 */ -+ #endif /* off64_t */ -+ -+ /* from endian.h */ -+ #if defined(__APPLE__) && defined(__MACH__) -+ #include -+ -+ #define htobe16(x) OSSwapHostToBigInt16(x) -+ #define htole16(x) OSSwapHostToLittleInt16(x) -+ #define be16toh(x) OSSwapBigToHostInt16(x) -+ #define le16toh(x) OSSwapLittleToHostInt16(x) -+ -+ #define htobe32(x) OSSwapHostToBigInt32(x) -+ #define htole32(x) OSSwapHostToLittleInt32(x) -+ #define be32toh(x) OSSwapBigToHostInt32(x) -+ #define le32toh(x) OSSwapLittleToHostInt32(x) -+ -+ #define htobe64(x) OSSwapHostToBigInt64(x) -+ #define htole64(x) OSSwapHostToLittleInt64(x) -+ #define be64toh(x) OSSwapBigToHostInt64(x) -+ #define le64toh(x) OSSwapLittleToHostInt64(x) -+ -+ #ifndef lseek64 -+ #define lseek64 lseek -+ #endif /* lseek64 */ -+ #endif /* __APPLE__ && __MACH__ */ -+#endif -+ - void die(const char *msg, ...) __attribute((noreturn)); - - /* Displays a prinf-style message and terminates the program. */ -diff --git a/src/file.c b/src/file.c -index 30adcde..1c1a5f0 100644 ---- a/src/file.c -+++ b/src/file.c -@@ -30,15 +30,8 @@ - #include - #include - --#define _LINUX_STAT_H /* hack to avoid inclusion of */ --#define _LINUX_STRING_H_ /* hack to avoid inclusion of */ --#define _LINUX_FS_H /* hack to avoid inclusion of */ -- --#include -- --#include -- - #include "common.h" -+#include "linux/msdos_fs.h" - #include "file.h" - #include "charconv.h" - -diff --git a/src/file.h b/src/file.h -index 3adfc96..f5dec16 100644 ---- a/src/file.h -+++ b/src/file.h -@@ -23,6 +23,8 @@ - #ifndef _FILE_H - #define _FILE_H - -+#include "linux/msdos_fs.h" -+ - typedef enum { fdt_none, fdt_drop, fdt_undelete } FD_TYPE; - - typedef struct _fptr { -diff --git a/src/fsck.fat.h b/src/fsck.fat.h -index e5ade5b..274820a 100644 ---- a/src/fsck.fat.h -+++ b/src/fsck.fat.h -@@ -28,19 +28,8 @@ - #define _DOSFSCK_H - - #include --#include --#define _LINUX_STAT_H /* hack to avoid inclusion of */ --#define _LINUX_STRING_H_ /* hack to avoid inclusion of */ --#define _LINUX_FS_H /* hack to avoid inclusion of */ -- --#include --#include -- --#include -- - #include - #include --#include - - #define VFAT_LN_ATTR (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME) - -diff --git a/src/io.c b/src/io.c -index 3755ba5..fa96b62 100644 ---- a/src/io.c -+++ b/src/io.c -@@ -40,10 +40,10 @@ - #include - #include - #include --#include - --#include "fsck.fat.h" -+#include "linux/fd.h" - #include "common.h" -+#include "fsck.fat.h" - #include "io.h" - - typedef struct _change { -diff --git a/src/linux/fd.h b/src/linux/fd.h -new file mode 100644 -index 0000000..ffe33a6 ---- /dev/null -+++ b/src/linux/fd.h -@@ -0,0 +1,383 @@ -+#ifndef _LINUX_FD_H -+#define _LINUX_FD_H -+ -+#ifdef __linux__ -+#include -+#endif -+ -+/* New file layout: Now the ioctl definitions immediately follow the -+ * definitions of the structures that they use */ -+ -+/* -+ * Geometry -+ */ -+struct floppy_struct { -+ unsigned int size, /* nr of sectors total */ -+ sect, /* sectors per track */ -+ head, /* nr of heads */ -+ track, /* nr of tracks */ -+ stretch; /* bit 0 !=0 means double track steps */ -+ /* bit 1 != 0 means swap sides */ -+ /* bits 2..9 give the first sector */ -+ /* number (the LSB is flipped) */ -+#define FD_STRETCH 1 -+#define FD_SWAPSIDES 2 -+#define FD_ZEROBASED 4 -+#define FD_SECTBASEMASK 0x3FC -+#define FD_MKSECTBASE(s) (((s) ^ 1) << 2) -+#define FD_SECTBASE(floppy) ((((floppy)->stretch & FD_SECTBASEMASK) >> 2) ^ 1) -+ -+ unsigned char gap, /* gap1 size */ -+ -+ rate, /* data rate. |= 0x40 for perpendicular */ -+#define FD_2M 0x4 -+#define FD_SIZECODEMASK 0x38 -+#define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8) -+#define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \ -+ 512 : 128 << FD_SIZECODE(floppy) ) -+#define FD_PERP 0x40 -+ -+ spec1, /* stepping rate, head unload time */ -+ fmt_gap; /* gap2 size */ -+ const char * name; /* used only for predefined formats */ -+}; -+ -+ -+/* commands needing write access have 0x40 set */ -+/* commands needing super user access have 0x80 set */ -+ -+#define FDCLRPRM _IO(2, 0x41) -+/* clear user-defined parameters */ -+ -+#define FDSETPRM _IOW(2, 0x42, struct floppy_struct) -+#define FDSETMEDIAPRM FDSETPRM -+/* set user-defined parameters for current media */ -+ -+#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct) -+#define FDGETPRM _IOR(2, 0x04, struct floppy_struct) -+#define FDDEFMEDIAPRM FDDEFPRM -+#define FDGETMEDIAPRM FDGETPRM -+/* set/get disk parameters */ -+ -+ -+#define FDMSGON _IO(2,0x45) -+#define FDMSGOFF _IO(2,0x46) -+/* issue/don't issue kernel messages on media type change */ -+ -+ -+/* -+ * Formatting (obsolete) -+ */ -+#define FD_FILL_BYTE 0xF6 /* format fill byte. */ -+ -+struct format_descr { -+ unsigned int device,head,track; -+}; -+ -+#define FDFMTBEG _IO(2,0x47) -+/* begin formatting a disk */ -+#define FDFMTTRK _IOW(2,0x48, struct format_descr) -+/* format the specified track */ -+#define FDFMTEND _IO(2,0x49) -+/* end formatting a disk */ -+ -+ -+/* -+ * Error thresholds -+ */ -+struct floppy_max_errors { -+ unsigned int -+ abort, /* number of errors to be reached before aborting */ -+ read_track, /* maximal number of errors permitted to read an -+ * entire track at once */ -+ reset, /* maximal number of errors before a reset is tried */ -+ recal, /* maximal number of errors before a recalibrate is -+ * tried */ -+ -+ /* -+ * Threshold for reporting FDC errors to the console. -+ * Setting this to zero may flood your screen when using -+ * ultra cheap floppies ;-) -+ */ -+ reporting; -+ -+}; -+ -+#define FDSETEMSGTRESH _IO(2,0x4a) -+/* set fdc error reporting threshold */ -+ -+#define FDFLUSH _IO(2,0x4b) -+/* flush buffers for media; either for verifying media, or for -+ * handling a media change without closing the file descriptor */ -+ -+#define FDSETMAXERRS _IOW(2, 0x4c, struct floppy_max_errors) -+#define FDGETMAXERRS _IOR(2, 0x0e, struct floppy_max_errors) -+/* set/get abortion and read_track threshold. See also floppy_drive_params -+ * structure */ -+ -+ -+typedef char floppy_drive_name[16]; -+#define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive_name) -+/* get drive type: 5 1/4 or 3 1/2 */ -+ -+ -+/* -+ * Drive parameters (user modifiable) -+ */ -+struct floppy_drive_params { -+ signed char cmos; /* CMOS type */ -+ -+ /* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms -+ * etc) and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA). -+ */ -+ unsigned long max_dtr; /* Step rate, usec */ -+ unsigned long hlt; /* Head load/settle time, msec */ -+ unsigned long hut; /* Head unload time (remnant of -+ * 8" drives) */ -+ unsigned long srt; /* Step rate, usec */ -+ -+ unsigned long spinup; /* time needed for spinup (expressed -+ * in jiffies) */ -+ unsigned long spindown; /* timeout needed for spindown */ -+ unsigned char spindown_offset; /* decides in which position the disk -+ * will stop */ -+ unsigned char select_delay; /* delay to wait after select */ -+ unsigned char rps; /* rotations per second */ -+ unsigned char tracks; /* maximum number of tracks */ -+ unsigned long timeout; /* timeout for interrupt requests */ -+ -+ unsigned char interleave_sect; /* if there are more sectors, use -+ * interleave */ -+ -+ struct floppy_max_errors max_errors; -+ -+ char flags; /* various flags, including ftd_msg */ -+/* -+ * Announce successful media type detection and media information loss after -+ * disk changes. -+ * Also used to enable/disable printing of overrun warnings. -+ */ -+ -+#define FTD_MSG 0x10 -+#define FD_BROKEN_DCL 0x20 -+#define FD_DEBUG 0x02 -+#define FD_SILENT_DCL_CLEAR 0x4 -+#define FD_INVERTED_DCL 0x80 /* must be 0x80, because of hardware -+ considerations */ -+ -+ char read_track; /* use readtrack during probing? */ -+ -+/* -+ * Auto-detection. Each drive type has eight formats which are -+ * used in succession to try to read the disk. If the FDC cannot lock onto -+ * the disk, the next format is tried. This uses the variable 'probing'. -+ */ -+ short autodetect[8]; /* autodetected formats */ -+ -+ int checkfreq; /* how often should the drive be checked for disk -+ * changes */ -+ int native_format; /* native format of this drive */ -+}; -+ -+enum { -+ FD_NEED_TWADDLE_BIT, /* more magic */ -+ FD_VERIFY_BIT, /* inquire for write protection */ -+ FD_DISK_NEWCHANGE_BIT, /* change detected, and no action undertaken yet -+ * to clear media change status */ -+ FD_UNUSED_BIT, -+ FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */ -+ FD_DISK_WRITABLE_BIT /* disk is writable */ -+}; -+ -+#define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params) -+#define FDGETDRVPRM _IOR(2, 0x11, struct floppy_drive_params) -+/* set/get drive parameters */ -+ -+ -+/* -+ * Current drive state (not directly modifiable by user, readonly) -+ */ -+struct floppy_drive_struct { -+ unsigned long flags; -+/* values for these flags */ -+#define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT) -+#define FD_VERIFY (1 << FD_VERIFY_BIT) -+#define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT) -+#define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT) -+#define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT) -+ -+ unsigned long spinup_date; -+ unsigned long select_date; -+ unsigned long first_read_date; -+ short probed_format; -+ short track; /* current track */ -+ short maxblock; /* id of highest block read */ -+ short maxtrack; /* id of highest half track read */ -+ int generation; /* how many diskchanges? */ -+ -+/* -+ * (User-provided) media information is _not_ discarded after a media change -+ * if the corresponding keep_data flag is non-zero. Positive values are -+ * decremented after each probe. -+ */ -+ int keep_data; -+ -+ /* Prevent "aliased" accesses. */ -+ int fd_ref; -+ int fd_device; -+ unsigned long last_checked; /* when was the drive last checked for a disk -+ * change? */ -+ -+ char *dmabuf; -+ int bufblocks; -+}; -+ -+#define FDGETDRVSTAT _IOR(2, 0x12, struct floppy_drive_struct) -+#define FDPOLLDRVSTAT _IOR(2, 0x13, struct floppy_drive_struct) -+/* get drive state: GET returns the cached state, POLL polls for new state */ -+ -+ -+/* -+ * reset FDC -+ */ -+enum reset_mode { -+ FD_RESET_IF_NEEDED, /* reset only if the reset flags is set */ -+ FD_RESET_IF_RAWCMD, /* obsolete */ -+ FD_RESET_ALWAYS /* reset always */ -+}; -+#define FDRESET _IO(2, 0x54) -+ -+ -+/* -+ * FDC state -+ */ -+struct floppy_fdc_state { -+ int spec1; /* spec1 value last used */ -+ int spec2; /* spec2 value last used */ -+ int dtr; -+ unsigned char version; /* FDC version code */ -+ unsigned char dor; -+ unsigned long address; /* io address */ -+ unsigned int rawcmd:2; -+ unsigned int reset:1; -+ unsigned int need_configure:1; -+ unsigned int perp_mode:2; -+ unsigned int has_fifo:1; -+ unsigned int driver_version; /* version code for floppy driver */ -+#define FD_DRIVER_VERSION 0x100 -+/* user programs using the floppy API should use floppy_fdc_state to -+ * get the version number of the floppy driver that they are running -+ * on. If this version number is bigger than the one compiled into the -+ * user program (the FD_DRIVER_VERSION define), it should be prepared -+ * to bigger structures -+ */ -+ -+ unsigned char track[4]; -+ /* Position of the heads of the 4 units attached to this FDC, -+ * as stored on the FDC. In the future, the position as stored -+ * on the FDC might not agree with the actual physical -+ * position of these drive heads. By allowing such -+ * disagreement, it will be possible to reset the FDC without -+ * incurring the expensive cost of repositioning all heads. -+ * Right now, these positions are hard wired to 0. */ -+ -+}; -+ -+#define FDGETFDCSTAT _IOR(2, 0x15, struct floppy_fdc_state) -+ -+ -+/* -+ * Asynchronous Write error tracking -+ */ -+struct floppy_write_errors { -+ /* Write error logging. -+ * -+ * These fields can be cleared with the FDWERRORCLR ioctl. -+ * Only writes that were attempted but failed due to a physical media -+ * error are logged. write(2) calls that fail and return an error code -+ * to the user process are not counted. -+ */ -+ -+ unsigned int write_errors; /* number of physical write errors -+ * encountered */ -+ -+ /* position of first and last write errors */ -+ unsigned long first_error_sector; -+ int first_error_generation; -+ unsigned long last_error_sector; -+ int last_error_generation; -+ -+ unsigned int badness; /* highest retry count for a read or write -+ * operation */ -+}; -+ -+#define FDWERRORCLR _IO(2, 0x56) -+/* clear write error and badness information */ -+#define FDWERRORGET _IOR(2, 0x17, struct floppy_write_errors) -+/* get write error and badness information */ -+ -+ -+/* -+ * Raw commands -+ */ -+/* new interface flag: now we can do them in batches */ -+#define FDHAVEBATCHEDRAWCMD -+ -+struct floppy_raw_cmd { -+ unsigned int flags; -+#define FD_RAW_READ 1 -+#define FD_RAW_WRITE 2 -+#define FD_RAW_NO_MOTOR 4 -+#define FD_RAW_DISK_CHANGE 4 /* out: disk change flag was set */ -+#define FD_RAW_INTR 8 /* wait for an interrupt */ -+#define FD_RAW_SPIN 0x10 /* spin up the disk for this command */ -+#define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command -+ * completion */ -+#define FD_RAW_NEED_DISK 0x40 /* this command needs a disk to be present */ -+#define FD_RAW_NEED_SEEK 0x80 /* this command uses an implied seek (soft) */ -+ -+/* more "in" flags */ -+#define FD_RAW_MORE 0x100 /* more records follow */ -+#define FD_RAW_STOP_IF_FAILURE 0x200 /* stop if we encounter a failure */ -+#define FD_RAW_STOP_IF_SUCCESS 0x400 /* stop if command successful */ -+#define FD_RAW_SOFTFAILURE 0x800 /* consider the return value for failure -+ * detection too */ -+ -+/* more "out" flags */ -+#define FD_RAW_FAILURE 0x10000 /* command sent to fdc, fdc returned error */ -+#define FD_RAW_HARDFAILURE 0x20000 /* fdc had to be reset, or timed out */ -+ -+ void *data; -+ char *kernel_data; /* location of data buffer in the kernel */ -+ struct floppy_raw_cmd *next; /* used for chaining of raw cmd's -+ * within the kernel */ -+ long length; /* in: length of dma transfer. out: remaining bytes */ -+ long phys_length; /* physical length, if different from dma length */ -+ int buffer_length; /* length of allocated buffer */ -+ -+ unsigned char rate; -+ unsigned char cmd_count; -+ unsigned char cmd[16]; -+ unsigned char reply_count; -+ unsigned char reply[16]; -+ int track; -+ int resultcode; -+ -+ int reserved1; -+ int reserved2; -+}; -+ -+#define FDRAWCMD _IO(2, 0x58) -+/* send a raw command to the fdc. Structure size not included, because of -+ * batches */ -+ -+#define FDTWADDLE _IO(2, 0x59) -+/* flicker motor-on bit before reading a sector. Experimental */ -+ -+ -+#define FDEJECT _IO(2, 0x5a) -+/* eject the disk */ -+ -+ -+ -+#endif /* _LINUX_FD_H */ -diff --git a/src/linux/fs.h b/src/linux/fs.h -new file mode 100644 -index 0000000..8639ce5 ---- /dev/null -+++ b/src/linux/fs.h -@@ -0,0 +1,206 @@ -+#ifndef _LINUX_FS_H -+#define _LINUX_FS_H -+ -+/* -+ * This file has definitions for some important file table -+ * structures etc. -+ */ -+ -+#ifdef __linux__ -+#include -+#include -+#include -+#endif -+ -+/* -+ * It's silly to have NR_OPEN bigger than NR_FILE, but you can change -+ * the file limit at runtime and only root can increase the per-process -+ * nr_file rlimit, so it's safe to set up a ridiculously high absolute -+ * upper limit on files-per-process. -+ * -+ * Some programs (notably those using select()) may have to be -+ * recompiled to take full advantage of the new limits.. -+ */ -+ -+/* Fixed constants first: */ -+#undef NR_OPEN -+#define INR_OPEN_CUR 1024 /* Initial setting for nfile rlimits */ -+#define INR_OPEN_MAX 4096 /* Hard limit for nfile rlimits */ -+ -+#define BLOCK_SIZE_BITS 10 -+#define BLOCK_SIZE (1< -+#endif -+ -+/* -+ * Command Header sizes for IOCTL commands -+ */ -+ -+#define HDIO_DRIVE_CMD_HDR_SIZE (4 * sizeof(__u8)) -+#define HDIO_DRIVE_HOB_HDR_SIZE (8 * sizeof(__u8)) -+#define HDIO_DRIVE_TASK_HDR_SIZE (8 * sizeof(__u8)) -+ -+#define IDE_DRIVE_TASK_NO_DATA 0 -+#define IDE_DRIVE_TASK_INVALID -1 -+#define IDE_DRIVE_TASK_SET_XFER 1 -+#define IDE_DRIVE_TASK_IN 2 -+#define IDE_DRIVE_TASK_OUT 3 -+#define IDE_DRIVE_TASK_RAW_WRITE 4 -+ -+/* -+ * Define standard taskfile in/out register -+ */ -+#define IDE_TASKFILE_STD_IN_FLAGS 0xFE -+#define IDE_HOB_STD_IN_FLAGS 0x3C -+#define IDE_TASKFILE_STD_OUT_FLAGS 0xFE -+#define IDE_HOB_STD_OUT_FLAGS 0x3C -+ -+typedef unsigned char task_ioreg_t; -+typedef unsigned long sata_ioreg_t; -+ -+typedef union ide_reg_valid_s { -+ unsigned all : 16; -+ struct { -+ unsigned data : 1; -+ unsigned error_feature : 1; -+ unsigned sector : 1; -+ unsigned nsector : 1; -+ unsigned lcyl : 1; -+ unsigned hcyl : 1; -+ unsigned select : 1; -+ unsigned status_command : 1; -+ -+ unsigned data_hob : 1; -+ unsigned error_feature_hob : 1; -+ unsigned sector_hob : 1; -+ unsigned nsector_hob : 1; -+ unsigned lcyl_hob : 1; -+ unsigned hcyl_hob : 1; -+ unsigned select_hob : 1; -+ unsigned control_hob : 1; -+ } b; -+} ide_reg_valid_t; -+ -+typedef struct ide_task_request_s { -+ __u8 io_ports[8]; -+ __u8 hob_ports[8]; /* bytes 6 and 7 are unused */ -+ ide_reg_valid_t out_flags; -+ ide_reg_valid_t in_flags; -+ int data_phase; -+ int req_cmd; -+ unsigned long out_size; -+ unsigned long in_size; -+} ide_task_request_t; -+ -+typedef struct ide_ioctl_request_s { -+ ide_task_request_t *task_request; -+ unsigned char *out_buffer; -+ unsigned char *in_buffer; -+} ide_ioctl_request_t; -+ -+struct hd_drive_cmd_hdr { -+ __u8 command; -+ __u8 sector_number; -+ __u8 feature; -+ __u8 sector_count; -+}; -+ -+typedef struct hd_drive_task_hdr { -+ __u8 data; -+ __u8 feature; -+ __u8 sector_count; -+ __u8 sector_number; -+ __u8 low_cylinder; -+ __u8 high_cylinder; -+ __u8 device_head; -+ __u8 command; -+} task_struct_t; -+ -+typedef struct hd_drive_hob_hdr { -+ __u8 data; -+ __u8 feature; -+ __u8 sector_count; -+ __u8 sector_number; -+ __u8 low_cylinder; -+ __u8 high_cylinder; -+ __u8 device_head; -+ __u8 control; -+} hob_struct_t; -+ -+#define TASKFILE_NO_DATA 0x0000 -+ -+#define TASKFILE_IN 0x0001 -+#define TASKFILE_MULTI_IN 0x0002 -+ -+#define TASKFILE_OUT 0x0004 -+#define TASKFILE_MULTI_OUT 0x0008 -+#define TASKFILE_IN_OUT 0x0010 -+ -+#define TASKFILE_IN_DMA 0x0020 -+#define TASKFILE_OUT_DMA 0x0040 -+#define TASKFILE_IN_DMAQ 0x0080 -+#define TASKFILE_OUT_DMAQ 0x0100 -+ -+#define TASKFILE_P_IN 0x0200 -+#define TASKFILE_P_OUT 0x0400 -+#define TASKFILE_P_IN_DMA 0x0800 -+#define TASKFILE_P_OUT_DMA 0x1000 -+#define TASKFILE_P_IN_DMAQ 0x2000 -+#define TASKFILE_P_OUT_DMAQ 0x4000 -+#define TASKFILE_48 0x8000 -+#define TASKFILE_INVALID 0x7fff -+ -+/* ATA/ATAPI Commands pre T13 Spec */ -+#define WIN_NOP 0x00 -+/* -+ * 0x01->0x02 Reserved -+ */ -+#define CFA_REQ_EXT_ERROR_CODE 0x03 /* CFA Request Extended Error Code */ -+/* -+ * 0x04->0x07 Reserved -+ */ -+#define WIN_SRST 0x08 /* ATAPI soft reset command */ -+#define WIN_DEVICE_RESET 0x08 -+/* -+ * 0x09->0x0F Reserved -+ */ -+#define WIN_RECAL 0x10 -+#define WIN_RESTORE WIN_RECAL -+/* -+ * 0x10->0x1F Reserved -+ */ -+#define WIN_READ 0x20 /* 28-Bit */ -+#define WIN_READ_ONCE 0x21 /* 28-Bit without retries */ -+#define WIN_READ_LONG 0x22 /* 28-Bit */ -+#define WIN_READ_LONG_ONCE 0x23 /* 28-Bit without retries */ -+#define WIN_READ_EXT 0x24 /* 48-Bit */ -+#define WIN_READDMA_EXT 0x25 /* 48-Bit */ -+#define WIN_READDMA_QUEUED_EXT 0x26 /* 48-Bit */ -+#define WIN_READ_NATIVE_MAX_EXT 0x27 /* 48-Bit */ -+/* -+ * 0x28 -+ */ -+#define WIN_MULTREAD_EXT 0x29 /* 48-Bit */ -+/* -+ * 0x2A->0x2F Reserved -+ */ -+#define WIN_WRITE 0x30 /* 28-Bit */ -+#define WIN_WRITE_ONCE 0x31 /* 28-Bit without retries */ -+#define WIN_WRITE_LONG 0x32 /* 28-Bit */ -+#define WIN_WRITE_LONG_ONCE 0x33 /* 28-Bit without retries */ -+#define WIN_WRITE_EXT 0x34 /* 48-Bit */ -+#define WIN_WRITEDMA_EXT 0x35 /* 48-Bit */ -+#define WIN_WRITEDMA_QUEUED_EXT 0x36 /* 48-Bit */ -+#define WIN_SET_MAX_EXT 0x37 /* 48-Bit */ -+#define CFA_WRITE_SECT_WO_ERASE 0x38 /* CFA Write Sectors without erase */ -+#define WIN_MULTWRITE_EXT 0x39 /* 48-Bit */ -+/* -+ * 0x3A->0x3B Reserved -+ */ -+#define WIN_WRITE_VERIFY 0x3C /* 28-Bit */ -+/* -+ * 0x3D->0x3F Reserved -+ */ -+#define WIN_VERIFY 0x40 /* 28-Bit - Read Verify Sectors */ -+#define WIN_VERIFY_ONCE 0x41 /* 28-Bit - without retries */ -+#define WIN_VERIFY_EXT 0x42 /* 48-Bit */ -+/* -+ * 0x43->0x4F Reserved -+ */ -+#define WIN_FORMAT 0x50 -+/* -+ * 0x51->0x5F Reserved -+ */ -+#define WIN_INIT 0x60 -+/* -+ * 0x61->0x5F Reserved -+ */ -+#define WIN_SEEK 0x70 /* 0x70-0x7F Reserved */ -+ -+#define CFA_TRANSLATE_SECTOR 0x87 /* CFA Translate Sector */ -+#define WIN_DIAGNOSE 0x90 -+#define WIN_SPECIFY 0x91 /* set drive geometry translation */ -+#define WIN_DOWNLOAD_MICROCODE 0x92 -+#define WIN_STANDBYNOW2 0x94 -+#define WIN_STANDBY2 0x96 -+#define WIN_SETIDLE2 0x97 -+#define WIN_CHECKPOWERMODE2 0x98 -+#define WIN_SLEEPNOW2 0x99 -+/* -+ * 0x9A VENDOR -+ */ -+#define WIN_PACKETCMD 0xA0 /* Send a packet command. */ -+#define WIN_PIDENTIFY 0xA1 /* identify ATAPI device */ -+#define WIN_QUEUED_SERVICE 0xA2 -+#define WIN_SMART 0xB0 /* self-monitoring and reporting */ -+#define CFA_ERASE_SECTORS 0xC0 -+#define WIN_MULTREAD 0xC4 /* read sectors using multiple mode*/ -+#define WIN_MULTWRITE 0xC5 /* write sectors using multiple mode */ -+#define WIN_SETMULT 0xC6 /* enable/disable multiple mode */ -+#define WIN_READDMA_QUEUED 0xC7 /* read sectors using Queued DMA transfers */ -+#define WIN_READDMA 0xC8 /* read sectors using DMA transfers */ -+#define WIN_READDMA_ONCE 0xC9 /* 28-Bit - without retries */ -+#define WIN_WRITEDMA 0xCA /* write sectors using DMA transfers */ -+#define WIN_WRITEDMA_ONCE 0xCB /* 28-Bit - without retries */ -+#define WIN_WRITEDMA_QUEUED 0xCC /* write sectors using Queued DMA transfers */ -+#define CFA_WRITE_MULTI_WO_ERASE 0xCD /* CFA Write multiple without erase */ -+#define WIN_GETMEDIASTATUS 0xDA -+#define WIN_ACKMEDIACHANGE 0xDB /* ATA-1, ATA-2 vendor */ -+#define WIN_POSTBOOT 0xDC -+#define WIN_PREBOOT 0xDD -+#define WIN_DOORLOCK 0xDE /* lock door on removable drives */ -+#define WIN_DOORUNLOCK 0xDF /* unlock door on removable drives */ -+#define WIN_STANDBYNOW1 0xE0 -+#define WIN_IDLEIMMEDIATE 0xE1 /* force drive to become "ready" */ -+#define WIN_STANDBY 0xE2 /* Set device in Standby Mode */ -+#define WIN_SETIDLE1 0xE3 -+#define WIN_READ_BUFFER 0xE4 /* force read only 1 sector */ -+#define WIN_CHECKPOWERMODE1 0xE5 -+#define WIN_SLEEPNOW1 0xE6 -+#define WIN_FLUSH_CACHE 0xE7 -+#define WIN_WRITE_BUFFER 0xE8 /* force write only 1 sector */ -+#define WIN_WRITE_SAME 0xE9 /* read ata-2 to use */ -+ /* SET_FEATURES 0x22 or 0xDD */ -+#define WIN_FLUSH_CACHE_EXT 0xEA /* 48-Bit */ -+#define WIN_IDENTIFY 0xEC /* ask drive to identify itself */ -+#define WIN_MEDIAEJECT 0xED -+#define WIN_IDENTIFY_DMA 0xEE /* same as WIN_IDENTIFY, but DMA */ -+#define WIN_SETFEATURES 0xEF /* set special drive features */ -+#define EXABYTE_ENABLE_NEST 0xF0 -+#define WIN_SECURITY_SET_PASS 0xF1 -+#define WIN_SECURITY_UNLOCK 0xF2 -+#define WIN_SECURITY_ERASE_PREPARE 0xF3 -+#define WIN_SECURITY_ERASE_UNIT 0xF4 -+#define WIN_SECURITY_FREEZE_LOCK 0xF5 -+#define WIN_SECURITY_DISABLE 0xF6 -+#define WIN_READ_NATIVE_MAX 0xF8 /* return the native maximum address */ -+#define WIN_SET_MAX 0xF9 -+#define DISABLE_SEAGATE 0xFB -+ -+/* WIN_SMART sub-commands */ -+ -+#define SMART_READ_VALUES 0xD0 -+#define SMART_READ_THRESHOLDS 0xD1 -+#define SMART_AUTOSAVE 0xD2 -+#define SMART_SAVE 0xD3 -+#define SMART_IMMEDIATE_OFFLINE 0xD4 -+#define SMART_READ_LOG_SECTOR 0xD5 -+#define SMART_WRITE_LOG_SECTOR 0xD6 -+#define SMART_WRITE_THRESHOLDS 0xD7 -+#define SMART_ENABLE 0xD8 -+#define SMART_DISABLE 0xD9 -+#define SMART_STATUS 0xDA -+#define SMART_AUTO_OFFLINE 0xDB -+ -+/* Password used in TF4 & TF5 executing SMART commands */ -+ -+#define SMART_LCYL_PASS 0x4F -+#define SMART_HCYL_PASS 0xC2 -+ -+/* WIN_SETFEATURES sub-commands */ -+#define SETFEATURES_EN_8BIT 0x01 /* Enable 8-Bit Transfers */ -+#define SETFEATURES_EN_WCACHE 0x02 /* Enable write cache */ -+#define SETFEATURES_DIS_DEFECT 0x04 /* Disable Defect Management */ -+#define SETFEATURES_EN_APM 0x05 /* Enable advanced power management */ -+#define SETFEATURES_EN_SAME_R 0x22 /* for a region ATA-1 */ -+#define SETFEATURES_DIS_MSN 0x31 /* Disable Media Status Notification */ -+#define SETFEATURES_DIS_RETRY 0x33 /* Disable Retry */ -+#define SETFEATURES_EN_AAM 0x42 /* Enable Automatic Acoustic Management */ -+#define SETFEATURES_RW_LONG 0x44 /* Set Length of VS bytes */ -+#define SETFEATURES_SET_CACHE 0x54 /* Set Cache segments to SC Reg. Val */ -+#define SETFEATURES_DIS_RLA 0x55 /* Disable read look-ahead feature */ -+#define SETFEATURES_EN_RI 0x5D /* Enable release interrupt */ -+#define SETFEATURES_EN_SI 0x5E /* Enable SERVICE interrupt */ -+#define SETFEATURES_DIS_RPOD 0x66 /* Disable reverting to power on defaults */ -+#define SETFEATURES_DIS_ECC 0x77 /* Disable ECC byte count */ -+#define SETFEATURES_DIS_8BIT 0x81 /* Disable 8-Bit Transfers */ -+#define SETFEATURES_DIS_WCACHE 0x82 /* Disable write cache */ -+#define SETFEATURES_EN_DEFECT 0x84 /* Enable Defect Management */ -+#define SETFEATURES_DIS_APM 0x85 /* Disable advanced power management */ -+#define SETFEATURES_EN_ECC 0x88 /* Enable ECC byte count */ -+#define SETFEATURES_EN_MSN 0x95 /* Enable Media Status Notification */ -+#define SETFEATURES_EN_RETRY 0x99 /* Enable Retry */ -+#define SETFEATURES_EN_RLA 0xAA /* Enable read look-ahead feature */ -+#define SETFEATURES_PREFETCH 0xAB /* Sets drive prefetch value */ -+#define SETFEATURES_EN_REST 0xAC /* ATA-1 */ -+#define SETFEATURES_4B_RW_LONG 0xBB /* Set Length of 4 bytes */ -+#define SETFEATURES_DIS_AAM 0xC2 /* Disable Automatic Acoustic Management */ -+#define SETFEATURES_EN_RPOD 0xCC /* Enable reverting to power on defaults */ -+#define SETFEATURES_DIS_RI 0xDD /* Disable release interrupt ATAPI */ -+#define SETFEATURES_EN_SAME_M 0xDD /* for a entire device ATA-1 */ -+#define SETFEATURES_DIS_SI 0xDE /* Disable SERVICE interrupt ATAPI */ -+ -+/* WIN_SECURITY sub-commands */ -+ -+#define SECURITY_SET_PASSWORD 0xBA -+#define SECURITY_UNLOCK 0xBB -+#define SECURITY_ERASE_PREPARE 0xBC -+#define SECURITY_ERASE_UNIT 0xBD -+#define SECURITY_FREEZE_LOCK 0xBE -+#define SECURITY_DISABLE_PASSWORD 0xBF -+ -+struct hd_geometry { -+ unsigned char heads; -+ unsigned char sectors; -+ unsigned short cylinders; -+ unsigned long start; -+}; -+ -+/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */ -+#define HDIO_GETGEO 0x0301 /* get device geometry */ -+#define HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */ -+#define HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */ -+#define HDIO_GET_QDMA 0x0305 /* get use-qdma flag */ -+ -+#define HDIO_SET_XFER 0x0306 /* set transfer rate via proc */ -+ -+#define HDIO_OBSOLETE_IDENTITY 0x0307 /* OBSOLETE, DO NOT USE: returns 142 bytes */ -+#define HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */ -+#define HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */ -+#define HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */ -+#define HDIO_GET_DMA 0x030b /* get use-dma flag */ -+#define HDIO_GET_NICE 0x030c /* get nice flags */ -+#define HDIO_GET_IDENTITY 0x030d /* get IDE identification info */ -+#define HDIO_GET_WCACHE 0x030e /* get write cache mode on|off */ -+#define HDIO_GET_ACOUSTIC 0x030f /* get acoustic value */ -+#define HDIO_GET_ADDRESS 0x0310 /* */ -+ -+#define HDIO_GET_BUSSTATE 0x031a /* get the bus state of the hwif */ -+#define HDIO_TRISTATE_HWIF 0x031b /* execute a channel tristate */ -+#define HDIO_DRIVE_RESET 0x031c /* execute a device reset */ -+#define HDIO_DRIVE_TASKFILE 0x031d /* execute raw taskfile */ -+#define HDIO_DRIVE_TASK 0x031e /* execute task and special drive command */ -+#define HDIO_DRIVE_CMD 0x031f /* execute a special drive command */ -+#define HDIO_DRIVE_CMD_AEB HDIO_DRIVE_TASK -+ -+/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */ -+#define HDIO_SET_MULTCOUNT 0x0321 /* change IDE blockmode */ -+#define HDIO_SET_UNMASKINTR 0x0322 /* permit other irqs during I/O */ -+#define HDIO_SET_KEEPSETTINGS 0x0323 /* keep ioctl settings on reset */ -+#define HDIO_SET_32BIT 0x0324 /* change io_32bit flags */ -+#define HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */ -+#define HDIO_SET_DMA 0x0326 /* change use-dma flag */ -+#define HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */ -+#define HDIO_SCAN_HWIF 0x0328 /* register and (re)scan interface */ -+#define HDIO_UNREGISTER_HWIF 0x032a /* unregister interface */ -+#define HDIO_SET_NICE 0x0329 /* set nice flags */ -+#define HDIO_SET_WCACHE 0x032b /* change write cache enable-disable */ -+#define HDIO_SET_ACOUSTIC 0x032c /* change acoustic behavior */ -+#define HDIO_SET_BUSSTATE 0x032d /* set the bus state of the hwif */ -+#define HDIO_SET_QDMA 0x032e /* change use-qdma flag */ -+#define HDIO_SET_ADDRESS 0x032f /* change lba addressing modes */ -+ -+/* bus states */ -+enum { -+ BUSSTATE_OFF = 0, -+ BUSSTATE_ON, -+ BUSSTATE_TRISTATE -+}; -+ -+/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x033n/0x033n */ -+/* 0x330 is reserved - used to be HDIO_GETGEO_BIG */ -+/* 0x331 is reserved - used to be HDIO_GETGEO_BIG_RAW */ -+/* 0x338 is reserved - used to be HDIO_SET_IDE_SCSI */ -+/* 0x339 is reserved - used to be HDIO_SET_SCSI_IDE */ -+ -+#define __NEW_HD_DRIVE_ID -+ -+/* -+ * Structure returned by HDIO_GET_IDENTITY, as per ANSI NCITS ATA6 rev.1b spec. -+ * -+ * If you change something here, please remember to update fix_driveid() in -+ * ide/probe.c. -+ */ -+struct hd_driveid { -+ unsigned short config; /* lots of obsolete bit flags */ -+ unsigned short cyls; /* Obsolete, "physical" cyls */ -+ unsigned short reserved2; /* reserved (word 2) */ -+ unsigned short heads; /* Obsolete, "physical" heads */ -+ unsigned short track_bytes; /* unformatted bytes per track */ -+ unsigned short sector_bytes; /* unformatted bytes per sector */ -+ unsigned short sectors; /* Obsolete, "physical" sectors per track */ -+ unsigned short vendor0; /* vendor unique */ -+ unsigned short vendor1; /* vendor unique */ -+ unsigned short vendor2; /* Retired vendor unique */ -+ unsigned char serial_no[20]; /* 0 = not_specified */ -+ unsigned short buf_type; /* Retired */ -+ unsigned short buf_size; /* Retired, 512 byte increments -+ * 0 = not_specified -+ */ -+ unsigned short ecc_bytes; /* for r/w long cmds; 0 = not_specified */ -+ unsigned char fw_rev[8]; /* 0 = not_specified */ -+ unsigned char model[40]; /* 0 = not_specified */ -+ unsigned char max_multsect; /* 0=not_implemented */ -+ unsigned char vendor3; /* vendor unique */ -+ unsigned short dword_io; /* 0=not_implemented; 1=implemented */ -+ unsigned char vendor4; /* vendor unique */ -+ unsigned char capability; /* (upper byte of word 49) -+ * 3: IORDYsup -+ * 2: IORDYsw -+ * 1: LBA -+ * 0: DMA -+ */ -+ unsigned short reserved50; /* reserved (word 50) */ -+ unsigned char vendor5; /* Obsolete, vendor unique */ -+ unsigned char tPIO; /* Obsolete, 0=slow, 1=medium, 2=fast */ -+ unsigned char vendor6; /* Obsolete, vendor unique */ -+ unsigned char tDMA; /* Obsolete, 0=slow, 1=medium, 2=fast */ -+ unsigned short field_valid; /* (word 53) -+ * 2: ultra_ok word 88 -+ * 1: eide_ok words 64-70 -+ * 0: cur_ok words 54-58 -+ */ -+ unsigned short cur_cyls; /* Obsolete, logical cylinders */ -+ unsigned short cur_heads; /* Obsolete, l heads */ -+ unsigned short cur_sectors; /* Obsolete, l sectors per track */ -+ unsigned short cur_capacity0; /* Obsolete, l total sectors on drive */ -+ unsigned short cur_capacity1; /* Obsolete, (2 words, misaligned int) */ -+ unsigned char multsect; /* current multiple sector count */ -+ unsigned char multsect_valid; /* when (bit0==1) multsect is ok */ -+ unsigned int lba_capacity; /* Obsolete, total number of sectors */ -+ unsigned short dma_1word; /* Obsolete, single-word dma info */ -+ unsigned short dma_mword; /* multiple-word dma info */ -+ unsigned short eide_pio_modes; /* bits 0:mode3 1:mode4 */ -+ unsigned short eide_dma_min; /* min mword dma cycle time (ns) */ -+ unsigned short eide_dma_time; /* recommended mword dma cycle time (ns) */ -+ unsigned short eide_pio; /* min cycle time (ns), no IORDY */ -+ unsigned short eide_pio_iordy; /* min cycle time (ns), with IORDY */ -+ unsigned short words69_70[2]; /* reserved words 69-70 -+ * future command overlap and queuing -+ */ -+ unsigned short words71_74[4]; /* reserved words 71-74 -+ * for IDENTIFY PACKET DEVICE command -+ */ -+ unsigned short queue_depth; /* (word 75) -+ * 15:5 reserved -+ * 4:0 Maximum queue depth -1 -+ */ -+ unsigned short words76_79[4]; /* reserved words 76-79 */ -+ unsigned short major_rev_num; /* (word 80) */ -+ unsigned short minor_rev_num; /* (word 81) */ -+ unsigned short command_set_1; /* (word 82) supported -+ * 15: Obsolete -+ * 14: NOP command -+ * 13: READ_BUFFER -+ * 12: WRITE_BUFFER -+ * 11: Obsolete -+ * 10: Host Protected Area -+ * 9: DEVICE Reset -+ * 8: SERVICE Interrupt -+ * 7: Release Interrupt -+ * 6: look-ahead -+ * 5: write cache -+ * 4: PACKET Command -+ * 3: Power Management Feature Set -+ * 2: Removable Feature Set -+ * 1: Security Feature Set -+ * 0: SMART Feature Set -+ */ -+ unsigned short command_set_2; /* (word 83) -+ * 15: Shall be ZERO -+ * 14: Shall be ONE -+ * 13: FLUSH CACHE EXT -+ * 12: FLUSH CACHE -+ * 11: Device Configuration Overlay -+ * 10: 48-bit Address Feature Set -+ * 9: Automatic Acoustic Management -+ * 8: SET MAX security -+ * 7: reserved 1407DT PARTIES -+ * 6: SetF sub-command Power-Up -+ * 5: Power-Up in Standby Feature Set -+ * 4: Removable Media Notification -+ * 3: APM Feature Set -+ * 2: CFA Feature Set -+ * 1: READ/WRITE DMA QUEUED -+ * 0: Download MicroCode -+ */ -+ unsigned short cfsse; /* (word 84) -+ * cmd set-feature supported extensions -+ * 15: Shall be ZERO -+ * 14: Shall be ONE -+ * 13:6 reserved -+ * 5: General Purpose Logging -+ * 4: Streaming Feature Set -+ * 3: Media Card Pass Through -+ * 2: Media Serial Number Valid -+ * 1: SMART selt-test supported -+ * 0: SMART error logging -+ */ -+ unsigned short cfs_enable_1; /* (word 85) -+ * command set-feature enabled -+ * 15: Obsolete -+ * 14: NOP command -+ * 13: READ_BUFFER -+ * 12: WRITE_BUFFER -+ * 11: Obsolete -+ * 10: Host Protected Area -+ * 9: DEVICE Reset -+ * 8: SERVICE Interrupt -+ * 7: Release Interrupt -+ * 6: look-ahead -+ * 5: write cache -+ * 4: PACKET Command -+ * 3: Power Management Feature Set -+ * 2: Removable Feature Set -+ * 1: Security Feature Set -+ * 0: SMART Feature Set -+ */ -+ unsigned short cfs_enable_2; /* (word 86) -+ * command set-feature enabled -+ * 15: Shall be ZERO -+ * 14: Shall be ONE -+ * 13: FLUSH CACHE EXT -+ * 12: FLUSH CACHE -+ * 11: Device Configuration Overlay -+ * 10: 48-bit Address Feature Set -+ * 9: Automatic Acoustic Management -+ * 8: SET MAX security -+ * 7: reserved 1407DT PARTIES -+ * 6: SetF sub-command Power-Up -+ * 5: Power-Up in Standby Feature Set -+ * 4: Removable Media Notification -+ * 3: APM Feature Set -+ * 2: CFA Feature Set -+ * 1: READ/WRITE DMA QUEUED -+ * 0: Download MicroCode -+ */ -+ unsigned short csf_default; /* (word 87) -+ * command set-feature default -+ * 15: Shall be ZERO -+ * 14: Shall be ONE -+ * 13:6 reserved -+ * 5: General Purpose Logging enabled -+ * 4: Valid CONFIGURE STREAM executed -+ * 3: Media Card Pass Through enabled -+ * 2: Media Serial Number Valid -+ * 1: SMART selt-test supported -+ * 0: SMART error logging -+ */ -+ unsigned short dma_ultra; /* (word 88) */ -+ unsigned short trseuc; /* time required for security erase */ -+ unsigned short trsEuc; /* time required for enhanced erase */ -+ unsigned short CurAPMvalues; /* current APM values */ -+ unsigned short mprc; /* master password revision code */ -+ unsigned short hw_config; /* hardware config (word 93) -+ * 15: Shall be ZERO -+ * 14: Shall be ONE -+ * 13: -+ * 12: -+ * 11: -+ * 10: -+ * 9: -+ * 8: -+ * 7: -+ * 6: -+ * 5: -+ * 4: -+ * 3: -+ * 2: -+ * 1: -+ * 0: Shall be ONE -+ */ -+ unsigned short acoustic; /* (word 94) -+ * 15:8 Vendor's recommended value -+ * 7:0 current value -+ */ -+ unsigned short msrqs; /* min stream request size */ -+ unsigned short sxfert; /* stream transfer time */ -+ unsigned short sal; /* stream access latency */ -+ unsigned int spg; /* stream performance granularity */ -+ unsigned long long lba_capacity_2;/* 48-bit total number of sectors */ -+ unsigned short words104_125[22];/* reserved words 104-125 */ -+ unsigned short last_lun; /* (word 126) */ -+ unsigned short word127; /* (word 127) Feature Set -+ * Removable Media Notification -+ * 15:2 reserved -+ * 1:0 00 = not supported -+ * 01 = supported -+ * 10 = reserved -+ * 11 = reserved -+ */ -+ unsigned short dlf; /* (word 128) -+ * device lock function -+ * 15:9 reserved -+ * 8 security level 1:max 0:high -+ * 7:6 reserved -+ * 5 enhanced erase -+ * 4 expire -+ * 3 frozen -+ * 2 locked -+ * 1 en/disabled -+ * 0 capability -+ */ -+ unsigned short csfo; /* (word 129) -+ * current set features options -+ * 15:4 reserved -+ * 3: auto reassign -+ * 2: reverting -+ * 1: read-look-ahead -+ * 0: write cache -+ */ -+ unsigned short words130_155[26];/* reserved vendor words 130-155 */ -+ unsigned short word156; /* reserved vendor word 156 */ -+ unsigned short words157_159[3];/* reserved vendor words 157-159 */ -+ unsigned short cfa_power; /* (word 160) CFA Power Mode -+ * 15 word 160 supported -+ * 14 reserved -+ * 13 -+ * 12 -+ * 11:0 -+ */ -+ unsigned short words161_175[15];/* Reserved for CFA */ -+ unsigned short words176_205[30];/* Current Media Serial Number */ -+ unsigned short words206_254[49];/* reserved words 206-254 */ -+ unsigned short integrity_word; /* (word 255) -+ * 15:8 Checksum -+ * 7:0 Signature -+ */ -+}; -+ -+/* -+ * IDE "nice" flags. These are used on a per drive basis to determine -+ * when to be nice and give more bandwidth to the other devices which -+ * share the same IDE bus. -+ */ -+#define IDE_NICE_DSC_OVERLAP (0) /* per the DSC overlap protocol */ -+#define IDE_NICE_ATAPI_OVERLAP (1) /* not supported yet */ -+#define IDE_NICE_1 (3) /* when probably won't affect us much */ -+#define IDE_NICE_0 (2) /* when sure that it won't affect us */ -+#define IDE_NICE_2 (4) /* when we know it's on our expense */ -+ -+#endif /* _LINUX_HDREG_H */ -diff --git a/src/linux/magic.h b/src/linux/magic.h -new file mode 100644 -index 0000000..77c6031 ---- /dev/null -+++ b/src/linux/magic.h -@@ -0,0 +1,76 @@ -+#ifndef __LINUX_MAGIC_H__ -+#define __LINUX_MAGIC_H__ -+ -+#define ADFS_SUPER_MAGIC 0xadf5 -+#define AFFS_SUPER_MAGIC 0xadff -+#define AFS_SUPER_MAGIC 0x5346414F -+#define AUTOFS_SUPER_MAGIC 0x0187 -+#define CODA_SUPER_MAGIC 0x73757245 -+#define CRAMFS_MAGIC 0x28cd3d45 /* some random number */ -+#define CRAMFS_MAGIC_WEND 0x453dcd28 /* magic number with the wrong endianess */ -+#define DEBUGFS_MAGIC 0x64626720 -+#define SECURITYFS_MAGIC 0x73636673 -+#define SELINUX_MAGIC 0xf97cff8c -+#define SMACK_MAGIC 0x43415d53 /* "SMAC" */ -+#define RAMFS_MAGIC 0x858458f6 /* some random number */ -+#define TMPFS_MAGIC 0x01021994 -+#define HUGETLBFS_MAGIC 0x958458f6 /* some random number */ -+#define SQUASHFS_MAGIC 0x73717368 -+#define ECRYPTFS_SUPER_MAGIC 0xf15f -+#define EFS_SUPER_MAGIC 0x414A53 -+#define EXT2_SUPER_MAGIC 0xEF53 -+#define EXT3_SUPER_MAGIC 0xEF53 -+#define XENFS_SUPER_MAGIC 0xabba1974 -+#define EXT4_SUPER_MAGIC 0xEF53 -+#define BTRFS_SUPER_MAGIC 0x9123683E -+#define NILFS_SUPER_MAGIC 0x3434 -+#define F2FS_SUPER_MAGIC 0xF2F52010 -+#define HPFS_SUPER_MAGIC 0xf995e849 -+#define ISOFS_SUPER_MAGIC 0x9660 -+#define JFFS2_SUPER_MAGIC 0x72b6 -+#define PSTOREFS_MAGIC 0x6165676C -+#define EFIVARFS_MAGIC 0xde5e81e4 -+#define HOSTFS_SUPER_MAGIC 0x00c0ffee -+ -+#define MINIX_SUPER_MAGIC 0x137F /* minix v1 fs, 14 char names */ -+#define MINIX_SUPER_MAGIC2 0x138F /* minix v1 fs, 30 char names */ -+#define MINIX2_SUPER_MAGIC 0x2468 /* minix v2 fs, 14 char names */ -+#define MINIX2_SUPER_MAGIC2 0x2478 /* minix v2 fs, 30 char names */ -+#define MINIX3_SUPER_MAGIC 0x4d5a /* minix v3 fs, 60 char names */ -+ -+#define MSDOS_SUPER_MAGIC 0x4d44 /* MD */ -+#define NCP_SUPER_MAGIC 0x564c /* Guess, what 0x564c is :-) */ -+#define NFS_SUPER_MAGIC 0x6969 -+#define OPENPROM_SUPER_MAGIC 0x9fa1 -+#define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */ -+#define QNX6_SUPER_MAGIC 0x68191122 /* qnx6 fs detection */ -+ -+#define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */ -+ /* used by file system utilities that -+ look at the superblock, etc. */ -+#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs" -+#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs" -+#define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs" -+ -+#define SMB_SUPER_MAGIC 0x517B -+#define CGROUP_SUPER_MAGIC 0x27e0eb -+ -+ -+#define STACK_END_MAGIC 0x57AC6E9D -+ -+#define V9FS_MAGIC 0x01021997 -+ -+#define BDEVFS_MAGIC 0x62646576 -+#define BINFMTFS_MAGIC 0x42494e4d -+#define DEVPTS_SUPER_MAGIC 0x1cd1 -+#define FUTEXFS_SUPER_MAGIC 0xBAD1DEA -+#define PIPEFS_MAGIC 0x50495045 -+#define PROC_SUPER_MAGIC 0x9fa0 -+#define SOCKFS_MAGIC 0x534F434B -+#define SYSFS_MAGIC 0x62656572 -+#define USBDEVICE_SUPER_MAGIC 0x9fa2 -+#define MTD_INODE_FS_MAGIC 0x11307854 -+#define ANON_INODE_FS_MAGIC 0x09041934 -+#define BTRFS_TEST_MAGIC 0x73727279 -+ -+#endif /* __LINUX_MAGIC_H__ */ -diff --git a/src/linux/msdos_fs.h b/src/linux/msdos_fs.h -new file mode 100644 -index 0000000..635d905 ---- /dev/null -+++ b/src/linux/msdos_fs.h -@@ -0,0 +1,201 @@ -+#ifndef _LINUX_MSDOS_FS_H -+#define _LINUX_MSDOS_FS_H -+ -+#ifdef __linux__ -+#include -+#include -+#endif -+#include "magic.h" -+ -+/* -+ * The MS-DOS filesystem constants/structures -+ */ -+ -+#define SECTOR_SIZE 512 /* sector size (bytes) */ -+#define SECTOR_BITS 9 /* log2(SECTOR_SIZE) */ -+#define MSDOS_DPB (MSDOS_DPS) /* dir entries per block */ -+#define MSDOS_DPB_BITS 4 /* log2(MSDOS_DPB) */ -+#define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry)) -+#define MSDOS_DPS_BITS 4 /* log2(MSDOS_DPS) */ -+#define MSDOS_LONGNAME 256 /* maximum name length */ -+#define CF_LE_W(v) le16_to_cpu(v) -+#define CF_LE_L(v) le32_to_cpu(v) -+#define CT_LE_W(v) cpu_to_le16(v) -+#define CT_LE_L(v) cpu_to_le32(v) -+ -+#define MSDOS_ROOT_INO 1 /* The root inode number */ -+#define MSDOS_FSINFO_INO 2 /* Used for managing the FSINFO block */ -+ -+#define MSDOS_DIR_BITS 5 /* log2(sizeof(struct msdos_dir_entry)) */ -+ -+/* directory limit */ -+#define FAT_MAX_DIR_ENTRIES (65536) -+#define FAT_MAX_DIR_SIZE (FAT_MAX_DIR_ENTRIES << MSDOS_DIR_BITS) -+ -+#define ATTR_NONE 0 /* no attribute bits */ -+#define ATTR_RO 1 /* read-only */ -+#define ATTR_HIDDEN 2 /* hidden */ -+#define ATTR_SYS 4 /* system */ -+#define ATTR_VOLUME 8 /* volume label */ -+#define ATTR_DIR 16 /* directory */ -+#define ATTR_ARCH 32 /* archived */ -+ -+/* attribute bits that are copied "as is" */ -+#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN) -+/* bits that are used by the Windows 95/Windows NT extended FAT */ -+#define ATTR_EXT (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME) -+ -+#define CASE_LOWER_BASE 8 /* base is lower case */ -+#define CASE_LOWER_EXT 16 /* extension is lower case */ -+ -+#define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */ -+#define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG) -+ -+#define FAT_LFN_LEN 255 /* maximum long name length */ -+#define MSDOS_NAME 11 /* maximum name length */ -+#define MSDOS_SLOTS 21 /* max # of slots for short and long names */ -+#define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */ -+#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */ -+ -+#define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \ -+ MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x)) -+ -+/* start of data cluster's entry (number of reserved clusters) */ -+#define FAT_START_ENT 2 -+ -+/* maximum number of clusters */ -+#define MAX_FAT12 0xFF4 -+#define MAX_FAT16 0xFFF4 -+#define MAX_FAT32 0x0FFFFFF6 -+#define MAX_FAT(s) (MSDOS_SB(s)->fat_bits == 32 ? MAX_FAT32 : \ -+ MSDOS_SB(s)->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12) -+ -+/* bad cluster mark */ -+#define BAD_FAT12 0xFF7 -+#define BAD_FAT16 0xFFF7 -+#define BAD_FAT32 0x0FFFFFF7 -+ -+/* standard EOF */ -+#define EOF_FAT12 0xFFF -+#define EOF_FAT16 0xFFFF -+#define EOF_FAT32 0x0FFFFFFF -+ -+#define FAT_ENT_FREE (0) -+#define FAT_ENT_BAD (BAD_FAT32) -+#define FAT_ENT_EOF (EOF_FAT32) -+ -+#define FAT_FSINFO_SIG1 0x41615252 -+#define FAT_FSINFO_SIG2 0x61417272 -+#define IS_FSINFO(x) (le32_to_cpu((x)->signature1) == FAT_FSINFO_SIG1 \ -+ && le32_to_cpu((x)->signature2) == FAT_FSINFO_SIG2) -+ -+#define FAT_STATE_DIRTY 0x01 -+ -+struct __fat_dirent { -+ long d_ino; -+ long d_off; -+ unsigned short d_reclen; -+ char d_name[256]; /* We must not include limits.h! */ -+}; -+ -+/* -+ * ioctl commands -+ */ -+#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct __fat_dirent[2]) -+#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct __fat_dirent[2]) -+/* has used 0x72 ('r') in collision, so skip a few */ -+#define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32) -+#define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32) -+/*Android kernel has used 0x12, so we use 0x13*/ -+#define FAT_IOCTL_GET_VOLUME_ID _IOR('r', 0x13, __u32) -+ -+struct fat_boot_sector { -+ __u8 ignored[3]; /* Boot strap short or near jump */ -+ __u8 system_id[8]; /* Name - can be used to special case -+ partition manager volumes */ -+ __u8 sector_size[2]; /* bytes per logical sector */ -+ __u8 sec_per_clus; /* sectors/cluster */ -+ __le16 reserved; /* reserved sectors */ -+ __u8 fats; /* number of FATs */ -+ __u8 dir_entries[2]; /* root directory entries */ -+ __u8 sectors[2]; /* number of sectors */ -+ __u8 media; /* media code */ -+ __le16 fat_length; /* sectors/FAT */ -+ __le16 secs_track; /* sectors per track */ -+ __le16 heads; /* number of heads */ -+ __le32 hidden; /* hidden sectors (unused) */ -+ __le32 total_sect; /* number of sectors (if sectors == 0) */ -+ -+ union { -+ struct { -+ /* Extended BPB Fields for FAT16 */ -+ __u8 drive_number; /* Physical drive number */ -+ __u8 state; /* undocumented, but used -+ for mount state. */ -+ __u8 signature; /* extended boot signature */ -+ __u8 vol_id[4]; /* volume ID */ -+ __u8 vol_label[11]; /* volume label */ -+ __u8 fs_type[8]; /* file system type */ -+ /* other fiealds are not added here */ -+ } fat16; -+ -+ struct { -+ /* only used by FAT32 */ -+ __le32 length; /* sectors/FAT */ -+ __le16 flags; /* bit 8: fat mirroring, -+ low 4: active fat */ -+ __u8 version[2]; /* major, minor filesystem -+ version */ -+ __le32 root_cluster; /* first cluster in -+ root directory */ -+ __le16 info_sector; /* filesystem info sector */ -+ __le16 backup_boot; /* backup boot sector */ -+ __le16 reserved2[6]; /* Unused */ -+ /* Extended BPB Fields for FAT32 */ -+ __u8 drive_number; /* Physical drive number */ -+ __u8 state; /* undocumented, but used -+ for mount state. */ -+ __u8 signature; /* extended boot signature */ -+ __u8 vol_id[4]; /* volume ID */ -+ __u8 vol_label[11]; /* volume label */ -+ __u8 fs_type[8]; /* file system type */ -+ /* other fiealds are not added here */ -+ } fat32; -+ }; -+}; -+ -+struct fat_boot_fsinfo { -+ __le32 signature1; /* 0x41615252L */ -+ __le32 reserved1[120]; /* Nothing as far as I can tell */ -+ __le32 signature2; /* 0x61417272L */ -+ __le32 free_clusters; /* Free cluster count. -1 if unknown */ -+ __le32 next_cluster; /* Most recently allocated cluster */ -+ __le32 reserved2[4]; -+}; -+ -+struct msdos_dir_entry { -+ __u8 name[MSDOS_NAME];/* name and extension */ -+ __u8 attr; /* attribute bits */ -+ __u8 lcase; /* Case for base and extension */ -+ __u8 ctime_cs; /* Creation time, centiseconds (0-199) */ -+ __le16 ctime; /* Creation time */ -+ __le16 cdate; /* Creation date */ -+ __le16 adate; /* Last access date */ -+ __le16 starthi; /* High 16 bits of cluster in FAT32 */ -+ __le16 time,date,start;/* time, date and first cluster */ -+ __le32 size; /* file size (in bytes) */ -+}; -+ -+/* Up to 13 characters of the name */ -+struct msdos_dir_slot { -+ __u8 id; /* sequence number for slot */ -+ __u8 name0_4[10]; /* first 5 characters in name */ -+ __u8 attr; /* attribute byte */ -+ __u8 reserved; /* always 0 */ -+ __u8 alias_checksum; /* checksum for 8.3 alias */ -+ __u8 name5_10[12]; /* 6 more characters in name */ -+ __le16 start; /* starting cluster number, 0 in long slots */ -+ __u8 name11_12[4]; /* last 2 characters in name */ -+}; -+ -+#endif /* _LINUX_MSDOS_FS_H */ -diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c -index e6f9390..ebdfdb5 100644 ---- a/src/mkfs.fat.c -+++ b/src/mkfs.fat.c -@@ -47,12 +47,6 @@ - #include "version.h" - - #include --#include --#include --#include --#include --#include --#include - #include - #include - #include -@@ -60,15 +54,23 @@ - #include - #include - #include --#include - #include - #include - #include - #include - #include --#include - --#include -+#if defined(__linux__) -+ #include -+#elif defined(__osx__) -+ #include -+ #include -+#endif -+ -+#include "common.h" -+#include "linux/fs.h" -+#include "linux/fd.h" -+#include "linux/hdreg.h" - - /* In earlier versions, an own llseek() was used, but glibc lseek() is - * sufficient (or even better :) for 64 bit offsets in the meantime */ -@@ -524,6 +526,7 @@ static uint64_t count_blocks(char *filename, int *remainder) - - static void check_mount(char *device_name) - { -+#if defined(__linux__) - FILE *f; - struct mntent *mnt; - -@@ -533,6 +536,17 @@ static void check_mount(char *device_name) - if (strcmp(device_name, mnt->mnt_fsname) == 0) - die("%s contains a mounted filesystem."); - endmntent(f); -+#elif defined(__osx__) -+ struct statfs* mounts; -+ int num_mounts = getmntinfo(&mounts, MNT_WAIT); -+ if (num_mounts < 0) -+ return; -+ for ( int i = 0; i < num_mounts; i++ ) -+ { -+ if (strcmp(device_name, mounts[i].f_mntfromname) == 0) -+ die("%s contains a mounted filesystem."); -+ } -+#endif - } - - /* Establish the geometry and media parameters for the device */ --- -1.9.1 - diff --git a/tools/dosfstools/patches/0001-Add-tags-and-editor-backup-files-to-.gitignore.patch b/tools/dosfstools/patches/0001-Add-tags-and-editor-backup-files-to-.gitignore.patch new file mode 100644 index 0000000000..b0fecdd732 --- /dev/null +++ b/tools/dosfstools/patches/0001-Add-tags-and-editor-backup-files-to-.gitignore.patch @@ -0,0 +1,25 @@ +From 75c5446d21f02038423d67139a6967975c9b90be Mon Sep 17 00:00:00 2001 +From: Andreas Bombe +Date: Sat, 15 Nov 2014 16:48:48 +0100 +Subject: [PATCH 01/14] Add tags and editor backup files to .gitignore + +Signed-off-by: Andreas Bombe +--- + .gitignore | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/.gitignore b/.gitignore +index 384f131..5c9366e 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -2,3 +2,7 @@ + /fatlabel + /fsck.fat + /mkfs.fat ++ ++tags ++*~ ++.*.sw[a-p] +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0002-Fix-indentation-of-fix-power-loss-damage-commit.patch b/tools/dosfstools/patches/0002-Fix-indentation-of-fix-power-loss-damage-commit.patch new file mode 100644 index 0000000000..b12c3b2d8e --- /dev/null +++ b/tools/dosfstools/patches/0002-Fix-indentation-of-fix-power-loss-damage-commit.patch @@ -0,0 +1,100 @@ +From 45aeed0c658cc86e93ae3ae101404e12bec6e102 Mon Sep 17 00:00:00 2001 +From: Andreas Bombe +Date: Sun, 16 Nov 2014 19:49:22 +0100 +Subject: [PATCH 02/14] Fix indentation of "fix power loss damage" commit + +I fixed the (sometimes misleading) indentation of the code introduced in +commit 6893c45 to be in line with the reset of the code and also removed +the /* PATCH ED+DL */ comments which are quite meaningless to the wider +world. + +Signed-off-by: Andreas Bombe +--- + src/check.c | 57 ++++++++++++++++++++++++--------------------------------- + 1 file changed, 24 insertions(+), 33 deletions(-) + +diff --git a/src/check.c b/src/check.c +index e8aaf92..daa6d69 100644 +--- a/src/check.c ++++ b/src/check.c +@@ -273,11 +273,10 @@ static int bad_name(DOS_FILE * file) + strncmp((const char *)name, "WP ROOT SF", 11) == 0) + return 0; + +- /* PATCH ED+DL */ +- /* check if we have neither a long filename nor a short name */ +- if ((file->lfn == NULL) && (file->dir_ent.lcase & FAT_NO_83NAME)) { +- return 1; +- } ++ /* check if we have neither a long filename nor a short name */ ++ if ((file->lfn == NULL) && (file->dir_ent.lcase & FAT_NO_83NAME)) { ++ return 1; ++ } + + /* don't complain about the dummy 11 bytes used by patched Linux + kernels */ +@@ -401,20 +400,16 @@ static void auto_rename(DOS_FILE * file) + (const char *)file->dir_ent.name, MSDOS_NAME)) + break; + if (!walk) { +- /* PATCH ED+DL */ +- if(file->dir_ent.lcase & FAT_NO_83NAME) +- { +- /* as we only assign a new 8.3 filename, reset flag that 8.3 name is not +- present */ +- file->dir_ent.lcase &= ~FAT_NO_83NAME; +- /* reset the attributes */ +- file->dir_ent.attr &= ~(ATTR_DIR | ATTR_VOLUME); /* only keep the DIR and VOLUME attributes */ +- fs_write(file->offset, MSDOS_NAME+2, file->dir_ent.name); +- } +- else +- { +- fs_write(file->offset, MSDOS_NAME, file->dir_ent.name); +- } ++ if (file->dir_ent.lcase & FAT_NO_83NAME) { ++ /* as we only assign a new 8.3 filename, reset flag that 8.3 name is not ++ present */ ++ file->dir_ent.lcase &= ~FAT_NO_83NAME; ++ /* reset the attributes, only keep DIR and VOLUME */ ++ file->dir_ent.attr &= ~(ATTR_DIR | ATTR_VOLUME); ++ fs_write(file->offset, MSDOS_NAME + 2, file->dir_ent.name); ++ } else { ++ fs_write(file->offset, MSDOS_NAME, file->dir_ent.name); ++ } + if (file->lfn) + lfn_fix_checksum(file->lfn_offset, file->offset, + (const char *)file->dir_ent.name); +@@ -448,20 +443,16 @@ static void rename_file(DOS_FILE * file) + walk[1] = 0; + for (walk = name; *walk == ' ' || *walk == '\t'; walk++) ; + if (file_cvt(walk, file->dir_ent.name)) { +- /* PATCH ED+DL */ +- if(file->dir_ent.lcase & FAT_NO_83NAME) +- { +- /* as we only assign a new 8.3 filename, reset flag that 8.3 name is not +- present */ +- file->dir_ent.lcase &= ~FAT_NO_83NAME; +- /* reset the attributes */ +- file->dir_ent.attr &= ~(ATTR_DIR | ATTR_VOLUME); /* only keep the DIR and VOLUME attributes */ +- fs_write(file->offset, MSDOS_NAME+2, file->dir_ent.name); +- } +- else +- { +- fs_write(file->offset, MSDOS_NAME, file->dir_ent.name); +- } ++ if (file->dir_ent.lcase & FAT_NO_83NAME) { ++ /* as we only assign a new 8.3 filename, reset flag that 8.3 name is not ++ present */ ++ file->dir_ent.lcase &= ~FAT_NO_83NAME; ++ /* reset the attributes, only keep DIR and VOLUME */ ++ file->dir_ent.attr &= ~(ATTR_DIR | ATTR_VOLUME); ++ fs_write(file->offset, MSDOS_NAME + 2, file->dir_ent.name); ++ } else { ++ fs_write(file->offset, MSDOS_NAME, file->dir_ent.name); ++ } + if (file->lfn) + lfn_fix_checksum(file->lfn_offset, file->offset, + (const char *)file->dir_ent.name); +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0003-mkfs.fat.c-Use-unsigned-char-for-binary-data.patch b/tools/dosfstools/patches/0003-mkfs.fat.c-Use-unsigned-char-for-binary-data.patch new file mode 100644 index 0000000000..842a7c1906 --- /dev/null +++ b/tools/dosfstools/patches/0003-mkfs.fat.c-Use-unsigned-char-for-binary-data.patch @@ -0,0 +1,33 @@ +From 8b8948c06de55455b63dc11f765d7ee39f30c4e0 Mon Sep 17 00:00:00 2001 +From: Andreas Bombe +Date: Mon, 29 Dec 2014 18:24:54 +0100 +Subject: [PATCH 03/14] mkfs.fat.c: Use unsigned char for binary data + +Simple char technically works for the dummy_boot_jump variables, but +some compiler warning settings would give a warning over a signed char +overflowing with the values given as initializers. + +Signed-off-by: Andreas Bombe +--- + src/mkfs.fat.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c +index 604b7d0..1f702ad 100644 +--- a/src/mkfs.fat.c ++++ b/src/mkfs.fat.c +@@ -219,9 +219,9 @@ struct msdos_dir_entry { + /* The "boot code" we put into the filesystem... it writes a message and + tells the user to try again */ + +-char dummy_boot_jump[3] = { 0xeb, 0x3c, 0x90 }; ++unsigned char dummy_boot_jump[3] = { 0xeb, 0x3c, 0x90 }; + +-char dummy_boot_jump_m68k[2] = { 0x60, 0x1c }; ++unsigned char dummy_boot_jump_m68k[2] = { 0x60, 0x1c }; + + #define MSG_OFFSET_OFFSET 3 + char dummy_boot_code[BOOTCODE_SIZE] = "\x0e" /* push cs */ +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0004-Make-all-char-that-may-take-literals-const.patch b/tools/dosfstools/patches/0004-Make-all-char-that-may-take-literals-const.patch new file mode 100644 index 0000000000..be553c8790 --- /dev/null +++ b/tools/dosfstools/patches/0004-Make-all-char-that-may-take-literals-const.patch @@ -0,0 +1,169 @@ +From 16e97e9741a02f6c2c29b3da45b62ac798d76403 Mon Sep 17 00:00:00 2001 +From: Andreas Bombe +Date: Wed, 28 Jan 2015 15:07:18 +0100 +Subject: [PATCH 04/14] Make all char* that may take literals const + +Every char* variable or function argument that may be given a literal +string is now made const. Additionally add -Wwrite-strings to CFLAGS to +enable a warning where const would be missing. + +Signed-off-by: Andreas Bombe +--- + Makefile | 2 +- + src/boot.c | 4 ++-- + src/check.c | 2 +- + src/common.c | 6 +++--- + src/common.h | 6 +++--- + src/mkfs.fat.c | 8 +++++--- + 6 files changed, 15 insertions(+), 13 deletions(-) + +diff --git a/Makefile b/Makefile +index 81256ef..3cbdb76 100644 +--- a/Makefile ++++ b/Makefile +@@ -30,7 +30,7 @@ MANDIR = $(PREFIX)/share/man + #OPTFLAGS = -O2 -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 + OPTFLAGS = -O2 -fomit-frame-pointer -D_GNU_SOURCE $(shell getconf LFS_CFLAGS) + #WARNFLAGS = -Wall -pedantic -std=c99 +-WARNFLAGS = -Wall -Wextra -Wno-sign-compare -Wno-missing-field-initializers -Wmissing-prototypes -Wstrict-prototypes ++WARNFLAGS = -Wall -Wextra -Wno-sign-compare -Wno-missing-field-initializers -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings + DEBUGFLAGS = -g + CFLAGS += $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS) + +diff --git a/src/boot.c b/src/boot.c +index 5b3825c..be7bfb7 100644 +--- a/src/boot.c ++++ b/src/boot.c +@@ -46,7 +46,7 @@ + + static struct { + __u8 media; +- char *descr; ++ const char *descr; + } mediabytes[] = { + { + 0xf0, "5.25\" or 3.5\" HD floppy"}, { +@@ -64,7 +64,7 @@ static struct { + #define GET_UNALIGNED_W(f) \ + ( (__u16)f[0] | ((__u16)f[1]<<8) ) + +-static char *get_media_descr(unsigned char media) ++static const char *get_media_descr(unsigned char media) + { + int i; + +diff --git a/src/check.c b/src/check.c +index daa6d69..488f715 100644 +--- a/src/check.c ++++ b/src/check.c +@@ -464,7 +464,7 @@ static void rename_file(DOS_FILE * file) + + static int handle_dot(DOS_FS * fs, DOS_FILE * file, int dots) + { +- char *name; ++ const char *name; + + name = + strncmp((const char *)file->dir_ent.name, MSDOS_DOT, +diff --git a/src/common.c b/src/common.c +index af222a2..9d11193 100644 +--- a/src/common.c ++++ b/src/common.c +@@ -37,7 +37,7 @@ typedef struct _link { + struct _link *next; + } LINK; + +-void die(char *msg, ...) ++void die(const char *msg, ...) + { + va_list args; + +@@ -48,7 +48,7 @@ void die(char *msg, ...) + exit(1); + } + +-void pdie(char *msg, ...) ++void pdie(const char *msg, ...) + { + va_list args; + +@@ -96,7 +96,7 @@ int min(int a, int b) + return a < b ? a : b; + } + +-char get_key(char *valid, char *prompt) ++char get_key(const char *valid, const char *prompt) + { + int ch, okay; + +diff --git a/src/common.h b/src/common.h +index 8508602..b127f63 100644 +--- a/src/common.h ++++ b/src/common.h +@@ -25,11 +25,11 @@ + #ifndef _COMMON_H + #define _COMMON_H + +-void die(char *msg, ...) __attribute((noreturn)); ++void die(const char *msg, ...) __attribute((noreturn)); + + /* Displays a prinf-style message and terminates the program. */ + +-void pdie(char *msg, ...) __attribute((noreturn)); ++void pdie(const char *msg, ...) __attribute((noreturn)); + + /* Like die, but appends an error message according to the state of errno. */ + +@@ -50,7 +50,7 @@ int min(int a, int b); + + /* Returns the smaller integer value of a and b. */ + +-char get_key(char *valid, char *prompt); ++char get_key(const char *valid, const char *prompt); + + /* Displays PROMPT and waits for user input. Only characters in VALID are + accepted. Terminates the program on EOF. Returns the character. */ +diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c +index 1f702ad..a3dff54 100644 +--- a/src/mkfs.fat.c ++++ b/src/mkfs.fat.c +@@ -250,7 +250,7 @@ char dummy_boot_code[BOOTCODE_SIZE] = "\x0e" /* push cs */ + + /* Global variables - the root of all evil :-) - see these and weep! */ + +-static char *program_name = "mkfs.fat"; /* Name of the program */ ++static const char *program_name = "mkfs.fat"; /* Name of the program */ + static char *device_name = NULL; /* Name of the device on which to create the filesystem */ + static int atari_format = 0; /* Use Atari variation of MS-DOS FS format */ + static int check = FALSE; /* Default to no readablity checking */ +@@ -1412,6 +1412,7 @@ int main(int argc, char **argv) + int create = 0; + uint64_t cblocks = 0; + int min_sector_size; ++ int bad_block_count = 0; + + if (argc && *argv) { /* What's the program name? */ + char *p; +@@ -1653,16 +1654,17 @@ int main(int argc, char **argv) + fprintf(stderr, "Warning: block count mismatch: "); + fprintf(stderr, "found %llu but assuming %llu.\n", (unsigned long long)cblocks, (unsigned long long)blocks); + } ++ if (*tmp) ++ bad_block_count = 1; + } else if (optind == argc - 1) { /* Or use value found */ + if (create) + die("Need intended size with -C."); + blocks = cblocks; +- tmp = ""; + } else { + fprintf(stderr, "No device specified!\n"); + usage(); + } +- if (*tmp) { ++ if (bad_block_count) { + printf("Bad block count : %s\n", argv[optind + 1]); + usage(); + } +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0005-mkfs.fat-Allow-0xF0-to-be-specified-as-media-byte.patch b/tools/dosfstools/patches/0005-mkfs.fat-Allow-0xF0-to-be-specified-as-media-byte.patch new file mode 100644 index 0000000000..4d2d26a526 --- /dev/null +++ b/tools/dosfstools/patches/0005-mkfs.fat-Allow-0xF0-to-be-specified-as-media-byte.patch @@ -0,0 +1,122 @@ +From 266a5fc635135a9ffaa8683da1ec03aae1553b7b Mon Sep 17 00:00:00 2001 +From: Andreas Bombe +Date: Fri, 20 Feb 2015 03:19:28 +0100 +Subject: [PATCH 05/14] mkfs.fat: Allow 0xF0 to be specified as media byte + +Let the -M option accept 0xF0, which should be the proper descriptor +byte for 3.5" 1.44 MB and 2.88 MB floppies. + +Also split the error reporting for -M between badly formatted and +invalid numbers. + +Signed-off-by: Andreas Bombe +--- + manpages/de/mkfs.fat.de.8 | 4 ++-- + manpages/en/mkfs.fat.8 | 2 +- + manpages/po/de/mkfs.fat.8.po | 6 +++--- + manpages/pot/mkfs.fat.8.pot | 6 +++--- + src/mkfs.fat.c | 12 ++++++++---- + 5 files changed, 17 insertions(+), 13 deletions(-) + +diff --git a/manpages/de/mkfs.fat.de.8 b/manpages/de/mkfs.fat.de.8 +index 5a6eb1a..2386410 100644 +--- a/manpages/de/mkfs.fat.de.8 ++++ b/manpages/de/mkfs.fat.de.8 +@@ -121,8 +121,8 @@ return\-line feed combinations, and tabs have been expanded. If the filename + is a hyphen (\-), the text is taken from standard input. + .IP "\fB\-M\fP \fIFAT\-media\-type\fP" 4 + Specify the media type to be stored in the FAT boot sector. This value is +-usually 0xF8 for hard disks and has a value from 0xF9 to 0xFF for floppies +-or partitions to be used for floppy emulation. ++usually 0xF8 for hard disks and is 0xF0 or a value from 0xF9 to 0xFF for ++floppies or partitions to be used for floppy emulation. + .IP "\fB\-n\fP \fIvolume\-name\fP" 4 + Sets the volume name (label) of the filesystem. The volume name can be up to + 11 characters long. The default is no label. +diff --git a/manpages/en/mkfs.fat.8 b/manpages/en/mkfs.fat.8 +index 9dd8115..81bf461 100644 +--- a/manpages/en/mkfs.fat.8 ++++ b/manpages/en/mkfs.fat.8 +@@ -58,7 +58,7 @@ Read the bad blocks list from \fIfilename\fR. + .IP "\fB\-m\fR \fImessage-file\fR" 4 + Sets the message the user receives on attempts to boot this filesystem without having properly installed an operating system. The message file must not exceed 418 bytes once line feeds have been converted to carriage return-line feed combinations, and tabs have been expanded. If the filename is a hyphen (-), the text is taken from standard input. + .IP "\fB\-M\fR \fIFAT-media-type\fR" 4 +-Specify the media type to be stored in the FAT boot sector. This value is usually 0xF8 for hard disks and has a value from 0xF9 to 0xFF for floppies or partitions to be used for floppy emulation. ++Specify the media type to be stored in the FAT boot sector. This value is usually 0xF8 for hard disks and is 0xF0 or a value from 0xF9 to 0xFF for floppies or partitions to be used for floppy emulation. + .IP "\fB\-n\fR \fIvolume-name\fR" 4 + Sets the volume name (label) of the filesystem. The volume name can be up to 11 characters long. The default is no label. + .IP "\fB\-r\fR \fIroot-dir-entries\fR" 4 +diff --git a/manpages/po/de/mkfs.fat.8.po b/manpages/po/de/mkfs.fat.8.po +index 2531179..360fe16 100644 +--- a/manpages/po/de/mkfs.fat.8.po ++++ b/manpages/po/de/mkfs.fat.8.po +@@ -3,7 +3,7 @@ + msgid "" + msgstr "" + "Project-Id-Version: dosfstools VERSION\n" +-"POT-Creation-Date: 2014-11-12 00:52+0100\n" ++"POT-Creation-Date: 2015-02-20 03:31+0100\n" + "PO-Revision-Date: 2013-06-06 09:34+0300\n" + "Last-Translator: Automatically generated\n" + "Language-Team: none\n" +@@ -354,8 +354,8 @@ msgstr "" + #: en/mkfs.fat.8:62 + msgid "" + "Specify the media type to be stored in the FAT boot sector. This value is " +-"usually 0xF8 for hard disks and has a value from 0xF9 to 0xFF for floppies " +-"or partitions to be used for floppy emulation." ++"usually 0xF8 for hard disks and is 0xF0 or a value from 0xF9 to 0xFF for " ++"floppies or partitions to be used for floppy emulation." + msgstr "" + + #. type: IP +diff --git a/manpages/pot/mkfs.fat.8.pot b/manpages/pot/mkfs.fat.8.pot +index a6106bc..32486ea 100644 +--- a/manpages/pot/mkfs.fat.8.pot ++++ b/manpages/pot/mkfs.fat.8.pot +@@ -7,7 +7,7 @@ + msgid "" + msgstr "" + "Project-Id-Version: dosfstools VERSION\n" +-"POT-Creation-Date: 2014-11-12 00:52+0100\n" ++"POT-Creation-Date: 2015-02-20 03:31+0100\n" + "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" + "Last-Translator: FULL NAME \n" + "Language-Team: LANGUAGE \n" +@@ -357,8 +357,8 @@ msgstr "" + #: en/mkfs.fat.8:62 + msgid "" + "Specify the media type to be stored in the FAT boot sector. This value is " +-"usually 0xF8 for hard disks and has a value from 0xF9 to 0xFF for floppies " +-"or partitions to be used for floppy emulation." ++"usually 0xF8 for hard disks and is 0xF0 or a value from 0xF9 to 0xFF for " ++"floppies or partitions to be used for floppy emulation." + msgstr "" + + #. type: IP +diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c +index a3dff54..e6f9390 100644 +--- a/src/mkfs.fat.c ++++ b/src/mkfs.fat.c +@@ -1569,10 +1569,14 @@ int main(int argc, char **argv) + break; + + case 'M': /* M : FAT Media byte */ +- fat_media_byte = (int) strtol (optarg, &tmp, 0); +- if (*tmp || fat_media_byte < 248 || fat_media_byte > 255) { +- printf ("FAT Media byte must be between 0xF8 and 0xFF : %s\n", optarg); +- usage (); ++ fat_media_byte = (int)strtol(optarg, &tmp, 0); ++ if (*tmp) { ++ printf("Bad number for media descriptor : %s\n", optarg); ++ usage(); ++ } ++ if (fat_media_byte != 0xf0 && (fat_media_byte < 0xf8 || fat_media_byte > 0xff)) { ++ printf("FAT Media byte must either be between 0xF8 and 0xFF or be 0xF0 : %s\n", optarg); ++ usage(); + } + break; + +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0006-fsck.fat-Make-r-option-default.patch b/tools/dosfstools/patches/0006-fsck.fat-Make-r-option-default.patch new file mode 100644 index 0000000000..20e7bdeb8b --- /dev/null +++ b/tools/dosfstools/patches/0006-fsck.fat-Make-r-option-default.patch @@ -0,0 +1,603 @@ +From 357ab077198bfa6239fa62fd03a546da959ec756 Mon Sep 17 00:00:00 2001 +From: Andreas Bombe +Date: Thu, 19 Feb 2015 21:22:54 +0100 +Subject: [PATCH 06/14] fsck.fat: Make -r option default + +Default mode is now to interactively repair with the option to write +the changes back at the end (like the -r option) instead of the previous +default mode of interactively correcting but never writing back the +changes. + +The -r option continues to be recognized by fsck.fat. + +Signed-off-by: Andreas Bombe +--- + manpages/de/fsck.fat.de.8 | 6 ++-- + manpages/en/fsck.fat.8 | 5 +-- + manpages/po/de/fsck.fat.8.po | 76 ++++++++++++++++++++------------------------ + manpages/pot/fsck.fat.8.pot | 76 ++++++++++++++++++++------------------------ + src/fsck.fat.c | 6 ++-- + 5 files changed, 76 insertions(+), 93 deletions(-) + +diff --git a/manpages/de/fsck.fat.de.8 b/manpages/de/fsck.fat.de.8 +index 1d96e23..f9d70b8 100644 +--- a/manpages/de/fsck.fat.de.8 ++++ b/manpages/de/fsck.fat.de.8 +@@ -123,7 +123,8 @@ anything to the filesystem. + Same as (\fB\-a\fP), for compatibility with other *fsck. + .IP \fB\-r\fP 4 + Interactively repair the filesystem. The user is asked for advice whenever +-there is more than one approach to fix an inconsistency. ++there is more than one approach to fix an inconsistency. This is the default ++mode and the option is only retained for backwards compatibility. + .IP \fB\-t\fP 4 + Mark unreadable clusters as bad. + .IP \fB\-u\fP 4 +@@ -143,9 +144,6 @@ Write changes to disk immediately. + .IP \fB\-y\fP 4 + Same as \fB\-a\fP (automatically repair filesystem) for compatibility with other + fsck tools. +-.PP +-\fBNote:\fP If \fB\-a\fP and \fB\-r\fP are absent, the filesystem is only checked, but +-not repaired. + + .SH "EXIT STATUS" + .IP 0 4 +diff --git a/manpages/en/fsck.fat.8 b/manpages/en/fsck.fat.8 +index 3d95dc8..8c54372 100644 +--- a/manpages/en/fsck.fat.8 ++++ b/manpages/en/fsck.fat.8 +@@ -93,8 +93,7 @@ anything to the filesystem. + .IP "\fB\-p\fR" 4 + Same as (\fB\-a\fR), for compatibility with other *fsck. + .IP "\fB\-r\fR" 4 +-Interactively repair the filesystem. The user is asked for advice whenever +-there is more than one approach to fix an inconsistency. ++Interactively repair the filesystem. The user is asked for advice whenever there is more than one approach to fix an inconsistency. This is the default mode and the option is only retained for backwards compatibility. + .IP "\fB\-t\fR" 4 + Mark unreadable clusters as bad. + .IP "\fB\-u\fR" 4 +@@ -107,8 +106,6 @@ Perform a verification pass. The filesystem check is repeated after the first ru + Write changes to disk immediately. + .IP "\fB\-y\fR" 4 + Same as \fB\-a\fR (automatically repair filesystem) for compatibility with other fsck tools. +-.PP +-\fBNote:\fR If \fB\-a\fR and \fB\-r\fR are absent, the filesystem is only checked, but not repaired. + + .SH "EXIT STATUS" + .IP "0" 4 +diff --git a/manpages/po/de/fsck.fat.8.po b/manpages/po/de/fsck.fat.8.po +index 3035906..7ca0bc1 100644 +--- a/manpages/po/de/fsck.fat.8.po ++++ b/manpages/po/de/fsck.fat.8.po +@@ -3,7 +3,7 @@ + msgid "" + msgstr "" + "Project-Id-Version: dosfstools VERSION\n" +-"POT-Creation-Date: 2014-11-12 00:52+0100\n" ++"POT-Creation-Date: 2015-02-20 20:47+0100\n" + "PO-Revision-Date: 2013-06-06 09:34+0300\n" + "Last-Translator: Automatically generated\n" + "Language-Team: none\n" +@@ -56,30 +56,30 @@ msgid "OPTIONS" + msgstr "" + + #. type: SH +-#: en/fatlabel.8:41 en/fsck.fat.8:128 en/mkfs.fat.8:78 ++#: en/fatlabel.8:41 en/fsck.fat.8:125 en/mkfs.fat.8:78 + #, no-wrap + msgid "SEE ALSO" + msgstr "" + + #. type: Plain text +-#: en/fatlabel.8:45 en/fsck.fat.8:132 ++#: en/fatlabel.8:45 en/fsck.fat.8:129 + msgid "B(8)" + msgstr "" + + #. type: SH +-#: en/fatlabel.8:46 en/fsck.fat.8:133 en/mkfs.fat.8:83 ++#: en/fatlabel.8:46 en/fsck.fat.8:130 en/mkfs.fat.8:83 + #, no-wrap + msgid "HOMEPAGE" + msgstr "" + + #. type: SH +-#: en/fatlabel.8:49 en/fsck.fat.8:136 en/mkfs.fat.8:86 ++#: en/fatlabel.8:49 en/fsck.fat.8:133 en/mkfs.fat.8:86 + #, no-wrap + msgid "AUTHORS" + msgstr "" + + #. type: Plain text +-#: en/fatlabel.8:50 en/fsck.fat.8:137 en/mkfs.fat.8:87 ++#: en/fatlabel.8:50 en/fsck.fat.8:134 en/mkfs.fat.8:87 + msgid "" + "B were written by Werner Almesberger EIE, Roman Hodek EI" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:98 ++#: en/fsck.fat.8:97 + msgid "" + "Interactively repair the filesystem. The user is asked for advice whenever " +-"there is more than one approach to fix an inconsistency." ++"there is more than one approach to fix an inconsistency. This is the default " ++"mode and the option is only retained for backwards compatibility." + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:98 ++#: en/fsck.fat.8:97 + #, no-wrap + msgid "B<-t>" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:100 ++#: en/fsck.fat.8:99 + msgid "Mark unreadable clusters as bad." + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:100 ++#: en/fsck.fat.8:99 + #, no-wrap + msgid "B<-u>" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:102 ++#: en/fsck.fat.8:101 + msgid "" + "Try to undelete the specified file. B tries to allocate a chain of " + "contiguous unallocated clusters beginning with the start cluster of the " +@@ -397,24 +398,24 @@ msgid "" + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:102 en/mkfs.fat.8:72 ++#: en/fsck.fat.8:101 en/mkfs.fat.8:72 + #, no-wrap + msgid "B<-v>" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:104 ++#: en/fsck.fat.8:103 + msgid "Verbose mode. Generates slightly more output." + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:104 ++#: en/fsck.fat.8:103 + #, no-wrap + msgid "B<-V>" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:106 ++#: en/fsck.fat.8:105 + msgid "" + "Perform a verification pass. The filesystem check is repeated after the " + "first run. The second pass should never report any fixable errors. It may " +@@ -424,91 +425,84 @@ msgid "" + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:106 ++#: en/fsck.fat.8:105 + #, no-wrap + msgid "B<-w>" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:108 ++#: en/fsck.fat.8:107 + msgid "Write changes to disk immediately." + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:108 ++#: en/fsck.fat.8:107 + #, no-wrap + msgid "B<-y>" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:110 ++#: en/fsck.fat.8:109 + msgid "" + "Same as B<-a> (automatically repair filesystem) for compatibility with other " + "fsck tools." + msgstr "" + +-#. type: Plain text +-#: en/fsck.fat.8:112 +-msgid "" +-"B If B<-a> and B<-r> are absent, the filesystem is only checked, but " +-"not repaired." +-msgstr "" +- + #. type: SH +-#: en/fsck.fat.8:113 ++#: en/fsck.fat.8:110 + #, no-wrap + msgid "EXIT STATUS" + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:114 ++#: en/fsck.fat.8:111 + #, no-wrap + msgid "0" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:116 ++#: en/fsck.fat.8:113 + msgid "No recoverable errors have been detected." + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:116 ++#: en/fsck.fat.8:113 + #, no-wrap + msgid "1" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:118 ++#: en/fsck.fat.8:115 + msgid "" + "Recoverable errors have been detected or B has discovered an " + "internal inconsistency." + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:118 ++#: en/fsck.fat.8:115 + #, no-wrap + msgid "2" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:120 ++#: en/fsck.fat.8:117 + msgid "Usage error. B did not access the filesystem." + msgstr "" + + #. type: SH +-#: en/fsck.fat.8:121 ++#: en/fsck.fat.8:118 + #, no-wrap + msgid "FILES" + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:122 ++#: en/fsck.fat.8:119 + #, no-wrap + msgid "fsck0000.rec, fsck0001.rec, ..." + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:124 ++#: en/fsck.fat.8:121 + msgid "" + "When recovering from a corrupted filesystem, B dumps recovered " + "data into files named 'fsckNNNN.rec' in the top level directory of the " +@@ -516,13 +510,13 @@ msgid "" + msgstr "" + + #. type: SH +-#: en/fsck.fat.8:125 en/mkfs.fat.8:75 ++#: en/fsck.fat.8:122 en/mkfs.fat.8:75 + #, no-wrap + msgid "BUGS" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:127 ++#: en/fsck.fat.8:124 + msgid "" + "Does not create . and .. files where necessary. Does not remove entirely " + "empty directories. Should give more diagnostic messages. Undeleting files " +@@ -530,12 +524,12 @@ msgid "" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:130 en/mkfs.fat.8:80 ++#: en/fsck.fat.8:127 en/mkfs.fat.8:80 + msgid "B(8)" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:135 en/mkfs.fat.8:85 ++#: en/fsck.fat.8:132 en/mkfs.fat.8:85 + msgid "" + "More information about B and B can be found at " + "EIE." +diff --git a/manpages/pot/fsck.fat.8.pot b/manpages/pot/fsck.fat.8.pot +index e411819..f5ca313 100644 +--- a/manpages/pot/fsck.fat.8.pot ++++ b/manpages/pot/fsck.fat.8.pot +@@ -7,7 +7,7 @@ + msgid "" + msgstr "" + "Project-Id-Version: dosfstools VERSION\n" +-"POT-Creation-Date: 2014-11-12 00:52+0100\n" ++"POT-Creation-Date: 2015-02-20 20:47+0100\n" + "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" + "Last-Translator: FULL NAME \n" + "Language-Team: LANGUAGE \n" +@@ -59,30 +59,30 @@ msgid "OPTIONS" + msgstr "" + + #. type: SH +-#: en/fatlabel.8:41 en/fsck.fat.8:128 en/mkfs.fat.8:78 ++#: en/fatlabel.8:41 en/fsck.fat.8:125 en/mkfs.fat.8:78 + #, no-wrap + msgid "SEE ALSO" + msgstr "" + + #. type: Plain text +-#: en/fatlabel.8:45 en/fsck.fat.8:132 ++#: en/fatlabel.8:45 en/fsck.fat.8:129 + msgid "B(8)" + msgstr "" + + #. type: SH +-#: en/fatlabel.8:46 en/fsck.fat.8:133 en/mkfs.fat.8:83 ++#: en/fatlabel.8:46 en/fsck.fat.8:130 en/mkfs.fat.8:83 + #, no-wrap + msgid "HOMEPAGE" + msgstr "" + + #. type: SH +-#: en/fatlabel.8:49 en/fsck.fat.8:136 en/mkfs.fat.8:86 ++#: en/fatlabel.8:49 en/fsck.fat.8:133 en/mkfs.fat.8:86 + #, no-wrap + msgid "AUTHORS" + msgstr "" + + #. type: Plain text +-#: en/fatlabel.8:50 en/fsck.fat.8:137 en/mkfs.fat.8:87 ++#: en/fatlabel.8:50 en/fsck.fat.8:134 en/mkfs.fat.8:87 + msgid "" + "B were written by Werner Almesberger EIE, Roman Hodek EI" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:98 ++#: en/fsck.fat.8:97 + msgid "" + "Interactively repair the filesystem. The user is asked for advice whenever " +-"there is more than one approach to fix an inconsistency." ++"there is more than one approach to fix an inconsistency. This is the default " ++"mode and the option is only retained for backwards compatibility." + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:98 ++#: en/fsck.fat.8:97 + #, no-wrap + msgid "B<-t>" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:100 ++#: en/fsck.fat.8:99 + msgid "Mark unreadable clusters as bad." + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:100 ++#: en/fsck.fat.8:99 + #, no-wrap + msgid "B<-u>" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:102 ++#: en/fsck.fat.8:101 + msgid "" + "Try to undelete the specified file. B tries to allocate a chain of " + "contiguous unallocated clusters beginning with the start cluster of the " +@@ -400,24 +401,24 @@ msgid "" + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:102 en/mkfs.fat.8:72 ++#: en/fsck.fat.8:101 en/mkfs.fat.8:72 + #, no-wrap + msgid "B<-v>" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:104 ++#: en/fsck.fat.8:103 + msgid "Verbose mode. Generates slightly more output." + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:104 ++#: en/fsck.fat.8:103 + #, no-wrap + msgid "B<-V>" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:106 ++#: en/fsck.fat.8:105 + msgid "" + "Perform a verification pass. The filesystem check is repeated after the " + "first run. The second pass should never report any fixable errors. It may " +@@ -427,91 +428,84 @@ msgid "" + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:106 ++#: en/fsck.fat.8:105 + #, no-wrap + msgid "B<-w>" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:108 ++#: en/fsck.fat.8:107 + msgid "Write changes to disk immediately." + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:108 ++#: en/fsck.fat.8:107 + #, no-wrap + msgid "B<-y>" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:110 ++#: en/fsck.fat.8:109 + msgid "" + "Same as B<-a> (automatically repair filesystem) for compatibility with other " + "fsck tools." + msgstr "" + +-#. type: Plain text +-#: en/fsck.fat.8:112 +-msgid "" +-"B If B<-a> and B<-r> are absent, the filesystem is only checked, but " +-"not repaired." +-msgstr "" +- + #. type: SH +-#: en/fsck.fat.8:113 ++#: en/fsck.fat.8:110 + #, no-wrap + msgid "EXIT STATUS" + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:114 ++#: en/fsck.fat.8:111 + #, no-wrap + msgid "0" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:116 ++#: en/fsck.fat.8:113 + msgid "No recoverable errors have been detected." + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:116 ++#: en/fsck.fat.8:113 + #, no-wrap + msgid "1" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:118 ++#: en/fsck.fat.8:115 + msgid "" + "Recoverable errors have been detected or B has discovered an " + "internal inconsistency." + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:118 ++#: en/fsck.fat.8:115 + #, no-wrap + msgid "2" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:120 ++#: en/fsck.fat.8:117 + msgid "Usage error. B did not access the filesystem." + msgstr "" + + #. type: SH +-#: en/fsck.fat.8:121 ++#: en/fsck.fat.8:118 + #, no-wrap + msgid "FILES" + msgstr "" + + #. type: IP +-#: en/fsck.fat.8:122 ++#: en/fsck.fat.8:119 + #, no-wrap + msgid "fsck0000.rec, fsck0001.rec, ..." + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:124 ++#: en/fsck.fat.8:121 + msgid "" + "When recovering from a corrupted filesystem, B dumps recovered " + "data into files named 'fsckNNNN.rec' in the top level directory of the " +@@ -519,13 +513,13 @@ msgid "" + msgstr "" + + #. type: SH +-#: en/fsck.fat.8:125 en/mkfs.fat.8:75 ++#: en/fsck.fat.8:122 en/mkfs.fat.8:75 + #, no-wrap + msgid "BUGS" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:127 ++#: en/fsck.fat.8:124 + msgid "" + "Does not create . and .. files where necessary. Does not remove entirely " + "empty directories. Should give more diagnostic messages. Undeleting files " +@@ -533,12 +527,12 @@ msgid "" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:130 en/mkfs.fat.8:80 ++#: en/fsck.fat.8:127 en/mkfs.fat.8:80 + msgid "B(8)" + msgstr "" + + #. type: Plain text +-#: en/fsck.fat.8:135 en/mkfs.fat.8:85 ++#: en/fsck.fat.8:132 en/mkfs.fat.8:85 + msgid "" + "More information about B and B can be found at " + "EIE." +diff --git a/src/fsck.fat.c b/src/fsck.fat.c +index c073d9a..6c7fd87 100644 +--- a/src/fsck.fat.c ++++ b/src/fsck.fat.c +@@ -108,8 +108,8 @@ int main(int argc, char **argv) + uint32_t free_clusters = 0; + + memset(&fs, 0, sizeof(fs)); +- rw = salvage_files = verify = 0; +- interactive = 1; ++ salvage_files = verify = 0; ++ rw = interactive = 1; + check_atari(); + + while ((c = getopt(argc, argv, "Aac:d:bflnprtu:vVwy")) != EOF) +@@ -169,7 +169,7 @@ int main(int argc, char **argv) + } + set_dos_codepage(-1); /* set default codepage if none was given in command line */ + if ((test || write_immed) && !rw) { +- fprintf(stderr, "-t and -w require -a or -r\n"); ++ fprintf(stderr, "-t and -w can not be used in read only mode\n"); + exit(2); + } + if (optind != argc - 1) +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0007-Makefile-fix-typo-in-uninstall-man.patch b/tools/dosfstools/patches/0007-Makefile-fix-typo-in-uninstall-man.patch new file mode 100644 index 0000000000..9eb8cc6cf8 --- /dev/null +++ b/tools/dosfstools/patches/0007-Makefile-fix-typo-in-uninstall-man.patch @@ -0,0 +1,30 @@ +From fb6aea6f5547d59b6e8c287ad8e61854af5a34b0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Thu, 26 Feb 2015 12:50:57 +0100 +Subject: [PATCH 07/14] Makefile: fix typo in uninstall-man +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Álvaro Fernández Rojas +Signed-off-by: Andreas Bombe +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 3cbdb76..d25510f 100644 +--- a/Makefile ++++ b/Makefile +@@ -127,7 +127,7 @@ uninstall-man: + for MANPAGE in manpages/en/*; \ + do \ + SECTION="8"; \ +- rm -f $(DESTDIR)/$(MANDIR}/man$${SECTION}/$$(basename $${MANPAGE} .en.$${SECTION}).$${SECTION}; \ ++ rm -f $(DESTDIR)/$(MANDIR)/man$${SECTION}/$$(basename $${MANPAGE} .en.$${SECTION}).$${SECTION}; \ + done + + for LANGUAGE in $(LANGUAGES); \ +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0008-Makefile-avoid-using-install-D.patch b/tools/dosfstools/patches/0008-Makefile-avoid-using-install-D.patch new file mode 100644 index 0000000000..ad59577c16 --- /dev/null +++ b/tools/dosfstools/patches/0008-Makefile-avoid-using-install-D.patch @@ -0,0 +1,43 @@ +From 02b5a6d9a407daebe903fe64fb1b22673aaa7e92 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Thu, 26 Feb 2015 12:51:23 +0100 +Subject: [PATCH 08/14] Makefile: avoid using install -D +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +OS X and FreeBSD are not compatible with this option + +Signed-off-by: Álvaro Fernández Rojas +Signed-off-by: Andreas Bombe +--- + Makefile | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index d25510f..1593f3d 100644 +--- a/Makefile ++++ b/Makefile +@@ -62,7 +62,8 @@ install-man: + for MANPAGE in manpages/en/*; \ + do \ + SECTION="8"; \ +- install -D -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/man$${SECTION}/$$(basename $${MANPAGE}); \ ++ mkdir -p $(DESTDIR)/$(MANDIR)/man$${SECTION}/; \ ++ install -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/man$${SECTION}/$$(basename $${MANPAGE}); \ + done + + for LANGUAGE in $(LANGUAGES); \ +@@ -70,7 +71,8 @@ install-man: + for MANPAGE in manpages/$${LANGUAGE}/*; \ + do \ + SECTION="8"; \ +- install -D -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/$${LANGUAGE}/man$${SECTION}/$$(basename $${MANPAGE} .$${LANGUAGE}.$${SECTION}).$${SECTION}; \ ++ mkdir -p $(DESTDIR)/$(MANDIR)/$${LANGUAGE}/man$${SECTION}/; \ ++ install -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/$${LANGUAGE}/man$${SECTION}/$$(basename $${MANPAGE} .$${LANGUAGE}.$${SECTION}).$${SECTION}; \ + done; \ + done + install-symlinks: install-bin install-man +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0009-Improve-.gitignore.patch b/tools/dosfstools/patches/0009-Improve-.gitignore.patch new file mode 100644 index 0000000000..25d5fe6518 --- /dev/null +++ b/tools/dosfstools/patches/0009-Improve-.gitignore.patch @@ -0,0 +1,28 @@ +From 628b3ec05b304e77eed05c57457ff7bb39401f6c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Thu, 26 Feb 2015 19:41:19 +0100 +Subject: [PATCH 09/14] Improve .gitignore +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Álvaro Fernández Rojas +Signed-off-by: Andreas Bombe +--- + .gitignore | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/.gitignore b/.gitignore +index 5c9366e..2dc4ca9 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -6,3 +6,6 @@ + tags + *~ + .*.sw[a-p] ++*.orig ++*.rej ++*.DS_Store +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0010-Remove-non-standard-int-types.patch b/tools/dosfstools/patches/0010-Remove-non-standard-int-types.patch new file mode 100644 index 0000000000..b3ee2adcf7 --- /dev/null +++ b/tools/dosfstools/patches/0010-Remove-non-standard-int-types.patch @@ -0,0 +1,538 @@ +From 245d0cce5e77d7465d61bfde91bc79477d5e6fd6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Thu, 26 Feb 2015 19:22:54 +0100 +Subject: [PATCH 10/14] Remove non standard int types +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Álvaro Fernández Rojas +Signed-off-by: Andreas Bombe +--- + src/boot.c | 16 +++---- + src/common.h | 2 - + src/file.c | 2 - + src/fsck.fat.h | 148 ++++++++++++++++++++++++++++----------------------------- + src/io.c | 1 - + src/lfn.c | 23 ++++----- + src/mkfs.fat.c | 95 ++++++++++++++++++------------------ + 7 files changed, 138 insertions(+), 149 deletions(-) + +diff --git a/src/boot.c b/src/boot.c +index be7bfb7..0c0918f 100644 +--- a/src/boot.c ++++ b/src/boot.c +@@ -25,8 +25,8 @@ + * by Roman Hodek */ + + #include ++#include + #include +-#include + #include + #include + +@@ -45,7 +45,7 @@ + #define FAT16_THRESHOLD 65525 + + static struct { +- __u8 media; ++ uint8_t media; + const char *descr; + } mediabytes[] = { + { +@@ -62,7 +62,7 @@ static struct { + + /* Unaligned fields must first be accessed byte-wise */ + #define GET_UNALIGNED_W(f) \ +- ( (__u16)f[0] | ((__u16)f[1]<<8) ) ++ ( (uint16_t)f[0] | ((uint16_t)f[1]<<8) ) + + static const char *get_media_descr(unsigned char media) + { +@@ -166,18 +166,18 @@ static void check_backup_boot(DOS_FS * fs, struct boot_sector *b, int lss) + fs_read(fs->backupboot_start, sizeof(b2), &b2); + if (memcmp(b, &b2, sizeof(b2)) != 0) { + /* there are any differences */ +- __u8 *p, *q; ++ uint8_t *p, *q; + int i, pos, first = 1; + char buf[20]; + + printf("There are differences between boot sector and its backup.\n"); + printf("This is mostly harmless. Differences: (offset:original/backup)\n "); + pos = 2; +- for (p = (__u8 *) b, q = (__u8 *) & b2, i = 0; i < sizeof(b2); ++ for (p = (uint8_t *) b, q = (uint8_t *) & b2, i = 0; i < sizeof(b2); + ++p, ++q, ++i) { + if (*p != *q) { + sprintf(buf, "%s%u:%02x/%02x", first ? "" : ", ", +- (unsigned)(p - (__u8 *) b), *p, *q); ++ (unsigned)(p - (uint8_t *) b), *p, *q); + if (pos + strlen(buf) > 78) + printf("\n "), pos = 2; + printf("%s", buf); +@@ -227,7 +227,7 @@ static void read_fsinfo(DOS_FS * fs, struct boot_sector *b, int lss) + if (interactive && get_key("12", "?") == '1') { + /* search for a free reserved sector (not boot sector and not + * backup boot sector) */ +- __u32 s; ++ uint32_t s; + for (s = 1; s < le16toh(b->reserved); ++s) + if (s != le16toh(b->backup_boot)) + break; +@@ -425,7 +425,7 @@ void read_boot(DOS_FS * fs) + fs->eff_fat_bits = (fs->fat_bits == 32) ? 28 : fs->fat_bits; + fs->fat_size = fat_length * logical_sector_size; + +- fs->label = calloc(12, sizeof(__u8)); ++ fs->label = calloc(12, sizeof(uint8_t)); + if (fs->fat_bits == 12 || fs->fat_bits == 16) { + struct boot_sector_16 *b16 = (struct boot_sector_16 *)&b; + if (b16->extended_sig == 0x29) +diff --git a/src/common.h b/src/common.h +index b127f63..c15efb5 100644 +--- a/src/common.h ++++ b/src/common.h +@@ -20,8 +20,6 @@ + can be found in /usr/share/common-licenses/GPL-3 file. + */ + +-#include +- + #ifndef _COMMON_H + #define _COMMON_H + +diff --git a/src/file.c b/src/file.c +index 30adcde..0b53840 100644 +--- a/src/file.c ++++ b/src/file.c +@@ -34,8 +34,6 @@ + #define _LINUX_STRING_H_ /* hack to avoid inclusion of */ + #define _LINUX_FS_H /* hack to avoid inclusion of */ + +-#include +- + #include + + #include "common.h" +diff --git a/src/fsck.fat.h b/src/fsck.fat.h +index e5ade5b..27e9d52 100644 +--- a/src/fsck.fat.h ++++ b/src/fsck.fat.h +@@ -28,14 +28,10 @@ + #define _DOSFSCK_H + + #include +-#include + #define _LINUX_STAT_H /* hack to avoid inclusion of */ + #define _LINUX_STRING_H_ /* hack to avoid inclusion of */ + #define _LINUX_FS_H /* hack to avoid inclusion of */ + +-#include +-#include +- + #include + + #include +@@ -49,95 +45,95 @@ + /* ++roman: Use own definition of boot sector structure -- the kernel headers' + * name for it is msdos_boot_sector in 2.0 and fat_boot_sector in 2.1 ... */ + struct boot_sector { +- __u8 ignored[3]; /* Boot strap short or near jump */ +- __u8 system_id[8]; /* Name - can be used to special case ++ uint8_t ignored[3]; /* Boot strap short or near jump */ ++ uint8_t system_id[8]; /* Name - can be used to special case + partition manager volumes */ +- __u8 sector_size[2]; /* bytes per logical sector */ +- __u8 cluster_size; /* sectors/cluster */ +- __u16 reserved; /* reserved sectors */ +- __u8 fats; /* number of FATs */ +- __u8 dir_entries[2]; /* root directory entries */ +- __u8 sectors[2]; /* number of sectors */ +- __u8 media; /* media code (unused) */ +- __u16 fat_length; /* sectors/FAT */ +- __u16 secs_track; /* sectors per track */ +- __u16 heads; /* number of heads */ +- __u32 hidden; /* hidden sectors (unused) */ +- __u32 total_sect; /* number of sectors (if sectors == 0) */ ++ uint8_t sector_size[2]; /* bytes per logical sector */ ++ uint8_t cluster_size; /* sectors/cluster */ ++ uint16_t reserved; /* reserved sectors */ ++ uint8_t fats; /* number of FATs */ ++ uint8_t dir_entries[2]; /* root directory entries */ ++ uint8_t sectors[2]; /* number of sectors */ ++ uint8_t media; /* media code (unused) */ ++ uint16_t fat_length; /* sectors/FAT */ ++ uint16_t secs_track; /* sectors per track */ ++ uint16_t heads; /* number of heads */ ++ uint32_t hidden; /* hidden sectors (unused) */ ++ uint32_t total_sect; /* number of sectors (if sectors == 0) */ + + /* The following fields are only used by FAT32 */ +- __u32 fat32_length; /* sectors/FAT */ +- __u16 flags; /* bit 8: fat mirroring, low 4: active fat */ +- __u8 version[2]; /* major, minor filesystem version */ +- __u32 root_cluster; /* first cluster in root directory */ +- __u16 info_sector; /* filesystem info sector */ +- __u16 backup_boot; /* backup boot sector */ +- __u8 reserved2[12]; /* Unused */ +- +- __u8 drive_number; /* Logical Drive Number */ +- __u8 reserved3; /* Unused */ +- +- __u8 extended_sig; /* Extended Signature (0x29) */ +- __u32 serial; /* Serial number */ +- __u8 label[11]; /* FS label */ +- __u8 fs_type[8]; /* FS Type */ ++ uint32_t fat32_length; /* sectors/FAT */ ++ uint16_t flags; /* bit 8: fat mirroring, low 4: active fat */ ++ uint8_t version[2]; /* major, minor filesystem version */ ++ uint32_t root_cluster; /* first cluster in root directory */ ++ uint16_t info_sector; /* filesystem info sector */ ++ uint16_t backup_boot; /* backup boot sector */ ++ uint8_t reserved2[12]; /* Unused */ ++ ++ uint8_t drive_number; /* Logical Drive Number */ ++ uint8_t reserved3; /* Unused */ ++ ++ uint8_t extended_sig; /* Extended Signature (0x29) */ ++ uint32_t serial; /* Serial number */ ++ uint8_t label[11]; /* FS label */ ++ uint8_t fs_type[8]; /* FS Type */ + + /* fill up to 512 bytes */ +- __u8 junk[422]; ++ uint8_t junk[422]; + } __attribute__ ((packed)); + + struct boot_sector_16 { +- __u8 ignored[3]; /* Boot strap short or near jump */ +- __u8 system_id[8]; /* Name - can be used to special case ++ uint8_t ignored[3]; /* Boot strap short or near jump */ ++ uint8_t system_id[8]; /* Name - can be used to special case + partition manager volumes */ +- __u8 sector_size[2]; /* bytes per logical sector */ +- __u8 cluster_size; /* sectors/cluster */ +- __u16 reserved; /* reserved sectors */ +- __u8 fats; /* number of FATs */ +- __u8 dir_entries[2]; /* root directory entries */ +- __u8 sectors[2]; /* number of sectors */ +- __u8 media; /* media code (unused) */ +- __u16 fat_length; /* sectors/FAT */ +- __u16 secs_track; /* sectors per track */ +- __u16 heads; /* number of heads */ +- __u32 hidden; /* hidden sectors (unused) */ +- __u32 total_sect; /* number of sectors (if sectors == 0) */ +- +- __u8 drive_number; /* Logical Drive Number */ +- __u8 reserved2; /* Unused */ +- +- __u8 extended_sig; /* Extended Signature (0x29) */ +- __u32 serial; /* Serial number */ +- __u8 label[11]; /* FS label */ +- __u8 fs_type[8]; /* FS Type */ ++ uint8_t sector_size[2]; /* bytes per logical sector */ ++ uint8_t cluster_size; /* sectors/cluster */ ++ uint16_t reserved; /* reserved sectors */ ++ uint8_t fats; /* number of FATs */ ++ uint8_t dir_entries[2]; /* root directory entries */ ++ uint8_t sectors[2]; /* number of sectors */ ++ uint8_t media; /* media code (unused) */ ++ uint16_t fat_length; /* sectors/FAT */ ++ uint16_t secs_track; /* sectors per track */ ++ uint16_t heads; /* number of heads */ ++ uint32_t hidden; /* hidden sectors (unused) */ ++ uint32_t total_sect; /* number of sectors (if sectors == 0) */ ++ ++ uint8_t drive_number; /* Logical Drive Number */ ++ uint8_t reserved2; /* Unused */ ++ ++ uint8_t extended_sig; /* Extended Signature (0x29) */ ++ uint32_t serial; /* Serial number */ ++ uint8_t label[11]; /* FS label */ ++ uint8_t fs_type[8]; /* FS Type */ + + /* fill up to 512 bytes */ +- __u8 junk[450]; ++ uint8_t junk[450]; + } __attribute__ ((packed)); + + struct info_sector { +- __u32 magic; /* Magic for info sector ('RRaA') */ +- __u8 junk[0x1dc]; +- __u32 reserved1; /* Nothing as far as I can tell */ +- __u32 signature; /* 0x61417272 ('rrAa') */ +- __u32 free_clusters; /* Free cluster count. -1 if unknown */ +- __u32 next_cluster; /* Most recently allocated cluster. */ +- __u32 reserved2[3]; +- __u16 reserved3; +- __u16 boot_sign; ++ uint32_t magic; /* Magic for info sector ('RRaA') */ ++ uint8_t junk[0x1dc]; ++ uint32_t reserved1; /* Nothing as far as I can tell */ ++ uint32_t signature; /* 0x61417272 ('rrAa') */ ++ uint32_t free_clusters; /* Free cluster count. -1 if unknown */ ++ uint32_t next_cluster; /* Most recently allocated cluster. */ ++ uint32_t reserved2[3]; ++ uint16_t reserved3; ++ uint16_t boot_sign; + }; + + typedef struct { +- __u8 name[8], ext[3]; /* name and extension */ +- __u8 attr; /* attribute bits */ +- __u8 lcase; /* Case for base and extension */ +- __u8 ctime_ms; /* Creation time, milliseconds */ +- __u16 ctime; /* Creation time */ +- __u16 cdate; /* Creation date */ +- __u16 adate; /* Last access date */ +- __u16 starthi; /* High 16 bits of cluster in FAT32 */ +- __u16 time, date, start; /* time, date and first cluster */ +- __u32 size; /* file size (in bytes) */ ++ uint8_t name[8], ext[3]; /* name and extension */ ++ uint8_t attr; /* attribute bits */ ++ uint8_t lcase; /* Case for base and extension */ ++ uint8_t ctime_ms; /* Creation time, milliseconds */ ++ uint16_t ctime; /* Creation time */ ++ uint16_t cdate; /* Creation date */ ++ uint16_t adate; /* Last access date */ ++ uint16_t starthi; /* High 16 bits of cluster in FAT32 */ ++ uint16_t time, date, start; /* time, date and first cluster */ ++ uint32_t size; /* file size (in bytes) */ + } __attribute__ ((packed)) DIR_ENT; + + typedef struct _dos_file { +diff --git a/src/io.c b/src/io.c +index 3755ba5..450432c 100644 +--- a/src/io.c ++++ b/src/io.c +@@ -31,7 +31,6 @@ + * by Roman Hodek */ + + #define _LARGEFILE64_SOURCE +-#include + #include + #include + #include +diff --git a/src/lfn.c b/src/lfn.c +index 2e60198..2601172 100644 +--- a/src/lfn.c ++++ b/src/lfn.c +@@ -21,6 +21,7 @@ + */ + + #include ++#include + #include + #include + #include +@@ -33,14 +34,14 @@ + #include "file.h" + + typedef struct { +- __u8 id; /* sequence number for slot */ +- __u8 name0_4[10]; /* first 5 characters in name */ +- __u8 attr; /* attribute byte */ +- __u8 reserved; /* always 0 */ +- __u8 alias_checksum; /* checksum for 8.3 alias */ +- __u8 name5_10[12]; /* 6 more characters in name */ +- __u16 start; /* starting cluster number, 0 in long slots */ +- __u8 name11_12[4]; /* last 2 characters in name */ ++ uint8_t id; /* sequence number for slot */ ++ uint8_t name0_4[10]; /* first 5 characters in name */ ++ uint8_t attr; /* attribute byte */ ++ uint8_t reserved; /* always 0 */ ++ uint8_t alias_checksum; /* checksum for 8.3 alias */ ++ uint8_t name5_10[12]; /* 6 more characters in name */ ++ uint16_t start; /* starting cluster number, 0 in long slots */ ++ uint8_t name11_12[4]; /* last 2 characters in name */ + } LFN_ENT; + + #define LFN_ID_START 0x40 +@@ -173,7 +174,7 @@ static void clear_lfn_slots(int start, int end) + void lfn_fix_checksum(loff_t from, loff_t to, const char *short_name) + { + int i; +- __u8 sum; ++ uint8_t sum; + for (sum = 0, i = 0; i < 11; i++) + sum = (((sum & 1) << 7) | ((sum & 0xfe) >> 1)) + short_name[i]; + +@@ -409,7 +410,7 @@ void lfn_add_slot(DIR_ENT * de, loff_t dir_offset) + char *lfn_get(DIR_ENT * de, loff_t * lfn_offset) + { + char *lfn; +- __u8 sum; ++ uint8_t sum; + int i; + + *lfn_offset = 0; +@@ -453,7 +454,7 @@ char *lfn_get(DIR_ENT * de, loff_t * lfn_offset) + return NULL; + case '3': + for (i = 0; i < lfn_parts; ++i) { +- __u8 id = (lfn_parts - i) | (i == 0 ? LFN_ID_START : 0); ++ uint8_t id = (lfn_parts - i) | (i == 0 ? LFN_ID_START : 0); + fs_write(lfn_offsets[i] + offsetof(LFN_ENT, id), + sizeof(id), &id); + } +diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c +index e6f9390..3d1512f 100644 +--- a/src/mkfs.fat.c ++++ b/src/mkfs.fat.c +@@ -60,7 +60,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -68,8 +67,6 @@ + #include + #include + +-#include +- + /* In earlier versions, an own llseek() was used, but glibc lseek() is + * sufficient (or even better :) for 64 bit offsets in the meantime */ + #define llseek lseek +@@ -148,72 +145,72 @@ static inline int cdiv(int a, int b) + * alignments */ + + struct msdos_volume_info { +- __u8 drive_number; /* BIOS drive number */ +- __u8 RESERVED; /* Unused */ +- __u8 ext_boot_sign; /* 0x29 if fields below exist (DOS 3.3+) */ +- __u8 volume_id[4]; /* Volume ID number */ +- __u8 volume_label[11]; /* Volume label */ +- __u8 fs_type[8]; /* Typically FAT12 or FAT16 */ ++ uint8_t drive_number; /* BIOS drive number */ ++ uint8_t RESERVED; /* Unused */ ++ uint8_t ext_boot_sign; /* 0x29 if fields below exist (DOS 3.3+) */ ++ uint8_t volume_id[4]; /* Volume ID number */ ++ uint8_t volume_label[11]; /* Volume label */ ++ uint8_t fs_type[8]; /* Typically FAT12 or FAT16 */ + } __attribute__ ((packed)); + + struct msdos_boot_sector { +- __u8 boot_jump[3]; /* Boot strap short or near jump */ +- __u8 system_id[8]; /* Name - can be used to special case ++ uint8_t boot_jump[3]; /* Boot strap short or near jump */ ++ uint8_t system_id[8]; /* Name - can be used to special case + partition manager volumes */ +- __u8 sector_size[2]; /* bytes per logical sector */ +- __u8 cluster_size; /* sectors/cluster */ +- __u16 reserved; /* reserved sectors */ +- __u8 fats; /* number of FATs */ +- __u8 dir_entries[2]; /* root directory entries */ +- __u8 sectors[2]; /* number of sectors */ +- __u8 media; /* media code (unused) */ +- __u16 fat_length; /* sectors/FAT */ +- __u16 secs_track; /* sectors per track */ +- __u16 heads; /* number of heads */ +- __u32 hidden; /* hidden sectors (unused) */ +- __u32 total_sect; /* number of sectors (if sectors == 0) */ ++ uint8_t sector_size[2]; /* bytes per logical sector */ ++ uint8_t cluster_size; /* sectors/cluster */ ++ uint16_t reserved; /* reserved sectors */ ++ uint8_t fats; /* number of FATs */ ++ uint8_t dir_entries[2]; /* root directory entries */ ++ uint8_t sectors[2]; /* number of sectors */ ++ uint8_t media; /* media code (unused) */ ++ uint16_t fat_length; /* sectors/FAT */ ++ uint16_t secs_track; /* sectors per track */ ++ uint16_t heads; /* number of heads */ ++ uint32_t hidden; /* hidden sectors (unused) */ ++ uint32_t total_sect; /* number of sectors (if sectors == 0) */ + union { + struct { + struct msdos_volume_info vi; +- __u8 boot_code[BOOTCODE_SIZE]; ++ uint8_t boot_code[BOOTCODE_SIZE]; + } __attribute__ ((packed)) _oldfat; + struct { +- __u32 fat32_length; /* sectors/FAT */ +- __u16 flags; /* bit 8: fat mirroring, low 4: active fat */ +- __u8 version[2]; /* major, minor filesystem version */ +- __u32 root_cluster; /* first cluster in root directory */ +- __u16 info_sector; /* filesystem info sector */ +- __u16 backup_boot; /* backup boot sector */ +- __u16 reserved2[6]; /* Unused */ ++ uint32_t fat32_length; /* sectors/FAT */ ++ uint16_t flags; /* bit 8: fat mirroring, low 4: active fat */ ++ uint8_t version[2]; /* major, minor filesystem version */ ++ uint32_t root_cluster; /* first cluster in root directory */ ++ uint16_t info_sector; /* filesystem info sector */ ++ uint16_t backup_boot; /* backup boot sector */ ++ uint16_t reserved2[6]; /* Unused */ + struct msdos_volume_info vi; +- __u8 boot_code[BOOTCODE_FAT32_SIZE]; ++ uint8_t boot_code[BOOTCODE_FAT32_SIZE]; + } __attribute__ ((packed)) _fat32; + } __attribute__ ((packed)) fstype; +- __u16 boot_sign; ++ uint16_t boot_sign; + } __attribute__ ((packed)); + #define fat32 fstype._fat32 + #define oldfat fstype._oldfat + + struct fat32_fsinfo { +- __u32 reserved1; /* Nothing as far as I can tell */ +- __u32 signature; /* 0x61417272L */ +- __u32 free_clusters; /* Free cluster count. -1 if unknown */ +- __u32 next_cluster; /* Most recently allocated cluster. ++ uint32_t reserved1; /* Nothing as far as I can tell */ ++ uint32_t signature; /* 0x61417272L */ ++ uint32_t free_clusters; /* Free cluster count. -1 if unknown */ ++ uint32_t next_cluster; /* Most recently allocated cluster. + * Unused under Linux. */ +- __u32 reserved2[4]; ++ uint32_t reserved2[4]; + }; + + struct msdos_dir_entry { + char name[8], ext[3]; /* name and extension */ +- __u8 attr; /* attribute bits */ +- __u8 lcase; /* Case for base and extension */ +- __u8 ctime_ms; /* Creation time, milliseconds */ +- __u16 ctime; /* Creation time */ +- __u16 cdate; /* Creation date */ +- __u16 adate; /* Last access date */ +- __u16 starthi; /* high 16 bits of first cl. (FAT32) */ +- __u16 time, date, start; /* time, date and first cluster */ +- __u32 size; /* file size (in bytes) */ ++ uint8_t attr; /* attribute bits */ ++ uint8_t lcase; /* Case for base and extension */ ++ uint8_t ctime_ms; /* Creation time, milliseconds */ ++ uint16_t ctime; /* Creation time */ ++ uint16_t cdate; /* Creation date */ ++ uint16_t adate; /* Last access date */ ++ uint16_t starthi; /* high 16 bits of first cl. (FAT32) */ ++ uint16_t time, date, start; /* time, date and first cluster */ ++ uint32_t size; /* file size (in bytes) */ + } __attribute__ ((packed)); + + /* The "boot code" we put into the filesystem... it writes a message and +@@ -826,7 +823,7 @@ static void setup_tables(void) + bs.hidden = htole32(hidden_sectors); + else { + /* In Atari format, hidden is a 16 bit field */ +- __u16 hidden = htole16(hidden_sectors); ++ uint16_t hidden = htole16(hidden_sectors); + if (hidden_sectors & ~0xffff) + die("#hidden doesn't fit in 16bit field of Atari format\n"); + memcpy(&bs.hidden, &hidden, 2); +@@ -1279,7 +1276,7 @@ static void setup_tables(void) + info->next_cluster = htole32(2); + + /* Info sector also must have boot sign */ +- *(__u16 *) (info_sector + 0x1fe) = htole16(BOOT_SIGN); ++ *(uint16_t *) (info_sector + 0x1fe) = htole16(BOOT_SIGN); + } + + if (!(blank_sector = malloc(sector_size))) +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0011-Remove-linux-msdos_fs.h-includes.patch b/tools/dosfstools/patches/0011-Remove-linux-msdos_fs.h-includes.patch new file mode 100644 index 0000000000..08bd36ddc4 --- /dev/null +++ b/tools/dosfstools/patches/0011-Remove-linux-msdos_fs.h-includes.patch @@ -0,0 +1,209 @@ +From e18d72f70e30109492e9602ace5560e0c90b4a8b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Sat, 7 Mar 2015 13:23:23 +0100 +Subject: [PATCH 11/14] Remove linux/msdos_fs.h includes +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Álvaro Fernández Rojas +Signed-off-by: Andreas Bombe +--- + src/file.c | 7 +------ + src/file.h | 2 ++ + src/fsck.fat.h | 8 ++------ + src/mkfs.fat.c | 32 +++--------------------------- + src/msdos_fs.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 5 files changed, 69 insertions(+), 41 deletions(-) + create mode 100644 src/msdos_fs.h + +diff --git a/src/file.c b/src/file.c +index 0b53840..9519070 100644 +--- a/src/file.c ++++ b/src/file.c +@@ -30,14 +30,9 @@ + #include + #include + +-#define _LINUX_STAT_H /* hack to avoid inclusion of */ +-#define _LINUX_STRING_H_ /* hack to avoid inclusion of */ +-#define _LINUX_FS_H /* hack to avoid inclusion of */ +- +-#include +- + #include "common.h" + #include "file.h" ++#include "msdos_fs.h" + #include "charconv.h" + + FDSC *fp_root = NULL; +diff --git a/src/file.h b/src/file.h +index 3adfc96..eaaf356 100644 +--- a/src/file.h ++++ b/src/file.h +@@ -23,6 +23,8 @@ + #ifndef _FILE_H + #define _FILE_H + ++#include "msdos_fs.h" ++ + typedef enum { fdt_none, fdt_drop, fdt_undelete } FD_TYPE; + + typedef struct _fptr { +diff --git a/src/fsck.fat.h b/src/fsck.fat.h +index 27e9d52..e5f6178 100644 +--- a/src/fsck.fat.h ++++ b/src/fsck.fat.h +@@ -28,16 +28,12 @@ + #define _DOSFSCK_H + + #include +-#define _LINUX_STAT_H /* hack to avoid inclusion of */ +-#define _LINUX_STRING_H_ /* hack to avoid inclusion of */ +-#define _LINUX_FS_H /* hack to avoid inclusion of */ +- +-#include +- + #include + #include + #include + ++#include "msdos_fs.h" ++ + #define VFAT_LN_ATTR (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME) + + #define FAT_STATE_DIRTY 0x01 +diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c +index 3d1512f..76d40d8 100644 +--- a/src/mkfs.fat.c ++++ b/src/mkfs.fat.c +@@ -67,6 +67,8 @@ + #include + #include + ++#include "msdos_fs.h" ++ + /* In earlier versions, an own llseek() was used, but glibc lseek() is + * sufficient (or even better :) for 64 bit offsets in the meantime */ + #define llseek lseek +@@ -99,21 +101,6 @@ static inline int cdiv(int a, int b) + return (a + b - 1) / b; + } + +-/* MS-DOS filesystem structures -- I included them here instead of +- including linux/msdos_fs.h since that doesn't include some fields we +- need */ +- +-#define ATTR_RO 1 /* read-only */ +-#define ATTR_HIDDEN 2 /* hidden */ +-#define ATTR_SYS 4 /* system */ +-#define ATTR_VOLUME 8 /* volume label */ +-#define ATTR_DIR 16 /* directory */ +-#define ATTR_ARCH 32 /* archived */ +- +-#define ATTR_NONE 0 /* no attribute bits */ +-#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN) +- /* attribute bits that are copied "as is" */ +- + /* FAT values */ + #define FAT_EOF (atari_format ? 0x0fffffff : 0x0ffffff8) + #define FAT_BAD 0x0ffffff7 +@@ -200,19 +187,6 @@ struct fat32_fsinfo { + uint32_t reserved2[4]; + }; + +-struct msdos_dir_entry { +- char name[8], ext[3]; /* name and extension */ +- uint8_t attr; /* attribute bits */ +- uint8_t lcase; /* Case for base and extension */ +- uint8_t ctime_ms; /* Creation time, milliseconds */ +- uint16_t ctime; /* Creation time */ +- uint16_t cdate; /* Creation date */ +- uint16_t adate; /* Last access date */ +- uint16_t starthi; /* high 16 bits of first cl. (FAT32) */ +- uint16_t time, date, start; /* time, date and first cluster */ +- uint32_t size; /* file size (in bytes) */ +-} __attribute__ ((packed)); +- + /* The "boot code" we put into the filesystem... it writes a message and + tells the user to try again */ + +@@ -1244,7 +1218,7 @@ static void setup_tables(void) + htole16((unsigned short)(ctime->tm_mday + + ((ctime->tm_mon + 1) << 5) + + ((ctime->tm_year - 80) << 9))); +- de->ctime_ms = 0; ++ de->ctime_cs = 0; + de->ctime = de->time; + de->cdate = de->date; + de->adate = de->date; +diff --git a/src/msdos_fs.h b/src/msdos_fs.h +new file mode 100644 +index 0000000..54b2a34 +--- /dev/null ++++ b/src/msdos_fs.h +@@ -0,0 +1,61 @@ ++/* msdos_fs.h - MS-DOS filesystem constants/structures ++ ++ This program is free software: you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation, either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . ++ ++ The complete text of the GNU General Public License ++ can be found in /usr/share/common-licenses/GPL-3 file. ++*/ ++ ++#ifndef _MSDOS_FS_H ++#define _MSDOS_FS_H ++ ++#include ++ ++#define SECTOR_SIZE 512 /* sector size (bytes) */ ++#define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry)) ++#define MSDOS_DPS_BITS 4 /* log2(MSDOS_DPS) */ ++#define MSDOS_DIR_BITS 5 /* log2(sizeof(struct msdos_dir_entry)) */ ++ ++#define ATTR_NONE 0 /* no attribute bits */ ++#define ATTR_RO 1 /* read-only */ ++#define ATTR_HIDDEN 2 /* hidden */ ++#define ATTR_SYS 4 /* system */ ++#define ATTR_VOLUME 8 /* volume label */ ++#define ATTR_DIR 16 /* directory */ ++#define ATTR_ARCH 32 /* archived */ ++ ++/* attribute bits that are copied "as is" */ ++#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN) ++ ++#define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */ ++#define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG) ++ ++#define MSDOS_NAME 11 /* maximum name length */ ++#define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */ ++#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */ ++ ++struct msdos_dir_entry { ++ uint8_t name[8], ext[3]; /* name and extension */ ++ uint8_t attr; /* attribute bits */ ++ uint8_t lcase; /* Case for base and extension */ ++ uint8_t ctime_cs; /* Creation time, centiseconds (0-199) */ ++ uint16_t ctime; /* Creation time */ ++ uint16_t cdate; /* Creation date */ ++ uint16_t adate; /* Last access date */ ++ uint16_t starthi; /* High 16 bits of cluster in FAT32 */ ++ uint16_t time, date, start; /* time, date and first cluster */ ++ uint32_t size; /* file size (in bytes) */ ++} __attribute__ ((packed)); ++ ++#endif /* _MSDOS_FS_H */ +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0012-fsck.fat-Fix-read-beyond-end-of-array-on-FAT12.patch b/tools/dosfstools/patches/0012-fsck.fat-Fix-read-beyond-end-of-array-on-FAT12.patch new file mode 100644 index 0000000000..cfc5db507a --- /dev/null +++ b/tools/dosfstools/patches/0012-fsck.fat-Fix-read-beyond-end-of-array-on-FAT12.patch @@ -0,0 +1,54 @@ +From a41fc323f2ef38f884954a4ba3773a296fd809f8 Mon Sep 17 00:00:00 2001 +From: Andreas Bombe +Date: Wed, 11 Mar 2015 21:45:04 +0100 +Subject: [PATCH 12/14] fsck.fat: Fix read beyond end of array on FAT12 + +When a FAT12 filesystem contains an odd number of clusters, setting the +last cluster with set_fat() will trigger a read of the next entry, +which does not exist in the fat array allocated for this. + +Round up the allocation to an even number of FAT entries for FAT12 so +that this is fixed without introducing special casing in get_fat(). + +Signed-off-by: Andreas Bombe +--- + src/fat.c | 14 +++++++++++--- + 1 file changed, 11 insertions(+), 3 deletions(-) + +diff --git a/src/fat.c b/src/fat.c +index 027c586..5a92f56 100644 +--- a/src/fat.c ++++ b/src/fat.c +@@ -80,7 +80,7 @@ void get_fat(FAT_ENTRY * entry, void *fat, uint32_t cluster, DOS_FS * fs) + */ + void read_fat(DOS_FS * fs) + { +- int eff_size; ++ int eff_size, alloc_size; + uint32_t i; + void *first, *second = NULL; + int first_ok, second_ok; +@@ -96,10 +96,18 @@ void read_fat(DOS_FS * fs) + + total_num_clusters = fs->clusters + 2UL; + eff_size = (total_num_clusters * fs->fat_bits + 7) / 8ULL; +- first = alloc(eff_size); ++ ++ if (fs->fat_bits != 12) ++ alloc_size = eff_size; ++ else ++ /* round up to an even number of FAT entries to avoid special ++ * casing the last entry in get_fat() */ ++ alloc_size = (total_num_clusters * 12 + 23) / 24 * 3; ++ ++ first = alloc(alloc_size); + fs_read(fs->fat_start, eff_size, first); + if (fs->nfats > 1) { +- second = alloc(eff_size); ++ second = alloc(alloc_size); + fs_read(fs->fat_start + fs->fat_size, eff_size, second); + } + if (second && memcmp(first, second, eff_size) != 0) { +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0013-Add-compatible-ioctl-calls-for-OSX-and-FreeBSD.patch b/tools/dosfstools/patches/0013-Add-compatible-ioctl-calls-for-OSX-and-FreeBSD.patch new file mode 100644 index 0000000000..244e4f4f45 --- /dev/null +++ b/tools/dosfstools/patches/0013-Add-compatible-ioctl-calls-for-OSX-and-FreeBSD.patch @@ -0,0 +1,217 @@ +From 50897e9d43f61b4ab238d3ebff62cc45d505206a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Sat, 7 Mar 2015 15:55:32 +0100 +Subject: [PATCH 13/14] Add compatible ioctl calls for OSX and FreeBSD +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Álvaro Fernández Rojas +--- + src/io.c | 2 -- + src/mkfs.fat.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- + 2 files changed, 96 insertions(+), 7 deletions(-) + +diff --git a/src/io.c b/src/io.c +index 450432c..7d0d49a 100644 +--- a/src/io.c ++++ b/src/io.c +@@ -36,10 +36,8 @@ + #include + #include + #include +-#include + #include + #include +-#include + + #include "fsck.fat.h" + #include "common.h" +diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c +index 76d40d8..02e0918 100644 +--- a/src/mkfs.fat.c ++++ b/src/mkfs.fat.c +@@ -47,17 +47,13 @@ + #include "version.h" + + #include +-#include + #include +-#include +-#include + #include + #include + #include + #include + #include + #include +-#include + #include + #include + #include +@@ -67,6 +63,40 @@ + #include + #include + ++#if defined(__linux__) ++ #include ++ #include ++ #include ++#elif defined(__FreeBSD__) || defined(__APPLE__) ++ #include ++ ++ #define BLOCK_SIZE_BITS 10 ++ #define BLOCK_SIZE (1< floppy later */ + case 720: /* 5.25", 2, 9, 40 - 360K */ +@@ -651,6 +696,17 @@ floppy_default: + { + /* Can we get the drive geometry? (Note I'm not too sure about */ + /* whether to use HDIO_GETGEO or HDIO_REQ) */ ++#if defined(__FreeBSD__) ++ if (ioctl(dev, DIOCGFWSECTORS, &geometry.sectors) || ioctl(dev, DIOCGFWHEADS, &geometry.heads) || geometry.sectors == 0 ++ || geometry.heads == 0) { ++ printf("unable to get drive geometry, using default 255/63\n"); ++ bs.secs_track = htole16(63); ++ bs.heads = htole16(255); ++ } else { ++ bs.secs_track = htole16(geometry.sectors); /* Set up the geometry information */ ++ bs.heads = htole16(geometry.heads); ++ } ++#elif defined(__linux__) + if (ioctl(dev, HDIO_GETGEO, &geometry) || geometry.sectors == 0 + || geometry.heads == 0) { + printf("unable to get drive geometry, using default 255/63\n"); +@@ -662,6 +718,11 @@ floppy_default: + if (!hidden_sectors_by_user) + hidden_sectors = htole32(geometry.start); + } ++#else ++ printf("unable to get drive geometry, using default 255/63\n"); ++ bs.secs_track = htole16(63); ++ bs.heads = htole16(255); ++#endif + def_hd_params: + bs.media = (char)0xf8; /* Set up the media descriptor for a hard drive */ + if (!size_fat && blocks * SECTORS_PER_BLOCK > 1064960) { +@@ -1693,6 +1754,15 @@ int main(int argc, char **argv) + die("Device partition expected, not making filesystem on entire device '%s' (use -I to override)"); + + if (sector_size_set) { ++#if defined(__FreeBSD__) ++ if (ioctl(dev, DIOCGSECTORSIZE, &min_sector_size) >= 0) ++ if (sector_size < min_sector_size) { ++ sector_size = min_sector_size; ++ fprintf(stderr, ++ "Warning: sector size was set to %d (minimal for this device)\n", ++ sector_size); ++ } ++#elif defined(__linux__) + if (ioctl(dev, BLKSSZGET, &min_sector_size) >= 0) + if (sector_size < min_sector_size) { + sector_size = min_sector_size; +@@ -1700,11 +1770,32 @@ int main(int argc, char **argv) + "Warning: sector size was set to %d (minimal for this device)\n", + sector_size); + } ++#elif defined(__APPLE__) ++ if (ioctl(dev, DKIOCGETPHYSICALBLOCKSIZE, &min_sector_size) >= 0) ++ if (sector_size < min_sector_size) { ++ sector_size = min_sector_size; ++ fprintf(stderr, ++ "Warning: sector size was set to %d (minimal for this device)\n", ++ sector_size); ++ } ++#endif + } else { ++#if defined(__FreeBSD__) ++ if (ioctl(dev, DIOCGSECTORSIZE, &min_sector_size) >= 0) { ++ sector_size = min_sector_size; ++ sector_size_set = 1; ++ } ++#elif defined(__linux__) + if (ioctl(dev, BLKSSZGET, &min_sector_size) >= 0) { + sector_size = min_sector_size; + sector_size_set = 1; + } ++#elif defined(__APPLE__) ++ if (ioctl(dev, DKIOCGETPHYSICALBLOCKSIZE, &min_sector_size) >= 0) { ++ sector_size = min_sector_size; ++ sector_size_set = 1; ++ } ++#endif + } + + if (sector_size > 4096) +-- +1.9.1 + diff --git a/tools/dosfstools/patches/0014-Add-OSX-and-FreeBSD-support.patch b/tools/dosfstools/patches/0014-Add-OSX-and-FreeBSD-support.patch new file mode 100644 index 0000000000..cc3c2c3d6e --- /dev/null +++ b/tools/dosfstools/patches/0014-Add-OSX-and-FreeBSD-support.patch @@ -0,0 +1,334 @@ +From 514985ae786dcde9842e46899ef5b6218662a119 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Sat, 7 Mar 2015 16:32:51 +0100 +Subject: [PATCH 14/14] Add OSX and FreeBSD support +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Álvaro Fernández Rojas +--- + Makefile | 9 ++++++++- + src/boot.c | 1 + + src/check.c | 1 + + src/endian.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + src/fat.c | 1 + + src/fatlabel.c | 1 + + src/fsck.fat.h | 3 +-- + src/io.h | 2 +- + src/lfn.c | 1 + + src/mkfs.fat.c | 19 ++++++++++++++++--- + src/types.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 11 files changed, 145 insertions(+), 7 deletions(-) + create mode 100644 src/endian.h + create mode 100644 src/types.h + +diff --git a/Makefile b/Makefile +index 1593f3d..7359a79 100644 +--- a/Makefile ++++ b/Makefile +@@ -28,12 +28,19 @@ DOCDIR = $(PREFIX)/share/doc + MANDIR = $(PREFIX)/share/man + + #OPTFLAGS = -O2 -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +-OPTFLAGS = -O2 -fomit-frame-pointer -D_GNU_SOURCE $(shell getconf LFS_CFLAGS) ++OPTFLAGS = -O2 -fomit-frame-pointer -D_GNU_SOURCE + #WARNFLAGS = -Wall -pedantic -std=c99 + WARNFLAGS = -Wall -Wextra -Wno-sign-compare -Wno-missing-field-initializers -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings + DEBUGFLAGS = -g + CFLAGS += $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS) + ++UNAME_S := $(shell uname -s) ++ifeq ($(UNAME_S),Darwin) ++ LDLIBS += -liconv ++else ++ OPTFLAGS += $(shell getconf LFS_CFLAGS) ++endif ++ + VPATH = src + + all: build +diff --git a/src/boot.c b/src/boot.c +index 0c0918f..1da9889 100644 +--- a/src/boot.c ++++ b/src/boot.c +@@ -31,6 +31,7 @@ + #include + + #include "common.h" ++#include "endian.h" + #include "fsck.fat.h" + #include "fat.h" + #include "io.h" +diff --git a/src/check.c b/src/check.c +index 488f715..17ff16a 100644 +--- a/src/check.c ++++ b/src/check.c +@@ -31,6 +31,7 @@ + #include + + #include "common.h" ++#include "endian.h" + #include "fsck.fat.h" + #include "io.h" + #include "fat.h" +diff --git a/src/endian.h b/src/endian.h +new file mode 100644 +index 0000000..6613e65 +--- /dev/null ++++ b/src/endian.h +@@ -0,0 +1,57 @@ ++/* endian.h - Endian functions ++ ++ Copyright (C) 2015 Álvaro Fernández Rojas ++ ++ This program is free software: you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation, either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . ++ ++ The complete text of the GNU General Public License ++ can be found in /usr/share/common-licenses/GPL-3 file. ++*/ ++ ++#ifndef _ENDIAN_H ++#define _ENDIAN_H ++ ++#if defined(__linux__) ++ #include ++#elif defined(__APPLE__) ++ #include ++ ++ #define htobe16(x) OSSwapHostToBigInt16(x) ++ #define htole16(x) OSSwapHostToLittleInt16(x) ++ #define be16toh(x) OSSwapBigToHostInt16(x) ++ #define le16toh(x) OSSwapLittleToHostInt16(x) ++ ++ #define htobe32(x) OSSwapHostToBigInt32(x) ++ #define htole32(x) OSSwapHostToLittleInt32(x) ++ #define be32toh(x) OSSwapBigToHostInt32(x) ++ #define le32toh(x) OSSwapLittleToHostInt32(x) ++ ++ #define htobe64(x) OSSwapHostToBigInt64(x) ++ #define htole64(x) OSSwapHostToLittleInt64(x) ++ #define be64toh(x) OSSwapBigToHostInt64(x) ++ #define le64toh(x) OSSwapLittleToHostInt64(x) ++#elif defined(__FreeBSD__) ++ #include ++ ++ #define be16toh(x) betoh16(x) ++ #define le16toh(x) letoh16(x) ++ ++ #define be32toh(x) betoh32(x) ++ #define le32toh(x) letoh32(x) ++ ++ #define be64toh(x) betoh64(x) ++ #define le64toh(x) letoh64(x) ++#endif ++ ++#endif /* _ENDIAN_H */ +diff --git a/src/fat.c b/src/fat.c +index 5a92f56..481c08a 100644 +--- a/src/fat.c ++++ b/src/fat.c +@@ -30,6 +30,7 @@ + #include + + #include "common.h" ++#include "endian.h" + #include "fsck.fat.h" + #include "io.h" + #include "check.h" +diff --git a/src/fatlabel.c b/src/fatlabel.c +index 1484ba5..6de831c 100644 +--- a/src/fatlabel.c ++++ b/src/fatlabel.c +@@ -33,6 +33,7 @@ + #include + + #include "common.h" ++#include "types.h" + #include "fsck.fat.h" + #include "io.h" + #include "boot.h" +diff --git a/src/fsck.fat.h b/src/fsck.fat.h +index e5f6178..8b0ccb9 100644 +--- a/src/fsck.fat.h ++++ b/src/fsck.fat.h +@@ -27,11 +27,10 @@ + #ifndef _DOSFSCK_H + #define _DOSFSCK_H + +-#include + #include + #include +-#include + ++#include "types.h" + #include "msdos_fs.h" + + #define VFAT_LN_ATTR (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME) +diff --git a/src/io.h b/src/io.h +index d23d07e..eecfdc5 100644 +--- a/src/io.h ++++ b/src/io.h +@@ -27,7 +27,7 @@ + #ifndef _IO_H + #define _IO_H + +-#include /* for loff_t */ ++#include "types.h" + + loff_t llseek(int fd, loff_t offset, int whence); + +diff --git a/src/lfn.c b/src/lfn.c +index 2601172..f679168 100644 +--- a/src/lfn.c ++++ b/src/lfn.c +@@ -28,6 +28,7 @@ + #include + + #include "common.h" ++#include "endian.h" + #include "io.h" + #include "fsck.fat.h" + #include "lfn.h" +diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c +index 02e0918..f2cee09 100644 +--- a/src/mkfs.fat.c ++++ b/src/mkfs.fat.c +@@ -48,8 +48,6 @@ + + #include + #include +-#include +-#include + #include + #include + #include +@@ -61,13 +59,14 @@ + #include + #include + #include +-#include + + #if defined(__linux__) ++ #include + #include + #include + #include + #elif defined(__FreeBSD__) || defined(__APPLE__) ++ #include + #include + + #define BLOCK_SIZE_BITS 10 +@@ -97,7 +96,9 @@ + }; + #endif + ++#include "endian.h" + #include "msdos_fs.h" ++#include "types.h" + + /* In earlier versions, an own llseek() was used, but glibc lseek() is + * sufficient (or even better :) for 64 bit offsets in the meantime */ +@@ -525,6 +526,7 @@ static uint64_t count_blocks(char *filename, int *remainder) + + static void check_mount(char *device_name) + { ++#if defined(__linux__) + FILE *f; + struct mntent *mnt; + +@@ -534,6 +536,17 @@ static void check_mount(char *device_name) + if (strcmp(device_name, mnt->mnt_fsname) == 0) + die("%s contains a mounted filesystem."); + endmntent(f); ++#elif defined(__APPLE__) || defined(__FreeBSD__) ++ struct statfs* mounts; ++ int num_mounts = getmntinfo(&mounts, MNT_WAIT); ++ if (num_mounts < 0) ++ return; ++ for ( int i = 0; i < num_mounts; i++ ) ++ { ++ if (strcmp(device_name, mounts[i].f_mntfromname) == 0) ++ die("%s contains a mounted filesystem."); ++ } ++#endif + } + + /* Establish the geometry and media parameters for the device */ +diff --git a/src/types.h b/src/types.h +new file mode 100644 +index 0000000..a3f1a47 +--- /dev/null ++++ b/src/types.h +@@ -0,0 +1,57 @@ ++/* types.h - Missing types ++ ++ Copyright (C) 2015 Álvaro Fernández Rojas ++ ++ This program is free software: you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation, either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . ++ ++ The complete text of the GNU General Public License ++ can be found in /usr/share/common-licenses/GPL-3 file. ++*/ ++ ++#ifndef _TYPES_H ++#define _TYPES_H ++ ++#if defined(__linux__) ++ #include ++#elif defined(__APPLE__) ++ #ifndef loff_t ++ typedef long long loff_t; ++ #endif /* loff_t */ ++ ++ #ifndef lseek64 ++ #define lseek64 lseek ++ #endif /* lseek64 */ ++ ++ #ifndef off64_t ++ #ifdef _LP64 ++ typedef off_t off64_t; ++ #else ++ typedef __longlong_t off64_t; ++ #endif /* _LP64 */ ++ #endif /* off64_t */ ++#elif defined(__FreeBSD__) ++ #ifndef loff_t ++ typedef long long loff_t; ++ #endif /* loff_t */ ++ ++ #ifndef lseek64 ++ #define lseek64 lseek ++ #endif /* lseek64 */ ++ ++ #ifndef off64_t ++ typedef off_t off64_t; ++ #endif /* off64_t */ ++#endif ++ ++#endif /* _TYPES_H */ +-- +1.9.1 + -- 2.25.1