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.
This commit is contained in:
Juli Mallett 2003-03-28 01:50:11 +00:00
parent c67c1ce843
commit 7a51271b68
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112730

View File

@ -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;
}