If we fail to open O_RDWR, try opening O_RDONLY, if we use ioctls
to fiddle the disk we can get away with it. Try to use DIOCBSDBB to write boot code.
This commit is contained in:
parent
9f690a61a9
commit
dd47d81f8c
@ -228,6 +228,10 @@ main(int argc, char *argv[])
|
||||
np = namebuf + strlen(specname) + 1;
|
||||
f = open(specname, op == READ ? O_RDONLY : O_RDWR);
|
||||
}
|
||||
if (f < 0 && errno == EBUSY) {
|
||||
/* lets try to get by with ioctls */
|
||||
f = open(specname, O_RDONLY);
|
||||
}
|
||||
if (f < 0)
|
||||
err(4, "%s", specname);
|
||||
|
||||
@ -378,6 +382,8 @@ writelabel(int f, const char *boot, struct disklabel *lp)
|
||||
sum += p[i];
|
||||
p[63] = sum;
|
||||
#endif
|
||||
if (ioctl(f, DIOCBSDBB, &boot) == 0)
|
||||
return (0);
|
||||
if (write(f, boot, lp->d_bbsize) != (int)lp->d_bbsize) {
|
||||
warn("write");
|
||||
return (1);
|
||||
|
@ -228,6 +228,10 @@ main(int argc, char *argv[])
|
||||
np = namebuf + strlen(specname) + 1;
|
||||
f = open(specname, op == READ ? O_RDONLY : O_RDWR);
|
||||
}
|
||||
if (f < 0 && errno == EBUSY) {
|
||||
/* lets try to get by with ioctls */
|
||||
f = open(specname, O_RDONLY);
|
||||
}
|
||||
if (f < 0)
|
||||
err(4, "%s", specname);
|
||||
|
||||
@ -378,6 +382,8 @@ writelabel(int f, const char *boot, struct disklabel *lp)
|
||||
sum += p[i];
|
||||
p[63] = sum;
|
||||
#endif
|
||||
if (ioctl(f, DIOCBSDBB, &boot) == 0)
|
||||
return (0);
|
||||
if (write(f, boot, lp->d_bbsize) != (int)lp->d_bbsize) {
|
||||
warn("write");
|
||||
return (1);
|
||||
|
Loading…
Reference in New Issue
Block a user