Skip to content

Commit

Permalink
check duplicate mount
Browse files Browse the repository at this point in the history
  • Loading branch information
kanjitalk755 committed Aug 7, 2023
1 parent a94a418 commit e90180a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions BasiliskII/src/cdrom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ static const uint8 bcd2bin[256] = {

// Struct for each drive
struct cdrom_drive_info {
cdrom_drive_info() : num(0), fh(NULL), start_byte(0), status(0) {}
cdrom_drive_info(void *fh_) : num(0), fh(fh_), start_byte(0), status(0) {}
cdrom_drive_info() : num(0), fh(NULL), start_byte(0), status(0), drop(false) {}
cdrom_drive_info(void *fh_) : num(0), fh(fh_), start_byte(0), status(0), drop(false) {}

void close_fh(void) { SysAllowRemoval(fh); Sys_close(fh); }

Expand All @@ -147,6 +147,7 @@ struct cdrom_drive_info {
bool repeat; // Repeat flag
uint8 power_mode; // Power mode
uint32 status; // Mac address of drive status record
bool drop;
};

// List of drives handled by this driver
Expand Down Expand Up @@ -321,8 +322,14 @@ void CDROMInit(void)
}

void CDROMDrop(const char *path) {
if (!drives.empty())
drives.front().fh = Sys_open(path, true, true);
if (!drives.empty()) {
cdrom_drive_info &info = drives.back();
if (!info.drop) {
info.fh = Sys_open(path, true, true);
if (info.fh)
info.drop = true;
}
}
}

/*
Expand Down Expand Up @@ -567,6 +574,7 @@ int16 CDROMControl(uint32 pb, uint32 dce)
info->twok_offset = -1;
info->close_fh();
info->fh = NULL;
info->drop = false;
return noErr;
} else {
return offLinErr;
Expand Down

0 comments on commit e90180a

Please sign in to comment.