Commit a2e57710 authored by Donald Haase's avatar Donald Haase
Browse files

Replace mounted global with the file_t for the bincue. Fill out vfs handler...

Replace mounted global with the file_t for the bincue. Fill out vfs handler struct to match modern KOS.
parent ec68e90d
......@@ -49,8 +49,7 @@ ISO9660 systems, as these were used as references as well.
static int init_percd(void);
static int percd_done;
static file_t bin_cue;
static int mounted = 0;
static file_t bin_cue = FILEHND_INVALID;
static int bincue_sector_size = 2048;
void bincue_set_sector_size(int size)
......@@ -60,30 +59,35 @@ void bincue_set_sector_size(int size)
static int bincue_read_sectors(void *buffer, int sector, int cnt)
{
int i;
int _sector;
/* sector -= 150; */ /* Maybe a check here would be appropriate to ensure that we
don't go below zero? */
_sector = sector-150;
switch (bincue_sector_size)
{
case 2048:
for (i = 0; i< cnt; i++){
fs_seek (bin_cue, (_sector*2352)+24, SEEK_SET);
fs_read (bin_cue, buffer+(i*2048), 2048);
_sector++;
}
break;
case 2352:
fs_seek (bin_cue, _sector*2352, SEEK_SET);
i = fs_read(bin_cue, buffer, 2352*cnt);
i/=2352;
break;
default:
i = 0;
break;
}
return i;
int i;
int _sector;
/* sector -= 150; */
/* Maybe a check here would be appropriate to ensure that we
don't go below zero? */
_sector = sector-150;
if (bin_cue == FILEHND_INVALID)
return -1;
switch (bincue_sector_size)
{
case 2048:
for (i = 0; i< cnt; i++) {
fs_seek (bin_cue, (_sector*2352)+24, SEEK_SET);
fs_read (bin_cue, buffer+(i*2048), 2048);
_sector++;
}
break;
case 2352:
fs_seek (bin_cue, _sector*2352, SEEK_SET);
i = fs_read(bin_cue, buffer, 2352*cnt);
i/=2352;
break;
default:
i = 0;
break;
}
return i;
}
/********************************************************************************/
......@@ -981,19 +985,33 @@ static vfs_handler_t vh = {
iso_ioctl,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, /* poll */
NULL, /* link */
NULL, /* symlink */
NULL, /* seek64 */
NULL, /* tell64 */
NULL, /* total64 */
NULL, /* readlink */
NULL,
NULL
};
/* Initialize the file system */
int fs_bincue_mount(const char *fn) {
int i;
if (mounted > 0) return -1;
mounted ++;
if (bin_cue != FILEHND_INVALID) return -1;
bin_cue = fs_open(fn, O_RDONLY);
if (bin_cue == -1)
if (bin_cue == FILEHND_INVALID)
return -1;
/* Reset fd's */
memset(fh, 0, sizeof(fh));
......@@ -1033,6 +1051,7 @@ int fs_bincue_unmount() {
vblank_handler_remove(iso_vblank_hnd);
fs_close (bin_cue);
bin_cue = FILEHND_INVALID;
/* Dealloc cache block space */
for(i = 0; i < NUM_CACHE_BLOCKS; i++) {
......@@ -1043,7 +1062,6 @@ int fs_bincue_unmount() {
}
read_sectors = cdrom_read_sectors;
mounted = 0;
/* Free muteces */
mutex_destroy(&cache_mutex);
mutex_destroy(&fh_mutex);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment