Hello! I had recently posted a question on this list about getting LBAs for a file on ext3. Andreas Dilger had provided a very handy solution to solve the above problem [Message attached along]. My goal is to be able to read files on a ext3 filesystem through the scsi generic (sg) driver. I first use debugfs to extract the block addresses for every file. I then multiply the block address by 8 [4K/ 512] to obtain the LBAs. I then use a progam sg_dd in the sg toolkit to read the data stored in the LBA obtained above. However, the data I read through the sg driver does not match the data in the file. Through some tinkering of my code, I found that when I offset the original LBA [obtained as block_address*8] by 63 sectors [63*512 bytes], the data perfectly matches. That is LBA' = LBA + 63 corresponds to the actual address used for the file. I have tested this well when the file is not fragmented. Initial testing on fragmented files also shows similar behavior. I googled around but could not find a convincing answer as to where this offset crops up from. Has anyone in the group done a similar experiment? I would really appreciate any pointers on this issue. thanks again, regards, -Aravind. --- Andreas Dilger <adilger@xxxxxxxxxxxxx> wrote: > On Apr 16, 2007 11:17 -0700, Aravindan Raghuveer > wrote: > > I need to write a user space tool that can dump > > logical block addresses used by every file in a > ext3 > > file system. For example, if file foo uses LBAs > 2,3 > > and file bar uses LBAs 100,102,156, then the > ouptut > > should read: > > > > FILENAME LBAs > > foo 2, 3 > > bar 100,102,156 > > > > Is there a tool that exists that can do this? If > not, > > what would be a good strategy to write this tool. > I am > > learning filesystem programming and would really > > appreciate any pointers. > > "debugfs -c -R 'stat /path/to/file' /dev/XXX" > reports, among other things > the blocks used by that file. > > Cheers, Andreas > -- > Andreas Dilger > Principal Software Engineer > Cluster File Systems, Inc. > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ Ext3-users mailing list Ext3-users@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/ext3-users