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
34 for name in $mappers; do
48 for name in $scanners; do
57 ###########################################################################
61 #### Find library directory and load library files
63 name="`basename "$0"`"
65 if [ "`basename "$X"`" == "bin" ]; then # `"
66 libdir="`dirname "$X"`/share/$name" #`"
68 if [ -z "$libdir" -o ! -d "$libdir" ]; then
72 if [ ! -d "$libdir" ]; then
73 echo "! Library directory not found" 1>&2
79 #### Parse command line arguments
81 X=`getopt -o "hV" --long "help,noscan,version" -n "$name" -- "$@"`
82 if [ $? != 0 ]; then exit 1; fi
90 -h|--help) help="0"; shift ;;
91 --noscan) noscan="0"; shift ;;
92 -V|--version) echo "$name $version"; exit 0 ;;
94 *) echo "! internal error"; exit 1 ;;
98 if [ -n "$help" -o -z "$2" ]; then
100 Usage: $name [-h|--help] [--noscan] <device> <sector>"
102 mapsector -- Map sector numbers to file name(s)
104 Given a device and a sector number, mapsector will try to find the
105 file name(s) mapping to this sector. It will try to gather as much
106 information about the given sector as possible.
108 mapsector currently has support for the following mapping schemes:
111 for mapper in $mappers; do
116 mapsector currently supports the following filesystems
119 for scanner in $scanners; do
124 mapsector will try it's best to find an associated file name but
125 depending on the filesystem state and the type of sector (e.g. if
126 the sector is part of a filesystem metadata block) this may not be
129 For mapsector to work, the filesystem must be currently active
130 (e.g. LVM must be running, crypted devices must have been set up). The
131 filesystem must not necessarily be mounted (though if mounted,
132 mapsector will give you the mountpoint).
134 if '--noscan' is given, the possibly lengthy (!!) filesystem scan for
135 filenames is skipped.
137 -- mapsector Version $version
145 echo "device $device"
146 echo "sector $sector"
149 if [ -z "$noscan" ]; then