diff options
Diffstat (limited to 'src/partvi')
-rwxr-xr-x | src/partvi | 33 |
1 files changed, 27 insertions, 6 deletions
@@ -174,12 +174,30 @@ format_guid() | |||
174 | printf '%s\n' "${1:0:8}-${1:8:4}-${1:12:4}-${1:16:4}-${1:20:12}" | 174 | printf '%s\n' "${1:0:8}-${1:8:4}-${1:12:4}-${1:16:4}-${1:20:12}" |
175 | } | 175 | } |
176 | 176 | ||
177 | get_partition_size() | ||
178 | { | ||
179 | case "$type" in | ||
180 | dm-verity-hashes|dm-verity-data) | ||
181 | stat -L -c '%s' "$builddir"/"${f%.conf}" | ||
182 | ;; | ||
183 | *) | ||
184 | require_var allocation | ||
185 | case "$allocation" in | ||
186 | *K) echo $(( ${allocation%?} * 1024 )) ;; | ||
187 | *M) echo $(( ${allocation%?} * 1024 * 1024 )) ;; | ||
188 | *G) echo $(( ${allocation%?} * 1024 * 1024 * 1024 )) ;; | ||
189 | *) return 1 ;; | ||
190 | esac | ||
191 | ;; | ||
192 | esac | ||
193 | } | ||
194 | |||
177 | create_ptable_conf() | 195 | create_ptable_conf() |
178 | { | 196 | { |
179 | unset partuuid | 197 | unset partuuid |
180 | inquire_var partuuid | 198 | inquire_var partuuid |
181 | part=$builddir/${f%.conf} | 199 | devsz=$(get_partition_size) || return |
182 | devsz=$(stat -L -c '%s' "$part") || return | 200 | |
183 | [ "$start" -a "$devsz" ] || return | 201 | [ "$start" -a "$devsz" ] || return |
184 | 202 | ||
185 | [ "$((devsz % 512))" -eq 0 ] | 203 | [ "$((devsz % 512))" -eq 0 ] |
@@ -275,8 +293,9 @@ cleanup() | |||
275 | fi | 293 | fi |
276 | } | 294 | } |
277 | 295 | ||
278 | copy_data_to_mounted_target_filesystems() | 296 | mount_part() |
279 | { | 297 | { |
298 | local source_dev="$1" | ||
280 | case "$type" in | 299 | case "$type" in |
281 | efi-system-partition|boot|samizdat-keys) ;; | 300 | efi-system-partition|boot|samizdat-keys) ;; |
282 | dm-verity-hashes|partition-table|bios-grub) return ;; | 301 | dm-verity-hashes|partition-table|bios-grub) return ;; |
@@ -284,12 +303,15 @@ copy_data_to_mounted_target_filesystems() | |||
284 | esac | 303 | esac |
285 | 304 | ||
286 | img=${f%.conf} | 305 | img=${f%.conf} |
287 | dev=/dev/mapper/${whole#/dev/}p${img#part} | ||
288 | mnt=${f%.conf}.mnt | 306 | mnt=${f%.conf}.mnt |
289 | 307 | ||
290 | mkdir -p "$mnt" | 308 | mkdir -p "$mnt" |
291 | loudly $sudo mount "$dev" "$mnt" | 309 | loudly $sudo mount "$source_dev" "$mnt" |
310 | } | ||
292 | 311 | ||
312 | copy_data_to_mounted_target_filesystems() | ||
313 | { | ||
314 | mount_part "/dev/mapper/${whole#/dev/}p${img#part}" | ||
293 | case "$type" in | 315 | case "$type" in |
294 | boot) | 316 | boot) |
295 | BOOT_DIR=$mnt | 317 | BOOT_DIR=$mnt |
@@ -350,7 +372,6 @@ fi | |||
350 | 372 | ||
351 | 373 | ||
352 | 374 | ||
353 | |||
354 | if whole=$(losetup -j "$target" -O NAME --noheadings) | 375 | if whole=$(losetup -j "$target" -O NAME --noheadings) |
355 | then | 376 | then |
356 | cleanup | 377 | cleanup |