diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-08-03 09:22:04 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-08-03 09:22:04 +0000 |
commit | 85c84ba9cd61ff4de8f4186927df8dce84c95fb6 (patch) | |
tree | 34dec2ab1d45ea908745d1d275df76d7ed022ac5 /sbin | |
parent | 9b1aa772395e0900e74204af7ab100140c4c120f (diff) |
Handle geometry parameters as unsigned quantities, getting rid of negative
number of sectors on large disks and other similar problems.
ok toby@ tom@ deraadt@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fdisk/disk.h | 10 | ||||
-rw-r--r-- | sbin/fdisk/fdisk.c | 11 | ||||
-rw-r--r-- | sbin/fdisk/part.c | 16 | ||||
-rw-r--r-- | sbin/fdisk/part.h | 10 |
4 files changed, 25 insertions, 22 deletions
diff --git a/sbin/fdisk/disk.h b/sbin/fdisk/disk.h index 8fe1b2d5e1f..361ae532171 100644 --- a/sbin/fdisk/disk.h +++ b/sbin/fdisk/disk.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disk.h,v 1.7 2003/06/03 01:13:19 weingart Exp $ */ +/* $OpenBSD: disk.h,v 1.8 2004/08/03 09:22:03 otto Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -30,10 +30,10 @@ /* Data types */ typedef struct _DISK_metrics { - int cylinders; - int heads; - int sectors; - int size; + u_int32_t cylinders; + u_int32_t heads; + u_int32_t sectors; + u_int32_t size; } DISK_metrics; typedef struct _disk_t { diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index eb7df39302b..086bc824944 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdisk.c,v 1.38 2004/01/07 16:28:52 tom Exp $ */ +/* $OpenBSD: fdisk.c,v 1.39 2004/08/03 09:22:03 otto Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -89,17 +89,20 @@ main(int argc, char *argv[]) case 'c': c_arg = atoi(optarg); if (c_arg < 1 || c_arg > 262144) - errx(1, "Cylinder argument out of range."); + errx(1, "Cylinder argument out of range " + "[1..262144]."); break; case 'h': h_arg = atoi(optarg); if (h_arg < 1 || h_arg > 256) - errx(1, "Head argument out of range."); + errx(1, "Head argument out of range " + "[1..256]."); break; case 's': s_arg = atoi(optarg); if (s_arg < 1 || s_arg > 63) - errx(1, "Sector argument out of range."); + errx(1, "Sector argument out of range " + "[1..63]."); break; default: usage(); diff --git a/sbin/fdisk/part.c b/sbin/fdisk/part.c index 1f01a2aefbc..7c27afeda98 100644 --- a/sbin/fdisk/part.c +++ b/sbin/fdisk/part.c @@ -1,4 +1,4 @@ -/* $OpenBSD: part.c,v 1.38 2004/07/13 06:00:33 tom Exp $ */ +/* $OpenBSD: part.c,v 1.39 2004/08/03 09:22:03 otto Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -284,7 +284,7 @@ PRT_print(int num, prt_t *partn, char *units) } else { size = (double)partn->ns * DEV_BSIZE / unit_types[i].conversion; - printf("%c%1d: %.2X %4d %3d %2d - %4d %3d %2d [%12d:%12.0f%s] %s\n", + printf("%c%1d: %.2X %4u %3u %2u - %4u %3u %2u [%12u:%12.0f%s] %s\n", (partn->flag == 0x80)?'*':' ', num, partn->id, partn->scyl, partn->shead, partn->ssect, @@ -298,9 +298,9 @@ PRT_print(int num, prt_t *partn, char *units) void PRT_fix_BN(disk_t *disk, prt_t *part, int pn) { - int spt, tpc, spc; - int start = 0; - int end = 0; + u_int32_t spt, tpc, spc; + u_int32_t start = 0; + u_int32_t end = 0; /* Zero out entry if not used */ if (part->id == DOSPTYP_UNUSED ) { @@ -332,9 +332,9 @@ PRT_fix_BN(disk_t *disk, prt_t *part, int pn) void PRT_fix_CHS(disk_t *disk, prt_t *part) { - int spt, tpc, spc; - int start, end, size; - int cyl, head, sect; + u_int32_t spt, tpc, spc; + u_int32_t start, end, size; + u_int32_t cyl, head, sect; /* Zero out entry if not used */ if (part->id == DOSPTYP_UNUSED ) { diff --git a/sbin/fdisk/part.h b/sbin/fdisk/part.h index bcc13b8164e..adcd6f556aa 100644 --- a/sbin/fdisk/part.h +++ b/sbin/fdisk/part.h @@ -1,4 +1,4 @@ -/* $OpenBSD: part.h,v 1.12 2004/07/13 06:00:33 tom Exp $ */ +/* $OpenBSD: part.h,v 1.13 2004/08/03 09:22:03 otto Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -30,10 +30,10 @@ /* Partition type */ typedef struct _prt_t { - int shead, scyl, ssect; - int ehead, ecyl, esect; - int bs; - int ns; + u_int32_t shead, scyl, ssect; + u_int32_t ehead, ecyl, esect; + u_int32_t bs; + u_int32_t ns; unsigned char flag; unsigned char id; } prt_t; |