View | Details | Raw Unified | Return to bug 6389
Collapse All | Expand All

(-)mkdosfs/mkdosfs.c.bootcode (-2 / +28 lines)
Lines 288-293 char dummy_boot_code[BOOTCODE_SIZE] = Link Here
288
static char *program_name = "mkdosfs";	/* Name of the program */
288
static char *program_name = "mkdosfs";	/* Name of the program */
289
static char *device_name = NULL;	/* Name of the device on which to create the filesystem */
289
static char *device_name = NULL;	/* Name of the device on which to create the filesystem */
290
static int atari_format = 0;	/* Use Atari variation of MS-DOS FS format */
290
static int atari_format = 0;	/* Use Atari variation of MS-DOS FS format */
291
static const char *bootcode_srcimage = NULL;  /* Source file/device from which read bootloader code */
291
static int check = FALSE;	/* Default to no readablity checking */
292
static int check = FALSE;	/* Default to no readablity checking */
292
static int verbose = 0;		/* Default to verbose mode off */
293
static int verbose = 0;		/* Default to verbose mode off */
293
static long volume_id;		/* Volume ID number */
294
static long volume_id;		/* Volume ID number */
Lines 793-798 establish_params (int device_num,int siz Link Here
793
}
794
}
794
795
795
796
797
static void
798
apply_external_bootcode(void)
799
{
800
  if ( !bootcode_srcimage )
801
    return;
802
  char *bootcodeptr = ( size_fat == 32 ) ?
803
    ( (char*) &bs.fat32.boot_code ) : ( (char*) &bs.oldfat.boot_code );
804
  int offset = ( int )( bootcodeptr - (char*)&bs );
805
  int nbytes = ( size_fat == 32 ) ? BOOTCODE_FAT32_SIZE : BOOTCODE_SIZE;
806
  int srcfile = open( bootcode_srcimage, O_RDONLY );
807
  if ( srcfile < 0 )
808
    die("Cannot open device/file for reading source bootloader code");
809
  if ( lseek( srcfile, offset, SEEK_SET ) < 0)
810
    die("Cannot seek to begin of source bootloader code");
811
  if ( read( srcfile, bootcodeptr, nbytes ) != nbytes )
812
    die("Cannot read source bootloader code");
813
}
814
796
/* Create the filesystem data tables */
815
/* Create the filesystem data tables */
797
816
798
static void
817
static void
Lines 851-856 setup_tables (void) Link Here
851
			(char *)&bs.oldfat.boot_code) -
870
			(char *)&bs.oldfat.boot_code) -
852
		       (char *)&bs) - 2;
871
		       (char *)&bs) - 2;
853
872
873
    if (bootcode_srcimage) {
874
        apply_external_bootcode();
875
    } else
854
    if (size_fat == 32) {
876
    if (size_fat == 32) {
855
	int offset = (char *)&bs.fat32.boot_code -
877
	int offset = (char *)&bs.fat32.boot_code -
856
		     (char *)&bs + MESSAGE_OFFSET + 0x7c00;
878
		     (char *)&bs + MESSAGE_OFFSET + 0x7c00;
Lines 1379-1385 usage (void) Link Here
1379
{
1401
{
1380
  fatal_error("\
1402
  fatal_error("\
1381
Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] [-b backup-boot-sector]\n\
1403
Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] [-b backup-boot-sector]\n\
1382
       [-m boot-msg-file] [-n volume-name] [-i volume-id]\n\
1404
       [-m boot-msg-file] [-n volume-name] [-i volume-id] [-B bootcode-image ]\n\
1383
       [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n\
1405
       [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs]\n\
1384
       [-h hidden-sectors] [-F fat-size] [-r root-dir-entries] [-R reserved-sectors]\n\
1406
       [-h hidden-sectors] [-F fat-size] [-r root-dir-entries] [-R reserved-sectors]\n\
1385
       /dev/name [blocks]\n");
1407
       /dev/name [blocks]\n");
Lines 1442-1448 main (int argc, char **argv) Link Here
1442
  printf ("%s " VERSION " (" VERSION_DATE ")\n",
1464
  printf ("%s " VERSION " (" VERSION_DATE ")\n",
1443
	   program_name);
1465
	   program_name);
1444
1466
1445
  while ((c = getopt (argc, argv, "AbcCf:F:Ii:l:m:n:r:R:s:S:h:v")) != EOF)
1467
  while ((c = getopt (argc, argv, "AB:bcCf:F:Ii:l:m:n:r:R:s:S:h:v")) != EOF)
1446
    /* Scan the command line for options */
1468
    /* Scan the command line for options */
1447
    switch (c)
1469
    switch (c)
1448
      {
1470
      {
Lines 1450-1455 main (int argc, char **argv) Link Here
1450
	atari_format = !atari_format;
1472
	atari_format = !atari_format;
1451
	break;
1473
	break;
1452
1474
1475
      case 'B':
1476
        bootcode_srcimage = optarg;
1477
        break;
1478
1453
      case 'b':		/* b : location of backup boot sector */
1479
      case 'b':		/* b : location of backup boot sector */
1454
	backup_boot = (int) strtol (optarg, &tmp, 0);
1480
	backup_boot = (int) strtol (optarg, &tmp, 0);
1455
	if (*tmp || backup_boot < 2 || backup_boot > 0xffff)
1481
	if (*tmp || backup_boot < 2 || backup_boot > 0xffff)
(-)mkdosfs/mkdosfs.8.bootcode (+13 lines)
Lines 9-14 Link Here
9
.B \-A
9
.B \-A
10
]
10
]
11
[
11
[
12
.B \-B 
13
.I source-bootcode-container
14
]
15
[
12
.B \-b 
16
.B \-b 
13
.I sector-of-backup
17
.I sector-of-backup
14
]
18
]
Lines 97-102 Link Here
97
option. Some PC-specific boot sector fields aren't written, and a boot
101
option. Some PC-specific boot sector fields aren't written, and a boot
98
message (option \fB\-m\fP) is ignored.
102
message (option \fB\-m\fP) is ignored.
99
.TP
103
.TP
104
.BI \-B " source-bootcode-container "
105
By default \fBmkdosfs\fP writes bootsector containing dummy code
106
that does nothing except displays stupid message. If you want to create
107
bootable DOS diskette and are ABSOULTELY sure that it has the same format
108
as another already existing diskette (most important is difference
109
between FAT and FAT32), you can extract boot loader from it.
110
\fIsource-container\fP should be device file like /dev/fd0,
111
as well as regular file like /mnt/windows/bootcode.dos
112
.TP
100
.BI \-b " sector-of-backup "
113
.BI \-b " sector-of-backup "
101
Selects the location of the backup boot sector for FAT32. Default
114
Selects the location of the backup boot sector for FAT32. Default
102
depends on number of reserved sectors, but usually is sector 6. The
115
depends on number of reserved sectors, but usually is sector 6. The

Return to bug 6389