summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2020-11-17 16:06:32 -0500
committerAndrew Cady <d@cryptonomic.net>2020-11-17 16:06:32 -0500
commit364f92b8dbe973fb0e172be53ffea792184bafb5 (patch)
tree73804052ce30beddec3de6be514b67b56c4d780f
parentb81f932b7df9b12511e5c7c9a1507c932f076e6e (diff)
partvi: create the dm map
-rw-r--r--partitions/part0.conf4
-rwxr-xr-xsrc/partvi42
2 files changed, 45 insertions, 1 deletions
diff --git a/partitions/part0.conf b/partitions/part0.conf
new file mode 100644
index 0000000..b81ea5b
--- /dev/null
+++ b/partitions/part0.conf
@@ -0,0 +1,4 @@
1name=ptable
2type=partition-table
3allocation=1M
4rebuild=always
diff --git a/src/partvi b/src/partvi
index 57a3dba..322b5ba 100755
--- a/src/partvi
+++ b/src/partvi
@@ -79,6 +79,7 @@ do
79 case "$type" in 79 case "$type" in
80 efi-system-partition|bios-grub|samizdat-*) ;; 80 efi-system-partition|bios-grub|samizdat-*) ;;
81 dm-verity-hashes|dm-verity-data) require_var data_path ;; 81 dm-verity-hashes|dm-verity-data) require_var data_path ;;
82 partition-table) ;;
82 *) die "invalid type: $type" ;; 83 *) die "invalid type: $type" ;;
83 esac 84 esac
84 85
@@ -129,9 +130,48 @@ do
129 cp -f -T --reflink "$data_path".verity "$builddir"/"$partuuid" 130 cp -f -T --reflink "$data_path".verity "$builddir"/"$partuuid"
130 ln -sfT "$partuuid" "$tmp" 131 ln -sfT "$partuuid" "$tmp"
131 ;; 132 ;;
132 *) die "Unrecognized type: $type" ;;
133 esac 133 esac
134 mv -T "$tmp" "$imgfile" 134 mv -T "$tmp" "$imgfile"
135 notice "Successfully wrote $imgfile" 135 notice "Successfully wrote $imgfile"
136 fi 136 fi
137done 137done
138
139if [ "$UID" = 0 ]
140then sudo=
141else sudo=sudo
142fi
143
144map_name=samline
145
146quietly()
147{
148 "$@" >/dev/null 2>&1 || true
149}
150
151quietly $sudo dmsetup remove "$map_name"
152quietly $sudo losetup -D
153
154start=0
155map=$builddir/dmsetup.map
156: > "$map"
157
158for f in part*.conf
159do
160 part=$builddir/${f%.conf}
161 if [ -h "$part" ]
162 then
163 partuuid=$(readlink -e "$part")
164 else
165 partuuid=
166 fi
167 #stat -L --format="$part %s" "$part"
168 $sudo losetup -L -f "$part"
169 dev=$(losetup -j "$part" -O NAME --noheadings)
170 devsz=$($sudo blockdev --getsz $dev)
171 printf '%d %d linear %s 0\n' $start $devsz "$dev" >> "$map"
172 start=$((start + devsz))
173
174done
175$sudo dmsetup -v create "$map_name" "$map"
176$sudo dmsetup remove "$map_name"
177