}
}
+ /* Busy check: reject if any process has cwd or root in this mount */
+ extern struct process* ready_queue_head;
+ extern spinlock_t sched_lock;
+
+ uintptr_t sched_fl = spin_lock_irqsave(&sched_lock);
+ struct process* p = ready_queue_head;
+ while (p) {
+ /* Check if cwd is within this mount */
+ if (p->cwd[0] && path_is_mountpoint_prefix(mp, p->cwd)) {
+ spin_unlock_irqrestore(&sched_lock, sched_fl);
+ return -EBUSY;
+ }
+ /* Check if root is within this mount (if different from cwd) */
+ /* Note: root is not stored as a path in current process struct,
+ * so we only check cwd for now. A full implementation would require
+ * storing root as a path or implementing vfs_getpath. */
+ p = p->rq_next;
+ }
+ spin_unlock_irqrestore(&sched_lock, sched_fl);
+
/* Release the block device */
if (g_mounts[idx].bdev) {
blockdev_release(g_mounts[idx].bdev);