开发者

Determine if raw disk sector is in use

开发者 https://www.devze.com 2023-03-05 04:06 出处:网络
I\'m tryi开发者_运维百科ng to write a free space zeroizer using open(2), lssek[64](2), and write(2). I am trying to determine of a disk sector is in use.

I'm tryi开发者_运维百科ng to write a free space zeroizer using open(2), lssek[64](2), and write(2). I am trying to determine of a disk sector is in use.

I have took a look at dd(1) from coreutils, but the utility is not performing similar checks. In the Windows world, I could call DeviceIoControl with FSCTL_GET_VOLUME_BITMAP.

Given a raw sector, is there a system call which allows me to determine if the sector is in use?


The traditional way this is accomplished (since your method is subject to filesystem-corrupting race conditions), is to create a giant file, zero it, then delete the file. In fact, you can do this with sh directly, no need for a file:

# dd will run until disk space is exhausted
dd if=/dev/zero of=__somefile.bin bs=1M conv=noerror; rm __somefile.bin
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号