summaryrefslogtreecommitdiff
path: root/sbin/fdisk/user.c
diff options
context:
space:
mode:
authorDale S. Rahn <rahnds@cvs.openbsd.org>1998-09-14 03:54:36 +0000
committerDale S. Rahn <rahnds@cvs.openbsd.org>1998-09-14 03:54:36 +0000
commit430fb2f326b8644b48e9dfac81edad297a72017d (patch)
tree3f5611ed885aa0e2a060ca4f738794819fbb6ef5 /sbin/fdisk/user.c
parent62d203b1aea6a5195937032bb27c074afa7e2f7c (diff)
Since on the powerpc, the system does not supply the user with
bios valid cyl,head,sector information (the information comes from the sd driver) I have made some changes to fdisk to do the following. Allow the powerpc to specify values larger than the bios limits. All platforms now have code that will translate the LBA values in the mbr into CHS values according to the disk geometry. This occurs if the start and ending CHS values have been stored as 0xffffff. If writing to the disk and one of the values of a partition violates the bios limits, it writes the requested values in the LBA fields , and stores 0xffffff for the starting and ending CHS values. This should not change the default formatting of any existing system other than the CHS and LBA values should always match given the detected geometry of the disk.
Diffstat (limited to 'sbin/fdisk/user.c')
-rw-r--r--sbin/fdisk/user.c38
1 files changed, 5 insertions, 33 deletions
diff --git a/sbin/fdisk/user.c b/sbin/fdisk/user.c
index 7cd9497c63c..f771fe965b5 100644
--- a/sbin/fdisk/user.c
+++ b/sbin/fdisk/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.13 1998/09/08 11:03:16 pefo Exp $ */
+/* $OpenBSD: user.c,v 1.14 1998/09/14 03:54:35 rahnds Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -74,36 +74,8 @@ USER_init(disk, tt)
int fd;
char mbr_buf[DEV_BSIZE];
- /* Fix up given mbr for this disk */
- tt->part[0].flag = 0;
- tt->part[1].flag = 0;
- tt->part[2].flag = 0;
- tt->part[3].flag = DOSACTIVE;
- tt->signature = DOSMBR_SIGNATURE;
-
- /* Use whole disk, save for first head, on first cyl. */
- tt->part[3].id = DOSPTYP_OPENBSD;
- tt->part[3].scyl = 0;
- tt->part[3].shead = 1;
- tt->part[3].ssect = 1;
-
- /* Go right to the end */
- tt->part[3].ecyl = disk->real->cylinders;
- tt->part[3].ehead = disk->real->heads;
- tt->part[3].esect = disk->real->sectors;
-
- /* Fix up start/length fields */
- PRT_fix_BN(disk, &tt->part[3]);
-
-#if defined(__powerpc__)
- /* Now fix up for the MS-DOS boot partition on PowerPC. */
- tt->part[0].flag = DOSACTIVE; /* Boot from dos part */
- tt->part[3].flag = 0;
- tt->part[3].ns += tt->part[3].bs;
- tt->part[3].bs = tt->part[0].bs + tt->part[0].ns;
- tt->part[3].ns -= tt->part[3].bs;
- PRT_fix_CHS(disk, &tt->part[3]);
-#endif
+ MBR_init(disk, tt);
+
/* Write sector 0 */
printf("\a\n"
"\t-----------------------------------------------------\n"
@@ -147,7 +119,7 @@ USER_modify(disk, tt, offset, reloff)
DISK_close(fd);
/* Parse the sucker */
- MBR_parse(mbr_buf, offset, reloff, &mbr);
+ MBR_parse(disk, mbr_buf, offset, reloff, &mbr);
printf("Enter 'help' for information\n");
@@ -222,7 +194,7 @@ USER_print_disk(disk)
do {
MBR_read(fd, (off_t)offset, mbr_buf);
- MBR_parse(mbr_buf, offset, firstoff, &mbr);
+ MBR_parse(disk, mbr_buf, offset, firstoff, &mbr);
printf("Offset: %d\t", (int)offset);
MBR_print(&mbr);