I am studying Linux OS and C programming language.
What is the most effective way to deal with hard disk sectors? I should write a block device module for linux. However, I don’t understand this. Which kernel functions should I use to read and write block devices?
The most effective way to read and write data is to use files.
See the English answer> Direct access to hard disk with no FS from C program on Linux. The data is stored in a block of 3 blocks. I need to read a single sector from a disk. The size of the data is 4 blocks. 4096. For high efficiency, I want to directly manipulate the blocks on the hard disk sector, and do not want to treat the data block as a file. I think one way is to treat the device as a file, such as /dev/sda1, and use lseek() read() and write() to read and write data. But I don’t know whether the file header is the first sector of the hard disk. I also doubt the efficiency of this method.
I am studying Linux OS and C programming language.
What is the most effective way to deal with hard disk sectors? I should write a block device module for linux. However, I don’t understand this. Which kernel functions should I use to read and write block devices?
“The block size is 4096” is not particularly necessary, and you did not mention any access mode that would destroy the kernel’s built-in cache mechanism.
p>
The most effective way to read and write data is to use files.