summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/dosfstools/dosfstools/mkdosfs-bootcode.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/dosfstools/dosfstools/mkdosfs-bootcode.patch')
-rw-r--r--meta/recipes-devtools/dosfstools/dosfstools/mkdosfs-bootcode.patch241
1 files changed, 241 insertions, 0 deletions
diff --git a/meta/recipes-devtools/dosfstools/dosfstools/mkdosfs-bootcode.patch b/meta/recipes-devtools/dosfstools/dosfstools/mkdosfs-bootcode.patch
new file mode 100644
index 0000000..ae21bee
--- /dev/null
+++ b/meta/recipes-devtools/dosfstools/dosfstools/mkdosfs-bootcode.patch
@@ -0,0 +1,241 @@
1Add option to read in bootcode from a file.
2
3Upstream-Status: Inappropriate [licensing]
4We're tracking an old release of dosfstools due to licensing issues.
5
6Signed-off-by: Scott Garman <scott.a.garman@intel.com>
7
8Index: dosfstools-2.11/mkdosfs/ChangeLog
9===================================================================
10--- dosfstools-2.11.orig/mkdosfs/ChangeLog 1997-06-18 10:09:38.000000000 +0000
11+++ dosfstools-2.11/mkdosfs/ChangeLog 2011-12-06 12:14:23.634011558 +0000
12@@ -1,3 +1,14 @@
13+19th June 2003 Sam Bingner (sam@bingner.com)
14+
15+ Added option to read in bootcode from a file so that if you have
16+ for example Windows 2000 boot code, you can have it write that
17+ as the bootcode. This is a dump of the behinning of a partition
18+ generally 512 bytes, but can be up to reserved sectors*512 bytes.
19+ Also writes 0x80 as the BIOS drive number if we are formatting a
20+ hard drive, and sets the number of hidden sectors to be the
21+ number of sectors in one track. These were required so that DOS
22+ could boot using the bootcode.
23+
24 28th January 1995 H. Peter Anvin (hpa@yggdrasil.com)
25
26 Better algorithm to select cluster sizes on large filesystems.
27Index: dosfstools-2.11/mkdosfs/mkdosfs.8
28===================================================================
29--- dosfstools-2.11.orig/mkdosfs/mkdosfs.8 2004-02-25 19:36:07.000000000 +0000
30+++ dosfstools-2.11/mkdosfs/mkdosfs.8 2011-12-06 12:19:54.777888434 +0000
31@@ -44,6 +44,10 @@
32 .I message-file
33 ]
34 [
35+.B \-B
36+.I bootcode-file
37+]
38+[
39 .B \-n
40 .I volume-name
41 ]
42@@ -165,6 +169,18 @@
43 carriage return-line feed combinations, and tabs have been expanded.
44 If the filename is a hyphen (-), the text is taken from standard input.
45 .TP
46+.BI \-B " bootcode-file"
47+Uses boot machine code from file "file". On any thing other than FAT32,
48+this only writes the first 3 bytes, and 480 bytes from offset 3Eh. On
49+FAT32, this writes the first 3 bytes, 420 bytes from offset 5Ah to both
50+primary and backup boot sectors. Also writes all other reserved sectors
51+excluding the sectors following boot sectors (usually sector 2 and 7).
52+Does not require that the input file be as large as reserved_sectors*512.
53+To make a FAT32 partition bootable, you will need at least the first
54+13 sectors (6656 bytes). You can also specify a partition as the argument
55+to clone the boot code from that partition.
56+i.e mkdosfs -B /dev/sda1 /dev/sda1
57+.TP
58 .BI \-n " volume-name"
59 Sets the volume name (label) of the filesystem. The volume name can
60 be up to 11 characters long. The default is no label.
61@@ -198,8 +214,9 @@
62 simply will not support it ;)
63 .SH AUTHOR
64 Dave Hudson - <dave@humbug.demon.co.uk>; modified by Peter Anvin
65-<hpa@yggdrasil.com>. Fixes and additions by Roman Hodek
66-<roman@hodek.net> for Debian/GNU Linux.
67+<hpa@yggdrasil.com> and Sam Bingner <sam@bingner.com>. Fixes and
68+additions by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
69+for Debian/GNU Linux.
70 .SH ACKNOWLEDGEMENTS
71 .B mkdosfs
72 is based on code from
73Index: dosfstools-2.11/mkdosfs/mkdosfs.c
74===================================================================
75--- dosfstools-2.11.orig/mkdosfs/mkdosfs.c 2005-03-12 16:12:16.000000000 +0000
76+++ dosfstools-2.11/mkdosfs/mkdosfs.c 2011-12-06 12:27:55.121886076 +0000
77@@ -24,6 +24,12 @@
78 - New options -A, -S, -C
79 - Support for filesystems > 2GB
80 - FAT32 support
81+
82+ Fixes/additions June 2003 by Sam Bingner
83+ <sam@bingner.com>:
84+ - Add -B option to read in bootcode from a file
85+ - Write BIOS drive number so that FS can properly boot
86+ - Set number of hidden sectors before boot code to be one track
87
88 Copying: Copyright 1993, 1994 David Hudson (dave@humbug.demon.co.uk)
89
90@@ -153,6 +159,8 @@
91 #define FAT_BAD 0x0ffffff7
92
93 #define MSDOS_EXT_SIGN 0x29 /* extended boot sector signature */
94+#define HD_DRIVE_NUMBER 0x80 /* Boot off first hard drive */
95+#define FD_DRIVE_NUMBER 0x00 /* Boot off first floppy drive */
96 #define MSDOS_FAT12_SIGN "FAT12 " /* FAT12 filesystem signature */
97 #define MSDOS_FAT16_SIGN "FAT16 " /* FAT16 filesystem signature */
98 #define MSDOS_FAT32_SIGN "FAT32 " /* FAT32 filesystem signature */
99@@ -175,6 +183,8 @@
100 #define BOOTCODE_SIZE 448
101 #define BOOTCODE_FAT32_SIZE 420
102
103+#define MAX_RESERVED 0xFFFF
104+
105 /* __attribute__ ((packed)) is used on all structures to make gcc ignore any
106 * alignments */
107
108@@ -202,7 +212,7 @@
109 __u16 fat_length; /* sectors/FAT */
110 __u16 secs_track; /* sectors per track */
111 __u16 heads; /* number of heads */
112- __u32 hidden; /* hidden sectors (unused) */
113+ __u32 hidden; /* hidden sectors (one track) */
114 __u32 total_sect; /* number of sectors (if sectors == 0) */
115 union {
116 struct {
117@@ -285,6 +295,8 @@
118
119 /* Global variables - the root of all evil :-) - see these and weep! */
120
121+static char *template_boot_code; /* Variable to store a full template boot sector in */
122+static int use_template = 0;
123 static char *program_name = "mkdosfs"; /* Name of the program */
124 static char *device_name = NULL; /* Name of the device on which to create the filesystem */
125 static int atari_format = 0; /* Use Atari variation of MS-DOS FS format */
126@@ -837,6 +849,12 @@
127 vi->volume_id[2] = (unsigned char) ((volume_id & 0x00ff0000) >> 16);
128 vi->volume_id[3] = (unsigned char) (volume_id >> 24);
129 }
130+ if (bs.media == 0xf8) {
131+ vi->drive_number = HD_DRIVE_NUMBER; /* Set bios drive number to 80h */
132+ }
133+ else {
134+ vi->drive_number = FD_DRIVE_NUMBER; /* Set bios drive number to 00h */
135+ }
136
137 if (!atari_format) {
138 memcpy(vi->volume_label, volume_name, 11);
139@@ -1362,6 +1380,32 @@
140 * dir area on FAT12/16, and the first cluster on FAT32. */
141 writebuf( (char *) root_dir, size_root_dir, "root directory" );
142
143+ if (use_template == 1) {
144+ /* dupe template into reserved sectors */
145+ seekto( 0, "Start of partition" );
146+ if (size_fat == 32) {
147+ writebuf( template_boot_code, 3, "backup jmpBoot" );
148+ seekto( 0x5a, "sector 1 boot area" );
149+ writebuf( template_boot_code+0x5a, 420, "sector 1 boot area" );
150+ seekto( 512*2, "third sector" );
151+ if (backup_boot != 0) {
152+ writebuf( template_boot_code+512*2, backup_boot*sector_size - 512*2, "data to backup boot" );
153+ seekto( backup_boot*sector_size, "backup boot sector" );
154+ writebuf( template_boot_code, 3, "backup jmpBoot" );
155+ seekto( backup_boot*sector_size+0x5a, "backup boot sector boot area" );
156+ writebuf( template_boot_code+0x5a, 420, "backup boot sector boot area" );
157+ seekto( (backup_boot+2)*sector_size, "sector following backup code" );
158+ writebuf( template_boot_code+(backup_boot+2)*sector_size, (reserved_sectors-backup_boot-2)*512, "remaining data" );
159+ } else {
160+ writebuf( template_boot_code+512*2, (reserved_sectors-2)*512, "remaining data" );
161+ }
162+ } else {
163+ writebuf( template_boot_code, 3, "jmpBoot" );
164+ seekto( 0x3e, "sector 1 boot area" );
165+ writebuf( template_boot_code+0x3e, 448, "boot code" );
166+ }
167+ }
168+
169 if (blank_sector) free( blank_sector );
170 if (info_sector) free( info_sector );
171 free (root_dir); /* Free up the root directory space from setup_tables */
172@@ -1376,7 +1420,7 @@
173 {
174 fatal_error("\
175 Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] [-b backup-boot-sector]\n\
176- [-m boot-msg-file] [-n volume-name] [-i volume-id]\n\
177+ [-m boot-msg-file] [-n volume-name] [-i volume-id] [-B bootcode]\n\
178 [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n\
179 [-h hidden-sectors] [-F fat-size] [-r root-dir-entries] [-R reserved-sectors]\n\
180 /dev/name [blocks]\n");
181@@ -1439,7 +1483,7 @@
182 printf ("%s " VERSION " (" VERSION_DATE ")\n",
183 program_name);
184
185- while ((c = getopt (argc, argv, "AbcCf:F:Ii:l:m:n:r:R:s:S:h:v")) != EOF)
186+ while ((c = getopt (argc, argv, "AbcCf:F:Ii:l:m:n:r:R:s:S:v:B:")) != EOF)
187 /* Scan the command line for options */
188 switch (c)
189 {
190@@ -1509,6 +1553,51 @@
191 listfile = optarg;
192 break;
193
194+ case 'B': /* B : read in bootcode */
195+ if ( strcmp(optarg, "-") )
196+ {
197+ msgfile = fopen(optarg, "r");
198+ if ( !msgfile )
199+ perror(optarg);
200+ }
201+ else
202+ msgfile = stdin;
203+
204+ if ( msgfile )
205+ {
206+ if (!(template_boot_code = malloc( MAX_RESERVED )))
207+ die( "Out of memory" );
208+ /* The template boot sector including reserved must not be > 65535 */
209+ use_template = 1;
210+ i = 0;
211+ do
212+ {
213+ ch = getc(msgfile);
214+ switch (ch)
215+ {
216+ case EOF:
217+ break;
218+
219+ default:
220+ template_boot_code[i++] = ch; /* Store character */
221+ break;
222+ }
223+ }
224+ while ( ch != EOF && i < MAX_RESERVED );
225+ ch = getc(msgfile); /* find out if we're at EOF */
226+
227+ /* Fill up with zeros */
228+ while( i < MAX_RESERVED )
229+ template_boot_code[i++] = '\0';
230+
231+ if ( ch != EOF )
232+ printf ("Warning: template too long; truncated after %d bytes\n", i);
233+
234+ if ( msgfile != stdin )
235+ fclose(msgfile);
236+ }
237+ break;
238+
239 case 'm': /* m : Set boot message */
240 if ( strcmp(optarg, "-") )
241 {