From 32520d0af4bcb7a688daf489798b08dfaa922d4c Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 23 Oct 2017 01:02:14 +0100 Subject: [PATCH] mount/umount: Fixups for the other cases I missed With this I seem to get the right behaviour --- Kernel/filesys.c | 10 ++++++---- Kernel/syscall_other.c | 9 ++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Kernel/filesys.c b/Kernel/filesys.c index 405d3d63..888bda90 100644 --- a/Kernel/filesys.c +++ b/Kernel/filesys.c @@ -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; } diff --git a/Kernel/syscall_other.c b/Kernel/syscall_other.c index bef27caa..bb6111e2 100644 --- a/Kernel/syscall_other.c +++ b/Kernel/syscall_other.c @@ -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; } -- 2.34.1