#!/bin/sh ########################################################################### mappers="" scanners="" version="unknown" register_mapper() { mappers="${mappers}${mappers:+ }$1" } register_scanner() { scanners="${scanners}${scanners:+ }$1" } load() { for lib in `ls "$1"/[0-9][0-9]_*.sh | sort`; do source $lib done } # Map device/sector through blockdevice mappings (e.g. lvm) run() { local found foundm=1 while [ -n "$found" ]; do found="" for name in "$@"; do if detect_$name; then found=1 if do_$name; then return fi break fi done done } ########################################################################### unset LANG #### Find library directory and load library files name="`basename "$0"`" X="`dirname "$0"`" if [ "`basename "$X"`" == "bin" ]; then # `" libdir="`dirname "$X"`/lib/$name" #`" fi if [ -z "$libdir" -o ! -d "$libdir" ]; then libdir="$X/lib" fi if [ ! -d "$libdir" ]; then echo "! Library directory not found" 1>&2 exit 1 fi load "$libdir" #### Parse command line arguments X=`getopt -o "hV" --long "help,noscan,version" -n "$name" -- "$@"` if [ $? != 0 ]; then exit 1; fi eval set -- "$X" noscan="" help="" while true; do case "$1" in -h|--help) help="0"; shift ;; --noscan) noscan="0"; shift ;; -V|--version) echo "$name $version"; exit 0 ;; --) shift; break ;; *) echo "! internal error"; exit 1 ;; esac done if [ -n "$help" -o -z "$2" ]; then cat < " mapsector -- Map sector numbers to file name(s) Given a device and a sector number, mapsector will try to find the file name(s) mapping to this sector. It will try to gather as much information about the given sector as possible. mapsector currently has support for the following mapping schemes: EOF for mapper in $mappers; do describe_$mapper done cat <