Some fixes for karmic
[mapsector.git] / lib / 50_map_partition.sh
1 detect_partition()
2 {
3     file -bks $device | grep -qF partition
4 }
5
6 describe_partition()
7 {
8     echo "    partition tables"
9 }
10
11 do_partition()
12 {
13     # Step 1: Find partition to which this sector belongs
14
15     local partdev
16     local partstart
17     local partsector
18
19     echo "# $device: partition table detected" 1>&2
20
21     partdev="`fdisk -ul $device | awk -v sector="$sector" -F '[ *]+' '/^\// && !/Extended$/ && $2<=sector && $3>=sector {print $1,$2}'`" #`"
22
23     if [ -z "$partdev" ]; then
24         echo "# sector $sector is not part of any partition on $device" 1>&2
25         exit 0
26     fi
27
28     partstart="${partdev#* }"
29     partdev="${partdev% *}"
30     partsector="`dc -e "$sector $partstart - p"`" # `"
31
32     echo "offset $partstart"
33     echo "device $partdev partition"
34     echo "sector $partsector"
35
36     device="$partdev"
37     sector="$partsector"
38
39     return 1
40 }
41
42 register_mapper "partition"