-2

I tried very hard to find a document on how to access sectors in the C programming language Or is it possible to read a file and it gives us the sector address Or access its value with the sector address But so far I have not reached a conclusion

MDev
  • 3
  • 2
  • A file doesn't "know" where it is on disk. When you look up the filename in a directory it gives you an inode. The inode gives you the sectors where the file is stored. – stark Jun 05 '22 at 12:34
  • Related? [Wikipedia article on INT 13H](https://en.wikipedia.org/wiki/INT_13H) explains how disk access (used to) works in real-mode in old OSes. Note: in modern OSes you cannot simply switch back and forth between real-mode and protected-mode willy-nilly. – pmg Jun 05 '22 at 12:49
  • 1
    It depends on your OS and it's not related to the C language at all. – Jabberwocky Jun 05 '22 at 13:10
  • in Windows 10 ... – MDev Jun 05 '22 at 13:14
  • This should answer your question https://stackoverflow.com/questions/8506767/how-do-i-use-createfile-to-access-a-physical-disk – Frankie_C Jun 05 '22 at 13:33
  • So you want to do this from a kernel mode driver? – Paul Sanders Jun 05 '22 at 16:23
  • Yes ........... – MDev Jun 06 '22 at 05:39

1 Answers1

1

The C programming language doesn't "know" what a hard disk is. It's in fact a very abstract thing, and things like memory and storage are formulated quite vaguely.

If you're implementing a operating system kernel level driver, then you'll have to use whatever I/O mechanisms are made available by that. If you're implementing the kernel yourself, then you'll have to look into the programming model documentation of your target platform, and implement what's specified there, by writing some bare bones I/O primitive in assembler, and make them available to the C environment by following the calling conventions used by your C compiler.

datenwolf
  • 159,371
  • 13
  • 185
  • 298