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 "hV" --long "help,noscan,version" -n "$name" -- "$@"`
71 if [ $? != 0 ]; then exit 1; fi
79 -h|--help) help="0"; shift ;;
80 --noscan) noscan="0"; shift ;;
81 -V|--version) echo "$name $version"; exit 0 ;;
83 *) echo "! internal error"; exit 1 ;;
87 if [ -n "$help" -o -z "$2" ]; then
89 Usage: $name [-h|--help] [--noscan] <device> <sector>"
91 mapsector -- Map sector numbers to file name(s)
93 Given a device and a sector number, mapsector will try to find the
94 file name(s) mapping to this sector. It will try to gather as much
95 information about the given sector as possible.
97 mapsector currently has support for the following mapping schemes:
100 for mapper in $mappers; do
105 mapsector currently supports the following filesystems
108 for scanner in $scanners; do
113 mapsector will try it's best to find an associated file name but
114 depending on the filesystem state and the type of sector (e.g. if
115 the sector is part of a filesystem metadata block) this may not be
118 For mapsector to work, the filesystem must be currently active
119 (e.g. LVM must be running, crypted devices must have been set up). The
120 filesystem must not necessarily be mounted (though if mounted,
121 mapsector will give you the mountpoint).
123 if '--noscan' is given, the possibly lengthy (!!) filesystem scan for
124 filenames is skipped.
126 -- mapsector Version $version
134 echo "device $device"
135 echo "sector $sector"
138 if [ -z "$noscan" ]; then