3 ###########################################################################
14 mappers="${mappers}${mappers:+ }$1"
19 scanners="${scanners}${scanners:+ }$1"
28 if [ "`basename "$X"`" == "bin" ]; then # `"
29 libdir="`dirname "$X"`/share/$name" #`"
31 if [ -z "$libdir" -o ! -d "$libdir" ]; then
35 if [ ! -d "$libdir" ]; then
36 echo "! Library directory not found" 1>&2
40 for lib in `ls "$libdir"/[0-9][0-9]_*.sh | sort`; do
45 # Map device/sector through blockdevice mappings (e.g. lvm)
51 while [ -n "$found" ]; do
53 for name in $mappers; do
67 for name in $scanners; do
76 ###########################################################################
78 #### Load library modules
82 #### Parse command line arguments
84 X=`getopt -o "hV" --long "help,noscan,version" -n "$name" -- "$@"`
85 if [ $? != 0 ]; then exit 1; fi
93 -h|--help) help="0"; shift ;;
94 --noscan) noscan="0"; shift ;;
95 -V|--version) echo "$name $version"; exit 0 ;;
97 *) echo "! internal error"; exit 1 ;;
101 if [ -n "$help" -o -z "$2" ]; then
103 Usage: $name [-h|--help] [--noscan] <device> <sector>"
105 mapsector -- Map sector number to file name(s)
107 Given a device and a sector number, mapsector will try to find the
108 file name(s) mapping to this sector. It will try to gather as much
109 information about the given sector as possible.
111 mapsector currently has support for the following mapping schemes:
114 for mapper in $mappers; do
119 mapsector currently supports the following filesystems
122 for scanner in $scanners; do
127 mapsector will try it's best to find an associated file name but
128 depending on the filesystem state and the type of sector (e.g. if
129 the sector is part of a filesystem metadata block) this may not be
132 For mapsector to work, the filesystem must be currently active
133 (e.g. LVM must be running, crypted devices must have been set up). The
134 filesystem must not necessarily be mounted (though if mounted,
135 mapsector will give you the mountpoint).
137 if '--noscan' is given, the possibly lengthy (!!) filesystem scan for
138 filenames is skipped.
140 -- mapsector $version
148 echo "device $device"
149 echo "sector $sector"
152 if [ -z "$noscan" ]; then