[source] dosfstools: update to v4.0

LEDE Commits lede-commits at lists.infradead.org
Mon Jul 4 03:12:32 PDT 2016


noltari pushed a commit to source.git, branch master:
https://git.lede-project.org/?p=source.git;a=commitdiff;h=a1b52e2b53f20e39894e5e80e7fc08c1950d9224

commit a1b52e2b53f20e39894e5e80e7fc08c1950d9224
Author: Álvaro Fernández Rojas <noltari at gmail.com>
AuthorDate: Tue Jun 21 08:33:50 2016 +0200

    dosfstools: update to v4.0
    
    Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
---
 tools/dosfstools/Makefile                          |   7 +-
 ...ags-and-editor-backup-files-to-.gitignore.patch |  25 -
 ...t-to-64-32-heads-sectors-for-targets-smal.patch |  39 ++
 ...dentation-of-fix-power-loss-damage-commit.patch | 100 ----
 ...s.fat.c-Use-unsigned-char-for-binary-data.patch |  33 --
 ...ake-all-char-that-may-take-literals-const.patch | 169 ------
 ...-Allow-0xF0-to-be-specified-as-media-byte.patch | 122 -----
 .../0006-fsck.fat-Make-r-option-default.patch      | 603 ---------------------
 .../0007-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 ------------------
 .../0011-Remove-linux-msdos_fs.h-includes.patch    | 209 -------
 ...fat-Fix-read-beyond-end-of-array-on-FAT12.patch |  54 --
 ...ompatible-ioctl-calls-for-OSX-and-FreeBSD.patch | 217 --------
 .../patches/0014-Add-OSX-and-FreeBSD-support.patch | 334 ------------
 16 files changed, 43 insertions(+), 2508 deletions(-)

diff --git a/tools/dosfstools/Makefile b/tools/dosfstools/Makefile
index 910e94f..56a9aa5 100644
--- a/tools/dosfstools/Makefile
+++ b/tools/dosfstools/Makefile
@@ -1,5 +1,6 @@
 #
 # Copyright (C) 2012-2015 OpenWrt.org
+# Copyright (C) 2016 LEDE-Project.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -7,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=dosfstools
-PKG_VERSION:=3.0.27
+PKG_VERSION:=4.0
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/dosfstools/dosfstools/releases/download/v$(PKG_VERSION)/ \
 		http://fossies.org/linux/misc
-PKG_MD5SUM:=2e31e7bdf92998e41ed17de505a4a552
+PKG_MD5SUM:=d96f46cbc5b84ad4c9766b4fbf6c8e09
 
 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION)
 
@@ -27,7 +28,7 @@ define Host/Compile
 endef
 
 define Host/Install
