First post, by superfury
What error code should an emulated ATA controller report when a disk write fails because of an failed allocation of disk space for the new sector? So, for example:
The disk image is 2550 sectors large.
The emulated system tries to write sector #2549, which isn't allocated in the sparse image yet.
The free disk space on the disk of the sparse disk image doesn't have enough space to hold a newly allocated sector (512 bytes).
So the emulator will try to allocate a new sector on the disk image to be written, but fails in doing so since there's not enough disk space on the host system (e.g. 510 bytes of free disk space, but 512+ bytes needed for the new sector, depending on the sparse disk image and host system filesystem (in my case it's got 1 root table of 1024 entries pointing to 1 sub table of 1024 entries, this in turn points to a sub table of 4096 entries which in turn points to the sector data itself. All tables are allocated when a sector is written to (only it's own root, sub and sector table. So in my case it's a maximum of (1024+1024+4096)x8(64-bit entries) plus 512 bytes of actual sector data, so 48KB of lookup tables plus 512 bytes of sector data = 49664 bytes in total for the first sector in an empty image. Actually all data, with the tables included, are allocated on a block by block basis: the root table is allocated when needed, as are the first sub table and the sector lookup table and the sector. If anything goes wrong when allocating a block, the data (with errors) already allocated will be kept, but the sector won't be written. So if a first level and second level lookup table is allocated, but the sector table fails because the space ran out on the disk, the allocated data stays allocated, but the final table won't be allocated (second table points to address 0) as does the sector data itself. The software will try to allocate the sector table and/or sector data itself when it's written to again later.)).
What error should be reported to the software (ATA error code) when allocation of the new sector fails, due to the host file system not having enough space left to write the new sector to the disk image?
Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io