remount: fix a corner case
authorAlan Cox <alan@linux.intel.com>
Wed, 8 Nov 2017 15:53:12 +0000 (15:53 +0000)
committerAlan Cox <alan@linux.intel.com>
Wed, 8 Nov 2017 15:53:12 +0000 (15:53 +0000)
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.

Kernel/syscall_other.c

index bb6111e..e57eb41 100644 (file)
@@ -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;
+                               }
                        }
                }
        }