-	$(INSTALL_BIN) $(HOST_BUILD_DIR)/mkfs.fat $(STAGING_DIR_HOST)/bin/
+	$(INSTALL_BIN) $(HOST_BUILD_DIR)/src/mkfs.fat $(STAGING_DIR_HOST)/bin/
 	$(LN) mkfs.fat $(STAGING_DIR_HOST)/bin/mkdosfs
 endef
 
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
deleted file mode 100644
index b0fecdd..0000000
--- a/tools/dosfstools/patches/0001-Add-tags-and-editor-backup-files-to-.gitignore.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From 75c5446d21f02038423d67139a6967975c9b90be Mon Sep 17 00:00:00 2001
-From: Andreas Bombe <aeb at debian.org>
-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 <aeb at debian.org>
----
- .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/0001-mkfs-Default-to-64-32-heads-sectors-for-targets-smal.patch b/tools/dosfstools/patches/0001-mkfs-Default-to-64-32-heads-sectors-for-targets-smal.patch
new file mode 100644
index 0000000..09e7320
--- /dev/null
+++ b/tools/dosfstools/patches/0001-mkfs-Default-to-64-32-heads-sectors-for-targets-smal.patch
@@ -0,0 +1,39 @@
+From 1e76e5778a1885452939a79d9145b80634a5b023 Mon Sep 17 00:00:00 2001
+From: Andreas Bombe <aeb at debian.org>
+Date: Wed, 11 May 2016 03:44:58 +0200
+Subject: [PATCH] mkfs: Default to 64/32 heads/sectors for targets smaller than
+ 512 MB
+
+This may put defaults in certain use cases a little bit more in line
+with the old defaults in versions up to 3.0.28. It has mostly aesthetic
+value in most cases.
+
+Signed-off-by: Andreas Bombe <aeb at debian.org>
+---
+ src/mkfs.fat.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c
+index 8a320fd..bad492b 100644
+--- a/src/mkfs.fat.c
++++ b/src/mkfs.fat.c
+@@ -519,6 +519,16 @@ static void establish_params(struct device_info *info)
+     unsigned int cluster_size = 4;  /* starting point for FAT12 and FAT16 */
+     int def_root_dir_entries = 512;
+ 
++    if (info->size < 512 * 1024 * 1024) {
++	/*
++	 * These values are more or less meaningless, but we can at least
++	 * use less extreme values for smaller filesystems where the large
++	 * dummy values signifying LBA only access are not needed.
++	 */
++	sec_per_track = 32;
++	heads = 64;
++    }
++
+     if (info->type != TYPE_FIXED) {
+ 	/* enter default parameters for floppy disks if the size matches */
+ 	switch (info->size / 1024) {
+-- 
+2.1.4
+
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
deleted file mode 100644
index b12c3b2..0000000
--- a/tools/dosfstools/patches/0002-Fix-indentation-of-fix-power-loss-damage-commit.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-From 45aeed0c658cc86e93ae3ae101404e12bec6e102 Mon Sep 17 00:00:00 2001
-From: Andreas Bombe <aeb at debian.org>
-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 <aeb at debian.org>
----
- 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
deleted file mode 100644
index 842a7c1..0000000
--- a/tools/dosfstools/patches/0003-mkfs.fat.c-Use-unsigned-char-for-binary-data.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 8b8948c06de55455b63dc11f765d7ee39f30c4e0 Mon Sep 17 00:00:00 2001
-From: Andreas Bombe <aeb at debian.org>
-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 <aeb at debian.org>
----
- 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
deleted file mode 100644
index be553c8..0000000
--- a/tools/dosfstools/patches/0004-Make-all-char-that-may-take-literals-const.patch
+++ /dev/null
@@ -1,169 +0,0 @@
-From 16e97e9741a02f6c2c29b3da45b62ac798d76403 Mon Sep 17 00:00:00 2001
-From: Andreas Bombe <aeb at debian.org>
-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 <aeb at debian.org>
----
- 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
deleted file mode 100644
index 4d2d26a..0000000
--- a/tools/dosfstools/patches/0005-mkfs.fat-Allow-0xF0-to-be-specified-as-media-byte.patch
+++ /dev/null
@@ -1,122 +0,0 @@
-From 266a5fc635135a9ffaa8683da1ec03aae1553b7b Mon Sep 17 00:00:00 2001
-From: Andreas Bombe <aeb at debian.org>
-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 <aeb at debian.org>
----
- 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 <EMAIL at ADDRESS>\n"
- "Language-Team: LANGUAGE <LL at li.org>\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
deleted file mode 100644
index 20e7bde..0000000
--- a/tools/dosfstools/patches/0006-fsck.fat-Make-r-option-default.patch
+++ /dev/null
@@ -1,603 +0,0 @@
-From 357ab077198bfa6239fa62fd03a546da959ec756 Mon Sep 17 00:00:00 2001
-From: Andreas Bombe <aeb at debian.org>
-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 <aeb at debian.org>
----
- 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<mkfs.fat>(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<dosfstools> were written by Werner Almesberger E<lt>I<werner."
- "almesberger at lrc.di.epfl.ch>E<gt>, Roman Hodek E<lt>I<Roman.Hodek at informatik."
-@@ -365,31 +365,32 @@ msgid "B<-r>"
- 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<fsck.fat> 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<Note:> 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<fsck.fat> 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<fsck.fat> 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<fsck.fat> 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<fatlabel>(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<fsck.fat> and B<dosfstools> can be found at "
- "E<lt>I<http://daniel-baumann.ch/software/dosfstools/>E<gt>."
-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 <EMAIL at ADDRESS>\n"
- "Language-Team: LANGUAGE <LL at li.org>\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<mkfs.fat>(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<dosfstools> were written by Werner Almesberger E<lt>I<werner."
- "almesberger at lrc.di.epfl.ch>E<gt>, Roman Hodek E<lt>I<Roman.Hodek at informatik."
-@@ -368,31 +368,32 @@ msgid "B<-r>"
- 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<fsck.fat> 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<Note:> 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<fsck.fat> 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<fsck.fat> 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<fsck.fat> 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<fatlabel>(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<fsck.fat> and B<dosfstools> can be found at "
- "E<lt>I<http://daniel-baumann.ch/software/dosfstools/>E<gt>."
-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
deleted file mode 100644
index 9eb8cc6..0000000
--- a/tools/dosfstools/patches/0007-Makefile-fix-typo-in-uninstall-man.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fb6aea6f5547d59b6e8c287ad8e61854af5a34b0 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari at gmail.com>
-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 <noltari at gmail.com>
-Signed-off-by: Andreas Bombe <aeb at debian.org>
----
- 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
deleted file mode 100644
index ad59577..0000000
--- a/tools/dosfstools/patches/0008-Makefile-avoid-using-install-D.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From 02b5a6d9a407daebe903fe64fb1b22673aaa7e92 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari at gmail.com>
-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 <noltari at gmail.com>
-Signed-off-by: Andreas Bombe <aeb at debian.org>
----
- 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
deleted file mode 100644
index 25d5fe6..0000000
--- a/tools/dosfstools/patches/0009-Improve-.gitignore.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 628b3ec05b304e77eed05c57457ff7bb39401f6c Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari at gmail.com>
-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 <noltari at gmail.com>
-Signed-off-by: Andreas Bombe <aeb at debian.org>
----
- .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
deleted file mode 100644
index b3ee2ad..0000000
--- a/tools/dosfstools/patches/0010-Remove-non-standard-int-types.patch
+++ /dev/null
@@ -1,538 +0,0 @@
-From 245d0cce5e77d7465d61bfde91bc79477d5e6fd6 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari at gmail.com>
-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 <noltari at gmail.com>
-Signed-off-by: Andreas Bombe <aeb at debian.org>
----
- 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 <Roman.Hodek at informatik.uni-erlangen.de> */
- 
- #include <stdio.h>
-+#include <stdint.h>
- #include <string.h>
--#include <sys/types.h>
- #include <stdlib.h>
- #include <time.h>
- 
-@@ -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 <asm/types.h>
--
- #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 <linux/string.h> */
- #define _LINUX_FS_H		/* hack to avoid inclusion of <linux/fs.h> */
- 
--#include <asm/types.h>
--
- #include <linux/msdos_fs.h>
- 
- #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 <fcntl.h>
--#include <sys/types.h>
- #define _LINUX_STAT_H		/* hack to avoid inclusion of <linux/stat.h> */
- #define _LINUX_STRING_H_	/* hack to avoid inclusion of <linux/string.h> */
- #define _LINUX_FS_H		/* hack to avoid inclusion of <linux/fs.h> */
- 
--#include <asm/types.h>
--#include <asm/byteorder.h>
--
- #include <linux/msdos_fs.h>
- 
- #include <stddef.h>
-@@ -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 <Roman.Hodek at informatik.uni-erlangen.de> */
- 
- #define _LARGEFILE64_SOURCE
--#include <sys/types.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
-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 <stdio.h>
-+#include <stdint.h>
- #include <stdlib.h>
- #include <string.h>
- #include <limits.h>
-@@ -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 <sys/ioctl.h>
- #include <sys/stat.h>
- #include <sys/time.h>
--#include <sys/types.h>
- #include <unistd.h>
- #include <time.h>
- #include <errno.h>
-@@ -68,8 +67,6 @@
- #include <stdint.h>
- #include <endian.h>
- 
--#include <asm/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 */
- #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
deleted file mode 100644
index 08bd36d..0000000
--- a/tools/dosfstools/patches/0011-Remove-linux-msdos_fs.h-includes.patch
+++ /dev/null
@@ -1,209 +0,0 @@
-From e18d72f70e30109492e9602ace5560e0c90b4a8b Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari at gmail.com>
-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 <noltari at gmail.com>
-Signed-off-by: Andreas Bombe <aeb at debian.org>
----
- 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 <ctype.h>
- #include <unistd.h>
- 
--#define _LINUX_STAT_H		/* hack to avoid inclusion of <linux/stat.h> */
--#define _LINUX_STRING_H_	/* hack to avoid inclusion of <linux/string.h> */
--#define _LINUX_FS_H		/* hack to avoid inclusion of <linux/fs.h> */
--
--#include <linux/msdos_fs.h>
--
- #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 <fcntl.h>
--#define _LINUX_STAT_H		/* hack to avoid inclusion of <linux/stat.h> */
--#define _LINUX_STRING_H_	/* hack to avoid inclusion of <linux/string.h> */
--#define _LINUX_FS_H		/* hack to avoid inclusion of <linux/fs.h> */
--
--#include <linux/msdos_fs.h>
--
- #include <stddef.h>
- #include <stdint.h>
- #include <endian.h>
- 
-+#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 <stdint.h>
- #include <endian.h>
- 
-+#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 <http://www.gnu.org/licenses/>.
-+
-+   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 <stdint.h>
-+
-+#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
deleted file mode 100644
index cfc5db5..0000000
--- a/tools/dosfstools/patches/0012-fsck.fat-Fix-read-beyond-end-of-array-on-FAT12.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From a41fc323f2ef38f884954a4ba3773a296fd809f8 Mon Sep 17 00:00:00 2001
-From: Andreas Bombe <aeb at debian.org>
-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 <aeb at debian.org>
----
- 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
deleted file mode 100644
index 244e4f4..0000000
--- a/tools/dosfstools/patches/0013-Add-compatible-ioctl-calls-for-OSX-and-FreeBSD.patch
+++ /dev/null
@@ -1,217 +0,0 @@
-From 50897e9d43f61b4ab238d3ebff62cc45d505206a Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari at gmail.com>
-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 <noltari at gmail.com>
----
- 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 <string.h>
- #include <unistd.h>
- #include <sys/stat.h>
--#include <sys/ioctl.h>
- #include <errno.h>
- #include <fcntl.h>
--#include <linux/fd.h>
- 
- #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 <fcntl.h>
--#include <linux/hdreg.h>
- #include <sys/mount.h>
--#include <linux/fs.h>
--#include <linux/fd.h>
- #include <endian.h>
- #include <mntent.h>
- #include <signal.h>
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
--#include <sys/ioctl.h>
- #include <sys/stat.h>
- #include <sys/time.h>
- #include <unistd.h>
-@@ -67,6 +63,40 @@
- #include <stdint.h>
- #include <endian.h>
- 
-+#if defined(__linux__)
-+    #include <linux/hdreg.h>
-+    #include <linux/fs.h>
-+    #include <linux/fd.h>
-+#elif defined(__FreeBSD__) || defined(__APPLE__)
-+    #include <sys/disk.h>
-+
-+    #define BLOCK_SIZE_BITS 10
-+    #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
-+
-+    struct floppy_struct {
-+        unsigned int size;	/* nr of sectors total */
-+        unsigned int sect;	/* sectors per track */
-+        unsigned int head;	/* nr of heads */
-+        unsigned int track;	/* nr of tracks */
-+        unsigned int 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) */
-+        unsigned char gap;	/* gap1 size */
-+        unsigned char rate;	/* data rate. |= 0x40 for perpendicular */
-+        unsigned char spec1;	/* stepping rate, head unload time */
-+        unsigned char fmt_gap;	/* gap2 size */
-+        const char * name;	/* used only for predefined formats */
-+    };
-+
-+    struct hd_geometry {
-+        unsigned char heads;
-+        unsigned char sectors;
-+        unsigned short cylinders;
-+        unsigned long start;
-+    };
-+#endif
-+
- #include "msdos_fs.h"
- 
- /* In earlier versions, an own llseek() was used, but glibc lseek() is
-@@ -511,7 +541,9 @@ static void check_mount(char *device_name)
- static void establish_params(int device_num, int size)
- {
-     long loop_size;
-+#if defined(__linux__) || defined(__FreeBSD__)
-     struct hd_geometry geometry;
-+#endif
-     struct floppy_struct param;
-     int def_root_dir_entries = 512;
- 
-@@ -549,9 +581,12 @@ static void establish_params(int device_num, int size)
- 	    }
- 
- 	} else {		/* is a floppy diskette */
--
-+#if defined(__linux__)
- 	    if (ioctl(dev, FDGETPRM, &param))	/*  Can we get the diskette geometry? */
- 		die("unable to get diskette geometry for '%s'");
-+#else
-+		die("unable to get diskette geometry for '%s'");
-+#endif
- 	}
- 	bs.secs_track = htole16(param.sect);	/*  Set up the geometry information */
- 	bs.heads = htole16(param.head);
-@@ -594,8 +629,18 @@ floppy_default:
- 		goto floppy_default;
- 	}
-     } else if ((device_num & 0xff00) == 0x0700) {	/* This is a loop device */
-+#if defined(__FreeBSD__)
-+	if (ioctl(dev, DIOCGSECTORSIZE, &loop_size))
-+	    die("unable to get loop device size");
-+#elif defined(__linux__)
- 	if (ioctl(dev, BLKGETSIZE, &loop_size))
- 	    die("unable to get loop device size");
-+#elif defined(__APPLE__)
-+	if (ioctl(dev, DKIOCGETBLOCKSIZE, &loop_size))
-+	    die("unable to get loop device size");
-+#else
-+	die("unable to get loop device size");
-+#endif
- 
- 	switch (loop_size) {	/* Assuming the loop device -> 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
deleted file mode 100644
index cc3c2c3..0000000
--- a/tools/dosfstools/patches/0014-Add-OSX-and-FreeBSD-support.patch
+++ /dev/null
@@ -1,334 +0,0 @@
-From 514985ae786dcde9842e46899ef5b6218662a119 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari at gmail.com>
-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 <noltari at gmail.com>
----
- 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 <time.h>
- 
- #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 <time.h>
- 
- #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 <noltari at gmail.com>
-+
-+   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 <http://www.gnu.org/licenses/>.
-+
-+   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 <endian.h>
-+#elif defined(__APPLE__)
-+	#include <libkern/OSByteOrder.h>
-+
-+	#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 <sys/endian.h>
-+
-+	#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 <unistd.h>
- 
- #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 <ctype.h>
- 
- #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 <fcntl.h>
- #include <stddef.h>
- #include <stdint.h>
--#include <endian.h>
- 
-+#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 <fcntl.h>		/* 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 <time.h>
- 
- #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 <fcntl.h>
- #include <sys/mount.h>
--#include <endian.h>
--#include <mntent.h>
- #include <signal.h>
- #include <string.h>
- #include <stdio.h>
-@@ -61,13 +59,14 @@
- #include <errno.h>
- #include <ctype.h>
- #include <stdint.h>
--#include <endian.h>
- 
- #if defined(__linux__)
-+    #include <mntent.h>
-     #include <linux/hdreg.h>
-     #include <linux/fs.h>
-     #include <linux/fd.h>
- #elif defined(__FreeBSD__) || defined(__APPLE__)
-+    #include <sys/mount.h>
-     #include <sys/disk.h>
- 
-     #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 <noltari at gmail.com>
-+
-+   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 <http://www.gnu.org/licenses/>.
-+
-+   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 <fcntl.h>
-+#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
-



More information about the lede-commits mailing list