3 ###########################################################################
10 mappers="${mappers}${mappers:+ }$1"
15 scanners="${scanners}${scanners:+ }$1"
20 for lib in `ls "$1"/[0-9][0-9]_*.sh | sort`; do
25 # Map device/sector through blockdevice mappings (e.g. lvm)
31 while [ -n "$found" ]; do
45 ###########################################################################
49 #### Find library directory and load library files
51 name="`basename "$0"`"
53 if [ "`basename "$X"`" == "bin" ]; then # `"
54 libdir="`dirname "$X"`/lib/$name" #`"
56 if [ -z "$libdir" -o ! -d "$libdir" ]; then
60 if [ ! -d "$libdir" ]; then
61 echo "! Library directory not found" 1>&2
67 #### Parse command line arguments
69 X=`getopt -o "h" --long "help,noscan" -n "$name" -- "$@"`
70 if [ $? != 0 ]; then exit 1; fi
78 -h|--help) help="0"; shift ;;
79 --noscan) noscan="0"; shift ;;
81 *) echo "! internal error"; exit 1 ;;
85 if [ -n "$help" -o -z "$2" ]; then
87 Usage: $name [-h|--help] [--noscan] <device> <sector>"
89 mapsector -- Map sector numbers to file name(s)
91 Given a device and a sector number, mapsector will try to find the
92 file name(s) mapping to this sector. It will try to gather as much
93 information about the given sector as possible.
95 mapsector currently has support for the following mapping schemes:
98 for mapper in $mappers; do
103 mapsector currently supports the following filesystems
106 for scanner in $scanners; do
111 mapsector will try it's best to find an associated file name but
112 depending on the filesystem state and the type of sector (e.g. if
113 the sector is part of a filesystem metadata block) this may not be
116 For mapsector to work, the filesystem must be currently active
117 (e.g. LVM must be running, crypted devices must have been set up). The
118 filesystem must not necessarily be mounted (though if mounted,
119 mapsector will give you the mountpoint).
121 if '--noscan' is given, the possibly lengthy (!!) filesystem scan for
122 filenames is skipped.
130 echo "device $device"
131 echo "sector $sector"
134 if [ -z "$noscan" ]; then