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
Loading
Loading
Loading
Loading
+50 −32
Original line number Diff line number Diff line
@@ -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)
@@ -62,9 +61,14 @@ 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
    /* 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:
@@ -981,6 +985,20 @@ 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
};

@@ -988,10 +1006,10 @@ static vfs_handler_t vh = {
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 */
@@ -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);