summaryrefslogtreecommitdiff
path: root/sbin/fdisk/cmd.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-10-18 11:52:33 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-10-18 11:52:33 +0000
commit35d4e28726a47268315c7419564895a3d4855b14 (patch)
tree2199f90c93a0b059eeabdeeb0d2ed338b0f13c8d /sbin/fdisk/cmd.c
parent15a5caadb8799f5d3c002a905086849c7ab9eee7 (diff)
constrain edit mode to size of BIOS part of disk; sorry
Diffstat (limited to 'sbin/fdisk/cmd.c')
-rw-r--r--sbin/fdisk/cmd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c
index 4dce5bc6ac7..704e39c7104 100644
--- a/sbin/fdisk/cmd.c
+++ b/sbin/fdisk/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.7 1997/10/16 10:35:05 deraadt Exp $ */
+/* $OpenBSD: cmd.c,v 1.8 1997/10/18 11:52:32 deraadt Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -42,7 +42,7 @@
#include "user.h"
#include "part.h"
#include "cmd.h"
-
+#define MAX(a, b) ((a) >= (b) ? (a) : (b))
int
Xreinit(cmd, disk, mbr, tt, offset)
@@ -177,11 +177,13 @@ Xedit(cmd, disk, mbr, tt, offset)
/* Fix up off/size values */
PRT_fix_BN(disk, pp);
}else{
+ u_int m;
/* Get data */
EDIT("Partition offset", ASK_DEC, pp->bs, 0,
disk->real->size, NULL);
+ m = MAX(pp->ns, disk->real->size - pp->bs);
EDIT("Partition size", ASK_DEC, pp->ns, 1,
- disk->real->size - pp->bs, NULL);
+ m, NULL);
/* Fix up CHS values */
PRT_fix_CHS(disk, pp);