From b703320748068bd8613f944d8b8c35beae496cba Mon Sep 17 00:00:00 2001 From: KrahJohlito Date: Sat, 21 Sep 2024 11:02:19 +0930 Subject: [PATCH] attempt to lock bd during subsequent mount operations --- modules/iopcore/cdvdman/device-bdm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/iopcore/cdvdman/device-bdm.c b/modules/iopcore/cdvdman/device-bdm.c index f3754e3b5..c0210da9a 100644 --- a/modules/iopcore/cdvdman/device-bdm.c +++ b/modules/iopcore/cdvdman/device-bdm.c @@ -26,6 +26,10 @@ void bdm_connect_bd(struct block_device *bd) { DPRINTF("connecting device %s%dp%d\n", bd->name, bd->devNr, bd->parNr); + // lock when performing additional device mount operations + if (g_bd != NULL) + WaitSema(bdm_io_sema); + if (g_bd == NULL && bd->devNr == cdvdman_settings.bdDeviceId) { DPRINTF("attaching to %s%dp%d\n", bd->name, bd->devNr, bd->parNr); g_bd = bd; @@ -33,6 +37,9 @@ void bdm_connect_bd(struct block_device *bd) // Free usage of block device SignalSema(bdm_io_sema); } + + if (g_bd != NULL && g_bd != bd) + SignalSema(bdm_io_sema); } void bdm_disconnect_bd(struct block_device *bd)