Path: utzoo!attcan!uunet!mcvax!unido!fauern!faui44!rtregn From: rtregn@faui44.informatik.uni-erlangen.de (Robert Regn ) Newsgroups: comp.os.minix Subject: Re: DOS[READ\WRITE\DIR] on hard disk Message-ID: <342@faui10.informatik.uni-erlangen.de> Date: 30 May 88 18:57:43 GMT References: <2649@louie.udel.EDU> Organization: CSD., University of Erlangen, W-Germany Lines: 136 Posted: Mon May 30 19:57:43 1988 I've already tried to modify DOSxxx to handle hard disk's. It uses the boot sector. I made a link of /dev/hd to /dev/at2, so I need not remember which partition is dos. The program - diff to 1.2 is included - works (for 12 bit fats) ok as dosdir and dosread, but as doswrite it destroys my dos partition (e.g. root dir)! Make a 100KB backup of the dos partition with dd if you try doswrite. I've put debug messages in "disk_io", but the behavior seems ok. If i use doswrite on a file which contains a copy of the dos partitions first MB, the program works! (Is the problem caused by the driver ??) Can somebody send me the "mega-equation" referenced by Marty ? Can somebody say what hiddensec means ? ------------------------------ diff to dosread.c 1.2 --------------- 20a21 > #define HARDDISK 0xF8 22,24c23,25 < #define MAX_CLUSTER_SIZE 1024 < #define MAX_FAT_SIZE 3584 /* 7 sectoren */ < #define MAX_ROOT_ENTRIES 224 /* 14 sectoren */ --- > #define MAX_CLUSTER_SIZE 4096 > #define MAX_FAT_SIZE 6144 > #define MAX_ROOT_ENTRIES 512 89c90 < short total_clusters, cluster_size, fat_size, --- > unsigned short total_clusters, cluster_size, fat_size, 114a116,141 > determine() > { > struct dosboot { > short jump; > char nop; > char name[8]; > char byteps_1; /* short wuerde um 1byte hochgeschoben */ > char byteps_2; > char secpclus; > short reservsec; > char fats; > char rooten_1; /* Alignment */ > char rooten_2; > char totsec_1; > char totsec_2; > char media; > short secpfat; > short secptrack; > short heads; > short hiddensec; > /* char fill[482]; */ > } boot; > unsigned int bytepers, dirents, totsec; > char stderr[100]; > /* read Bios-Parameterblock */ > disk_read(0L, &boot, sizeof boot); 115a143,190 > bytepers = ((int) boot.byteps_2) <<8 + boot.byteps_1; > dirents = ((int) boot.rooten_2) <<8 + boot.rooten_1; > /*totsec = ((int) boot.totsec_2) <<8 + boot.totsec_1;*/ > totsec = boot.totsec_2 <<8; > totsec += boot.totsec_1; > > total_clusters = totsec/boot.secpclus; > cluster_size = bytepers * boot.secpclus; > fat_size = boot.secpfat * bytepers; > data_start = bytepers + boot.fats* fat_size + dirents * 32; > root_entries = dirents; > sub_entries = boot.secpclus * bytepers/32; > > #ifdef debug > sprintf(stderr, "fatsize: %u totclusters: %u totsec %u ( %x %x)\n", > fat_size,total_clusters, totsec, boot.totsec_2, boot.totsec_1); > write(2,stderr, strlen(stderr)); > sprintf(stderr, "dirents %u bytepers %u\n", dirents, bytepers); > write(2,stderr, strlen(stderr)); > #endif > > /* safety checking */ > if ( boot.fats != 2 && dos_write) > {print_string (TRUE, "fats != 2 - Can't handle disk\n"); > leave (2); > } > if ( boot.reservsec != 1) > {print_string (TRUE, "reserved != 1 - Can't handle disk\n"); > leave (2); > } > if ( total_clusters > 4096) > {print_string (TRUE, "no 12 Bit fat - Can't handle disk\n"); > leave (2); > } > if (fat_size > MAX_FAT_SIZE) > {print_string (TRUE, "fatsize to big - Can't handle disk\n"); > leave (2); > } > if (cluster_size > MAX_CLUSTER_SIZE) > {print_string (TRUE, "clustersize to big - Can't handle disk\n"); > leave (2); > } > if ( boot.media &0xFF != HARDDISK) > {printf("improper media descriptor: %x\n", boot.media); > leave (2); > } > } > 184a260,261 > else if (fat[0] == HARDDISK) /*Hard Disk*/ > determine(); 199c276 < if (dos_dir) { --- > if (dos_dir && Lflag) { 211c288,289 < print(STD_OUT, "Root directory:\n", 0); --- > if (Lflag) > print(STD_OUT, "Root directory:\n", 0); 213c291,292 < free_blocks(); --- > if (Lflag) > free_blocks(); 229c308 < if (dos_dir) --- > if (dos_dir && Lflag) 236c315,316 < free_blocks(); --- > if (Lflag) > free_blocks(); ------------------------------ end diff to dosread.c 1.2 --------------- Robert Regn