Search code examples
linuxmemorydriverdiskminix

Load a Disc (HD) trail into memory (Minix)


Minix is a micro-kernel OS, programmed in C, based in the unix archtecture, used sometimes in embbeded systems, and I have a task to alter the way it works in some ways.

In Minix there is a cache for disk blocks (used to make access to disk fast). I need to alter that cache, so it will keep disc trails instead of disk blocks.

A trail is a circular area of the HD, composed of sectors.

So I'm a bit lost here, how can I load a disk trail into memory ? (Answers related to Linux systems might help)

Should I alter the disk driver or use functions and methods of an existing one ?

How to calculate where in the HD a disk block is located ?

Thanks for your attention.


Solution

  • The typical term for what you're describing is a disk cylinder, not a "trail".

    What you're trying to do isn't precisely possible; modern hard drives do not expose their physical organization to the operating system. While cylinder/head/sector addressing is still supported for compatibility, the numbers used have no relationship to the actual location of data on the drive.

    Instead, consider defining fixed "chunks" of the disk which will always be loaded into cache together. (For instance, perhaps you could group every 128 sectors together, creating a 64 KB "chunk". So a read for sector 400 would cause the cache to pull in sectors 384-511, for example.) Figuring out how to make the Minix disk cache do this will be your project. :)