Update dosfstools

* Version 3.0.28
* Update filenames in source
* Remove unnecessary symlink to fsck
* Commit "Recode short filenames from DOS codepage (default 437)." has
  been reverted since we do not have access to iconv
* Commits cherry-picked on top of 3.0.28:
    - mkfs.fat: fix incorrect int type
    - Prevent out of bound array read in date_dos2unix()

Change-Id: I50310235c62ec2e6bc90afcd10f2814d3afb5113
diff --git a/dosfstools/Makefile b/dosfstools/Makefile
index 050b750..fa99355 100644
--- a/dosfstools/Makefile
+++ b/dosfstools/Makefile
@@ -1,6 +1,6 @@
 # Makefile
 #
-# Copyright (C) 2008 Daniel Baumann <daniel@debian.org>
+# Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
 #
 # 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
@@ -15,9 +15,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 #
-# On Debian systems, the complete text of the GNU General Public License
+# The complete text of the GNU General Public License
 # can be found in /usr/share/common-licenses/GPL-3 file.
 
+SHELL := sh -e
+LANGUAGES = $(shell cd manpages/po && ls)
+
 DESTDIR =
 PREFIX = /usr/local
 SBINDIR = $(PREFIX)/sbin
@@ -25,9 +28,9 @@
 MANDIR = $(PREFIX)/share/man
 
 #OPTFLAGS = -O2 -fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-OPTFLAGS = -O2 -fomit-frame-pointer $(shell getconf LFS_CFLAGS)
+OPTFLAGS = -O2 -fomit-frame-pointer -D_GNU_SOURCE $(shell getconf LFS_CFLAGS)
 #WARNFLAGS = -Wall -pedantic -std=c99
-WARNFLAGS = -Wall
+WARNFLAGS = -Wall -Wextra -Wno-sign-compare -Wno-missing-field-initializers -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings
 DEBUGFLAGS = -g
 CFLAGS += $(OPTFLAGS) $(WARNFLAGS) $(DEBUGFLAGS)
 
@@ -35,51 +38,85 @@
 
 all: build
 
-build: dosfsck dosfslabel mkdosfs
+build: fatlabel fsck.fat mkfs.fat
 
-dosfsck: boot.o check.o common.o fat.o file.o io.o lfn.o dosfsck.o
+fatlabel: boot.o check.o common.o fat.o file.o io.o lfn.o fatlabel.o
 
-dosfslabel: boot.o check.o common.o fat.o file.o io.o lfn.o dosfslabel.o
+fsck.fat: boot.o check.o common.o fat.o file.o io.o lfn.o fsck.fat.o
 
-mkdosfs: mkdosfs.o
+mkfs.fat: mkfs.fat.o
 
 rebuild: distclean build
 
-install: install-bin install-doc install-man
+install: install-bin install-doc install-man install-symlinks
 
 install-bin: build
 	install -d -m 0755 $(DESTDIR)/$(SBINDIR)
