C++ / Linux - File location address on hard drive

64 Views Asked by At

I need to create some files on a ubuntu core (22.04) VM within a SNAP Environment.

  • first file: contains some metadata and the absolute addresses of min. two other files on the same hard-drive.

  • second & third file: contains custom data sets which used to identify the files.

With these 3 files, i want to check if the VM got cloned on the same hard-drive. If the two absolute addresses changed, but the distance between the to file addresses remain the same, there is a chance, that the VM got cloned. So the addresses on the hard-drive is the only variable i can use.

How do i get the absolute addresses from the files? I know, it is dependent on the format (ext4, fat32,...) and it is against the encapsulation of the OS. I checked the File* struct but due to the usage of kernel methods and drivers, i can't get the information i need.

Maybe someone have an idea how to solve this or which objects/methods i can use instead of files?

I found some interesting things like the possibility to open the hard-drive as a file or to iterate through the blocks. But it is not possible for this environment.

0

There are 0 best solutions below