|
@@ -24,7 +24,7 @@
|
|
|
- New options -A, -S, -C
|
|
|
- Support for filesystems > 2GB
|
|
|
- FAT32 support
|
|
|
-
|
|
|
+
|
|
|
Copying: Copyright 1993, 1994 David Hudson (dave@humbug.demon.co.uk)
|
|
|
|
|
|
Portions copyright 1992, 1993 Remy Card (card@masi.ibp.fr)
|
|
@@ -85,7 +85,7 @@
|
|
|
#define CT_LE_W(v) CF_LE_W(v)
|
|
|
#define CT_LE_L(v) CF_LE_L(v)
|
|
|
#endif /* defined(__le16_to_cpu) */
|
|
|
-
|
|
|
+
|
|
|
#else
|
|
|
|
|
|
#define CF_LE_W(v) (v)
|
|
@@ -604,7 +604,7 @@ establish_params (int device_num,int size)
|
|
|
case 720:
|
|
|
param.sect = 9 ;
|
|
|
param.head = 2;
|
|
|
- break;
|
|
|
+ break;
|
|
|
case 1440:
|
|
|
param.sect = 9;
|
|
|
param.head = 2;
|
|
@@ -627,7 +627,7 @@ establish_params (int device_num,int size)
|
|
|
param.head = 64;
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
else /* is a floppy diskette */
|
|
|
{
|
|
@@ -658,7 +658,7 @@ establish_params (int device_num,int size)
|
|
|
bs.dir_entries[0] = (char) 224;
|
|
|
bs.dir_entries[1] = (char) 0;
|
|
|
break;
|
|
|
-
|
|
|
+
|
|
|
case 5760: /* 3.5", 2, 36, 80 - 2880K */
|
|
|
bs.media = (char) 0xf0;
|
|
|
bs.cluster_size = (char) 2;
|
|
@@ -683,7 +683,7 @@ establish_params (int device_num,int size)
|
|
|
}
|
|
|
else if ((device_num & 0xff00) == 0x0700) /* This is a loop device */
|
|
|
{
|
|
|
- if (ioctl (dev, BLKGETSIZE, &loop_size))
|
|
|
+ if (ioctl (dev, BLKGETSIZE, &loop_size))
|
|
|
die ("unable to get loop device size");
|
|
|
|
|
|
switch (loop_size) /* Assuming the loop device -> floppy later */
|
|
@@ -714,7 +714,7 @@ establish_params (int device_num,int size)
|
|
|
bs.dir_entries[0] = (char) 224;
|
|
|
bs.dir_entries[1] = (char) 0;
|
|
|
break;
|
|
|
-
|
|
|
+
|
|
|
case 5760: /* 3.5", 2, 36, 80 - 2880K */
|
|
|
bs.secs_track = CF_LE_W(36);
|
|
|
bs.heads = CF_LE_W(2);
|
|
@@ -796,7 +796,7 @@ setup_tables (void)
|
|
|
unsigned fatdata; /* Sectors for FATs + data area */
|
|
|
struct tm *ctime;
|
|
|
struct msdos_volume_info *vi = (size_fat == 32 ? &bs.fat32.vi : &bs.oldfat.vi);
|
|
|
-
|
|
|
+
|
|
|
if (atari_format)
|
|
|
/* On Atari, the first few bytes of the boot sector are assigned
|
|
|
* differently: The jump code is only 2 bytes (and m68k machine code
|
|
@@ -836,7 +836,7 @@ setup_tables (void)
|
|
|
|
|
|
if (!atari_format) {
|
|
|
memcpy(vi->volume_label, volume_name, 11);
|
|
|
-
|
|
|
+
|
|
|
memcpy(bs.boot_jump, dummy_boot_jump, 3);
|
|
|
/* Patch in the correct offset to the boot code */
|
|
|
bs.boot_jump[1] = ((size_fat == 32 ?
|
|
@@ -892,7 +892,7 @@ setup_tables (void)
|
|
|
unsigned maxclust12, maxclust16, maxclust32;
|
|
|
unsigned clust12, clust16, clust32;
|
|
|
int maxclustsize;
|
|
|
-
|
|
|
+
|
|
|
fatdata = num_sectors - cdiv (root_dir_entries * 32, sector_size) -
|
|
|
reserved_sectors;
|
|
|
|
|
@@ -1040,14 +1040,14 @@ setup_tables (void)
|
|
|
bs.fat32.fat32_length = CT_LE_L(fatlength32);
|
|
|
memcpy(vi->fs_type, MSDOS_FAT32_SIGN, 8);
|
|
|
break;
|
|
|
-
|
|
|
+
|
|
|
default:
|
|
|
die("FAT not 12, 16 or 32 bits");
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
unsigned clusters, maxclust;
|
|
|
-
|
|
|
+
|
|
|
/* GEMDOS always uses a 12 bit FAT on floppies, and always a 16 bit FAT on
|
|
|
* hard disks. So use 12 bit if the size of the file system suggests that
|
|
|
* this fs is for a floppy disk, if the user hasn't explicitly requested a
|
|
@@ -1093,7 +1093,7 @@ setup_tables (void)
|
|
|
if (verbose >= 2)
|
|
|
printf( "ss=%d: #clu=%d, fat_len=%d, maxclu=%d\n",
|
|
|
sector_size, clusters, fat_length, maxclust );
|
|
|
-
|
|
|
+
|
|
|
/* last 10 cluster numbers are special (except FAT32: 4 high bits rsvd);
|
|
|
* first two numbers are reserved */
|
|
|
if (maxclust <= (size_fat == 32 ? MAX_CLUST_32 : (1<<size_fat)-0x10) &&
|
|
@@ -1110,7 +1110,7 @@ setup_tables (void)
|
|
|
num_sectors >>= 1;
|
|
|
sector_size <<= 1;
|
|
|
} while( sector_size <= GEMDOS_MAX_SECTOR_SIZE );
|
|
|
-
|
|
|
+
|
|
|
if (sector_size > GEMDOS_MAX_SECTOR_SIZE)
|
|
|
die( "Would need a sector size > 16k, which GEMDOS can't work with");
|
|
|
|
|
@@ -1150,7 +1150,7 @@ setup_tables (void)
|
|
|
bs.fat32.backup_boot = CT_LE_W(backup_boot);
|
|
|
memset( &bs.fat32.reserved2, 0, sizeof(bs.fat32.reserved2) );
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (atari_format) {
|
|
|
/* Just some consistency checks */
|
|
|
if (num_sectors >= GEMDOS_MAX_SECTORS)
|
|
@@ -1184,7 +1184,7 @@ setup_tables (void)
|
|
|
die ("Attempting to create a too large file system");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/* The two following vars are in hard sectors, i.e. 512 byte sectors! */
|
|
|
start_data_sector = (reserved_sectors + nr_fats * fat_length) *
|
|
|
(sector_size/HARD_SECTOR_SIZE);
|
|
@@ -1198,7 +1198,7 @@ setup_tables (void)
|
|
|
{
|
|
|
printf("%s has %d head%s and %d sector%s per track,\n",
|
|
|
device_name, CF_LE_W(bs.heads), (CF_LE_W(bs.heads) != 1) ? "s" : "",
|
|
|
- CF_LE_W(bs.secs_track), (CF_LE_W(bs.secs_track) != 1) ? "s" : "");
|
|
|
+ CF_LE_W(bs.secs_track), (CF_LE_W(bs.secs_track) != 1) ? "s" : "");
|
|
|
printf("logical sector size is %d,\n",sector_size);
|
|
|
printf("using 0x%02x media descriptor, with %d sectors;\n",
|
|
|
(int) (bs.media), num_sectors);
|
|
@@ -1270,7 +1270,7 @@ setup_tables (void)
|
|
|
if (size_fat == 32) {
|
|
|
/* For FAT32, create an info sector */
|
|
|
struct fat32_fsinfo *info;
|
|
|
-
|
|
|
+
|
|
|
if (!(info_sector = malloc( sector_size )))
|
|
|
die("Out of memory");
|
|
|
memset(info_sector, 0, sector_size);
|
|
@@ -1292,7 +1292,7 @@ setup_tables (void)
|
|
|
/* Info sector also must have boot sign */
|
|
|
*(__u16 *)(info_sector + 0x1fe) = CT_LE_W(BOOT_SIGN);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (!(blank_sector = malloc( sector_size )))
|
|
|
die( "Out of memory" );
|
|
|
memset(blank_sector, 0, sector_size);
|
|
@@ -1423,7 +1423,7 @@ main (int argc, char **argv)
|
|
|
int create = 0;
|
|
|
unsigned long long cblocks;
|
|
|
int min_sector_size;
|
|
|
-
|
|
|
+
|
|
|
if (argc && *argv) { /* What's the program name? */
|
|
|
char *p;
|
|
|
program_name = *argv;
|
|
@@ -1434,7 +1434,7 @@ main (int argc, char **argv)
|
|
|
time(&create_time);
|
|
|
volume_id = (long)create_time; /* Default volume ID = creation time */
|
|
|
check_atari();
|
|
|
-
|
|
|
+
|
|
|
printf ("%s " VERSION " (" VERSION_DATE ")\n",
|
|
|
program_name);
|
|
|
|
|
@@ -1454,7 +1454,7 @@ main (int argc, char **argv)
|
|
|
usage ();
|
|
|
}
|
|
|
break;
|
|
|
-
|
|
|
+
|
|
|
case 'c': /* c : Check FS as we build it */
|
|
|
check = TRUE;
|
|
|
break;
|
|
@@ -1566,10 +1566,10 @@ main (int argc, char **argv)
|
|
|
while( i < BOOTCODE_SIZE-1 )
|
|
|
dummy_boot_code[i++] = '\0';
|
|
|
dummy_boot_code[BOOTCODE_SIZE-1] = '\0'; /* Just in case */
|
|
|
-
|
|
|
+
|
|
|
if ( ch != EOF )
|
|
|
printf ("Warning: message too long; truncated\n");
|
|
|
-
|
|
|
+
|
|
|
if ( msgfile != stdin )
|
|
|
fclose(msgfile);
|
|
|
}
|
|
@@ -1596,7 +1596,7 @@ main (int argc, char **argv)
|
|
|
usage ();
|
|
|
}
|
|
|
break;
|
|
|
-
|
|
|
+
|
|
|
case 's': /* s : Sectors per cluster */
|
|
|
sectors_per_cluster = (int) strtol (optarg, &tmp, 0);
|
|
|
if (*tmp || (sectors_per_cluster != 1 && sectors_per_cluster != 2
|
|
@@ -1625,7 +1625,7 @@ main (int argc, char **argv)
|
|
|
case 'v': /* v : Verbose execution */
|
|
|
++verbose;
|
|
|
break;
|
|
|
-
|
|
|
+
|
|
|
default:
|
|
|
printf( "Unknown option: %c\n", c );
|
|
|
usage ();
|
|
@@ -1694,7 +1694,7 @@ main (int argc, char **argv)
|
|
|
if (llseek( dev, 0, SEEK_SET ) != 0)
|
|
|
die( "seek failed" );
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (fstat (dev, &statbuf) < 0)
|
|
|
die ("unable to stat %s");
|
|
|
if (!S_ISBLK (statbuf.st_mode)) {
|
|
@@ -1736,11 +1736,11 @@ main (int argc, char **argv)
|
|
|
}
|
|
|
|
|
|
if (sector_size > 4096)
|
|
|
- fprintf(stderr,
|
|
|
+ fprintf(stderr,
|
|
|
"Warning: sector size is set to %d > 4096, such filesystem will not propably mount\n",
|
|
|
sector_size);
|
|
|
|
|
|
- establish_params (statbuf.st_rdev,statbuf.st_size);
|
|
|
+ establish_params (statbuf.st_rdev,statbuf.st_size);
|
|
|
/* Establish the media parameters */
|
|
|
|
|
|
setup_tables (); /* Establish the file system tables */
|