how to write the shared library?

I want to write one shared lib,just like socket library,indeed it is the harddisk driver,so I can add it to my exec file,I want to know what’s the structure of lib?Does it include the main() function?how to write and how to compile it?

lol, if you are wanting to do that then you won’t be needing an OS.

There is so many layers between the average user program and a hard drive. The top layer is read() and write() , those are a library calls. Beyond that you get all sorts of variations but a filesystem will be sandwiched in the middle and can be a separate process of it’s own. At the bottom of the software layers is the bus driver that manages the hardware block transfers, this is another process. The layers are there to allow multiple apps to use multiple filesystems on multiple discs. And, of course, to provide some uniform transparency, even accross networks.

At the very minimum you should try to use the process, devb-eide, to talk the hardware; assuming it’s an ATA device you are using.

Could you explain why you need to write a “harddisk driver”. Maybe there are easier ways to acheive what you need.

indeed,I want to share some programme with others,but I don’t like to give my source code to him,so I think the share lib maybe the good idea,:).

I’m not asking about the share library I’m asking about the harddisk driver? Why do you need to write code that will access the harddisk directly instead of going through the the filesystem.