From 2b3cee5134417f2ebe1bf390715f841f8fc7bb55 Mon Sep 17 00:00:00 2001 From: jmallett Date: Fri, 28 Mar 2003 01:50:11 +0000 Subject: [PATCH] Close the disk file descriptor that is RO before trying to open the new one, and do not fall back to the RO fd. There was a bug here in that the RO fd was never closed, if the RDRW open succeeded, but this code is bogus anyway, and it breaks newfs of floppies, at least for me, due to "Device busy." Anything that wants to fall back is doing something significantly odd that it should have some more complex code on its end. --- lib/libufs/type.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/libufs/type.c b/lib/libufs/type.c index e5cb06245572..3d65167b2c53 100644 --- a/lib/libufs/type.c +++ b/lib/libufs/type.c @@ -182,19 +182,16 @@ again: if (stat(name, &st) < 0) { int ufs_disk_write(struct uufsd *disk) { - int rofd; - ERROR(disk, NULL); if (disk->d_mine & MINE_WRITE) return 0; - rofd = disk->d_fd; + close(disk->d_fd); disk->d_fd = open(disk->d_name, O_RDWR); if (disk->d_fd < 0) { ERROR(disk, "failed to open disk for writing"); - disk->d_fd = rofd; return -1; }