diff options
author | phk <phk@FreeBSD.org> | 2003-01-26 21:55:43 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2003-01-26 21:55:43 +0000 |
commit | a27e16309de9e115ccbe0d11f91ca6ab49c891e8 (patch) | |
tree | 281363e0e7a5981d1edb3d338d89cb4c9147ba17 /sbin/bsdlabel/bsdlabel.c | |
parent | f71e2dab31370e0325052fc73b068e52032e831e (diff) | |
download | FreeBSD-src-a27e16309de9e115ccbe0d11f91ca6ab49c891e8.zip FreeBSD-src-a27e16309de9e115ccbe0d11f91ca6ab49c891e8.tar.gz |
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.
Diffstat (limited to 'sbin/bsdlabel/bsdlabel.c')
-rw-r--r-- | sbin/bsdlabel/bsdlabel.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c index d01f0ea..ecb1705 100644 --- a/sbin/bsdlabel/bsdlabel.c +++ b/sbin/bsdlabel/bsdlabel.c @@ -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); |