如何编写自己的基本磁盘扫描程序
我想编写一些基本的磁盘扫描程序实用程序。基本上,我希望能够以系统磁盘实用程序(如 Windows 中的错误检查和碎片整理)的方式读取写入磁盘的某个文件的原始字节。我想用 C 语言来做。
我的第一步应该是什么?显然 fopen 是不够的。
任何指导将不胜感激(我不要求解决方案,只是一点理论并推动正确的方向,因为我什至不知道从哪里开始......)。
I would like to write some basic disk scanner utility. Basically I would like to be able to read raw bytes of a certain file(s) as written to the disk in the way system's disk utilities (like error checking and defragmentation in windows) do it. I would like to do it in C.
What should be my first steps? Obviously fopen is not enough.
Any guidance would be much appreciated (I don't ask for a solution, just a bit of theory and push in a right direction as I don't even know where to start from...).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下资源可能有用:
The following resources might be of use:
您正在冒险进入驾驶员的土地。大多数文件访问 API 仍然使您处于比磁盘本身更高的级别。您可能正在与 CD、RAMDisk、SAN 或 HDD 上的文件系统进行通信,但您不必关心。
如果您需要直接访问磁盘,那么卷管理 API 应该可以在 Windows 上帮助您:
卷管理 API
You are venturing into the land of the driver here. Most of the file access APIs still hold you at a level higher than the disk itself. You could be talking to a file system on a CD, a RAMDisk, a SAN or HDD and you shouldn't care.
If you need to hit the disk directly then the Volume Managment API should help you out on Windows:
Volume Management API
fopen 和 fread 可以工作。如果您想使用无缓冲接口,请使用 open 和 阅读 代替。打开和读取是 POSIX 标准的一部分,因此它们也适用于 Windows,尽管您可能需要查找 Windows 手册页以确保捕获行为上的任何细微差异。
fopen and fread will work. If you want to use an unbuffered interface, use open and read instead. Open and read are part of the POSIX standard, so they work in Windows too, although you may want to find manual pages for windows to be sure to catch any subtle differences in behaviour.