From: Alan Cox Date: Wed, 8 Nov 2017 15:53:12 +0000 (+0000) Subject: remount: fix a corner case X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=0f830de105dc98778a45d8f2c47e5d24e60d806c;p=FUZIX.git remount: fix a corner case If we have a file open that has no on disk references then irrespective of whether we have it open for read or not we cannot make the disk read only because we need to write to erase the file on close. --- diff --git a/Kernel/syscall_other.c b/Kernel/syscall_other.c index bb6111e2..e57eb41c 100644 --- a/Kernel/syscall_other.c +++ b/Kernel/syscall_other.c @@ -370,10 +370,14 @@ static int do_umount(uint16_t dev) can't remount it read only */ if (flags & (MS_RDONLY|MS_REMOUNT) == (MS_RDONLY|MS_REMOUNT)) { for (ptr = i_tab ; ptr < i_tab + ITABSIZE; ++ptr) { - if (ptr->c_dev == dev && ptr->c_writers && - !isdevice(ptr)) { - udata.u_error = EBUSY; - return -1; + if (ptr->c_dev == dev && !isdevice(ptr)) { + /* Files being written block the remount ro, but so + do files that when closed will be deleted */ + if (ptr->c_writers || + !ptr->c_node.i_nlink) { + udata.u_error = EBUSY; + return -1; + } } } }