-	install -m 0755 dosfsck dosfslabel mkdosfs $(DESTDIR)/$(SBINDIR)
-
-	ln -sf dosfsck $(DESTDIR)/$(SBINDIR)/fsck.msdos
-	ln -sf dosfsck $(DESTDIR)/$(SBINDIR)/fsck.vfat
-	ln -sf mkdosfs $(DESTDIR)/$(SBINDIR)/mkfs.msdos
-	ln -sf mkdosfs $(DESTDIR)/$(SBINDIR)/mkfs.vfat
+	install -m 0755 fatlabel fsck.fat mkfs.fat $(DESTDIR)/$(SBINDIR)
 
 install-doc:
 	install -d -m 0755 $(DESTDIR)/$(DOCDIR)/dosfstools
 	install -p -m 0644 ChangeLog doc/* $(DESTDIR)/$(DOCDIR)/dosfstools
 
 install-man:
-	install -d -m 0755 $(DESTDIR)/$(MANDIR)/man8
-	install -p -m 0644 man/*.8 $(DESTDIR)/$(MANDIR)/man8
+	for MANPAGE in manpages/en/*; \
+	do \
+		SECTION="8"; \
+		mkdir -p $(DESTDIR)/$(MANDIR)/man$${SECTION}/; \
+		install -m 0644 $${MANPAGE} $(DESTDIR)/$(MANDIR)/man$${SECTION}/$$(basename $${MANPAGE}); \
+	done
 
-	ln -sf dosfsck.8 $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8
-	ln -sf dosfsck.8 $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8
-	ln -sf mkdosfs.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8
-	ln -sf mkdosfs.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8
+	for LANGUAGE in $(LANGUAGES); \
+	do \
+		for MANPAGE in manpages/$${LANGUAGE}/*; \
+		do \
+			SECTION="8"; \
+			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
+	if [ -e $(DESTDIR)/$(SBINDIR)/fatlabel ]; \
+	then \
+		ln -sf fatlabel $(DESTDIR)/$(SBINDIR)/dosfslabel; \
+		if [ -e $(DESTDIR)/$(MANDIR)/man8/fatlabel.8 ]; \
+		then \
+			ln -sf fatlabel.8 $(DESTDIR)/$(MANDIR)/man8/dosfslabel.8; \
+		fi; \
+	fi
 
-uninstall: uninstall-bin uninstall-doc uninstall-man
+	if [ -e $(DESTDIR)/$(SBINDIR)/fsck.fat ]; \
+	then \
+		ln -sf fsck.fat $(DESTDIR)/$(SBINDIR)/dosfsck; \
+		ln -sf fsck.fat $(DESTDIR)/$(SBINDIR)/fsck.msdos; \
+		ln -sf fsck.fat $(DESTDIR)/$(SBINDIR)/fsck.vfat; \
+		if [ -e $(DESTDIR)/$(MANDIR)/man8/fsck.fat.8 ]; \
+		then \
+			ln -sf fsck.fat.8 $(DESTDIR)/$(MANDIR)/man8/dosfsck.8; \
+			ln -sf fsck.fat.8 $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8; \
+			ln -sf fsck.fat.8 $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8; \
+		fi; \
+	fi
+
+	if [ -e $(DESTDIR)/$(SBINDIR)/mkfs.fat ]; \
+	then \
+		ln -sf mkfs.fat $(DESTDIR)/$(SBINDIR)/mkdosfs; \
+		ln -sf mkfs.fat $(DESTDIR)/$(SBINDIR)/mkfs.msdos; \
+		ln -sf mkfs.fat $(DESTDIR)/$(SBINDIR)/mkfs.vfat; \
+		if [ -e $(DESTDIR)/$(MANDIR)/man8/mkfs.fat.8 ]; \
+		then \
+			ln -sf mkfs.fat.8 $(DESTDIR)/$(MANDIR)/man8/mkdosfs.8; \
+			ln -sf mkfs.fat.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8; \
+			ln -sf mkfs.fat.8 $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8; \
+		fi; \
+	fi
+
+uninstall: uninstall-symlinks uninstall-man uninstall-doc uninstall-bin
 
 uninstall-bin:
-	rm -f $(DESTDIR)/$(SBINDIR)/dosfsck
-	rm -f $(DESTDIR)/$(SBINDIR)/dosfslabel
-	rm -f $(DESTDIR)/$(SBINDIR)/mkdosfs
-
-	rm -f $(DESTDIR)/$(SBINDIR)/fsck.msdos
-	rm -f $(DESTDIR)/$(SBINDIR)/fsck.vfat
-	rm -f $(DESTDIR)/$(SBINDIR)/mkfs.msdos
-	rm -f $(DESTDIR)/$(SBINDIR)/mkfs.vfat
+	rm -f $(DESTDIR)/$(SBINDIR)/fatlabel
+	rm -f $(DESTDIR)/$(SBINDIR)/fsck.fat
+	rm -f $(DESTDIR)/$(SBINDIR)/mkfs.fat
 
 	rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(SBINDIR)
 
@@ -89,17 +126,38 @@
 	rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(DOCDIR)
 
 uninstall-man:
-	rm -f $(DESTDIR)/$(MANDIR)/man8/dosfsck.8
+	for MANPAGE in manpages/en/*; \
+	do \
+		SECTION="8"; \
+		rm -f $(DESTDIR)/$(MANDIR)/man$${SECTION}/$$(basename $${MANPAGE} .en.$${SECTION}).$${SECTION}; \
+	done
+
+	for LANGUAGE in $(LANGUAGES); \
+	do \
+		for MANPAGE in manpages/$${LANGUAGE}/*; \
+		do \
+			SECTION="8"; \
+			rm -f $(DESTDIR)/$(MANDIR)/$${LANGUAGE}/man$${SECTION}/$$(basename $${MANPAGE} .$${LANGUAGE}.$${SECTION}).$${SECTION}; \
+		done; \
+	done
+
+uninstall-symlinks:
+	rm -f $(DESTDIR)/$(SBINDIR)/dosfslabel
 	rm -f $(DESTDIR)/$(MANDIR)/man8/dosfslabel.8
-	rm -f $(DESTDIR)/$(MANDIR)/man8/mkdosfs.8
 
+	rm -f $(DESTDIR)/$(SBINDIR)/dosfsck
+	rm -f $(DESTDIR)/$(MANDIR)/man8/dosfsck.8
+	rm -f $(DESTDIR)/$(SBINDIR)/fsck.msdos
 	rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.msdos.8
+	rm -f $(DESTDIR)/$(SBINDIR)/fsck.vfat
 	rm -f $(DESTDIR)/$(MANDIR)/man8/fsck.vfat.8
-	rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8
-	rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8
 
-	rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(MANDIR)/man8
-	rmdir --ignore-fail-on-non-empty $(DESTDIR)/$(MANDIR)
+	rm -f $(DESTDIR)/$(SBINDIR)/mkdosfs
+	rm -f $(DESTDIR)/$(MANDIR)/man8/mkdosfs.8
+	rm -f $(DESTDIR)/$(SBINDIR)/mkfs.msdos
+	rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.msdos.8
+	rm -f $(DESTDIR)/$(SBINDIR)/mkfs.vfat
+	rm -f $(DESTDIR)/$(MANDIR)/man8/mkfs.vfat.8
 
 reinstall: distclean install
 
@@ -107,6 +165,6 @@
 	rm -f *.o
 
 distclean: clean
-	rm -f dosfsck dosfslabel mkdosfs
+	rm -f fatlabel fsck.fat mkfs.fat
 
-.PHONY: build rebuild install install-bin install-doc install-man uninstall uninstall-bin uninstall-doc uninstall-man reinstall clean distclean
+.PHONY: build rebuild install install-bin install-doc install-man install-symlinks uninstall uninstall-bin uninstall-doc uninstall-man uninstall-symlinks reinstall clean distclean