#! /usr/bin/perl use warnings; my %files; # Filename => First physical block open FIND,"-|","find","/","-xdev","-type","f"; open FH,"> /tmp/debugfs_commands.txt"; while(){ print FH "dump_extents $_"; } open DEBUGFS,"-|","debugfs","-f","/tmp/debugfs_commands.txt","/dev/sda1"; my $file; while(){ chomp; $file = $1 if(/dump_extents\s+(\S+)$/); next unless defined $file; next unless my($logicalStart,$logicalEnd,$physicalStart,$physicalEnd) = /\s*(\d+)\s*\-\s*(\d+)\s+(\d+)\s*\-\s*(\d+)/; $files{$file} = $physicalStart; $file = undef; } for my $file (sort {$files{$a} <=> $files{$b}} keys %files){ printf("%10d: %s\n",$files{$file},$file); }