From 9d1ac5015340aa7a4cc71cb7f63bae8c1718b8ee Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Thu, 23 Sep 2021 16:31:42 +0000 Subject: keep GUID specific attributes Keep GUID specific attributes when writing GPT. Signed-off-by: Brian C. Lane --- tests/Makefile.am | 3 +- tests/gpt-attrs | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/t0215-gpt-attrs.sh | 46 +++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100755 tests/gpt-attrs create mode 100644 tests/t0215-gpt-attrs.sh (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index f9340aa..3dc6e72 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -26,6 +26,7 @@ TESTS = \ t0211-gpt-rewrite-header.sh \ t0212-gpt-many-partitions.sh \ t0213-mkpart-start-negative.sh \ + t0215-gpt-attrs.sh \ t0220-gpt-msftres.sh \ t0250-gpt.sh \ t0251-gpt-unicode.sh \ @@ -98,7 +99,7 @@ TESTS = \ EXTRA_DIST = \ $(TESTS) t-local.sh t-lvm.sh \ init.cfg init.sh t-lib-helpers.sh gpt-header-munge \ - gpt-header-move msdos-overlap + gpt-header-move msdos-overlap gpt-attrs check_PROGRAMS = print-align print-flags print-max dup-clobber duplicate \ fs-resize diff --git a/tests/gpt-attrs b/tests/gpt-attrs new file mode 100755 index 0000000..0a01447 --- /dev/null +++ b/tests/gpt-attrs @@ -0,0 +1,72 @@ +#!/usr/bin/python3 + +# Copyright (C) 2021 SUSE LLC + +# program to show gpt partition attributes or set attributes of +# partition 1 + +# only works with 512 sectors and standard GPT header layout (128 +# partition entires with 128 bytes each, secondary header at end of +# device) + + +from struct import unpack_from, pack_into +from zipfile import crc32 +import array +import sys + + +class Gpt: + + # Calculate and insert the CRCs of the partition entires and the + # header. + def calc_crcs(self, header, entries): + # compute crc of partition entries + crc2 = crc32(entries) & 0xFFFFFFFF + pack_into('. + +. "${srcdir=.}/init.sh"; path_prepend_ ../parted $srcdir +require_512_byte_sector_size_ + +dev=loop-file + +# create device +truncate --size 50MiB "$dev" || fail=1 + +# create gpt label and one partitions +parted --script "$dev" mklabel gpt > out 2>&1 || fail=1 +parted --script "$dev" mkpart "test1" ext4 0% 10% > out 2>&1 || fail=1 + +# set guid specific bit +gpt-attrs "$dev" set 0x100000000000000 || fail=1 + +# create additional partition +parted --script "$dev" mkpart "test2" ext4 10% 20% > out 2>&1 || fail=1 + +cat < exp || fail=1 +0x100000000000000 +EOF + +# check guid specific bit +gpt-attrs "$dev" show > out || fail=1 +compare exp out || fail=1 + +Exit $fail -- cgit v1.2.1