我有一个稀疏文件,其中只分配了一些块:
~% du -h --apparent-size example
100K example
~% du -h example
52K example
Run Code Online (Sandbox Code Playgroud)
我想知道实际分配了文件的哪些块。是否有系统调用或内核接口可用于获取分配列表或文件漏洞列表?
简单地检查足够长的零字符串(GNU cp、rsync 等使用的方法)无法正常工作:
~% cp example example1
~% du -h example1
32K example1
Run Code Online (Sandbox Code Playgroud)
它检测到实际分配的其他零序列。