4

In Linux, we can call the FIBMAP() ioctl to determine which blocks a file occupies within a file system.

What I am curious about is- how can I determine if any random block is occupied with a file (or any data). Is there an ioctl to do this as well, or do I have to simply lseek to the block and see if there has been data written to it or not? If there's a simple ioctl call to determine if a block is occupied - that would be ideal.

jww
  • 97,681
  • 90
  • 411
  • 885
rocktone
  • 49
  • 2
  • For ext[234] filesystems, you can look at the [C source code](https://fossies.org/dox/e2fsprogs-1.43.4/icheck_8c_source.html) for the `icheck` command in `debugfs` to see how it traverses the raw filesystem. – Mark Plotnick Jun 21 '17 at 22:23
  • Much appreciated, thank you. – rocktone Jun 22 '17 at 02:44

0 Answers0