读取启动盘上的扇区 [英] Reading a sector on the boot disk
问题描述
这是关于阅读超级块的延续。
假设我想在Mac OS X中定位HFS +文件系统。我怎么读取启动盘的扇区2?据我所知,Unix只提供系统调用来读取文件,这些文件永远不会存储在这个位置。
这是否需要1)程序运行内核模式或者2)程序要在Assembly中写入?我宁愿避免这些限制之一,尤其是后者。在Linux中,你可以从特殊的设备文件中读取数据。
/ dev / sda
,假设您想要读取的硬盘是第一个。你需要以root身份来读取这个文件。要读取扇区2,您只需设法抵消 2 * SECTOR_SIZE
并读入 SECTOR_SIZE
字节。 我不知道这个设备文件是否在OS X上可用。检查 / dev
下有趣的命名文件,比如 / dev / sda
或 / dev / hda
。
This is a continuation of my question about reading the superblock.
Let's say I want to target the HFS+ file system in Mac OS X. How could I read sector 2 of the boot disk? As far as I know Unix only provides system calls to read from files, which are never stored at that location.
Does this require either 1) the program to run kernel mode, or 2) the program to be written in Assembly? I would prefer to avoid either of these restrictions, particularly the latter.
In Linux, you can read from the special device file /dev/sda
, assuming the hard drive you want to read is the first one. You need to be root to read this file. To read sector 2, you just seek to offset 2*SECTOR_SIZE
and read in SECTOR_SIZE
bytes.
I don't know if this device file is available on OS X. Check for interestingly named files under /dev
such as /dev/sda
or /dev/hda
.
这篇关于读取启动盘上的扇区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!