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.
This commit is contained in:
parent
0bf495e561
commit
0b461cd7de
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3723
@ -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?")) {
|
||||
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;
|
||||
}
|
||||
|
@ -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?")) {
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user