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. ...@@ -49,8 +49,7 @@ ISO9660 systems, as these were used as references as well.
static int init_percd(void); static int init_percd(void);
static int percd_done; static int percd_done;
static file_t bin_cue; static file_t bin_cue = FILEHND_INVALID;
static int mounted = 0;
static int bincue_sector_size = 2048; static int bincue_sector_size = 2048;
void bincue_set_sector_size(int size) void bincue_set_sector_size(int size)
...@@ -60,30 +59,35 @@ 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) static int bincue_read_sectors(void *buffer, int sector, int cnt)
{ {
int i; int i;
int _sector; int _sector;
/* sector -= 150; */ /* Maybe a check here would be appropriate to ensure that we /* sector -= 150; */
don't go below zero? */ /* Maybe a check here would be appropriate to ensure that we
_sector = sector-150; don't go below zero? */
switch (bincue_sector_size) _sector = sector-150;
{
case 2048: if (bin_cue == FILEHND_INVALID)
for (i = 0; i< cnt; i++){ return -1;
fs_seek (bin_cue, (_sector*2352)+24, SEEK_SET);
fs_read (bin_cue, buffer+(i*2048), 2048); switch (bincue_sector_size)
_sector++; {
} case 2048:
break; for (i = 0; i< cnt; i++) {
case 2352: fs_seek (bin_cue, (_sector*2352)+24, SEEK_SET);
fs_seek (bin_cue, _sector*2352, SEEK_SET); fs_read (bin_cue, buffer+(i*2048), 2048);
i = fs_read(bin_cue, buffer, 2352*cnt); _sector++;
i/=2352; }
break; break;
default: case 2352:
i = 0; fs_seek (bin_cue, _sector*2352, SEEK_SET);
break; i = fs_read(bin_cue, buffer, 2352*cnt);
} i/=2352;
return i; break;
default:
i = 0;
break;
}
return i;
} }
/********************************************************************************/ /********************************************************************************/
...@@ -981,19 +985,33 @@ static vfs_handler_t vh = { ...@@ -981,19 +985,33 @@ static vfs_handler_t vh = {
iso_ioctl, iso_ioctl,
NULL, NULL,
NULL, NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, /* poll */
NULL, /* link */
NULL, /* symlink */
NULL, /* seek64 */
NULL, /* tell64 */
NULL, /* total64 */
NULL, /* readlink */
NULL,
NULL NULL
}; };
/* Initialize the file system */ /* Initialize the file system */
int fs_bincue_mount(const char *fn) { int fs_bincue_mount(const char *fn) {
int i; int i;
if (mounted > 0) return -1; if (bin_cue != FILEHND_INVALID) return -1;
mounted ++;
bin_cue = fs_open(fn, O_RDONLY); bin_cue = fs_open(fn, O_RDONLY);
if (bin_cue == -1) if (bin_cue == FILEHND_INVALID)
return -1; return -1;
/* Reset fd's */ /* Reset fd's */
memset(fh, 0, sizeof(fh)); memset(fh, 0, sizeof(fh));
...@@ -1033,6 +1051,7 @@ int fs_bincue_unmount() { ...@@ -1033,6 +1051,7 @@ int fs_bincue_unmount() {
vblank_handler_remove(iso_vblank_hnd); vblank_handler_remove(iso_vblank_hnd);
fs_close (bin_cue); fs_close (bin_cue);
bin_cue = FILEHND_INVALID;
/* Dealloc cache block space */ /* Dealloc cache block space */
for(i = 0; i < NUM_CACHE_BLOCKS; i++) { for(i = 0; i < NUM_CACHE_BLOCKS; i++) {
...@@ -1043,7 +1062,6 @@ int fs_bincue_unmount() { ...@@ -1043,7 +1062,6 @@ int fs_bincue_unmount() {
} }
read_sectors = cdrom_read_sectors; read_sectors = cdrom_read_sectors;
mounted = 0;
/* Free muteces */ /* Free muteces */
mutex_destroy(&cache_mutex); mutex_destroy(&cache_mutex);
mutex_destroy(&fh_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