summaryrefslogtreecommitdiff
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/packages/dosfstools/dosfstools-native_2.10.bb27
-rw-r--r--meta/packages/dosfstools/dosfstools_2.10.bb22
-rw-r--r--meta/packages/dosfstools/dosfstools_2.11.bb21
-rw-r--r--meta/packages/dosfstools/files/2.6.20-syscall.patch65
-rw-r--r--meta/packages/dosfstools/files/alignment_hack.patch34
-rw-r--r--meta/packages/dosfstools/files/dosfstools-2.10-kernel-2.6.patch74
-rw-r--r--meta/packages/dosfstools/files/dosfstools-msdos_fs-types.patch30
-rw-r--r--meta/packages/dosfstools/files/include-linux-types.patch17
-rw-r--r--meta/packages/dosfstools/files/mkdosfs-bootcode.patch240
-rw-r--r--meta/packages/dosfstools/files/mkdosfs-dir.patch634
-rw-r--r--meta/packages/dosfstools/files/msdos_fat12_undefined.patch12
11 files changed, 1176 insertions, 0 deletions
diff --git a/meta/packages/dosfstools/dosfstools-native_2.10.bb b/meta/packages/dosfstools/dosfstools-native_2.10.bb
new file mode 100644
index 000000000..1fbbe37c7
--- /dev/null
+++ b/meta/packages/dosfstools/dosfstools-native_2.10.bb
@@ -0,0 +1,27 @@
+# dosfstools-native OE build file
+# Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved
+# Released under the MIT license (see packages/COPYING)
+
+require dosfstools_${PV}.bb
+FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/dosfstools-${PV}"
+
+S="${WORKDIR}/dosfstools-${PV}"
+
+PR="r4"
+
+SRC_URI = "ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/dosfstools-${PV}.src.tar.gz \
+ file://mkdosfs-bootcode.patch;patch=1 \
+ file://mkdosfs-dir.patch;patch=1 \
+ file://alignment_hack.patch;patch=1 \
+ file://dosfstools-2.10-kernel-2.6.patch;patch=1 \
+ file://msdos_fat12_undefined.patch;patch=1 \
+ file://dosfstools-msdos_fs-types.patch;patch=1 \
+ file://include-linux-types.patch;patch=1 \
+ file://2.6.20-syscall.patch;patch=1"
+
+inherit native
+
+do_stage() {
+ install -m 755 ${S}/mkdosfs/mkdosfs ${STAGING_BINDIR}/mkdosfs
+ install -m 755 ${S}/dosfsck/dosfsck ${STAGING_BINDIR}/dosfsck
+}
diff --git a/meta/packages/dosfstools/dosfstools_2.10.bb b/meta/packages/dosfstools/dosfstools_2.10.bb
new file mode 100644
index 000000000..100044b75
--- /dev/null
+++ b/meta/packages/dosfstools/dosfstools_2.10.bb
@@ -0,0 +1,22 @@
+# dosfstools OE build file
+# Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved
+# Released under the MIT license (see packages/COPYING)
+
+DESCRIPTION = "DOS FAT Filesystem Utilities"
+
+SECTION = "base"
+PRIORITY = "optional"
+LICENSE = "GPL"
+
+PR = "r2"
+
+SRC_URI = "ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/dosfstools-${PV}.src.tar.gz \
+ file://alignment_hack.patch;patch=1 \
+ file://dosfstools-2.10-kernel-2.6.patch;patch=1 \
+ file://msdos_fat12_undefined.patch;patch=1 \
+ file://include-linux-types.patch;patch=1"
+
+do_install () {
+ oe_runmake "PREFIX=${D}" "SBINDIR=${D}${sbindir}" \
+ "MANDIR=${D}${mandir}/man8" install
+}
diff --git a/meta/packages/dosfstools/dosfstools_2.11.bb b/meta/packages/dosfstools/dosfstools_2.11.bb
new file mode 100644
index 000000000..a5f6e034d
--- /dev/null
+++ b/meta/packages/dosfstools/dosfstools_2.11.bb
@@ -0,0 +1,21 @@
+# dosfstools OE build file
+# Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved
+# Released under the MIT license (see packages/COPYING)
+
+DESCRIPTION = "DOS FAT Filesystem Utilities"
+
+SECTION = "base"
+PRIORITY = "optional"
+LICENSE = "GPL"
+
+PR = "r0"
+
+SRC_URI = "ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/dosfstools-${PV}.src.tar.gz \
+ file://alignment_hack.patch;patch=1 \
+ file://msdos_fat12_undefined.patch;patch=1 \
+ file://include-linux-types.patch;patch=1"
+
+do_install () {
+ oe_runmake "PREFIX=${D}" "SBINDIR=${D}${sbindir}" \
+ "MANDIR=${D}${mandir}/man8" install
+}
diff --git a/meta/packages/dosfstools/files/2.6.20-syscall.patch b/meta/packages/dosfstools/files/2.6.20-syscall.patch
new file mode 100644
index 000000000..7cf2662d2
--- /dev/null
+++ b/meta/packages/dosfstools/files/2.6.20-syscall.patch
@@ -0,0 +1,65 @@
+Index: dosfstools-2.10/dosfsck/io.c
+===================================================================
+--- dosfstools-2.10.orig/dosfsck/io.c 2007-06-07 16:15:52.000000000 +0200
++++ dosfstools-2.10/dosfsck/io.c 2007-06-07 16:16:06.000000000 +0200
+@@ -42,28 +42,11 @@
+ /* Use the _llseek system call directly, because there (once?) was a bug in
+ * the glibc implementation of it. */
+ #include <linux/unistd.h>
+-#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__
+ /* On alpha, the syscall is simply lseek, because it's a 64 bit system. */
+ static loff_t llseek( int fd, loff_t offset, int whence )
+ {
+ return lseek(fd, offset, whence);
+ }
+-#else
+-# ifndef __NR__llseek
+-# error _llseek system call not present
+-# endif
+-static _syscall5( int, _llseek, uint, fd, ulong, hi, ulong, lo,
+- loff_t *, res, uint, wh );
+-
+-static loff_t llseek( int fd, loff_t offset, int whence )
+-{
+- loff_t actual;
+-
+- if (_llseek(fd, offset>>32, offset&0xffffffff, &actual, whence) != 0)
+- return (loff_t)-1;
+- return actual;
+-}
+-#endif
+
+
+ void fs_open(char *path,int rw)
+Index: dosfstools-2.10/mkdosfs/mkdosfs.c
+===================================================================
+--- dosfstools-2.10.orig/mkdosfs/mkdosfs.c 2007-06-07 16:15:11.000000000 +0200
++++ dosfstools-2.10/mkdosfs/mkdosfs.c 2007-06-07 16:15:30.000000000 +0200
+@@ -116,27 +116,11 @@
+ /* Use the _llseek system call directly, because there (once?) was a bug in
+ * the glibc implementation of it. */
+ #include <linux/unistd.h>
+-#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__
+ /* On alpha, the syscall is simply lseek, because it's a 64 bit system. */
+ static loff_t llseek( int fd, loff_t offset, int whence )
+ {
+ return lseek(fd, offset, whence);
+ }
+-#else
+-# ifndef __NR__llseek
+-# error _llseek system call not present
+-# endif
+-static _syscall5( int, _llseek, uint, fd, ulong, hi, ulong, lo,
+- loff_t *, res, uint, wh );
+-static loff_t llseek( int fd, loff_t offset, int whence )
+-{
+- loff_t actual;
+-
+- if (_llseek(fd, offset>>32, offset&0xffffffff, &actual, whence) != 0)
+- return (loff_t)-1;
+- return actual;
+-}
+-#endif
+
+ #define ROUND_UP(value, divisor) (value + (divisor - (value % divisor))) / divisor
+
diff --git a/meta/packages/dosfstools/files/alignment_hack.patch b/meta/packages/dosfstools/files/alignment_hack.patch
new file mode 100644
index 000000000..e15060a6f
--- /dev/null
+++ b/meta/packages/dosfstools/files/alignment_hack.patch
@@ -0,0 +1,34 @@
+The problem is that unsigned char[2] is
+guranteed to be 8Bit aligned on arm
+but unsigned short is/needs to be 16bit aligned
+the union { unsigned short; unsigned char[2] } trick
+didn't work so no we use the alpha hack.
+
+memcpy into an 16bit aligned
+
+ -zecke
+
+
+--- dosfstools/dosfsck/boot.c.orig 2003-05-15 19:32:23.000000000 +0200
++++ dosfstools/dosfsck/boot.c 2003-06-13 17:44:25.000000000 +0200
+@@ -36,17 +36,15 @@
+ { 0xff, "5.25\" 320k floppy 2s/40tr/8sec" },
+ };
+
+-#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__
++
+ /* Unaligned fields must first be copied byte-wise */
+ #define GET_UNALIGNED_W(f) \
+ ({ \
+ unsigned short __v; \
+ memcpy( &__v, &f, sizeof(__v) ); \
+- CF_LE_W( *(unsigned short *)&f ); \
++ CF_LE_W( *(unsigned short *)&__v ); \
+ })
+-#else
+-#define GET_UNALIGNED_W(f) CF_LE_W( *(unsigned short *)&f )
+-#endif
++
+
+
+ static char *get_media_descr( unsigned char media )
diff --git a/meta/packages/dosfstools/files/dosfstools-2.10-kernel-2.6.patch b/meta/packages/dosfstools/files/dosfstools-2.10-kernel-2.6.patch
new file mode 100644
index 000000000..3ecafc324
--- /dev/null
+++ b/meta/packages/dosfstools/files/dosfstools-2.10-kernel-2.6.patch
@@ -0,0 +1,74 @@
+Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
+Date: 2004-02-09
+Initial Package Version: 2.6
+Origin: Jim Gifford
+Upstream Status: Accepted
+Description: Fixes Compile Issues with the 2.6 Kernel
+
+--- dosfstools-2.10/dosfsck/common.h.orig 2004-02-09 18:37:59.056737458 +0000
++++ dosfstools-2.10/dosfsck/common.h 2004-02-09 18:38:18.333392952 +0000
+@@ -2,6 +2,13 @@
+
+ /* Written 1993 by Werner Almesberger */
+
++#include <linux/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
++ #define __KERNEL__
++ #include <asm/types.h>
++ #undef __KERNEL__
++ #define MSDOS_FAT12 4084 /* maximum number of clusters in a 12 bit FAT */
++#endif
+
+ #ifndef _COMMON_H
+ #define _COMMON_H
+--- dosfstools-2.10/dosfsck/file.c.orig 2004-02-09 18:40:52.016728845 +0000
++++ dosfstools-2.10/dosfsck/file.c 2004-02-09 18:40:03.665117865 +0000
+@@ -15,6 +15,14 @@
+ #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/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
++ #define __KERNEL__
++ #include <asm/types.h>
++ #undef __KERNEL__
++#endif
++
+ #include <linux/msdos_fs.h>
+
+ #include "common.h"
+--- dosfstools-2.10/dosfsck/dosfsck.h.orig 2004-02-09 18:57:11.022870974 +0000
++++ dosfstools-2.10/dosfsck/dosfsck.h 2004-02-09 18:56:20.628614393 +0000
+@@ -13,6 +13,15 @@
+ #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/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
++ #define __KERNEL__
++ #include <asm/types.h>
++ #include <asm/byteorder.h>
++ #undef __KERNEL__
++#endif
++
+ #include <linux/msdos_fs.h>
+
+ /* 2.1 kernels use le16_to_cpu() type functions for CF_LE_W & Co., but don't
+--- dosfstools-2.10/mkdosfs/mkdosfs.c.orig 2004-02-09 18:31:41.997157413 +0000
++++ dosfstools-2.10/mkdosfs/mkdosfs.c 2004-02-09 18:34:07.311945252 +0000
+@@ -66,6 +66,13 @@
+ #include <time.h>
+ #include <errno.h>
+
++#include <linux/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
++ #define __KERNEL__
++ #include <asm/types.h>
++ #undef __KERNEL__
++#endif
++
+ #if __BYTE_ORDER == __BIG_ENDIAN
+
+ #include <asm/byteorder.h>
diff --git a/meta/packages/dosfstools/files/dosfstools-msdos_fs-types.patch b/meta/packages/dosfstools/files/dosfstools-msdos_fs-types.patch
new file mode 100644
index 000000000..e70a3ead2
--- /dev/null
+++ b/meta/packages/dosfstools/files/dosfstools-msdos_fs-types.patch
@@ -0,0 +1,30 @@
+--- dosfstools-2.10/dosfsck/dosfsck.h.org 2006-02-21 08:36:14.000000000 -0700
++++ dosfstools-2.10/dosfsck/dosfsck.h 2006-02-21 08:40:12.000000000 -0700
+@@ -22,6 +22,14 @@
+ #undef __KERNEL__
+ #endif
+
++#ifndef __s8
++#include <asm/types.h>
++#endif
++
++#ifndef __ASM_STUB_BYTEORDER_H__
++#include <asm/byteorder.h>
++#endif
++
+ #include <linux/msdos_fs.h>
+
+ /* 2.1 kernels use le16_to_cpu() type functions for CF_LE_W & Co., but don't
+--- dosfstools-2.10/dosfsck/file.c.org 2006-02-21 08:37:36.000000000 -0700
++++ dosfstools-2.10/dosfsck/file.c 2006-02-21 08:37:47.000000000 -0700
+@@ -23,6 +23,10 @@
+ #undef __KERNEL__
+ #endif
+
++#ifndef __s8
++#include <asm/types.h>
++#endif
++
+ #include <linux/msdos_fs.h>
+
+ #include "common.h"
diff --git a/meta/packages/dosfstools/files/include-linux-types.patch b/meta/packages/dosfstools/files/include-linux-types.patch
new file mode 100644
index 000000000..4bbd4e76e
--- /dev/null
+++ b/meta/packages/dosfstools/files/include-linux-types.patch
@@ -0,0 +1,17 @@
+mkdsofs is using types of the style __u8, which it gets with some
+versions of libc headers via linux/hdreg.h including asm/types.h.
+Newer version of fedora (at least) have a hdreg.h whichdoes not
+include asm/types.h. To work around this patch mkdosfs.c to explicity
+include linux/types.h which will in turn pull in asm/types.h which
+defines these variables.
+
+--- dosfstools-2.10/mkdosfs/mkdosfs.c~ 2006-07-12 18:46:21.000000000 +1000
++++ dosfstools-2.10/mkdosfs/mkdosfs.c 2006-07-12 18:46:21.000000000 +1000
+@@ -60,6 +60,7 @@
+ #include "../version.h"
+
+ #include <fcntl.h>
++#include <linux/types.h>
+ #include <linux/hdreg.h>
+ #include <linux/fs.h>
+ #include <linux/fd.h>
diff --git a/meta/packages/dosfstools/files/mkdosfs-bootcode.patch b/meta/packages/dosfstools/files/mkdosfs-bootcode.patch
new file mode 100644
index 000000000..52be86284
--- /dev/null
+++ b/meta/packages/dosfstools/files/mkdosfs-bootcode.patch
@@ -0,0 +1,240 @@
+diff -urN dosfstools-2.10.orig/mkdosfs/ChangeLog dosfstools-2.10/mkdosfs/ChangeLog
+--- dosfstools-2.10.orig/mkdosfs/ChangeLog 1997-06-18 03:09:38.000000000 -0700
++++ dosfstools-2.10/mkdosfs/ChangeLog 2004-08-02 20:57:57.734939816 -0700
+@@ -1,3 +1,14 @@
++19th June 2003 Sam Bingner (sam@bingner.com)
++
++ Added option to read in bootcode from a file so that if you have
++ for example Windows 2000 boot code, you can have it write that
++ as the bootcode. This is a dump of the behinning of a partition
++ generally 512 bytes, but can be up to reserved sectors*512 bytes.
++ Also writes 0x80 as the BIOS drive number if we are formatting a
++ hard drive, and sets the number of hidden sectors to be the
++ number of sectors in one track. These were required so that DOS
++ could boot using the bootcode.
++
+ 28th January 1995 H. Peter Anvin (hpa@yggdrasil.com)
+
+ Better algorithm to select cluster sizes on large filesystems.
+diff -urN dosfstools-2.10.orig/mkdosfs/mkdosfs.8 dosfstools-2.10/mkdosfs/mkdosfs.8
+--- dosfstools-2.10.orig/mkdosfs/mkdosfs.8 2003-05-15 11:28:28.000000000 -0700
++++ dosfstools-2.10/mkdosfs/mkdosfs.8 2004-08-02 20:57:57.735939664 -0700
+@@ -40,6 +40,10 @@
+ .I message-file
+ ]
+ [
++.B \-B
++.I bootcode-file
++]
++[
+ .B \-n
+ .I volume-name
+ ]
+@@ -155,6 +159,18 @@
+ carriage return-line feed combinations, and tabs have been expanded.
+ If the filename is a hyphen (-), the text is taken from standard input.
+ .TP
++.BI \-B " bootcode-file"
++Uses boot machine code from file "file". On any thing other than FAT32,
++this only writes the first 3 bytes, and 480 bytes from offset 3Eh. On
++FAT32, this writes the first 3 bytes, 420 bytes from offset 5Ah to both
++primary and backup boot sectors. Also writes all other reserved sectors
++excluding the sectors following boot sectors (usually sector 2 and 7).
++Does not require that the input file be as large as reserved_sectors*512.
++To make a FAT32 partition bootable, you will need at least the first
++13 sectors (6656 bytes). You can also specify a partition as the argument
++to clone the boot code from that partition.
++i.e mkdosfs -B /dev/sda1 /dev/sda1
++.TP
+ .BI \-n " volume-name"
+ Sets the volume name (label) of the filesystem. The volume name can
+ be up to 11 characters long. The default is no label.
+@@ -188,8 +204,9 @@
+ simply will not support it ;)
+ .SH AUTHOR
+ Dave Hudson - <dave@humbug.demon.co.uk>; modified by Peter Anvin
+-<hpa@yggdrasil.com>. Fixes and additions by Roman Hodek
+-<Roman.Hodek@informatik.uni-erlangen.de> for Debian/GNU Linux.
++<hpa@yggdrasil.com> and Sam Bingner <sam@bingner.com>. Fixes and
++additions by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
++for Debian/GNU Linux.
+ .SH ACKNOWLEDGEMENTS
+ .B mkdosfs
+ is based on code from
+diff -urN dosfstools-2.10.orig/mkdosfs/mkdosfs.c dosfstools-2.10/mkdosfs/mkdosfs.c
+--- dosfstools-2.10.orig/mkdosfs/mkdosfs.c 2003-06-14 13:07:08.000000000 -0700
++++ dosfstools-2.10/mkdosfs/mkdosfs.c 2004-08-02 20:57:57.736939512 -0700
+@@ -24,6 +24,12 @@
+ - New options -A, -S, -C
+ - Support for filesystems > 2GB
+ - FAT32 support
++
++ Fixes/additions June 2003 by Sam Bingner
++ <sam@bingner.com>:
++ - Add -B option to read in bootcode from a file
++ - Write BIOS drive number so that FS can properly boot
++ - Set number of hidden sectors before boot code to be one track
+
+ Copying: Copyright 1993, 1994 David Hudson (dave@humbug.demon.co.uk)
+
+@@ -167,6 +173,8 @@
+ #define FAT_BAD 0x0ffffff7
+
+ #define MSDOS_EXT_SIGN 0x29 /* extended boot sector signature */
++#define HD_DRIVE_NUMBER 0x80 /* Boot off first hard drive */
++#define FD_DRIVE_NUMBER 0x00 /* Boot off first floppy drive */
+ #define MSDOS_FAT12_SIGN "FAT12 " /* FAT12 filesystem signature */
+ #define MSDOS_FAT16_SIGN "FAT16 " /* FAT16 filesystem signature */
+ #define MSDOS_FAT32_SIGN "FAT32 " /* FAT32 filesystem signature */
+@@ -188,6 +196,8 @@
+ #define BOOTCODE_SIZE 448
+ #define BOOTCODE_FAT32_SIZE 420
+
++#define MAX_RESERVED 0xFFFF
++
+ /* __attribute__ ((packed)) is used on all structures to make gcc ignore any
+ * alignments */
+
+@@ -215,7 +225,7 @@
+ __u16 fat_length; /* sectors/FAT */
+ __u16 secs_track; /* sectors per track */
+ __u16 heads; /* number of heads */
+- __u32 hidden; /* hidden sectors (unused) */
++ __u32 hidden; /* hidden sectors (one track) */
+ __u32 total_sect; /* number of sectors (if sectors == 0) */
+ union {
+ struct {
+@@ -298,6 +308,8 @@
+
+ /* Global variables - the root of all evil :-) - see these and weep! */
+
++static char *template_boot_code; /* Variable to store a full template boot sector in */
++static int use_template = 0;
+ static char *program_name = "mkdosfs"; /* 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 */
+@@ -842,6 +854,12 @@
+ vi->volume_id[2] = (unsigned char) ((volume_id & 0x00ff0000) >> 16);
+ vi->volume_id[3] = (unsigned char) (volume_id >> 24);
+ }
++ if (bs.media == 0xf8) {
++ vi->drive_number = HD_DRIVE_NUMBER; /* Set bios drive number to 80h */
++ }
++ else {
++ vi->drive_number = FD_DRIVE_NUMBER; /* Set bios drive number to 00h */
++ }
+
+ if (!atari_format) {
+ memcpy(vi->volume_label, volume_name, 11);
+@@ -886,7 +904,7 @@
+ printf( "Using %d reserved sectors\n", reserved_sectors );
+ bs.fats = (char) nr_fats;
+ if (!atari_format || size_fat == 32)
+- bs.hidden = CT_LE_L(0);
++ bs.hidden = bs.secs_track;
+ else
+ /* In Atari format, hidden is a 16 bit field */
+ memset( &bs.hidden, 0, 2 );
+@@ -1358,6 +1376,32 @@
+ * dir area on FAT12/16, and the first cluster on FAT32. */
+ writebuf( (char *) root_dir, size_root_dir, "root directory" );
+
++ if (use_template == 1) {
++ /* dupe template into reserved sectors */
++ seekto( 0, "Start of partition" );
++ if (size_fat == 32) {
++ writebuf( template_boot_code, 3, "backup jmpBoot" );
++ seekto( 0x5a, "sector 1 boot area" );
++ writebuf( template_boot_code+0x5a, 420, "sector 1 boot area" );
++ seekto( 512*2, "third sector" );
++ if (backup_boot != 0) {
++ writebuf( template_boot_code+512*2, backup_boot*sector_size - 512*2, "data to backup boot" );
++ seekto( backup_boot*sector_size, "backup boot sector" );
++ writebuf( template_boot_code, 3, "backup jmpBoot" );
++ seekto( backup_boot*sector_size+0x5a, "backup boot sector boot area" );
++ writebuf( template_boot_code+0x5a, 420, "backup boot sector boot area" );
++ seekto( (backup_boot+2)*sector_size, "sector following backup code" );
++ writebuf( template_boot_code+(backup_boot+2)*sector_size, (reserved_sectors-backup_boot-2)*512, "remaining data" );
++ } else {
++ writebuf( template_boot_code+512*2, (reserved_sectors-2)*512, "remaining data" );
++ }
++ } else {
++ writebuf( template_boot_code, 3, "jmpBoot" );
++ seekto( 0x3e, "sector 1 boot area" );
++ writebuf( template_boot_code+0x3e, 448, "boot code" );
++ }
++ }
++
+ if (info_sector) free( info_sector );
+ free (root_dir); /* Free up the root directory space from setup_tables */
+ free (fat); /* Free up the fat table space reserved during setup_tables */
+@@ -1371,7 +1415,7 @@
+ {
+ fatal_error("\
+ Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] [-b backup-boot-sector]\n\
+- [-m boot-msg-file] [-n volume-name] [-i volume-id]\n\
++ [-m boot-msg-file] [-n volume-name] [-i volume-id] [-B bootcode]\n\
+ [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n\
+ [-F fat-size] [-r root-dir-entries] [-R reserved-sectors]\n\
+ /dev/name [blocks]\n");
+@@ -1433,7 +1477,7 @@
+ printf ("%s " VERSION " (" VERSION_DATE ")\n",
+ program_name);
+
+- while ((c = getopt (argc, argv, "AcCf:F:Ii:l:m:n:r:R:s:S:v")) != EOF)
++ while ((c = getopt (argc, argv, "AcCf:F:Ii:l:m:n:r:R:s:S:v:B:b")) != EOF)
+ /* Scan the command line for options */
+ switch (c)
+ {
+@@ -1494,6 +1538,51 @@
+ listfile = optarg;
+ break;
+
++ case 'B': /* B : read in bootcode */
++ if ( strcmp(optarg, "-") )
++ {
++ msgfile = fopen(optarg, "r");
++ if ( !msgfile )
++ perror(optarg);
++ }
++ else
++ msgfile = stdin;
++
++ if ( msgfile )
++ {
++ if (!(template_boot_code = malloc( MAX_RESERVED )))
++ die( "Out of memory" );
++ /* The template boot sector including reserved must not be > 65535 */
++ use_template = 1;
++ i = 0;
++ do
++ {
++ ch = getc(msgfile);
++ switch (ch)
++ {
++ case EOF:
++ break;
++
++ default:
++ template_boot_code[i++] = ch; /* Store character */
++ break;
++ }
++ }
++ while ( ch != EOF && i < MAX_RESERVED );
++ ch = getc(msgfile); /* find out if we're at EOF */
++
++ /* Fill up with zeros */
++ while( i < MAX_RESERVED )
++ template_boot_code[i++] = '\0';
++
++ if ( ch != EOF )
++ printf ("Warning: template too long; truncated after %d bytes\n", i);
++
++ if ( msgfile != stdin )
++ fclose(msgfile);
++ }
++ break;
++
+ case 'm': /* m : Set boot message */
+ if ( strcmp(optarg, "-") )
+ {
diff --git a/meta/packages/dosfstools/files/mkdosfs-dir.patch b/meta/packages/dosfstools/files/mkdosfs-dir.patch
new file mode 100644
index 000000000..8f753b052
--- /dev/null
+++ b/meta/packages/dosfstools/files/mkdosfs-dir.patch
@@ -0,0 +1,634 @@
+diff -urN dosfstools-2.10.orig/mkdosfs/mkdosfs.c dosfstools-2.10/mkdosfs/mkdosfs.c
+--- dosfstools-2.10.orig/mkdosfs/mkdosfs.c 2004-08-02 20:48:45.000000000 -0700
++++ dosfstools-2.10/mkdosfs/mkdosfs.c 2004-08-02 20:49:44.296953792 -0700
+@@ -18,6 +18,10 @@
+ as a rule), and not the block. For example the boot block does not
+ occupy a full cluster.
+
++ June 2004 - Jordan Crouse (info.linux@amd.com)
++ Added -d <directory> support to populate the image
++ Copyright (C) 2004, Advanced Micro Devices, All Rights Reserved
++
+ Fixes/additions May 1998 by Roman Hodek
+ <Roman.Hodek@informatik.uni-erlangen.de>:
+ - Atari format support
+@@ -71,6 +75,8 @@
+ #include <unistd.h>
+ #include <time.h>
+ #include <errno.h>
++#include <libgen.h>
++#include <dirent.h>
+
+ #if __BYTE_ORDER == __BIG_ENDIAN
+
+@@ -124,6 +130,8 @@
+ }
+ #endif
+
++#define ROUND_UP(value, divisor) (value + (divisor - (value % divisor))) / divisor
++
+ /* Constant definitions */
+
+ #define TRUE 1 /* Boolean constants */
+@@ -163,7 +171,6 @@
+ #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" */
+@@ -258,6 +265,19 @@
+ __u32 reserved2[4];
+ };
+
++/* This stores up to 13 chars of the name */
++
++struct msdos_dir_slot {
++ __u8 id; /* sequence number for slot */
++ __u8 name0_4[10]; /* first 5 characters in name */
++ __u8 attr; /* attribute byte */
++ __u8 reserved; /* always 0 */
++ __u8 alias_checksum; /* checksum for 8.3 alias */
++ __u8 name5_10[12]; /* 6 more characters in name */
++ __u16 start; /* starting cluster number, 0 in long slots */
++ __u8 name11_12[4]; /* last 2 characters in name */
++};
++
+ struct msdos_dir_entry
+ {
+ char name[8], ext[3]; /* name and extension */
+@@ -306,6 +326,15 @@
+
+ #define MESSAGE_OFFSET 29 /* Offset of message in above code */
+
++/* Special structure to keep track of directories as we add them for the -d option */
++
++struct dir_entry {
++ int root; /* Specifies if this is the root dir or not */
++ int count; /* Number of items in the table */
++ int entries; /* Number of entries in the table */
++ struct msdos_dir_entry *table; /* Pointer to the entry table */
++};
++
+ /* Global variables - the root of all evil :-) - see these and weep! */
+
+ static char *template_boot_code; /* Variable to store a full template boot sector in */
+@@ -339,6 +368,9 @@
+ static int size_root_dir; /* Size of the root directory in bytes */
+ static int sectors_per_cluster = 0; /* Number of sectors per disk cluster */
+ static int root_dir_entries = 0; /* Number of root directory entries */
++static int root_dir_num_entries = 0;
++static int last_cluster_written = 0;
++
+ static char *blank_sector; /* Blank sector - all zeros */
+
+
+@@ -411,7 +443,6 @@
+ }
+ }
+
+-
+ /* Mark a specified sector as having a particular value in it's FAT entry */
+
+ static void
+@@ -1262,6 +1293,9 @@
+ die ("unable to allocate space for root directory in memory");
+ }
+
++
++ last_cluster_written = 2;
++
+ memset(root_dir, 0, size_root_dir);
+ if ( memcmp(volume_name, " ", 11) )
+ {
+@@ -1310,11 +1344,11 @@
+ }
+
+ if (!(blank_sector = malloc( sector_size )))
+- die( "Out of memory" );
++ die( "Out of memory" );
++
+ memset(blank_sector, 0, sector_size);
+ }
+-
+-
++
+ /* Write the new filesystem's data tables to wherever they're going to end up! */
+
+ #define error(str) \
+@@ -1336,7 +1370,7 @@
+ do { \
+ int __size = (size); \
+ if (write (dev, buf, __size) != __size) \
+- error ("failed whilst writing " errstr); \
++ error ("failed whilst writing " errstr); \
+ } while(0)
+
+
+@@ -1407,6 +1441,452 @@
+ free (fat); /* Free up the fat table space reserved during setup_tables */
+ }
+
++/* Add a file to the specified directory entry, and also write it into the image */
++
++static void copy_filename(char *filename, char *base, char *ext) {
++
++ char *ch = filename;
++ int i, len;
++
++ memset(base, 0x20, 8);
++ memset(ext, 0x20, 3);
++
++ for(len = 0 ; *ch && *ch != '.'; ch++) {
++ base[len++] = toupper(*ch);
++ if (len == 8) break;
++ }
++
++ for ( ; *ch && *ch != '.'; ch++);
++ if (*ch) ch++;
++
++ for(len = 0 ; *ch; ch++) {
++ ext[len++] = toupper(*ch);
++ if (len == 3) break;
++ }
++}
++
++/* Check for an .attrib.<filename> file, and read the attributes therein */
++
++/* We are going to be pretty pedantic about this. The file needs 3
++ bytes at the beginning, the attributes are listed in this order:
++
++ (H)idden|(S)ystem|(A)rchived
++
++ A capital HSA means to enable it, anything else will disable it
++ (I recommend a '-') The unix user attributes will still be used
++ for write access.
++
++ For example, to enable system file access for ldlinux.sys, write
++ the following to .attrib.ldlinux.sys: -S-
++*/
++
++unsigned char check_attrib_file(char *dir, char *filename) {
++
++ char attrib[4] = { '-', '-', '-' };
++ unsigned char *buffer = 0;
++ int ret = ATTR_NONE;
++ int fd = -1;
++
++ buffer = (char *) calloc(1, strlen(dir) + strlen(filename) + 10);
++ if (!buffer) return ATTR_NONE;
++
++ sprintf(buffer, "%s/.attrib.%s", dir, filename);
++
++ if (access(buffer, R_OK))
++ goto exit_attrib;
++
++ if ((fd = open(buffer, O_RDONLY, 0)) < 0)
++ goto exit_attrib;
++
++ if (read(fd, attrib, 3) < 0)
++ goto exit_attrib;
++
++ if (attrib[0] == 'H') ret |= ATTR_HIDDEN;
++ if (attrib[1] == 'S') ret |= ATTR_SYS;
++ if (attrib[2] == 'A') ret |= ATTR_ARCH;
++
++ printf("%s: Setting atrribute %x\n", filename, ret);
++
++ exit_attrib:
++ if (fd >= 0) close(fd);
++ if (buffer) free(buffer);
++
++ return ret;
++}
++
++static void copy_name(char *buffer, int size, char **pointer) {
++ int i;
++
++ for(i = 0; i < size; i += 2) {
++ if (*pointer) {
++ buffer[i] = **pointer;
++ buffer[i + 1] = 0x00;
++ *pointer = **pointer ? *pointer + 1 : 0;
++ }
++ else {
++ buffer[i] = 0xFF;
++ buffer[i + 1] = 0xFF;
++ }
++ }
++}
++
++static int add_file(char *filename, struct dir_entry *dir, unsigned char attr)
++{
++ struct stat stat;
++ struct msdos_dir_entry *entry;
++ int infile = 0;
++ int sectors, clusters;
++ struct tm *ctime;
++ int c, s;
++ int ptr;
++ char *buffer, *base;
++ int start;
++ int usedsec, totalsec;
++
++ char name83[8], ext83[3];
++
++ struct msdos_dir_slot *slot;
++ int i;
++ char *p;
++
++ /* The root directory is static, everything else grows as needed */
++
++ if (dir->root) {
++ if (dir->count == dir->entries) {
++ printf("Error - too many directory entries\n");
++ }
++ }
++ else {
++ if (dir->count == dir->entries) {
++ if (!dir->table)
++ dir->table =
++ (struct msdos_dir_entry *) malloc(sizeof(struct msdos_dir_entry));
++ else {
++ dir->table =
++ (struct msdos_dir_entry *) realloc(dir->table, (dir->entries + 1) *
++ sizeof(struct msdos_dir_entry));
++
++ memset(&dir->table[dir->entries], 0, sizeof(struct msdos_dir_entry));
++ }
++
++ dir->entries++;
++ }
++ }
++
++ infile = open(filename, O_RDONLY, 0);
++ if (!infile) return;
++
++ if (fstat(infile, &stat))
++ goto exit_add;
++
++ if (S_ISCHR(stat.st_mode) ||S_ISBLK(stat.st_mode) ||
++ S_ISFIFO(stat.st_mode) || S_ISLNK(stat.st_mode)) {
++ printf("Error - cannot create a special file in a FATFS\n");
++ goto exit_add;
++ }
++
++ /* FIXME: This isn't very pretty */
++
++ usedsec = start_data_sector + (size_root_dir / sector_size) +
++ (last_cluster_written * bs.cluster_size);
++
++ totalsec = blocks * BLOCK_SIZE / sector_size;
++
++ /* Figure out how many sectors / clustors the file requires */
++
++ sectors = ROUND_UP(stat.st_size, sector_size);
++ clusters = ROUND_UP(sectors, (int) bs.cluster_size);
++
++ if (usedsec + sectors > totalsec) {
++ printf("Error - %s is too big (%d vs %d)\n", filename, sectors, totalsec - usedsec);
++ close(infile);
++ return -1;
++ }
++
++ printf("ADD %s\n", filename);
++
++ /* Grab the basename of the file */
++ base = basename(filename);
++
++ /* Extract out the 8.3 name */
++ copy_filename(base, name83, ext83);
++
++ /* Make an extended name slot */
++
++ slot = (struct msdos_dir_slot *) &dir->table[dir->count++];
++ slot->id = 'A';
++ slot->attr = 0x0F;
++ slot->reserved = 0;
++ slot->start = 0;
++
++ slot->alias_checksum = 0;
++
++ for(i = 0; i < 8; i++)
++ slot->alias_checksum = (((slot->alias_checksum&1)<<7)|((slot->alias_checksum&0xfe)>>1)) + name83[i];
++
++ for(i = 0; i < 3; i++)
++ slot->alias_checksum = (((slot->alias_checksum&1)<<7)|((slot->alias_checksum&0xfe)>>1)) + ext83[i];
++
++ p = base;
++
++ copy_name(slot->name0_4, 10, &p);
++ copy_name(slot->name5_10, 12, &p);
++ copy_name(slot->name11_12, 4, &p);
++
++
++ /* Get the entry from the root filesytem */
++ entry = &dir->table[dir->count++];
++
++ strncpy(entry->name, name83, 8);
++ strncpy(entry->ext, ext83, 3);
++
++
++ /* If the user has it read only, then add read only to the incoming
++ attribute settings */
++
++ if (!(stat.st_mode & S_IWUSR)) attr |= ATTR_RO;
++ entry->attr = attr;
++
++ /* Set the access time on the file */
++ ctime = localtime(&create_time);
++
++ entry->time = CT_LE_W((unsigned short)((ctime->tm_sec >> 1) +
++ (ctime->tm_min << 5) + (ctime->tm_hour << 11)));
++
++ entry->date = CT_LE_W((unsigned short)(ctime->tm_mday +
++ ((ctime->tm_mon+1) << 5) +
++ ((ctime->tm_year-80) << 9)));
++
++ entry->ctime_ms = 0;
++ entry->ctime = entry->time;
++ entry->cdate = entry->date;
++ entry->adate = entry->date;
++ entry->size = stat.st_size;
++
++ start = last_cluster_written;
++
++ entry->start = CT_LE_W(start); /* start sector */
++ entry->starthi = CT_LE_W((start & 0xFFFF0000) >> 16); /* High start sector (for FAT32) */
++
++ /* We mark all of the clusters we use in the FAT */
++
++ for(c = 0; c < clusters; c++ ) {
++ int free;
++ int next = c == (clusters - 1) ? FAT_EOF : start + c + 1;
++ mark_FAT_cluster(start + c, next);
++ last_cluster_written++;
++ }
++
++ /* This confused me too - cluster 2 starts after the
++ root directory data - search me as to why */
++
++ ptr = (start_data_sector * sector_size) + size_root_dir;
++ ptr += (start - 2) * bs.cluster_size * sector_size;
++
++ buffer = (char *) malloc(sector_size);
++
++ if (!buffer) {
++ printf("Error - couldn't allocate memory\n");
++ goto exit_add;
++ }
++
++ /* Write the file into the file block */
++
++ seekto(ptr, "datafile");
++
++ while(1) {
++ int size = read(infile, buffer, sector_size);
++ if (size <= 0) break;
++
++ writebuf(buffer, size, "data");
++ }
++
++ exit_add:
++ if (infile) close(infile);
++}
++
++/* Add a new directory to the specified directory entry, and in turn populate
++ it with its own files */
++
++/* FIXME: This should check to make sure there is enough size to add itself */
++
++static void add_directory(char *filename, struct dir_entry *dir) {
++
++ struct dir_entry *newdir = 0;
++ struct msdos_dir_entry *entry;
++ struct tm *ctime;
++ DIR *rddir = opendir(filename);
++ struct dirent *dentry = 0;
++ int remain;
++ char *data;
++
++ /* If the directory doesn't exist */
++ if (!rddir) return;
++
++ if (dir->root) {
++ if (dir->count == dir->entries) {
++ printf("Error - too many directory entries\n");
++ goto exit_add_dir;
++ }
++ }
++ else {
++ if (dir->count == dir->entries) {
++ if (!dir->table)
++ dir->table = (struct msdos_dir_entry *) malloc(sizeof(struct msdos_dir_entry));
++ else {
++ dir->table = (struct msdos_dir_entry *) realloc(dir->table, (dir->entries + 1) *
++ sizeof(struct msdos_dir_entry));
++
++ /* Zero it out to avoid issues */
++ memset(&dir->table[dir->entries], 0, sizeof(struct msdos_dir_entry));
++ }
++ dir->entries++;
++ }
++ }
++
++ /* Now, create a new directory entry for the new directory */
++ newdir = (struct dir_entry *) calloc(1, sizeof(struct dir_entry));
++ if (!newdir) goto exit_add_dir;
++
++ entry = &dir->table[dir->count++];
++
++ strncpy(entry->name, basename(filename), sizeof(entry->name));
++
++ entry->attr = ATTR_DIR;
++ ctime = localtime(&create_time);
++
++ entry->time = CT_LE_W((unsigned short)((ctime->tm_sec >> 1) +
++ (ctime->tm_min << 5) + (ctime->tm_hour << 11)));
++
++ entry->date = CT_LE_W((unsigned short)(ctime->tm_mday +
++ ((ctime->tm_mon+1) << 5) +
++ ((ctime->tm_year-80) << 9)));
++
++ entry->ctime_ms = 0;
++ entry->ctime = entry->time;
++ entry->cdate = entry->date;
++ entry->adate = entry->date;
++
++ /* Now, read the directory */
++
++ while((dentry = readdir(rddir))) {
++ struct stat st;
++ char *buffer;
++
++ if (!strcmp(dentry->d_name, ".") || !strcmp(dentry->d_name, ".."))
++ continue;
++
++ /* DOS wouldn't like a typical unix . (dot) file, so we skip those too */
++ if (dentry->d_name[0] == '.') continue;
++
++ buffer = malloc(strlen(filename) + strlen(dentry->d_name) + 3);
++ if (!buffer) continue;
++
++ sprintf(buffer, "%s/%s", filename, dentry->d_name);
++ if (!stat(buffer, &st)) {
++ if (S_ISDIR(st.st_mode))
++ add_directory(buffer, newdir);
++ else if (S_ISREG(st.st_mode)) {
++ unsigned char attrib = check_attrib_file(filename, dentry->d_name);
++ add_file(buffer, newdir, attrib);
++ }
++ }
++
++ free(buffer);
++ }
++
++ /* Now that the entire directory has been written, go ahead and write the directory
++ entry as well */
++
++ entry->start = CT_LE_W(last_cluster_written);
++ entry->starthi = CT_LE_W((last_cluster_written & 0xFFFF0000) >> 16);
++ entry->size = newdir->count * sizeof(struct msdos_dir_entry);
++
++ remain = entry->size;
++ data = (char *) newdir->table;
++
++ while(remain) {
++ int size =
++ remain > bs.cluster_size * sector_size ? bs.cluster_size * sector_size : remain;
++
++ int pos = (start_data_sector * sector_size) + size_root_dir;
++ pos += (last_cluster_written - 2) * bs.cluster_size * sector_size;
++
++ seekto(pos, "add_dir");
++ writebuf(data, size, "add_dir");
++
++ remain -= size;
++ data += size;
++
++ mark_FAT_cluster(last_cluster_written, remain ? last_cluster_written + 1 : FAT_EOF);
++ last_cluster_written++;
++ }
++
++ exit_add_dir:
++ if (rddir) closedir(rddir);
++ if (newdir->table) free(newdir->table);
++ if (newdir) free(newdir);
++}
++
++/* Given a directory, add all the files and directories to the root directory of the
++ image.
++*/
++
++static void add_root_directory(char *dirname)
++{
++ DIR *dir = opendir(dirname);
++ struct dirent *entry = 0;
++ struct dir_entry *newdir = 0;
++
++ if (!dir) {
++ printf("Error - directory %s does not exist\n", dirname);
++ return;
++ }
++
++ /* Create the root directory structure - this is a bit different then
++ above, because the table already exists, we just refer to it. */
++
++ newdir = (struct dir_entry *) calloc(1,sizeof(struct dir_entry));
++
++ if (!newdir) {
++ closedir(dir);
++ return;
++ }
++
++ newdir->entries = root_dir_entries;
++ newdir->root = 1;
++ newdir->count = 0;
++ newdir->table = root_dir;
++
++ while((entry = readdir(dir))) {
++ struct stat st;
++ char *buffer;
++
++ if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
++ continue;
++
++ /* DOS wouldn't like a typical unix . (dot) file, so we skip those too */
++ if (entry->d_name[0] == '.') continue;
++
++ buffer = malloc(strlen(dirname) + strlen(entry->d_name) + 3);
++ if (!buffer) continue;
++
++ sprintf(buffer, "%s/%s", dirname, entry->d_name);
++ if (!stat(buffer, &st)) {
++ if (S_ISDIR(st.st_mode))
++ add_directory(buffer, newdir);
++ else if (S_ISREG(st.st_mode)) {
++ unsigned char attrib = check_attrib_file(dirname, entry->d_name);
++ add_file(buffer, newdir, attrib);
++ }
++ }
++
++ free(buffer);
++ }
++
++ closedir(dir);
++ if (newdir) free(newdir);
++}
+
+ /* Report the command usage and return a failure error code */
+
+@@ -1418,9 +1898,9 @@
+ [-m boot-msg-file] [-n volume-name] [-i volume-id] [-B bootcode]\n\
+ [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n\
+ [-F fat-size] [-r root-dir-entries] [-R reserved-sectors]\n\
+- /dev/name [blocks]\n");
++ [-d directory] /dev/name [blocks]\n");
+ }
+-
++
+ /*
+ * ++roman: On m68k, check if this is an Atari; if yes, turn on Atari variant
+ * of MS-DOS filesystem by default.
+@@ -1458,6 +1938,8 @@
+ int c;
+ char *tmp;
+ char *listfile = NULL;
++ char *dirname = NULL;
++
+ FILE *msgfile;
+ struct stat statbuf;
+ int i = 0, pos, ch;
+@@ -1477,7 +1959,7 @@
+ printf ("%s " VERSION " (" VERSION_DATE ")\n",
+ program_name);
+
+- while ((c = getopt (argc, argv, "AcCf:F:Ii:l:m:n:r:R:s:S:v:B:b")) != EOF)
++ while ((c = getopt (argc, argv, "AcCd:f:F:Ii:l:m:n:r:R:s:S:v:B:b")) != EOF)
+ /* Scan the command line for options */
+ switch (c)
+ {
+@@ -1502,6 +1984,10 @@
+ create = TRUE;
+ break;
+
++ case 'd':
++ dirname = optarg;
++ break;
++
+ case 'f': /* f : Choose number of FATs */
+ nr_fats = (int) strtol (optarg, &tmp, 0);
+ if (*tmp || nr_fats < 1 || nr_fats > 4)
+@@ -1796,8 +2282,10 @@
+ else if (listfile)
+ get_list_blocks (listfile);
+
+- write_tables (); /* Write the file system tables away! */
+
++ if (dirname) add_root_directory(dirname);
++
++ write_tables (); /* Write the file system tables away! */
+ exit (0); /* Terminate with no errors! */
+ }
+
diff --git a/meta/packages/dosfstools/files/msdos_fat12_undefined.patch b/meta/packages/dosfstools/files/msdos_fat12_undefined.patch
new file mode 100644
index 000000000..4987aa301
--- /dev/null
+++ b/meta/packages/dosfstools/files/msdos_fat12_undefined.patch
@@ -0,0 +1,12 @@
+--- dosfstools-2.10/dosfsck/boot.c.orig 2004-10-15 08:51:42.394725176 -0600
++++ dosfstools-2.10/dosfsck/boot.c 2004-10-15 08:49:16.776862456 -0600
+@@ -14,6 +14,9 @@
+ #include "io.h"
+ #include "boot.h"
+
++#ifndef MSDOS_FAT12
++#define MSDOS_FAT12 4084
++#endif
+
+ #define ROUND_TO_MULTIPLE(n,m) ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0)
+ /* don't divide by zero */