从磁盘读取单个扇区 [英] Read a single sector from a disk
本文介绍了从磁盘读取单个扇区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试直接从磁盘读取单个特定扇区.我目前的想法已经用完了,关于如何实现它的任何建议都很棒!
I am trying to read a single specific sector from the disk directly. I've currently run out of ideas and any suggestions how to go about it would be great!
推荐答案
尝试通过CLI进行类似操作:
Try something like this to do it from the CLI:
# df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 27G 24G 1.6G 94% /
# dd bs=512 if=/dev/sda2 of=/tmp/sector200 skip=200 count=1
1+0 records in
1+0 records out
来自man 4 sd
:
FILES
/dev/sd[a-h]: the whole device
/dev/sd[a-h][0-8]: individual block partitions
如果要在程序中执行此操作,只需将man 2 ...
之类的man 2 ...
和read
之类的系统调用与dd
示例中的参数结合使用即可.
And if you want to do this from within a program, just use a combination of system calls from man 2 ...
like open, lseek,
, and read
, with the parameters from the dd
example.
这篇关于从磁盘读取单个扇区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文