summaryrefslogtreecommitdiffstats
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 0000000000..1fbbe37c76
--- /dev/null
+++ b/meta/packages/dosfstools/dosfstools-native_2.10.bb
@@ -0,0 +1,27 @@
1# dosfstools-native OE build file
2# Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved
3# Released under the MIT license (see packages/COPYING)
4
5require dosfstools_${PV}.bb
6FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/dosfstools-${PV}"
7
8S="${WORKDIR}/dosfstools-${PV}"
9
10PR="r4"
11
12SRC_URI = "ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/dosfstools-${PV}.src.tar.gz \
13 file://mkdosfs-bootcode.patch;patch=1 \
14 file://mkdosfs-dir.patch;patch=1 \
15 file://alignment_hack.patch;patch=1 \
16 file://dosfstools-2.10-kernel-2.6.patch;patch=1 \
17 file://msdos_fat12_undefined.patch;patch=1 \
18 file://dosfstools-msdos_fs-types.patch;patch=1 \
19 file://include-linux-types.patch;patch=1 \
20 file://2.6.20-syscall.patch;patch=1"
21
22inherit native
23
24do_stage() {
25 install -m 755 ${S}/mkdosfs/mkdosfs ${STAGING_BINDIR}/mkdosfs
26 install -m 755 ${S}/dosfsck/dosfsck ${STAGING_BINDIR}/dosfsck
27}
diff --git a/meta/packages/dosfstools/dosfstools_2.10.bb b/meta/packages/dosfstools/dosfstools_2.10.bb
new file mode 100644
index 0000000000..100044b75d
--- /dev/null
+++ b/meta/packages/dosfstools/dosfstools_2.10.bb
@@ -0,0 +1,22 @@
1# dosfstools OE build file
2# Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved
3# Released under the MIT license (see packages/COPYING)
4
5DESCRIPTION = "DOS FAT Filesystem Utilities"
6
7SECTION = "base"
8PRIORITY = "optional"
9LICENSE = "GPL"
10
11PR = "r2"
12
13SRC_URI = "ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/dosfstools-${PV}.src.tar.gz \
14 file://alignment_hack.patch;patch=1 \
15 file://dosfstools-2.10-kernel-2.6.patch;patch=1 \
16 file://msdos_fat12_undefined.patch;patch=1 \
17 file://include-linux-types.patch;patch=1"
18
19do_install () {
20 oe_runmake "PREFIX=${D}" "SBINDIR=${D}${sbindir}" \
21 "MANDIR=${D}${mandir}/man8" install
22}
diff --git a/meta/packages/dosfstools/dosfstools_2.11.bb b/meta/packages/dosfstools/dosfstools_2.11.bb
new file mode 100644
index 0000000000..a5f6e034dd
--- /dev/null
+++ b/meta/packages/dosfstools/dosfstools_2.11.bb
@@ -0,0 +1,21 @@
1# dosfstools OE build file
2# Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved
3# Released under the MIT license (see packages/COPYING)
4
5DESCRIPTION = "DOS FAT Filesystem Utilities"
6
7SECTION = "base"
8PRIORITY = "optional"
9LICENSE = "GPL"
10
11PR = "r0"
12
13SRC_URI = "ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/dosfstools-${PV}.src.tar.gz \
14 file://alignment_hack.patch;patch=1 \
15 file://msdos_fat12_undefined.patch;patch=1 \
16 file://include-linux-types.patch;patch=1"
17
18do_install () {
19 oe_runmake "PREFIX=${D}" "SBINDIR=${D}${sbindir}" \
20 "MANDIR=${D}${mandir}/man8" install
21}
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 0000000000..7cf2662d27
--- /dev/null
+++ b/meta/packages/dosfstools/files/2.6.20-syscall.patch
@@ -0,0 +1,65 @@
1Index: dosfstools-2.10/dosfsck/io.c
2===================================================================
3--- dosfstools-2.10.orig/dosfsck/io.c 2007-06-07 16:15:52.000000000 +0200
4+++ dosfstools-2.10/dosfsck/io.c 2007-06-07 16:16:06.000000000 +0200
5@@ -42,28 +42,11 @@
6 /* Use the _llseek system call directly, because there (once?) was a bug in
7 * the glibc implementation of it. */
8 #include <linux/unistd.h>
9-#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__
10 /* On alpha, the syscall is simply lseek, because it's a 64 bit system. */
11 static loff_t llseek( int fd, loff_t offset, int whence )
12 {
13 return lseek(fd, offset, whence);
14 }
15-#else
16-# ifndef __NR__llseek
17-# error _llseek system call not present
18-# endif
19-static _syscall5( int, _llseek, uint, fd, ulong, hi, ulong, lo,
20- loff_t *, res, uint, wh );
21-
22-static loff_t llseek( int fd, loff_t offset, int whence )
23-{
24- loff_t actual;
25-
26- if (_llseek(fd, offset>>32, offset&0xffffffff, &actual, whence) != 0)
27- return (loff_t)-1;
28- return actual;
29-}
30-#endif
31
32
33 void fs_open(char *path,int rw)
34Index: dosfstools-2.10/mkdosfs/mkdosfs.c
35===================================================================
36--- dosfstools-2.10.orig/mkdosfs/mkdosfs.c 2007-06-07 16:15:11.000000000 +0200
37+++ dosfstools-2.10/mkdosfs/mkdosfs.c 2007-06-07 16:15:30.000000000 +0200
38@@ -116,27 +116,11 @@
39 /* Use the _llseek system call directly, because there (once?) was a bug in
40 * the glibc implementation of it. */
41 #include <linux/unistd.h>
42-#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__
43 /* On alpha, the syscall is simply lseek, because it's a 64 bit system. */
44 static loff_t llseek( int fd, loff_t offset, int whence )
45 {
46 return lseek(fd, offset, whence);
47 }
48-#else
49-# ifndef __NR__llseek
50-# error _llseek system call not present
51-# endif
52-static _syscall5( int, _llseek, uint, fd, ulong, hi, ulong, lo,
53- loff_t *, res, uint, wh );
54-static loff_t llseek( int fd, loff_t offset, int whence )
55-{
56- loff_t actual;
57-
58- if (_llseek(fd, offset>>32, offset&0xffffffff, &actual, whence) != 0)
59- return (loff_t)-1;
60- return actual;
61-}
62-#endif
63
64 #define ROUND_UP(value, divisor) (value + (divisor - (value % divisor))) / divisor
65
diff --git a/meta/packages/dosfstools/files/alignment_hack.patch b/meta/packages/dosfstools/files/alignment_hack.patch
new file mode 100644
index 0000000000..e15060a6fe
--- /dev/null
+++ b/meta/packages/dosfstools/files/alignment_hack.patch
@@ -0,0 +1,34 @@
1The problem is that unsigned char[2] is
2guranteed to be 8Bit aligned on arm
3but unsigned short is/needs to be 16bit aligned
4the union { unsigned short; unsigned char[2] } trick
5didn't work so no we use the alpha hack.
6
7memcpy into an 16bit aligned
8
9 -zecke
10
11
12--- dosfstools/dosfsck/boot.c.orig 2003-05-15 19:32:23.000000000 +0200
13+++ dosfstools/dosfsck/boot.c 2003-06-13 17:44:25.000000000 +0200
14@@ -36,17 +36,15 @@
15 { 0xff, "5.25\" 320k floppy 2s/40tr/8sec" },
16 };
17
18-#if defined __alpha || defined __ia64__ || defined __s390x__ || defined __x86_64__ || defined __ppc64__
19+
20 /* Unaligned fields must first be copied byte-wise */
21 #define GET_UNALIGNED_W(f) \
22 ({ \
23 unsigned short __v; \
24 memcpy( &__v, &f, sizeof(__v) ); \
25- CF_LE_W( *(unsigned short *)&f ); \
26+ CF_LE_W( *(unsigned short *)&__v ); \
27 })
28-#else
29-#define GET_UNALIGNED_W(f) CF_LE_W( *(unsigned short *)&f )
30-#endif
31+
32
33
34 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 0000000000..3ecafc324b
--- /dev/null
+++ b/meta/packages/dosfstools/files/dosfstools-2.10-kernel-2.6.patch
@@ -0,0 +1,74 @@
1Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
2Date: 2004-02-09
3Initial Package Version: 2.6
4Origin: Jim Gifford
5Upstream Status: Accepted
6Description: Fixes Compile Issues with the 2.6 Kernel
7
8--- dosfstools-2.10/dosfsck/common.h.orig 2004-02-09 18:37:59.056737458 +0000
9+++ dosfstools-2.10/dosfsck/common.h 2004-02-09 18:38:18.333392952 +0000
10@@ -2,6 +2,13 @@
11
12 /* Written 1993 by Werner Almesberger */
13
14+#include <linux/version.h>
15+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
16+ #define __KERNEL__
17+ #include <asm/types.h>
18+ #undef __KERNEL__
19+ #define MSDOS_FAT12 4084 /* maximum number of clusters in a 12 bit FAT */
20+#endif
21
22 #ifndef _COMMON_H
23 #define _COMMON_H
24--- dosfstools-2.10/dosfsck/file.c.orig 2004-02-09 18:40:52.016728845 +0000
25+++ dosfstools-2.10/dosfsck/file.c 2004-02-09 18:40:03.665117865 +0000
26@@ -15,6 +15,14 @@
27 #define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
28 #define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h>*/
29 #define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
30+
31+#include <linux/version.h>
32+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
33+ #define __KERNEL__
34+ #include <asm/types.h>
35+ #undef __KERNEL__
36+#endif
37+
38 #include <linux/msdos_fs.h>
39
40 #include "common.h"
41--- dosfstools-2.10/dosfsck/dosfsck.h.orig 2004-02-09 18:57:11.022870974 +0000
42+++ dosfstools-2.10/dosfsck/dosfsck.h 2004-02-09 18:56:20.628614393 +0000
43@@ -13,6 +13,15 @@
44 #define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
45 #define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h>*/
46 #define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
47+
48+#include <linux/version.h>
49+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
50+ #define __KERNEL__
51+ #include <asm/types.h>
52+ #include <asm/byteorder.h>
53+ #undef __KERNEL__
54+#endif
55+
56 #include <linux/msdos_fs.h>
57
58 /* 2.1 kernels use le16_to_cpu() type functions for CF_LE_W & Co., but don't
59--- dosfstools-2.10/mkdosfs/mkdosfs.c.orig 2004-02-09 18:31:41.997157413 +0000
60+++ dosfstools-2.10/mkdosfs/mkdosfs.c 2004-02-09 18:34:07.311945252 +0000
61@@ -66,6 +66,13 @@
62 #include <time.h>
63 #include <errno.h>
64
65+#include <linux/version.h>
66+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
67+ #define __KERNEL__
68+ #include <asm/types.h>
69+ #undef __KERNEL__
70+#endif
71+
72 #if __BYTE_ORDER == __BIG_ENDIAN
73
74 #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 0000000000..e70a3ead2a
--- /dev/null
+++ b/meta/packages/dosfstools/files/dosfstools-msdos_fs-types.patch
@@ -0,0 +1,30 @@
1--- dosfstools-2.10/dosfsck/dosfsck.h.org 2006-02-21 08:36:14.000000000 -0700
2+++ dosfstools-2.10/dosfsck/dosfsck.h 2006-02-21 08:40:12.000000000 -0700
3@@ -22,6 +22,14 @@
4 #undef __KERNEL__
5 #endif
6
7+#ifndef __s8
8+#include <asm/types.h>
9+#endif
10+
11+#ifndef __ASM_STUB_BYTEORDER_H__
12+#include <asm/byteorder.h>
13+#endif
14+
15 #include <linux/msdos_fs.h>
16
17 /* 2.1 kernels use le16_to_cpu() type functions for CF_LE_W & Co., but don't
18--- dosfstools-2.10/dosfsck/file.c.org 2006-02-21 08:37:36.000000000 -0700
19+++ dosfstools-2.10/dosfsck/file.c 2006-02-21 08:37:47.000000000 -0700
20@@ -23,6 +23,10 @@
21 #undef __KERNEL__
22 #endif
23
24+#ifndef __s8
25+#include <asm/types.h>
26+#endif
27+
28 #include <linux/msdos_fs.h>
29
30 #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 0000000000..4bbd4e76e4
--- /dev/null
+++ b/meta/packages/dosfstools/files/include-linux-types.patch
@@ -0,0 +1,17 @@
1mkdsofs is using types of the style __u8, which it gets with some
2versions of libc headers via linux/hdreg.h including asm/types.h.
3Newer version of fedora (at least) have a hdreg.h whichdoes not
4include asm/types.h. To work around this patch mkdosfs.c to explicity
5include linux/types.h which will in turn pull in asm/types.h which
6defines these variables.
7
8--- dosfstools-2.10/mkdosfs/mkdosfs.c~ 2006-07-12 18:46:21.000000000 +1000
9+++ dosfstools-2.10/mkdosfs/mkdosfs.c 2006-07-12 18:46:21.000000000 +1000
10@@ -60,6 +60,7 @@
11 #include "../version.h"
12
13 #include <fcntl.h>
14+#include <linux/types.h>
15 #include <linux/hdreg.h>
16 #include <linux/fs.h>
17 #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 0000000000..52be86284b
--- /dev/null
+++ b/meta/packages/dosfstools/files/mkdosfs-bootcode.patch
@@ -0,0 +1,240 @@
1diff -urN dosfstools-2.10.orig/mkdosfs/ChangeLog dosfstools-2.10/mkdosfs/ChangeLog
2--- dosfstools-2.10.orig/mkdosfs/ChangeLog 1997-06-18 03:09:38.000000000 -0700
3+++ dosfstools-2.10/mkdosfs/ChangeLog 2004-08-02 20:57:57.734939816 -0700
4@@ -1,3 +1,14 @@
5+19th June 2003 Sam Bingner (sam@bingner.com)
6+
7+ Added option to read in bootcode from a file so that if you have
8+ for example Windows 2000 boot code, you can have it write that
9+ as the bootcode. This is a dump of the behinning of a partition
10+ generally 512 bytes, but can be up to reserved sectors*512 bytes.
11+ Also writes 0x80 as the BIOS drive number if we are formatting a
12+ hard drive, and sets the number of hidden sectors to be the
13+ number of sectors in one track. These were required so that DOS
14+ could boot using the bootcode.
15+
16 28th January 1995 H. Peter Anvin (hpa@yggdrasil.com)
17
18 Better algorithm to select cluster sizes on large filesystems.
19diff -urN dosfstools-2.10.orig/mkdosfs/mkdosfs.8 dosfstools-2.10/mkdosfs/mkdosfs.8
20--- dosfstools-2.10.orig/mkdosfs/mkdosfs.8 2003-05-15 11:28:28.000000000 -0700
21+++ dosfstools-2.10/mkdosfs/mkdosfs.8 2004-08-02 20:57:57.735939664 -0700
22@@ -40,6 +40,10 @@
23 .I message-file
24 ]
25 [
26+.B \-B
27+.I bootcode-file
28+]
29+[
30 .B \-n
31 .I volume-name
32 ]
33@@ -155,6 +159,18 @@
34 carriage return-line feed combinations, and tabs have been expanded.
35 If the filename is a hyphen (-), the text is taken from standard input.
36 .TP
37+.BI \-B " bootcode-file"
38+Uses boot machine code from file "file". On any thing other than FAT32,
39+this only writes the first 3 bytes, and 480 bytes from offset 3Eh. On
40+FAT32, this writes the first 3 bytes, 420 bytes from offset 5Ah to both
41+primary and backup boot sectors. Also writes all other reserved sectors
42+excluding the sectors following boot sectors (usually sector 2 and 7).
43+Does not require that the input file be as large as reserved_sectors*512.
44+To make a FAT32 partition bootable, you will need at least the first
45+13 sectors (6656 bytes). You can also specify a partition as the argument
46+to clone the boot code from that partition.
47+i.e mkdosfs -B /dev/sda1 /dev/sda1
48+.TP
49 .BI \-n " volume-name"
50 Sets the volume name (label) of the filesystem. The volume name can
51 be up to 11 characters long. The default is no label.
52@@ -188,8 +204,9 @@
53 simply will not support it ;)
54 .SH AUTHOR
55 Dave Hudson - <dave@humbug.demon.co.uk>; modified by Peter Anvin
56-<hpa@yggdrasil.com>. Fixes and additions by Roman Hodek
57-<Roman.Hodek@informatik.uni-erlangen.de> for Debian/GNU Linux.
58+<hpa@yggdrasil.com> and Sam Bingner <sam@bingner.com>. Fixes and
59+additions by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
60+for Debian/GNU Linux.
61 .SH ACKNOWLEDGEMENTS
62 .B mkdosfs
63 is based on code from
64diff -urN dosfstools-2.10.orig/mkdosfs/mkdosfs.c dosfstools-2.10/mkdosfs/mkdosfs.c
65--- dosfstools-2.10.orig/mkdosfs/mkdosfs.c 2003-06-14 13:07:08.000000000 -0700
66+++ dosfstools-2.10/mkdosfs/mkdosfs.c 2004-08-02 20:57:57.736939512 -0700
67@@ -24,6 +24,12 @@
68 - New options -A, -S, -C
69 - Support for filesystems > 2GB
70 - FAT32 support
71+
72+ Fixes/additions June 2003 by Sam Bingner
73+ <sam@bingner.com>:
74+ - Add -B option to read in bootcode from a file
75+ - Write BIOS drive number so that FS can properly boot
76+ - Set number of hidden sectors before boot code to be one track
77
78 Copying: Copyright 1993, 1994 David Hudson (dave@humbug.demon.co.uk)
79
80@@ -167,6 +173,8 @@
81 #define FAT_BAD 0x0ffffff7
82
83 #define MSDOS_EXT_SIGN 0x29 /* extended boot sector signature */
84+#define HD_DRIVE_NUMBER 0x80 /* Boot off first hard drive */
85+#define FD_DRIVE_NUMBER 0x00 /* Boot off first floppy drive */
86 #define MSDOS_FAT12_SIGN "FAT12 " /* FAT12 filesystem signature */
87 #define MSDOS_FAT16_SIGN "FAT16 " /* FAT16 filesystem signature */
88 #define MSDOS_FAT32_SIGN "FAT32 " /* FAT32 filesystem signature */
89@@ -188,6 +196,8 @@
90 #define BOOTCODE_SIZE 448
91 #define BOOTCODE_FAT32_SIZE 420
92
93+#define MAX_RESERVED 0xFFFF
94+
95 /* __attribute__ ((packed)) is used on all structures to make gcc ignore any
96 * alignments */
97
98@@ -215,7 +225,7 @@
99 __u16 fat_length; /* sectors/FAT */
100 __u16 secs_track; /* sectors per track */
101 __u16 heads; /* number of heads */
102- __u32 hidden; /* hidden sectors (unused) */
103+ __u32 hidden; /* hidden sectors (one track) */
104 __u32 total_sect; /* number of sectors (if sectors == 0) */
105 union {
106 struct {
107@@ -298,6 +308,8 @@
108
109 /* Global variables - the root of all evil :-) - see these and weep! */
110
111+static char *template_boot_code; /* Variable to store a full template boot sector in */
112+static int use_template = 0;
113 static char *program_name = "mkdosfs"; /* Name of the program */
114 static char *device_name = NULL; /* Name of the device on which to create the filesystem */
115 static int atari_format = 0; /* Use Atari variation of MS-DOS FS format */
116@@ -842,6 +854,12 @@
117 vi->volume_id[2] = (unsigned char) ((volume_id & 0x00ff0000) >> 16);
118 vi->volume_id[3] = (unsigned char) (volume_id >> 24);
119 }
120+ if (bs.media == 0xf8) {
121+ vi->drive_number = HD_DRIVE_NUMBER; /* Set bios drive number to 80h */
122+ }
123+ else {
124+ vi->drive_number = FD_DRIVE_NUMBER; /* Set bios drive number to 00h */
125+ }
126
127 if (!atari_format) {
128 memcpy(vi->volume_label, volume_name, 11);
129@@ -886,7 +904,7 @@
130 printf( "Using %d reserved sectors\n", reserved_sectors );
131 bs.fats = (char) nr_fats;
132 if (!atari_format || size_fat == 32)
133- bs.hidden = CT_LE_L(0);
134+ bs.hidden = bs.secs_track;
135 else
136 /* In Atari format, hidden is a 16 bit field */
137 memset( &bs.hidden, 0, 2 );
138@@ -1358,6 +1376,32 @@
139 * dir area on FAT12/16, and the first cluster on FAT32. */
140 writebuf( (char *) root_dir, size_root_dir, "root directory" );
141
142+ if (use_template == 1) {
143+ /* dupe template into reserved sectors */
144+ seekto( 0, "Start of partition" );
145+ if (size_fat == 32) {
146+ writebuf( template_boot_code, 3, "backup jmpBoot" );
147+ seekto( 0x5a, "sector 1 boot area" );
148+ writebuf( template_boot_code+0x5a, 420, "sector 1 boot area" );
149+ seekto( 512*2, "third sector" );
150+ if (backup_boot != 0) {
151+ writebuf( template_boot_code+512*2, backup_boot*sector_size - 512*2, "data to backup boot" );
152+ seekto( backup_boot*sector_size, "backup boot sector" );
153+ writebuf( template_boot_code, 3, "backup jmpBoot" );
154+ seekto( backup_boot*sector_size+0x5a, "backup boot sector boot area" );
155+ writebuf( template_boot_code+0x5a, 420, "backup boot sector boot area" );
156+ seekto( (backup_boot+2)*sector_size, "sector following backup code" );
157+ writebuf( template_boot_code+(backup_boot+2)*sector_size, (reserved_sectors-backup_boot-2)*512, "remaining data" );
158+ } else {
159+ writebuf( template_boot_code+512*2, (reserved_sectors-2)*512, "remaining data" );
160+ }
161+ } else {
162+ writebuf( template_boot_code, 3, "jmpBoot" );
163+ seekto( 0x3e, "sector 1 boot area" );
164+ writebuf( template_boot_code+0x3e, 448, "boot code" );
165+ }
166+ }
167+
168 if (info_sector) free( info_sector );
169 free (root_dir); /* Free up the root directory space from setup_tables */
170 free (fat); /* Free up the fat table space reserved during setup_tables */
171@@ -1371,7 +1415,7 @@
172 {
173 fatal_error("\
174 Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] [-b backup-boot-sector]\n\
175- [-m boot-msg-file] [-n volume-name] [-i volume-id]\n\
176+ [-m boot-msg-file] [-n volume-name] [-i volume-id] [-B bootcode]\n\
177 [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n\
178 [-F fat-size] [-r root-dir-entries] [-R reserved-sectors]\n\
179 /dev/name [blocks]\n");
180@@ -1433,7 +1477,7 @@
181 printf ("%s " VERSION " (" VERSION_DATE ")\n",
182 program_name);
183
184- while ((c = getopt (argc, argv, "AcCf:F:Ii:l:m:n:r:R:s:S:v")) != EOF)
185+ while ((c = getopt (argc, argv, "AcCf:F:Ii:l:m:n:r:R:s:S:v:B:b")) != EOF)
186 /* Scan the command line for options */
187 switch (c)
188 {
189@@ -1494,6 +1538,51 @@
190 listfile = optarg;
191 break;
192
193+ case 'B': /* B : read in bootcode */
194+ if ( strcmp(optarg, "-") )
195+ {
196+ msgfile = fopen(optarg, "r");
197+ if ( !msgfile )
198+ perror(optarg);
199+ }
200+ else
201+ msgfile = stdin;
202+
203+ if ( msgfile )
204+ {
205+ if (!(template_boot_code = malloc( MAX_RESERVED )))
206+ die( "Out of memory" );
207+ /* The template boot sector including reserved must not be > 65535 */
208+ use_template = 1;
209+ i = 0;
210+ do
211+ {
212+ ch = getc(msgfile);
213+ switch (ch)
214+ {
215+ case EOF:
216+ break;
217+
218+ default:
219+ template_boot_code[i++] = ch; /* Store character */
220+ break;
221+ }
222+ }
223+ while ( ch != EOF && i < MAX_RESERVED );
224+ ch = getc(msgfile); /* find out if we're at EOF */
225+
226+ /* Fill up with zeros */
227+ while( i < MAX_RESERVED )
228+ template_boot_code[i++] = '\0';
229+
230+ if ( ch != EOF )
231+ printf ("Warning: template too long; truncated after %d bytes\n", i);
232+
233+ if ( msgfile != stdin )
234+ fclose(msgfile);
235+ }
236+ break;
237+
238 case 'm': /* m : Set boot message */
239 if ( strcmp(optarg, "-") )
240 {
diff --git a/meta/packages/dosfstools/files/mkdosfs-dir.patch b/meta/packages/dosfstools/files/mkdosfs-dir.patch
new file mode 100644
index 0000000000..8f753b052c
--- /dev/null
+++ b/meta/packages/dosfstools/files/mkdosfs-dir.patch
@@ -0,0 +1,634 @@
1diff -urN dosfstools-2.10.orig/mkdosfs/mkdosfs.c dosfstools-2.10/mkdosfs/mkdosfs.c
2--- dosfstools-2.10.orig/mkdosfs/mkdosfs.c 2004-08-02 20:48:45.000000000 -0700
3+++ dosfstools-2.10/mkdosfs/mkdosfs.c 2004-08-02 20:49:44.296953792 -0700
4@@ -18,6 +18,10 @@
5 as a rule), and not the block. For example the boot block does not
6 occupy a full cluster.
7
8+ June 2004 - Jordan Crouse (info.linux@amd.com)
9+ Added -d <directory> support to populate the image
10+ Copyright (C) 2004, Advanced Micro Devices, All Rights Reserved
11+
12 Fixes/additions May 1998 by Roman Hodek
13 <Roman.Hodek@informatik.uni-erlangen.de>:
14 - Atari format support
15@@ -71,6 +75,8 @@
16 #include <unistd.h>
17 #include <time.h>
18 #include <errno.h>
19+#include <libgen.h>
20+#include <dirent.h>
21
22 #if __BYTE_ORDER == __BIG_ENDIAN
23
24@@ -124,6 +130,8 @@
25 }
26 #endif
27
28+#define ROUND_UP(value, divisor) (value + (divisor - (value % divisor))) / divisor
29+
30 /* Constant definitions */
31
32 #define TRUE 1 /* Boolean constants */
33@@ -163,7 +171,6 @@
34 #define ATTR_VOLUME 8 /* volume label */
35 #define ATTR_DIR 16 /* directory */
36 #define ATTR_ARCH 32 /* archived */
37-
38 #define ATTR_NONE 0 /* no attribute bits */
39 #define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
40 /* attribute bits that are copied "as is" */
41@@ -258,6 +265,19 @@
42 __u32 reserved2[4];
43 };
44
45+/* This stores up to 13 chars of the name */
46+
47+struct msdos_dir_slot {
48+ __u8 id; /* sequence number for slot */
49+ __u8 name0_4[10]; /* first 5 characters in name */
50+ __u8 attr; /* attribute byte */
51+ __u8 reserved; /* always 0 */
52+ __u8 alias_checksum; /* checksum for 8.3 alias */
53+ __u8 name5_10[12]; /* 6 more characters in name */
54+ __u16 start; /* starting cluster number, 0 in long slots */
55+ __u8 name11_12[4]; /* last 2 characters in name */
56+};
57+
58 struct msdos_dir_entry
59 {
60 char name[8], ext[3]; /* name and extension */
61@@ -306,6 +326,15 @@
62
63 #define MESSAGE_OFFSET 29 /* Offset of message in above code */
64
65+/* Special structure to keep track of directories as we add them for the -d option */
66+
67+struct dir_entry {
68+ int root; /* Specifies if this is the root dir or not */
69+ int count; /* Number of items in the table */
70+ int entries; /* Number of entries in the table */
71+ struct msdos_dir_entry *table; /* Pointer to the entry table */
72+};
73+
74 /* Global variables - the root of all evil :-) - see these and weep! */
75
76 static char *template_boot_code; /* Variable to store a full template boot sector in */
77@@ -339,6 +368,9 @@
78 static int size_root_dir; /* Size of the root directory in bytes */
79 static int sectors_per_cluster = 0; /* Number of sectors per disk cluster */
80 static int root_dir_entries = 0; /* Number of root directory entries */
81+static int root_dir_num_entries = 0;
82+static int last_cluster_written = 0;
83+
84 static char *blank_sector; /* Blank sector - all zeros */
85
86
87@@ -411,7 +443,6 @@
88 }
89 }
90
91-
92 /* Mark a specified sector as having a particular value in it's FAT entry */
93
94 static void
95@@ -1262,6 +1293,9 @@
96 die ("unable to allocate space for root directory in memory");
97 }
98
99+
100+ last_cluster_written = 2;
101+
102 memset(root_dir, 0, size_root_dir);
103 if ( memcmp(volume_name, " ", 11) )
104 {
105@@ -1310,11 +1344,11 @@
106 }
107
108 if (!(blank_sector = malloc( sector_size )))
109- die( "Out of memory" );
110+ die( "Out of memory" );
111+
112 memset(blank_sector, 0, sector_size);
113 }
114-
115-
116+
117 /* Write the new filesystem's data tables to wherever they're going to end up! */
118
119 #define error(str) \
120@@ -1336,7 +1370,7 @@
121 do { \
122 int __size = (size); \
123 if (write (dev, buf, __size) != __size) \
124- error ("failed whilst writing " errstr); \
125+ error ("failed whilst writing " errstr); \
126 } while(0)
127
128
129@@ -1407,6 +1441,452 @@
130 free (fat); /* Free up the fat table space reserved during setup_tables */
131 }
132
133+/* Add a file to the specified directory entry, and also write it into the image */
134+
135+static void copy_filename(char *filename, char *base, char *ext) {
136+
137+ char *ch = filename;
138+ int i, len;
139+
140+ memset(base, 0x20, 8);
141+ memset(ext, 0x20, 3);
142+
143+ for(len = 0 ; *ch && *ch != '.'; ch++) {
144+ base[len++] = toupper(*ch);
145+ if (len == 8) break;
146+ }
147+
148+ for ( ; *ch && *ch != '.'; ch++);
149+ if (*ch) ch++;
150+
151+ for(len = 0 ; *ch; ch++) {
152+ ext[len++] = toupper(*ch);
153+ if (len == 3) break;
154+ }
155+}
156+
157+/* Check for an .attrib.<filename> file, and read the attributes therein */
158+
159+/* We are going to be pretty pedantic about this. The file needs 3
160+ bytes at the beginning, the attributes are listed in this order:
161+
162+ (H)idden|(S)ystem|(A)rchived
163+
164+ A capital HSA means to enable it, anything else will disable it
165+ (I recommend a '-') The unix user attributes will still be used
166+ for write access.
167+
168+ For example, to enable system file access for ldlinux.sys, write
169+ the following to .attrib.ldlinux.sys: -S-
170+*/
171+
172+unsigned char check_attrib_file(char *dir, char *filename) {
173+
174+ char attrib[4] = { '-', '-', '-' };
175+ unsigned char *buffer = 0;
176+ int ret = ATTR_NONE;
177+ int fd = -1;
178+
179+ buffer = (char *) calloc(1, strlen(dir) + strlen(filename) + 10);
180+ if (!buffer) return ATTR_NONE;
181+
182+ sprintf(buffer, "%s/.attrib.%s", dir, filename);
183+
184+ if (access(buffer, R_OK))
185+ goto exit_attrib;
186+
187+ if ((fd = open(buffer, O_RDONLY, 0)) < 0)
188+ goto exit_attrib;
189+
190+ if (read(fd, attrib, 3) < 0)
191+ goto exit_attrib;
192+
193+ if (attrib[0] == 'H') ret |= ATTR_HIDDEN;
194+ if (attrib[1] == 'S') ret |= ATTR_SYS;
195+ if (attrib[2] == 'A') ret |= ATTR_ARCH;
196+
197+ printf("%s: Setting atrribute %x\n", filename, ret);
198+
199+ exit_attrib:
200+ if (fd >= 0) close(fd);
201+ if (buffer) free(buffer);
202+
203+ return ret;
204+}
205+
206+static void copy_name(char *buffer, int size, char **pointer) {
207+ int i;
208+
209+ for(i = 0; i < size; i += 2) {
210+ if (*pointer) {
211+ buffer[i] = **pointer;
212+ buffer[i + 1] = 0x00;
213+ *pointer = **pointer ? *pointer + 1 : 0;
214+ }
215+ else {
216+ buffer[i] = 0xFF;
217+ buffer[i + 1] = 0xFF;
218+ }
219+ }
220+}
221+
222+static int add_file(char *filename, struct dir_entry *dir, unsigned char attr)
223+{
224+ struct stat stat;
225+ struct msdos_dir_entry *entry;
226+ int infile = 0;
227+ int sectors, clusters;
228+ struct tm *ctime;
229+ int c, s;
230+ int ptr;
231+ char *buffer, *base;
232+ int start;
233+ int usedsec, totalsec;
234+
235+ char name83[8], ext83[3];
236+
237+ struct msdos_dir_slot *slot;
238+ int i;
239+ char *p;
240+
241+ /* The root directory is static, everything else grows as needed */
242+
243+ if (dir->root) {
244+ if (dir->count == dir->entries) {
245+ printf("Error - too many directory entries\n");
246+ }
247+ }
248+ else {
249+ if (dir->count == dir->entries) {
250+ if (!dir->table)
251+ dir->table =
252+ (struct msdos_dir_entry *) malloc(sizeof(struct msdos_dir_entry));
253+ else {
254+ dir->table =
255+ (struct msdos_dir_entry *) realloc(dir->table, (dir->entries + 1) *
256+ sizeof(struct msdos_dir_entry));
257+
258+ memset(&dir->table[dir->entries], 0, sizeof(struct msdos_dir_entry));
259+ }
260+
261+ dir->entries++;
262+ }
263+ }
264+
265+ infile = open(filename, O_RDONLY, 0);
266+ if (!infile) return;
267+
268+ if (fstat(infile, &stat))
269+ goto exit_add;
270+
271+ if (S_ISCHR(stat.st_mode) ||S_ISBLK(stat.st_mode) ||
272+ S_ISFIFO(stat.st_mode) || S_ISLNK(stat.st_mode)) {
273+ printf("Error - cannot create a special file in a FATFS\n");
274+ goto exit_add;
275+ }
276+
277+ /* FIXME: This isn't very pretty */
278+
279+ usedsec = start_data_sector + (size_root_dir / sector_size) +
280+ (last_cluster_written * bs.cluster_size);
281+
282+ totalsec = blocks * BLOCK_SIZE / sector_size;
283+
284+ /* Figure out how many sectors / clustors the file requires */
285+
286+ sectors = ROUND_UP(stat.st_size, sector_size);
287+ clusters = ROUND_UP(sectors, (int) bs.cluster_size);
288+
289+ if (usedsec + sectors > totalsec) {
290+ printf("Error - %s is too big (%d vs %d)\n", filename, sectors, totalsec - usedsec);
291+ close(infile);
292+ return -1;
293+ }
294+
295+ printf("ADD %s\n", filename);
296+
297+ /* Grab the basename of the file */
298+ base = basename(filename);
299+
300+ /* Extract out the 8.3 name */
301+ copy_filename(base, name83, ext83);
302+
303+ /* Make an extended name slot */
304+
305+ slot = (struct msdos_dir_slot *) &dir->table[dir->count++];
306+ slot->id = 'A';
307+ slot->attr = 0x0F;
308+ slot->reserved = 0;
309+ slot->start = 0;
310+
311+ slot->alias_checksum = 0;
312+
313+ for(i = 0; i < 8; i++)
314+ slot->alias_checksum = (((slot->alias_checksum&1)<<7)|((slot->alias_checksum&0xfe)>>1)) + name83[i];
315+
316+ for(i = 0; i < 3; i++)
317+ slot->alias_checksum = (((slot->alias_checksum&1)<<7)|((slot->alias_checksum&0xfe)>>1)) + ext83[i];
318+
319+ p = base;
320+
321+ copy_name(slot->name0_4, 10, &p);
322+ copy_name(slot->name5_10, 12, &p);
323+ copy_name(slot->name11_12, 4, &p);
324+
325+
326+ /* Get the entry from the root filesytem */
327+ entry = &dir->table[dir->count++];
328+
329+ strncpy(entry->name, name83, 8);
330+ strncpy(entry->ext, ext83, 3);
331+
332+
333+ /* If the user has it read only, then add read only to the incoming
334+ attribute settings */
335+
336+ if (!(stat.st_mode & S_IWUSR)) attr |= ATTR_RO;
337+ entry->attr = attr;
338+
339+ /* Set the access time on the file */
340+ ctime = localtime(&create_time);
341+
342+ entry->time = CT_LE_W((unsigned short)((ctime->tm_sec >> 1) +
343+ (ctime->tm_min << 5) + (ctime->tm_hour << 11)));
344+
345+ entry->date = CT_LE_W((unsigned short)(ctime->tm_mday +
346+ ((ctime->tm_mon+1) << 5) +
347+ ((ctime->tm_year-80) << 9)));
348+
349+ entry->ctime_ms = 0;
350+ entry->ctime = entry->time;
351+ entry->cdate = entry->date;
352+ entry->adate = entry->date;
353+ entry->size = stat.st_size;
354+
355+ start = last_cluster_written;
356+
357+ entry->start = CT_LE_W(start); /* start sector */
358+ entry->starthi = CT_LE_W((start & 0xFFFF0000) >> 16); /* High start sector (for FAT32) */
359+
360+ /* We mark all of the clusters we use in the FAT */
361+
362+ for(c = 0; c < clusters; c++ ) {
363+ int free;
364+ int next = c == (clusters - 1) ? FAT_EOF : start + c + 1;
365+ mark_FAT_cluster(start + c, next);
366+ last_cluster_written++;
367+ }
368+
369+ /* This confused me too - cluster 2 starts after the
370+ root directory data - search me as to why */
371+
372+ ptr = (start_data_sector * sector_size) + size_root_dir;
373+ ptr += (start - 2) * bs.cluster_size * sector_size;
374+
375+ buffer = (char *) malloc(sector_size);
376+
377+ if (!buffer) {
378+ printf("Error - couldn't allocate memory\n");
379+ goto exit_add;
380+ }
381+
382+ /* Write the file into the file block */
383+
384+ seekto(ptr, "datafile");
385+
386+ while(1) {
387+ int size = read(infile, buffer, sector_size);
388+ if (size <= 0) break;
389+
390+ writebuf(buffer, size, "data");
391+ }
392+
393+ exit_add:
394+ if (infile) close(infile);
395+}
396+
397+/* Add a new directory to the specified directory entry, and in turn populate
398+ it with its own files */
399+
400+/* FIXME: This should check to make sure there is enough size to add itself */
401+
402+static void add_directory(char *filename, struct dir_entry *dir) {
403+
404+ struct dir_entry *newdir = 0;
405+ struct msdos_dir_entry *entry;
406+ struct tm *ctime;
407+ DIR *rddir = opendir(filename);
408+ struct dirent *dentry = 0;
409+ int remain;
410+ char *data;
411+
412+ /* If the directory doesn't exist */
413+ if (!rddir) return;
414+
415+ if (dir->root) {
416+ if (dir->count == dir->entries) {
417+ printf("Error - too many directory entries\n");
418+ goto exit_add_dir;
419+ }
420+ }
421+ else {
422+ if (dir->count == dir->entries) {
423+ if (!dir->table)
424+ dir->table = (struct msdos_dir_entry *) malloc(sizeof(struct msdos_dir_entry));
425+ else {
426+ dir->table = (struct msdos_dir_entry *) realloc(dir->table, (dir->entries + 1) *
427+ sizeof(struct msdos_dir_entry));
428+
429+ /* Zero it out to avoid issues */
430+ memset(&dir->table[dir->entries], 0, sizeof(struct msdos_dir_entry));
431+ }
432+ dir->entries++;
433+ }
434+ }
435+
436+ /* Now, create a new directory entry for the new directory */
437+ newdir = (struct dir_entry *) calloc(1, sizeof(struct dir_entry));
438+ if (!newdir) goto exit_add_dir;
439+
440+ entry = &dir->table[dir->count++];
441+
442+ strncpy(entry->name, basename(filename), sizeof(entry->name));
443+
444+ entry->attr = ATTR_DIR;
445+ ctime = localtime(&create_time);
446+
447+ entry->time = CT_LE_W((unsigned short)((ctime->tm_sec >> 1) +
448+ (ctime->tm_min << 5) + (ctime->tm_hour << 11)));
449+
450+ entry->date = CT_LE_W((unsigned short)(ctime->tm_mday +
451+ ((ctime->tm_mon+1) << 5) +
452+ ((ctime->tm_year-80) << 9)));
453+
454+ entry->ctime_ms = 0;
455+ entry->ctime = entry->time;
456+ entry->cdate = entry->date;
457+ entry->adate = entry->date;
458+
459+ /* Now, read the directory */
460+
461+ while((dentry = readdir(rddir))) {
462+ struct stat st;
463+ char *buffer;
464+
465+ if (!strcmp(dentry->d_name, ".") || !strcmp(dentry->d_name, ".."))
466+ continue;
467+
468+ /* DOS wouldn't like a typical unix . (dot) file, so we skip those too */
469+ if (dentry->d_name[0] == '.') continue;
470+
471+ buffer = malloc(strlen(filename) + strlen(dentry->d_name) + 3);
472+ if (!buffer) continue;
473+
474+ sprintf(buffer, "%s/%s", filename, dentry->d_name);
475+ if (!stat(buffer, &st)) {
476+ if (S_ISDIR(st.st_mode))
477+ add_directory(buffer, newdir);
478+ else if (S_ISREG(st.st_mode)) {
479+ unsigned char attrib = check_attrib_file(filename, dentry->d_name);
480+ add_file(buffer, newdir, attrib);
481+ }
482+ }
483+
484+ free(buffer);
485+ }
486+
487+ /* Now that the entire directory has been written, go ahead and write the directory
488+ entry as well */
489+
490+ entry->start = CT_LE_W(last_cluster_written);
491+ entry->starthi = CT_LE_W((last_cluster_written & 0xFFFF0000) >> 16);
492+ entry->size = newdir->count * sizeof(struct msdos_dir_entry);
493+
494+ remain = entry->size;
495+ data = (char *) newdir->table;
496+
497+ while(remain) {
498+ int size =
499+ remain > bs.cluster_size * sector_size ? bs.cluster_size * sector_size : remain;
500+
501+ int pos = (start_data_sector * sector_size) + size_root_dir;
502+ pos += (last_cluster_written - 2) * bs.cluster_size * sector_size;
503+
504+ seekto(pos, "add_dir");
505+ writebuf(data, size, "add_dir");
506+
507+ remain -= size;
508+ data += size;
509+
510+ mark_FAT_cluster(last_cluster_written, remain ? last_cluster_written + 1 : FAT_EOF);
511+ last_cluster_written++;
512+ }
513+
514+ exit_add_dir:
515+ if (rddir) closedir(rddir);
516+ if (newdir->table) free(newdir->table);
517+ if (newdir) free(newdir);
518+}
519+
520+/* Given a directory, add all the files and directories to the root directory of the
521+ image.
522+*/
523+
524+static void add_root_directory(char *dirname)
525+{
526+ DIR *dir = opendir(dirname);
527+ struct dirent *entry = 0;
528+ struct dir_entry *newdir = 0;
529+
530+ if (!dir) {
531+ printf("Error - directory %s does not exist\n", dirname);
532+ return;
533+ }
534+
535+ /* Create the root directory structure - this is a bit different then
536+ above, because the table already exists, we just refer to it. */
537+
538+ newdir = (struct dir_entry *) calloc(1,sizeof(struct dir_entry));
539+
540+ if (!newdir) {
541+ closedir(dir);
542+ return;
543+ }
544+
545+ newdir->entries = root_dir_entries;
546+ newdir->root = 1;
547+ newdir->count = 0;
548+ newdir->table = root_dir;
549+
550+ while((entry = readdir(dir))) {
551+ struct stat st;
552+ char *buffer;
553+
554+ if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
555+ continue;
556+
557+ /* DOS wouldn't like a typical unix . (dot) file, so we skip those too */
558+ if (entry->d_name[0] == '.') continue;
559+
560+ buffer = malloc(strlen(dirname) + strlen(entry->d_name) + 3);
561+ if (!buffer) continue;
562+
563+ sprintf(buffer, "%s/%s", dirname, entry->d_name);
564+ if (!stat(buffer, &st)) {
565+ if (S_ISDIR(st.st_mode))
566+ add_directory(buffer, newdir);
567+ else if (S_ISREG(st.st_mode)) {
568+ unsigned char attrib = check_attrib_file(dirname, entry->d_name);
569+ add_file(buffer, newdir, attrib);
570+ }
571+ }
572+
573+ free(buffer);
574+ }
575+
576+ closedir(dir);
577+ if (newdir) free(newdir);
578+}
579
580 /* Report the command usage and return a failure error code */
581
582@@ -1418,9 +1898,9 @@
583 [-m boot-msg-file] [-n volume-name] [-i volume-id] [-B bootcode]\n\
584 [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n\
585 [-F fat-size] [-r root-dir-entries] [-R reserved-sectors]\n\
586- /dev/name [blocks]\n");
587+ [-d directory] /dev/name [blocks]\n");
588 }
589-
590+
591 /*
592 * ++roman: On m68k, check if this is an Atari; if yes, turn on Atari variant
593 * of MS-DOS filesystem by default.
594@@ -1458,6 +1938,8 @@
595 int c;
596 char *tmp;
597 char *listfile = NULL;
598+ char *dirname = NULL;
599+
600 FILE *msgfile;
601 struct stat statbuf;
602 int i = 0, pos, ch;
603@@ -1477,7 +1959,7 @@
604 printf ("%s " VERSION " (" VERSION_DATE ")\n",
605 program_name);
606
607- while ((c = getopt (argc, argv, "AcCf:F:Ii:l:m:n:r:R:s:S:v:B:b")) != EOF)
608+ while ((c = getopt (argc, argv, "AcCd:f:F:Ii:l:m:n:r:R:s:S:v:B:b")) != EOF)
609 /* Scan the command line for options */
610 switch (c)
611 {
612@@ -1502,6 +1984,10 @@
613 create = TRUE;
614 break;
615
616+ case 'd':
617+ dirname = optarg;
618+ break;
619+
620 case 'f': /* f : Choose number of FATs */
621 nr_fats = (int) strtol (optarg, &tmp, 0);
622 if (*tmp || nr_fats < 1 || nr_fats > 4)
623@@ -1796,8 +2282,10 @@
624 else if (listfile)
625 get_list_blocks (listfile);
626
627- write_tables (); /* Write the file system tables away! */
628
629+ if (dirname) add_root_directory(dirname);
630+
631+ write_tables (); /* Write the file system tables away! */
632 exit (0); /* Terminate with no errors! */
633 }
634
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 0000000000..4987aa3019
--- /dev/null
+++ b/meta/packages/dosfstools/files/msdos_fat12_undefined.patch
@@ -0,0 +1,12 @@
1--- dosfstools-2.10/dosfsck/boot.c.orig 2004-10-15 08:51:42.394725176 -0600
2+++ dosfstools-2.10/dosfsck/boot.c 2004-10-15 08:49:16.776862456 -0600
3@@ -14,6 +14,9 @@
4 #include "io.h"
5 #include "boot.h"
6
7+#ifndef MSDOS_FAT12
8+#define MSDOS_FAT12 4084
9+#endif
10
11 #define ROUND_TO_MULTIPLE(n,m) ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0)
12 /* don't divide by zero */