Hi,
WaterOS wrote:
I need help to get the filename of a sector. Would that be possible? Basic programming in Assembly would be good.
It should be possible to determine the name/s of the file/s that use a specific sector. However, file systems are not designed for this - they're designed to do the opposite (find the sector/s for a file given the file name). This means that it's going to be extremely slow - e.g. check every file in every directory until you find one that uses the sector.
Also note that there are 3 possible cases:
Sector is not used by any file: This should be obvious (e.g. sector is free, or used by directory information or metadata)
Sector is used by one file: This is what you seem to be expecting, and includes "sector is only partially used by a file" and "sector contains directory info and a tiny file" (e.g. ReiserFS "tail packing")
Sector is used by 2 or more files: This can happen due to file system's block size being smaller than sector size (e.g. FAT image stored on CD), packing tiny files together (e.g. the old "DriveSpace" disk compression Windows had), data deduplication, hard links (and symbolic links?), etc.
Of course there are very few sane reasons for wanting to do this in the first place; so it's probably better to describe why you think you want to do this (so that we have a chance to describe a much better way of doing whatever you think you're doing).
WaterOS wrote:
Also, how would I get the disk type e.g "0' or "1" for floppy and print it?
That depends how often you want to be wrong. If you don't mind being wrong often, then you could assume that "BIOS device numbers" from 0x00 to 0x7F are floppies, "BIOS device numbers" from 0x80 to 0xBF are hard drives, and "BIOS device numbers" from 0xC0 to 0xFF are CD-ROMs.
If you want to be "less wrong, less often"; then you can try to use
"Int 0x13, ah=0x48" to get more information.
If you actually want to be "very right very often" (e.g. including knowing the difference between "hard disk connected to SATA" and "SSD connected to SATA") you have to stop using BIOS and start writing native drivers that don't suck.
Cheers,
Brendan