summaryrefslogtreecommitdiffstats
path: root/sbin/fdisk
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1994-10-19 21:25:28 +0000
committerbde <bde@FreeBSD.org>1994-10-19 21:25:28 +0000
commitf7b7df385e7529f0ec16791f85618ccbdebaefc8 (patch)
tree07973555e89fd201cbf94e6a51832b9214a9c884 /sbin/fdisk
parent5db7e440c85470c3e334465686d498bb7fb1de59 (diff)
downloadFreeBSD-src-f7b7df385e7529f0ec16791f85618ccbdebaefc8.zip
FreeBSD-src-f7b7df385e7529f0ec16791f85618ccbdebaefc8.tar.gz
Don't change the active partition when the user says not to change it.
Convert absolute sector 0 to C/H/S 0/0/0, not 0/0/1. Open in O_RDWR mode for the undocumented -a option, so that -a can be used without -u.
Diffstat (limited to 'sbin/fdisk')
-rw-r--r--sbin/fdisk/fdisk.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index 9339060..cc8b564 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/fdisk/fdisk.c
@@ -390,11 +390,11 @@ struct dos_partition *partp = ((struct dos_partition *) &mboot.parts);
if (a_flag && which != -1)
active = which;
- if (ok("Do you want to change the active partition?")) {
- do
- Decimal("active partition", active, tmp);
- while(!ok("Are you happy with this choice"));
- }
+ if (!ok("Do you want to change the active partition?"))
+ return;
+ do
+ Decimal("active partition", active, tmp);
+ while (!ok("Are you happy with this choice"));
for (i = 0; i < NDOSPART; i++)
partp[i].dp_flag = 0;
partp[active].dp_flag = ACTIVE;
@@ -429,6 +429,11 @@ unsigned char *c, *s, *h;
int cy;
int hd;
+ if (sec == 0) {
+ *s = *c = *h = 0;
+ return;
+ }
+
cy = sec / ( dos_cylsecs );
sec = sec - cy * ( dos_cylsecs );
@@ -456,7 +461,7 @@ struct stat st;
if ( !(st.st_mode & S_IFCHR) )
fprintf(stderr,"%s: Device %s is not character special\n",
name, disk);
- if ((fd = open(disk, u_flag?O_RDWR:O_RDONLY)) == -1) {
+ if ((fd = open(disk, a_flag || u_flag ? O_RDWR : O_RDONLY)) == -1) {
fprintf(stderr,"%s: Can't open device %s\n", name, disk);
return -1;
}
OpenPOWER on IntegriCloud