Path: utzoo!attcan!uunet!mcvax!unido!fauern!faui44!immd3.informatik.uni-erlangen.de!rtregn From: rtregn@immd3.informatik.uni-erlangen.de (Robert Regn) Newsgroups: comp.os.minix Subject: Re: Fdisk Message-ID: <810@faui10.informatik.uni-erlangen.de> Date: 20 Jan 89 19:32:16 GMT References: <1904@ast.cs.vu.nl> Organization: IMMD I, University of Erlangen, W-Erlangen Lines: 147 From article <1904@ast.cs.vu.nl>, by ast@cs.vu.nl (Andy Tanenbaum): > > The fdisk that Robert Regn posted a while back came in here truncated. Could > you please post the cdif against 1.3 again. Has this been thoroughly tested? > Fdisk is not the kind of program one would like to have bugs in. > For such disks I have a little improved fdisk.c. It's usage is: fdisk [-heads] [/dev/hdx] The default is -4 and /dev/hd0. It recognizes DOS4 (for 3.3) and Xenix partitions also. I have used it several times. The changes are not great so I think it has no bugs - and it prints the number of heads for your check. A good improvement would be to print the partitions in the same order as they are mapped by the disk driver into /dev/hd[1-4]. So the danger destroying another filesystem with mkfs is reduced. *** minix/1.3/a.fertig/commands/fdisk.c Tue Oct 4 12:43:10 1988 --- FDISK.C Tue Dec 6 16:53:34 1988 *************** *** 55,61 **** --- 55,64 ---- char secbuf[SECSIZE]; char *devname; char *dosstr = " DOS "; + char *dosstr4 = " DOS 4"; char *ndosstr = "Non-DOS"; + char *xenstr = " Xenix "; + int heads; #ifdef DOS union REGS regs; *************** *** 75,86 **** /* init */ ! if (argc != 2) { ! printf("Usage: fdisk /dev/hdx\n"); exit(1); } ! devname = argv[1]; getboot(secbuf); /* get boot sector */ do { --- 78,99 ---- /* init */ ! if ( argc > 1 && (*++argv)[0] == '-') /*flag*/ ! {heads = atoi( & (*argv)[1]); ! printf("heads: %d ", heads); ! argv++; ! argc--; ! } ! else heads = NHEAD; ! ! if (argc > 2) { ! printf("Usage: fdisk [-heads] [/dev/hdx]\n"); exit(1); } ! if ( argc == 1) ! devname = "/dev/hd0"; ! else devname = *argv; getboot(secbuf); /* get boot sector */ do { *************** *** 339,346 **** if (entry->sysind == 0x01) typestring = dosstr; ! else ! typestring = ndosstr; printf("%5d %s ",number,typestring); temp = entry->start_sec & 0xc0; low_cyl = (entry->start_cyl & 0xff) + (temp << 2); --- 352,363 ---- if (entry->sysind == 0x01) typestring = dosstr; ! else if (entry->sysind == 0x02) ! typestring = xenstr; ! else if (entry->sysind == 0x04) ! typestring = dosstr4; ! else ! typestring = ndosstr; printf("%5d %s ",number,typestring); temp = entry->start_sec & 0xc0; low_cyl = (entry->start_cyl & 0xff) + (temp << 2); *************** *** 423,432 **** { int bigcyl; ! bigcyl = logsec / (NHEAD * NSEC); *sec = (logsec % NSEC) + 1 + ((bigcyl >> 2) & 0xc0); *cyl = bigcyl & 0xff; ! *hd = (logsec % (NHEAD * NSEC)) / NSEC; } /* --- 440,449 ---- { int bigcyl; ! bigcyl = logsec / (heads * NSEC); *sec = (logsec % NSEC) + 1 + ((bigcyl >> 2) & 0xc0); *cyl = bigcyl & 0xff; ! *hd = (logsec % (heads * NSEC)) / NSEC; } /* *************** *** 487,497 **** return; } low = first & 0xffff; ! low = low * NSEC * NHEAD; if (low == 0) low = 1; /* sec0 is master boot record */ high = last & 0xffff; ! high = (high + 1)*NSEC*NHEAD - 1; entry->lowsec = low; entry->size = high - low + 1; sec_to_hst(low, --- 504,514 ---- return; } low = first & 0xffff; ! low = low * NSEC * heads; if (low == 0) low = 1; /* sec0 is master boot record */ high = last & 0xffff; ! high = (high + 1)*NSEC*heads - 1; entry->lowsec = low; entry->size = high - low + 1; sec_to_hst(low, ------------------------------------------------- Robert Regn rtregn@faui32.uucp rtregn@immd3.informatik.uni-erlangen.de West Germany