ld-tool portability fix: MacOS build experience
[lunaix-os.git] / lunaix-os / kernel / fs / mount.c
index 96cc7418cec8a702573120a70b824d79fcaf89ac..2b996d413c8b304dfb6e7efc71454ddbd9a8c226 100644 (file)
@@ -63,6 +63,8 @@ __vfs_do_unmount(struct v_mount* mnt)
 
     mnt_chillax(mnt->parent);
 
+    mnt->mnt_point->mnt = mnt->parent;
+
     vfs_sb_free(sb);
     atomic_fetch_sub(&mnt->mnt_point->ref_count, 1);
     vfree(mnt);
@@ -249,6 +251,11 @@ __DEFINE_LXSYSCALL4(int,
         goto done;
     }
 
+    if (mnt->mnt->mnt_point == mnt) {
+        errno = EBUSY;
+        goto done;
+    }
+
     // By our convention.
     // XXX could we do better?
     struct device* device = NULL;