3 ###########################################################################
11 mappers="${mappers}${mappers:+ }$1"
16 scanners="${scanners}${scanners:+ }$1"
21 for lib in `ls "$1"/[0-9][0-9]_*.sh | sort`; do
26 # Map device/sector through blockdevice mappings (e.g. lvm)
32 while [ -n "$found" ]; do
46 ###########################################################################
50 #### Find library directory and load library files
52 name="`basename "$0"`"
54 if [ "`basename "$X"`" == "bin" ]; then # `"
55 libdir="`dirname "$X"`/lib/$name" #`"
57 if [ -z "$libdir" -o ! -d "$libdir" ]; then
61 if [ ! -d "$libdir" ]; then
62 echo "! Library directory not found" 1>&2
68 #### Parse command line arguments
70 X=`getopt -o "h" --long "help,noscan" -n "$name" -- "$@"`
71 if [ $? != 0 ]; then exit 1; fi
79 -h|--help) help="0"; shift ;;
80 --noscan) noscan="0"; shift ;;
82 *) echo "! internal error"; exit 1 ;;
86 if [ -n "$help" -o -z "$2" ]; then
88 Usage: $name [-h|--help] [--noscan] <device> <sector>"
90 mapsector -- Map sector numbers to file name(s)
92 Given a device and a sector number, mapsector will try to find the
93 file name(s) mapping to this sector. It will try to gather as much
94 information about the given sector as possible.
96 mapsector currently has support for the following mapping schemes:
99 for mapper in $mappers; do
104 mapsector currently supports the following filesystems
107 for scanner in $scanners; do
112 mapsector will try it's best to find an associated file name but
113 depending on the filesystem state and the type of sector (e.g. if
114 the sector is part of a filesystem metadata block) this may not be
117 For mapsector to work, the filesystem must be currently active
118 (e.g. LVM must be running, crypted devices must have been set up). The
119 filesystem must not necessarily be mounted (though if mounted,
120 mapsector will give you the mountpoint).
122 if '--noscan' is given, the possibly lengthy (!!) filesystem scan for
123 filenames is skipped.
125 -- mapsector Version $version
133 echo "device $device"
134 echo "sector $sector"
137 if [ -z "$noscan" ]; then