Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing disk mounts from webui prevents disk rotation on Atari #597

Open
mozzwald opened this issue Apr 29, 2023 · 0 comments
Open

Changing disk mounts from webui prevents disk rotation on Atari #597

mozzwald opened this issue Apr 29, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@mozzwald
Copy link
Member

Steps to reproduce:

  1. Mount DOS disk to slot 1, all other slots empty
  2. Boot to DOS
  3. Mount disk to slot 2 and 3 from webui
  4. press disk rotate button (button A) and disks are not rotated

The file handles are reset when mounting from webui and not recreated in populate_slots_from_config() and the disk rotate function checks for file handles being null.

This attempt at recreating the file handle sometimes worked, but not always and I'm not sure why. Maybe there's another way to do it.

void sioFuji::_populate_slots_from_config()
{
    char flag[3] = {'r', 0, 0};

    for (int i = 0; i < MAX_HOSTS; i++)
    {
        if (Config.get_host_type(i) == fnConfig::host_types::HOSTTYPE_INVALID)
            _fnHosts[i].set_hostname("");
        else
            _fnHosts[i].set_hostname(Config.get_host_name(i).c_str());
    }

    for (int i = 0; i < MAX_DISK_DEVICES; i++)
    {
        _fnDisks[i].reset();

        if (Config.get_mount_host_slot(i) != HOST_SLOT_INVALID)
        {
            if (Config.get_mount_host_slot(i) >= 0 && Config.get_mount_host_slot(i) <= MAX_HOSTS)
            {
                strlcpy(_fnDisks[i].filename,
                        Config.get_mount_path(i).c_str(), sizeof(fujiDisk::filename));
                _fnDisks[i].host_slot = Config.get_mount_host_slot(i);
                if (Config.get_mount_mode(i) == fnConfig::mount_modes::MOUNTMODE_WRITE)
                {
                    _fnDisks[i].access_mode = DISK_ACCESS_MODE_WRITE;
                    flag[1] = '+';
                }
                else
                    _fnDisks[i].access_mode = DISK_ACCESS_MODE_READ;

                // Open the file
               _fnDisks[i].fileh = _fnHosts[Config.get_mount_host_slot(i)].file_open(_fnDisks[i].filename, _fnDisks[i].filename, sizeof(_fnDisks[i].filename), flag);
            }
            else
                Debug_printf("populate_slots_from_config: slot %d out of range\n", i);
        }
        else
            Debug_printf("populate_slots_from_config: invalid host slot %d\n", i);
    }
}
@mozzwald mozzwald added the bug Something isn't working label Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant