mount/umount: Fixups for the other cases I missed
authorAlan Cox <alan@linux.intel.com>
Mon, 23 Oct 2017 00:02:14 +0000 (01:02 +0100)
committerAlan Cox <alan@linux.intel.com>
Mon, 23 Oct 2017 00:02:14 +0000 (01:02 +0100)
With this I seem to get the right behaviour

Kernel/filesys.c
Kernel/syscall_other.c

index 405d3d6..888bda9 100644 (file)
@@ -492,10 +492,12 @@ fsptr getdev(uint16_t dev)
         /* Return needed to persuade SDCC all is ok */
         return NULL;
     }
-    rdtime(&t);
-    mnt->m_fs.s_time = t.low;
-    mnt->m_fs.s_timeh = t.high;
-    mnt->m_fs.s_fmod = FMOD_DIRTY;
+    if (!(mnt->m_flags & MS_RDONLY)) {
+        rdtime(&t);
+        mnt->m_fs.s_time = t.low;
+        mnt->m_fs.s_timeh = t.high;
+        mnt->m_fs.s_fmod = FMOD_DIRTY;
+    }
     return &mnt->m_fs;
 }
 
index bef27ca..bb6111e 100644 (file)
@@ -370,7 +370,8 @@ 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) {
+                       if (ptr->c_dev == dev && ptr->c_writers &&
+                               !isdevice(ptr)) {
                                udata.u_error = EBUSY;
                                return -1;
                        }
@@ -380,12 +381,14 @@ static int do_umount(uint16_t dev)
        /* Sweep the inode table. If unmounting look for any references
           and if so fail. If remounting update the CRDONLY flags */
        for (ptr = i_tab; ptr < i_tab + ITABSIZE; ++ptr) {
-               if (ptr->c_refs > 0 && ptr->c_dev == dev) {
+               if (ptr->c_dev == dev) {
                        if (rm) {
                                ptr->c_flags &= ~CRDONLY;
                                if (flags & MS_RDONLY)
                                        ptr->c_flags |= CRDONLY;
-                       } else {
+                               else
+                                       ptr->c_flags &= ~CRDONLY;
+                       } else if (ptr->c_refs) {
                                udata.u_error = EBUSY;
                                return -1;
                        }