- Upstream 3.4.64 Alpha release

- Dropped all patches included in new upstream release
- Bumped minor version on libparted.so and libparted-fs-resize.so
This commit is contained in:
Brian C. Lane 2022-03-30 10:26:37 -07:00
parent e0dc6bb4b8
commit dc62f3b119
48 changed files with 16 additions and 5051 deletions

2
.gitignore vendored
View File

@ -19,3 +19,5 @@ clog
/parted-3.3.52.tar.xz.sig
/parted-3.4.tar.xz
/parted-3.4.tar.xz.sig
/parted-3.4.64.tar.xz
/parted-3.4.64.tar.xz.sig

View File

@ -1,123 +0,0 @@
From 7c9a96209af2b84e1eec98ad3527f82ddd966cdf Mon Sep 17 00:00:00 2001
From: Cristian Klein <cristian.klein@elastisys.com>
Date: Fri, 11 Dec 2020 22:19:22 +0100
Subject: [PATCH 1/5] parted: add --fix to "fix" in script mode
Use-case: VMs are booted from images that are smaller than their virtual
disk. This means that -- almost by definition -- the secondary GPT
header will be "misplaced", i.e., not at the end of the virtual disk.
Without this patch, parted cannot be used for custom/exotic partitioning
when the VM boots (e.g., in cloud-init's `bootcmd`). Specifically, it
will fail as follows:
```
$ sudo parted --script /dev/vda "mkpart 2 10GB -1"
Warning: Not all of the space available to /dev/vda appears to be used,
you can fix the GPT to use all of the space (an extra 500 blocks) or continue with the current setting?
Error: Unable to satisfy all constraints on the partition.
```
This happens because, in script mode, exceptions are usually not
resolved.
This patch adds `--fix`. This allows exceptions to be automatically
resolved with Fix. As a result, the following command will work:
```
$ sudo parted --fix --script /dev/vda "mkpart 2 10GB -1"
```
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
parted/parted.c | 8 ++++++--
parted/ui.c | 7 +++++++
parted/ui.h | 1 +
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/parted/parted.c b/parted/parted.c
index e84e66d..41edb7f 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -116,6 +116,7 @@ static struct option const options[] = {
{"list", 0, NULL, 'l'},
{"machine", 0, NULL, 'm'},
{"script", 0, NULL, 's'},
+ {"fix", 0, NULL, 'f'},
{"version", 0, NULL, 'v'},
{"align", required_argument, NULL, 'a'},
{"-pretend-input-tty", 0, NULL, PRETEND_INPUT_TTY},
@@ -127,12 +128,14 @@ static const char *const options_help [][2] = {
{"list", N_("lists partition layout on all block devices")},
{"machine", N_("displays machine parseable output")},
{"script", N_("never prompts for user intervention")},
+ {"fix", N_("in script mode, fix instead of abort when asked")},
{"version", N_("displays the version")},
{"align=[none|cyl|min|opt]", N_("alignment for new partitions")},
{NULL, NULL}
};
int opt_script_mode = 0;
+int opt_fix_mode = 0;
int pretend_input_tty = 0;
int opt_machine_mode = 0;
int disk_is_modified = 0;
@@ -2191,7 +2194,7 @@ int opt, help = 0, list = 0, version = 0, wrong = 0;
while (1)
{
- opt = getopt_long (*argc_ptr, *argv_ptr, "hlmsva:",
+ opt = getopt_long (*argc_ptr, *argv_ptr, "hlmsfva:",
options, NULL);
if (opt == -1)
break;
@@ -2201,6 +2204,7 @@ while (1)
case 'l': list = 1; break;
case 'm': opt_machine_mode = 1; break;
case 's': opt_script_mode = 1; break;
+ case 'f': opt_fix_mode = 1; break;
case 'v': version = 1; break;
case 'a':
alignment = XARGMATCH ("--align", optarg,
@@ -2217,7 +2221,7 @@ while (1)
if (wrong == 1) {
fprintf (stderr,
- _("Usage: %s [-hlmsv] [-a<align>] [DEVICE [COMMAND [PARAMETERS]]...]\n"),
+ _("Usage: %s [-hlmsfv] [-a<align>] [DEVICE [COMMAND [PARAMETERS]]...]\n"),
program_name);
return 0;
}
diff --git a/parted/ui.c b/parted/ui.c
index 973bd26..b5948d3 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -644,6 +644,13 @@ exception_handler (PedException* ex)
if (!option_get_next (ex->options, opt))
return opt;
+ /* script-mode and fix? */
+ int fix_is_an_option = (ex->options & PED_EXCEPTION_FIX);
+ if (opt_script_mode && opt_fix_mode && fix_is_an_option) {
+ printf ("Fixing, due to --fix\n");
+ return PED_EXCEPTION_FIX;
+ }
+
/* script-mode: don't handle the exception */
if (opt_script_mode || (!isatty (0) && !pretend_input_tty))
return PED_EXCEPTION_UNHANDLED;
diff --git a/parted/ui.h b/parted/ui.h
index 3b07782..e4e88b6 100644
--- a/parted/ui.h
+++ b/parted/ui.h
@@ -89,6 +89,7 @@ extern void print_using_dev (PedDevice* dev);
/* in parted.c */
extern int opt_script_mode;
+extern int opt_fix_mode;
extern int pretend_input_tty;
extern void print_options_help ();
--
2.26.2

View File

@ -1,47 +0,0 @@
From 8aa569aa60c37526a8c37b06e88a833745a7a6ef Mon Sep 17 00:00:00 2001
From: Cristian Klein <cristian.klein@elastisys.com>
Date: Fri, 11 Dec 2020 22:19:23 +0100
Subject: [PATCH 2/5] doc: Document --fix flag
Also fix copyright year, to please `make syntax-check`.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
doc/C/parted.8 | 3 +++
doc/parted.texi | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/doc/C/parted.8 b/doc/C/parted.8
index 297c39a..d8e556e 100644
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
@@ -27,6 +27,9 @@ displays machine parseable output
.B -s, --script
never prompts for user intervention
.TP
+.B -f, --fix
+automatically answer "fix" to exceptions in script mode
+.TP
.B -v, --version
displays the version
.TP
diff --git a/doc/parted.texi b/doc/parted.texi
index d89d74d..33212f0 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -406,6 +406,12 @@ display a help message
@itemx --script
never prompt the user
+@item -f
+@itemx --fix
+automatically answer exceptions with "fix" in script mode, whcih is useful for:
+GPT header not including full disk size; moving the backup GPT table to the end of the disk;
+MAC fix missing partition map entry; etc.
+
@item -a alignment-type
@itemx --align alignment-type
Set alignment for newly created partitions, valid alignment types are:
--
2.26.2

View File

@ -1,135 +0,0 @@
From 6b2c8806b42a7214d726cc2b3dac6b96013a6cce Mon Sep 17 00:00:00 2001
From: Cristian Klein <cristian.klein@elastisys.com>
Date: Fri, 11 Dec 2020 22:19:24 +0100
Subject: [PATCH 3/5] tests: Add tests for --fix
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
tests/Makefile.am | 3 +-
tests/t9060-gpt-grow-script-fix.sh | 100 +++++++++++++++++++++++++++++
2 files changed, 102 insertions(+), 1 deletion(-)
create mode 100755 tests/t9060-gpt-grow-script-fix.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0d7c022..3473e6b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -89,7 +89,8 @@ TESTS = \
t9040-many-partitions.sh \
t9041-undetected-in-use-16th-partition.sh \
t9042-dos-partition-limit.sh \
- t9050-partition-table-types.sh
+ t9050-partition-table-types.sh \
+ t9060-gpt-grow-script-fix.sh
EXTRA_DIST = \
$(TESTS) t-local.sh t-lvm.sh \
diff --git a/tests/t9060-gpt-grow-script-fix.sh b/tests/t9060-gpt-grow-script-fix.sh
new file mode 100755
index 0000000..4a3a8a9
--- /dev/null
+++ b/tests/t9060-gpt-grow-script-fix.sh
@@ -0,0 +1,100 @@
+#!/bin/sh
+# grow a gpt disk, ensure that parted offers to update the gpt size
+# do this in script mode with fix
+
+# Copyright (C) 2009-2012, 2014, 2019 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+require_512_byte_sector_size_
+dev=loop-file
+
+ss=$sector_size_
+n_sectors=5000
+
+dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
+
+# create gpt label
+parted -s $dev mklabel gpt > empty 2>&1 || fail=1
+compare /dev/null empty || fail=1
+
+# print the empty table
+parted -m -s $dev unit s print > t 2>&1 || fail=1
+sed "s,.*/$dev:,$dev:," t > out || fail=1
+
+# check for expected output
+printf "BYT;\n$dev:${n_sectors}s:file:$sector_size_:$sector_size_:gpt::;\n" \
+ > exp || fail=1
+compare exp out || fail=1
+
+# grow disk
+n_sectors=5500
+dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
+
+# printing must warn, but not fix in script mode
+parted -s $dev print > out 2>&1 || fail=1
+
+# Transform the actual output, to avoid spurious differences when
+# $PWD contains a symlink-to-dir. Also, remove the ^M ...^M bogosity.
+# normalize the actual output
+mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s, * ,,g;s, $,," \
+ -e "s,^.*/lt-parted: ,parted: ," o2 > out
+
+# check for expected diagnostic
+cat <<EOF > exp || fail=1
+Warning: Not all of the space available to DEVICE appears to be used, you can fix the GPT to use all of the space (an extra 500 blocks) or continue with the current setting?
+Model: (file)
+Disk DEVICE: 2816kB
+Sector size (logical/physical): 512B/512B
+Partition Table: gpt
+Disk Flags:
+
+Number Start End Size File system Name Flags
+
+EOF
+compare exp out || fail=1
+
+# now we fix
+parted --script --fix $dev print > out 2>&1 || fail=1
+
+# Transform the actual output, to avoid spurious differences when
+# $PWD contains a symlink-to-dir. Also, remove the ^M ...^M bogosity.
+# normalize the actual output
+mv out o2 && sed -e "s,/.*/$dev,DEVICE,;s, * ,,g;s, $,," \
+ -e "s,^.*/lt-parted: ,parted: ," o2 > out
+
+# check for expected diagnostic
+cat <<EOF > exp || fail=1
+Warning: Not all of the space available to DEVICE appears to be used, you can fix the GPT to use all of the space (an extra 500 blocks) or continue with the current setting?
+Fixing, due to --fix
+Model: (file)
+Disk DEVICE: 2816kB
+Sector size (logical/physical): 512B/512B
+Partition Table: gpt
+Disk Flags:
+
+Number Start End Size File system Name Flags
+
+EOF
+compare exp out || fail=1
+
+
+# Now should not warn
+
+parted -s $dev print > err 2>&1 || fail=1
+grep Warning: err > k ; mv k err
+compare /dev/null err || fail=1
+
+Exit $fail
--
2.26.2

View File

@ -1,35 +0,0 @@
From 9bb4afe61426419c8bb83a25aa9822e00611c8f3 Mon Sep 17 00:00:00 2001
From: Cristian Klein <cristian.klein@elastisys.com>
Date: Fri, 11 Dec 2020 22:19:25 +0100
Subject: [PATCH 4/5] tests: Fix test t1700-probe-fs
mkfs.ext3 (see version below) was complaining that the filesystem is too small
for a journal, which made the test fail.
```
$ mkfs.ext3 -V
mke2fs 1.45.5 (07-Jan-2020)
Using EXT2FS Library version 1.45.5
```
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
tests/t1700-probe-fs.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh
index 848d3e3..5c08e97 100755
--- a/tests/t1700-probe-fs.sh
+++ b/tests/t1700-probe-fs.sh
@@ -57,7 +57,7 @@ done
# Some features should indicate ext4 by themselves.
for feature in uninit_bg flex_bg; do
# create an ext3 file system
- dd if=/dev/null of=$dev bs=1024 seek=4096 >/dev/null || skip_ "dd failed"
+ dd if=/dev/null of=$dev bs=1024 seek=8192 >/dev/null || skip_ "dd failed"
mkfs.ext3 -F $dev >/dev/null || skip_ "mkfs.ext3 failed"
# set the feature
--
2.26.2

View File

@ -1,33 +0,0 @@
From 6ed9c9e82ea6cfbee93a47e82e92a90abdb82343 Mon Sep 17 00:00:00 2001
From: Cristian Klein <cristian.klein@elastisys.com>
Date: Fri, 11 Dec 2020 22:19:26 +0100
Subject: [PATCH 5/5] tests: Fix t9041-undetected-in-use-16th-partition
Sometimes fails with:
```
+ mkfs.ext3 /dev/sda15
mke2fs 1.45.5 (07-Jan-2020)
/dev/sda15: Not enough space to build proposed filesystem while setting up superblock
```
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
tests/t9041-undetected-in-use-16th-partition.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/t9041-undetected-in-use-16th-partition.sh b/tests/t9041-undetected-in-use-16th-partition.sh
index a4a3020..129bf15 100644
--- a/tests/t9041-undetected-in-use-16th-partition.sh
+++ b/tests/t9041-undetected-in-use-16th-partition.sh
@@ -25,7 +25,7 @@ grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||
skip_ 'this system lacks a new-enough libblkid'
ss=$sector_size_
-partition_sectors=256 # sectors per partition
+partition_sectors=512 # sectors per partition
n_partitions=17 # how many partitions to create
start=2048 # start sector for the first partition
gpt_slop=34 # sectors at end of disk reserved for GPT
--
2.26.2

View File

@ -1,26 +0,0 @@
From dacdfc20957d92eff7a3c9fd72baa849b45485e3 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 10 Jun 2021 15:39:04 -0700
Subject: [PATCH 06/13] libparted: Fix fd check in _flush_cache
In theory open() could return 0 so the correct error value is -1.
---
libparted/arch/linux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 94ea176..9dc90b5 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1678,7 +1678,7 @@ _flush_cache (PedDevice* dev)
break;
if (!_partition_is_mounted_by_path (name)) {
fd = open (name, WR_MODE, 0);
- if (fd > 0) {
+ if (fd > -1) {
ioctl (fd, BLKFLSBUF);
retry:
if (fsync (fd) < 0 || close (fd) < 0)
--
2.31.1

View File

@ -1,38 +0,0 @@
From 8e6976661409d7c87b1f0a80ebdddc450b4db2dd Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 10 Jun 2021 15:41:33 -0700
Subject: [PATCH 07/13] libparted: Fix potential memory leak in
sdmmc_get_product_info
---
libparted/arch/linux.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 9dc90b5..aacc94f 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1399,13 +1399,19 @@ static int
init_sdmmc (PedDevice* dev)
{
char id[128];
- char *type, *name;
+ char *type = NULL;
+ char *name = NULL;
if (sdmmc_get_product_info (dev, &type, &name)) {
snprintf (id, sizeof(id) - 1, "%s %s", type, name);
free (type);
free (name);
} else {
+ // One or the other may have been allocated, free it
+ if (type)
+ free(type);
+ if (name)
+ free(name);
snprintf (id, sizeof(id) - 1, "%s",
_("Generic SD/MMC Storage Card"));
}
--
2.31.1

View File

@ -1,34 +0,0 @@
From acb5300bfc37f8b8c217758e83a31b7ecca84f4a Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 10 Jun 2021 15:45:57 -0700
Subject: [PATCH 08/13] fs: Fix copy-paste error in HFS journal code
---
libparted/fs/r/hfs/journal.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libparted/fs/r/hfs/journal.c b/libparted/fs/r/hfs/journal.c
index 862d3d3..c7cd009 100644
--- a/libparted/fs/r/hfs/journal.c
+++ b/libparted/fs/r/hfs/journal.c
@@ -337,12 +337,14 @@ hfsj_replay_journal(PedFileSystem* fs)
}
jh->checksum = HFS_CPU_TO_32(cksum, is_le);
- /* The 2 following test are in the XNU Darwin source code */
- /* so I assume they're needed */
+ /* https://github.com/apple-opensource/hfs/blob/master/core/hfs_journal.c#L1167
+ * indicates that this is:
+ * wrap the start ptr if it points to the very end of the journal
+ */
if (jh->start == jh->size)
jh->start = HFS_CPU_TO_64(PED_SECTOR_SIZE_DEFAULT, is_le);
if (jh->end == jh->size)
- jh->start = HFS_CPU_TO_64(PED_SECTOR_SIZE_DEFAULT, is_le);
+ jh->end = HFS_CPU_TO_64(PED_SECTOR_SIZE_DEFAULT, is_le);
if (jh->start == jh->end)
return 1;
--
2.31.1

View File

@ -1,53 +0,0 @@
From 3a7f644f21703afcf7088a5994be1a6dff19f679 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 10 Jun 2021 15:51:12 -0700
Subject: [PATCH 09/13] parted: Fix end_input leak in do_mkpart
---
parted/parted.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/parted/parted.c b/parted/parted.c
index 41edb7f..e9aa240 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -645,6 +645,7 @@ do_mkpart (PedDevice** dev, PedDisk** diskp)
char* part_name = NULL;
char *start_usr = NULL, *end_usr = NULL;
char *start_sol = NULL, *end_sol = NULL;
+ char *end_input = NULL;
if (*diskp)
disk = *diskp;
@@ -698,12 +699,10 @@ do_mkpart (PedDevice** dev, PedDisk** diskp)
if (!command_line_get_sector (_("Start?"), *dev, &start, &range_start, NULL))
goto error;
- char *end_input;
if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_input))
goto error;
_adjust_end_if_iec(&start, &end, range_end, end_input);
- free(end_input);
/* processing starts here */
part = ped_partition_new (disk, part_type, fs_type, start, end);
@@ -839,6 +838,7 @@ do_mkpart (PedDevice** dev, PedDisk** diskp)
free (end_usr);
free (start_sol);
free (end_sol);
+ free(end_input);
if ((*dev)->type != PED_DEVICE_FILE)
disk_is_modified = 1;
@@ -860,6 +860,7 @@ error:
free (end_usr);
free (start_sol);
free (end_sol);
+ free(end_input);
return 0;
}
--
2.31.1

View File

@ -1,25 +0,0 @@
From fbd83d9df7bf5fd0c830935decb9bbc482bf95f4 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 10 Jun 2021 15:52:28 -0700
Subject: [PATCH 10/13] parted: Free tmp usage inside do_print
str_list_create calls gettext_to_wchar which makes a copy of it.
---
parted/parted.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/parted/parted.c b/parted/parted.c
index e9aa240..ba152c3 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1192,6 +1192,7 @@ do_print (PedDevice** dev, PedDisk** diskp)
sprintf (tmp, "%2s ", "");
StrList *row = str_list_create (tmp, NULL);
+ free(tmp);
start = ped_unit_format (*dev, part->geom.start);
end = ped_unit_format_byte (
--
2.31.1

View File

@ -1,43 +0,0 @@
From 6c4050af2c6c0abdbe1d553fdf2f19a6b600e9d1 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 10 Jun 2021 15:55:59 -0700
Subject: [PATCH 11/13] parted: Fix memory leaks in do_resizepart
---
parted/parted.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/parted/parted.c b/parted/parted.c
index ba152c3..22b5818 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1582,7 +1582,6 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
/* Push the End value back onto the command_line, if it exists */
if (end_size) {
command_line_push_word(end_size);
- free(end_size);
}
start = part->geom.start;
@@ -1590,7 +1589,7 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_input))
goto error;
_adjust_end_if_iec(&start, &end, range_end, end_input);
- free(end_input);
+
/* Do not move start of the partition */
constraint = constraint_from_start_end_fixed_start (*dev, start, range_end);
if (!ped_disk_set_partition_geom (disk, part, constraint,
@@ -1616,6 +1615,9 @@ error_destroy_constraint:
error:
if (range_end != NULL)
ped_geometry_destroy (range_end);
+ free(end_input);
+ free(end_size);
+
return rc;
}
--
2.31.1

View File

@ -1,57 +0,0 @@
From 86594612f8ae4dbc416e3cd1bc8bb05445df09e5 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Fri, 11 Jun 2021 12:05:22 -0700
Subject: [PATCH 12/13] libparted: Fix warning about buffer size in Atari label
When the Atari table is empty it copies 'PARTEDATARI' into the id, and
the start and size bytes. This can be confusion, so turn it into a
union of the string and the non-empty values.
---
libparted/labels/atari.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/libparted/labels/atari.c b/libparted/labels/atari.c
index 7923487..2ac03d2 100644
--- a/libparted/labels/atari.c
+++ b/libparted/labels/atari.c
@@ -137,9 +137,14 @@ static AtariFS2PartId atr_fs2pid[] = {
struct __attribute__ ((packed)) _AtariRawPartition {
uint8_t flag; /* bit 0: active; bit 7: bootable */
- uint8_t id[3]; /* "GEM", "BGM", "XGM", ... */
- uint32_t start; /* start of partition */
- uint32_t size; /* length of partition */
+ union {
+ uint8_t empty[11]; /* Empty table */
+ struct __attribute__ ((packed)) {
+ uint8_t id[3]; /* "GEM", "BGM", "XGM", ... */
+ uint32_t start; /* start of partition */
+ uint32_t size; /* length of partition */
+ };
+ };
};
typedef struct _AtariRawPartition AtariRawPartition;
@@ -241,8 +246,8 @@ static int
atr_is_signature_entry (AtariRawPartition* part)
{
return part->flag == 0
- && !memcmp (part->id, SIGNATURE_EMPTY_TABLE,
- SIGNATURE_EMPTY_SIZE );
+ && !memcmp (part->empty, SIGNATURE_EMPTY_TABLE,
+ SIGNATURE_EMPTY_SIZE );
}
/* Set Parted signature in an AHDI entry */
@@ -250,7 +255,7 @@ static void
atr_put_signature_entry (AtariRawPartition* part)
{
part->flag = 0;
- memcpy (part->id, SIGNATURE_EMPTY_TABLE, SIGNATURE_EMPTY_SIZE);
+ memcpy (part->empty, SIGNATURE_EMPTY_TABLE, SIGNATURE_EMPTY_SIZE);
}
#define atr_part_known(part, pid_list) (atr_pid_known ((part)->id, pid_list))
--
2.31.1

View File

@ -1,44 +0,0 @@
From 16751493376db612abcceae5ae81fd798c0a4d18 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Fri, 11 Jun 2021 13:43:02 -0700
Subject: [PATCH 13/13] libparted: Fix potential memory leak in gpt_write
_generate_header() can return with 1 after allocating gpt so it needs to
be freed in the error path.
---
libparted/labels/gpt.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 93f7add..9b987c1 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1292,8 +1292,10 @@ gpt_write (const PedDisk *disk)
/* Write PTH and PTEs */
/* FIXME: Caution: this code is nearly identical to what's just below. */
- if (_generate_header (disk, 0, ptes_crc, &gpt) != 0)
- goto error_free_ptes;
+ if (_generate_header (disk, 0, ptes_crc, &gpt) != 0) {
+ pth_free(gpt);
+ goto error_free_ptes;
+ }
pth_raw = pth_get_raw (disk->dev, gpt);
pth_free (gpt);
if (pth_raw == NULL)
@@ -1307,8 +1309,10 @@ gpt_write (const PedDisk *disk)
/* Write Alternate PTH & PTEs */
/* FIXME: Caution: this code is nearly identical to what's just above. */
- if (_generate_header (disk, 1, ptes_crc, &gpt) != 0)
- goto error_free_ptes;
+ if (_generate_header (disk, 1, ptes_crc, &gpt) != 0) {
+ pth_free(gpt);
+ goto error_free_ptes;
+ }
pth_raw = pth_get_raw (disk->dev, gpt);
pth_free (gpt);
if (pth_raw == NULL)
--
2.31.1

View File

@ -1,34 +0,0 @@
From f801496427db11cc468065dcd77d1c610c0a1047 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 14 Jun 2021 14:23:46 -0700
Subject: [PATCH 14/15] tests: t0400 - Work around a mkswap bug by using
/dev/zero
mkswap gets stuck, in some situations, when operating on a file full of
holes (see https://bugzilla.redhat.com/show_bug.cgi?id=1971877) so work
around that by using /dev/zero instead of /dev/null
---
tests/t0400-loop-clobber-infloop.sh | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tests/t0400-loop-clobber-infloop.sh b/tests/t0400-loop-clobber-infloop.sh
index 2d2190d..d05a8e0 100644
--- a/tests/t0400-loop-clobber-infloop.sh
+++ b/tests/t0400-loop-clobber-infloop.sh
@@ -22,7 +22,12 @@
N=1M
dev=loop-file
-dd if=/dev/null of=$dev bs=1 seek=$N || fail=1
+
+cleanup_() {
+ rm -f $dev;
+}
+
+dd if=/dev/zero of=$dev bs=$N count=1 || fail=1
mkswap $dev || fail=1
--
2.31.1

View File

@ -1,46 +0,0 @@
From ea1a97b57d4e84005c66bc9c05f2e7c9244b5118 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 14 Jun 2021 15:04:05 -0700
Subject: [PATCH 15/15] tests: t9050 Use /dev/zero for temporary file and
mkswap
and clean up the usage a little bit by giving it a proper name and
removing the file when finished.
---
tests/t9050-partition-table-types.sh | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/tests/t9050-partition-table-types.sh b/tests/t9050-partition-table-types.sh
index 57e004a..d63fa80 100755
--- a/tests/t9050-partition-table-types.sh
+++ b/tests/t9050-partition-table-types.sh
@@ -35,16 +35,22 @@ pc98
sun
mkswap
'
+N=1M
+dev=loop-file
-dd if=/dev/null of=f bs=1 seek=30M || framework_failure_
+cleanup_() {
+ rm -f $dev;
+}
+
+dd if=/dev/zero of=$dev bs=$N count=30 || framework_failure_
for i in $types; do
for j in $types; do
echo $i:$j
- case $i in mkswap) mkswap f || fail=1;;
- *) parted -s f mklabel $i || fail=1;; esac
+ case $i in mkswap) mkswap $dev || fail=1;;
+ *) parted -s $dev mklabel $i || fail=1;; esac
case $j in mkswap) continue;; esac
- parted -s f mklabel $j || fail=1
+ parted -s $dev mklabel $j || fail=1
done
done
--
2.31.1

View File

@ -1,41 +0,0 @@
From 4a053e111beacbeabeddc20c71d0215aedf219fb Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 12 Jul 2021 15:26:36 -0700
Subject: [PATCH 16/24] tests/t1100: Change dev_size_mb to 10
This is backed by memory, so using more than is needed limits the size
of the system it can run on.
---
tests/t1100-busy-label.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/t1100-busy-label.sh b/tests/t1100-busy-label.sh
index f1a13df..71b847c 100755
--- a/tests/t1100-busy-label.sh
+++ b/tests/t1100-busy-label.sh
@@ -21,11 +21,11 @@ require_root_
require_scsi_debug_module_
ss=$sector_size_
-scsi_debug_setup_ sector_size=$ss dev_size_mb=90 > dev-name ||
+scsi_debug_setup_ sector_size=$ss dev_size_mb=10 > dev-name ||
skip_ 'failed to create scsi_debug device'
dev=$(cat dev-name)
-parted -s "$dev" mklabel msdos mkpart primary fat32 1 40 > out 2>&1 || fail=1
+parted -s "$dev" mklabel msdos mkpart primary fat32 1 4 > out 2>&1 || fail=1
compare /dev/null out || fail=1
wait_for_dev_to_appear_ ${dev}1 || fail=1
mkfs.vfat ${dev}1 || fail=1
@@ -48,7 +48,7 @@ compare exp out || fail=1
# Adding a partition must succeed, even though another
# on this same device is mounted (active).
-parted -s "$dev" mkpart primary fat32 41 85 > out 2>&1 || fail=1
+parted -s "$dev" mkpart primary fat32 5 10 > out 2>&1 || fail=1
compare /dev/null out || fail=1
parted -s "$dev" u s print
--
2.31.1

View File

@ -1,40 +0,0 @@
From f1c0f474670612b79a30d70863b4351c5883b5f6 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 12 Jul 2021 15:27:30 -0700
Subject: [PATCH 17/24] tests/t1101: Change dev_size_mb to 10
This is backed by memory, so using more than is needed limits the size
of the system it can run on.
---
tests/t1101-busy-partition.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/t1101-busy-partition.sh b/tests/t1101-busy-partition.sh
index e35e6f0..5e37814 100755
--- a/tests/t1101-busy-partition.sh
+++ b/tests/t1101-busy-partition.sh
@@ -24,7 +24,7 @@ require_root_
require_scsi_debug_module_
# create memory-backed device
-scsi_debug_setup_ dev_size_mb=80 > dev-name ||
+scsi_debug_setup_ dev_size_mb=10 > dev-name ||
skip_ 'failed to create scsi_debug device'
dev=$(cat dev-name)
@@ -37,10 +37,10 @@ parted -s "$dev" mklabel msdos > out 2>&1 || fail=1
# expect no output
compare /dev/null out || fail=1
-parted -s "$dev" mkpart primary fat32 1 40 > out 2>&1 || fail=1
+parted -s "$dev" mkpart primary fat32 1 4 > out 2>&1 || fail=1
compare /dev/null out || fail=1
-parted -s "$dev" mkpart primary fat32 40 80 > out 2>&1 || fail=1
+parted -s "$dev" mkpart primary fat32 4 10 > out 2>&1 || fail=1
compare /dev/null out || fail=1
# wait for new partition device to appear
--
2.31.1

View File

@ -1,43 +0,0 @@
From 29cf5841f7c046e149e3554a0f92a96169681bec Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 12 Jul 2021 15:28:33 -0700
Subject: [PATCH 18/24] tests/t1102: Change dev_size_mb to 10
This is backed by memory, so using more than is needed limits the size
of the system it can run on.
---
tests/t1102-loop-label.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/t1102-loop-label.sh b/tests/t1102-loop-label.sh
index 091227b..0a120b9 100644
--- a/tests/t1102-loop-label.sh
+++ b/tests/t1102-loop-label.sh
@@ -23,7 +23,7 @@ require_root_
require_scsi_debug_module_
ss=$sector_size_
-scsi_debug_setup_ sector_size=$ss dev_size_mb=90 > dev-name ||
+scsi_debug_setup_ sector_size=$ss dev_size_mb=10 > dev-name ||
skip_ 'failed to create scsi_debug device'
dev=$(cat dev-name)
@@ -31,13 +31,13 @@ mke2fs -F $dev
parted -s "$dev" print > out 2>&1 || fail=1
cat <<EOF > exp
Model: Linux scsi_debug (scsi)
-Disk DEVICE: 94.4MB
+Disk DEVICE: 10.5MB
Sector size (logical/physical): ${ss}B/${ss}B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
- 1 0.00B 94.4MB 94.4MB ext2
+ 1 0.00B 10.5MB 10.5MB ext2
EOF
mv out o2 && sed -e "s,$dev,DEVICE,;s/ *$//" o2 > out
--
2.31.1

View File

@ -1,36 +0,0 @@
From 843a800098705c71698dabb3c2e549912b17606a Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 12 Jul 2021 15:29:03 -0700
Subject: [PATCH 19/24] tests/t1701: Change dev_size_mb to 10
This is backed by memory, so using more than is needed limits the size
of the system it can run on.
---
tests/t1701-rescue-fs.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/t1701-rescue-fs.sh b/tests/t1701-rescue-fs.sh
index 050c064..71d545d 100644
--- a/tests/t1701-rescue-fs.sh
+++ b/tests/t1701-rescue-fs.sh
@@ -22,7 +22,7 @@ require_root_
require_scsi_debug_module_
# create memory-backed device
-scsi_debug_setup_ sector_size=$sector_size_ dev_size_mb=32 > dev-name ||
+scsi_debug_setup_ sector_size=$sector_size_ dev_size_mb=10 > dev-name ||
skip_ 'failed to create scsi_debug device'
scsi_dev=$(cat dev-name)
@@ -39,7 +39,7 @@ parted -s $scsi_dev rm 1 || fail=1
# rescue the partition
echo yes | parted ---pretend-input-tty $scsi_dev rescue 1m 100% > out 2>&1
cat > exp <<EOF
-Information: A ext4 primary partition was found at 1049kB -> 33.6MB. Do you want to add it to the partition table?
+Information: A ext4 primary partition was found at 1049kB -> 10.5MB. Do you want to add it to the partition table?
Yes/No/Cancel? yes
Information: You may need to update /etc/fstab.
EOF
--
2.31.1

View File

@ -1,32 +0,0 @@
From e72dc01c85fb6baa8e065660bda6ec92e21bee49 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 12 Jul 2021 15:29:29 -0700
Subject: [PATCH 20/24] tests/t3000: Change dev_size_mb to 267
FAT32 needs a minimum partition size of 256MB so this is as small as we
can make it.
This is backed by memory, so using more than is needed limits the size
of the system it can run on.
---
tests/t3000-resize-fs.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh
index 64b038d..1f2e46e 100755
--- a/tests/t3000-resize-fs.sh
+++ b/tests/t3000-resize-fs.sh
@@ -29,8 +29,8 @@ start=63s
default_end=546147s
new_end=530144s
-# create memory-backed device
-scsi_debug_setup_ dev_size_mb=550 > dev-name ||
+# create memory-backed device. Must be > 256MB+8MB
+scsi_debug_setup_ dev_size_mb=267 > dev-name ||
skip_ 'failed to create scsi_debug device'
dev=$(cat dev-name)
--
2.31.1

View File

@ -1,36 +0,0 @@
From 18556277b93ebb7dd88da5d4928189386c0eb132 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 12 Jul 2021 15:29:59 -0700
Subject: [PATCH 21/24] tests/t3200: Change dev_size_mb to 10
This is backed by memory, so using more than is needed limits the size
of the system it can run on.
---
tests/t3200-type-change.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/t3200-type-change.sh b/tests/t3200-type-change.sh
index 39904e0..3ad8604 100755
--- a/tests/t3200-type-change.sh
+++ b/tests/t3200-type-change.sh
@@ -25,7 +25,7 @@ grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||
skip_ 'this system lacks a new-enough libblkid'
# create memory-backed device
-scsi_debug_setup_ dev_size_mb=550 > dev-name ||
+scsi_debug_setup_ dev_size_mb=10 > dev-name ||
skip_ 'failed to create scsi_debug device'
scsi_dev=$(cat dev-name)
@@ -34,7 +34,7 @@ scsi_dev=$(cat dev-name)
# partition and ensure that parted doesn't "helpfully" change the partition
# type to match the newly-detected FS type.
-parted -s $scsi_dev mklabel msdos mkpart primary fat32 64s 80000s || fail=1
+parted -s $scsi_dev mklabel msdos mkpart primary fat32 1MiB 100% || fail=1
parted -s $scsi_dev u s p
--
2.31.1

View File

@ -1,48 +0,0 @@
From 0caf2d7f1363b9c4b3b63cf7d3a1260eb5a72f34 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Mon, 12 Jul 2021 15:30:45 -0700
Subject: [PATCH 22/24] tests/t6006: Change dev_size_mb to 10
This is backed by memory, so using more than is needed limits the size
of the system it can run on.
---
tests/t6006-dm-512b-sectors.sh | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/t6006-dm-512b-sectors.sh b/tests/t6006-dm-512b-sectors.sh
index 2460c49..83bf3b1 100644
--- a/tests/t6006-dm-512b-sectors.sh
+++ b/tests/t6006-dm-512b-sectors.sh
@@ -46,9 +46,9 @@ cleanup_fn_() {
udevadm settle
}
-# Create a 500M device
+# Create a 10M device
ss=$sector_size_
-scsi_debug_setup_ sector_size=$ss dev_size_mb=500 > dev-name ||
+scsi_debug_setup_ sector_size=$ss dev_size_mb=11 > dev-name ||
skip_ 'failed to create scsi_debug device'
scsi_dev=$(cat dev-name)
@@ -58,13 +58,13 @@ scsi_dev_size=$(blockdev --getsz $scsi_dev) || framework_failure
dmsetup create $linear_ --table "0 $scsi_dev_size linear $scsi_dev 0" || framework_failure
dev="/dev/mapper/$linear_"
-# Create msdos partition table with a partition from 1MiB to 100MiB
-parted -s $dev mklabel msdos mkpart primary ext2 1MiB 101MiB > out 2>&1 || fail=1
+# Create msdos partition table with a partition from 1MiB to 10MiB
+parted -s $dev mklabel msdos mkpart primary ext2 1MiB 100% > out 2>&1 || fail=1
compare /dev/null out || fail=1
wait_for_dev_to_appear_ ${dev}1 || fail=1
-# The size of the partition should be 100MiB, or 204800 512b sectors
+# The size of the partition should be 10MiB, or 20480 512b sectors
p1_size=$(blockdev --getsz ${dev}1) || framework_failure
-[ $p1_size == 204800 ] || fail=1
+[ $p1_size == 20480 ] || fail=1
Exit $fail
--
2.31.1

View File

@ -1,54 +0,0 @@
From 262a9242f5ad121ddcb42edaacadbc2e6a650333 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 15 Jul 2021 08:27:00 -0700
Subject: [PATCH 23/24] tests/t3000: Check for hfs and vfat support separately
Previously the whole test would be skipped if either mkfs.hfs or
mkfs.vfat were not installed, leading to missing test coverage. This
change checks for them individually so that the test will run with
either or both of them installed
---
tests/t3000-resize-fs.sh | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh
index 1f2e46e..282b6fc 100755
--- a/tests/t3000-resize-fs.sh
+++ b/tests/t3000-resize-fs.sh
@@ -17,12 +17,22 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/init.sh"; path_prepend_ ../parted .
-require_hfs_
-require_fat_
require_root_
require_scsi_debug_module_
require_512_byte_sector_size_
+
+FSTYPES=""
+
+# Is mkfs.hfs available?
+mkfs.hfs 2>&1 | grep '^usage:' && FSTYPES="hfs+"
+
+# Is mkfs.vfat available?
+mkfs.vfat 2>&1 | grep '^Usage:' && FSTYPES="$FSTYPES fat32 fat16"
+
+[ -n "$FSTYPES" ] || skip_ "Neither mkfs.hfs nor mkfs.vfat installed"
+
+
ss=$sector_size_
start=63s
@@ -53,7 +63,7 @@ mkdir "$mount_point" || fail=1
# be sure to unmount upon interrupt, failure, etc.
cleanup_fn_() { umount "${dev}1" > /dev/null 2>&1; }
-for fs_type in hfs+ fat32 fat16; do
+for fs_type in $FSTYPES; do
echo "fs_type=$fs_type"
# create an empty $fs_type partition, cylinder aligned, size > 256 MB
--
2.31.1

View File

@ -1,43 +0,0 @@
From 964bc37f6c95308a64aa96534b29412ce55835fd Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 29 Jul 2021 11:19:15 -0700
Subject: [PATCH 24/24] tests/t3000: Use mkfs.hfsplus and fsck.hfsplus for
resize tests
---
tests/t3000-resize-fs.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh
index 282b6fc..cf46c81 100755
--- a/tests/t3000-resize-fs.sh
+++ b/tests/t3000-resize-fs.sh
@@ -24,13 +24,13 @@ require_512_byte_sector_size_
FSTYPES=""
-# Is mkfs.hfs available?
-mkfs.hfs 2>&1 | grep '^usage:' && FSTYPES="hfs+"
+# Is mkfs.hfsplus available?
+mkfs.hfsplus 2>&1 | grep '^usage:' && FSTYPES="hfs+"
# Is mkfs.vfat available?
mkfs.vfat 2>&1 | grep '^Usage:' && FSTYPES="$FSTYPES fat32 fat16"
-[ -n "$FSTYPES" ] || skip_ "Neither mkfs.hfs nor mkfs.vfat installed"
+[ -n "$FSTYPES" ] || skip_ "Neither mkfs.hfsplus nor mkfs.vfat installed"
ss=$sector_size_
@@ -79,7 +79,7 @@ for fs_type in $FSTYPES; do
case $fs_type in
fat16) mkfs_cmd='mkfs.vfat -F 16'; fsck='fsck.vfat -v';;
fat32) mkfs_cmd='mkfs.vfat -F 32'; fsck='fsck.vfat -v';;
- hfs*) mkfs_cmd='mkfs.hfs'; fsck=fsck.hfs;;
+ hfs*) mkfs_cmd='mkfs.hfsplus'; fsck=fsck.hfsplus;;
*) error "internal error: unhandled fs type: $fs_type";;
esac
--
2.31.1

View File

@ -1,77 +0,0 @@
From fabd4e35427ab156d1e0b28745c926d0253a72cd Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 10 Aug 2021 09:40:28 -0700
Subject: [PATCH 25/30] Move Exception Option values into enum
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Adding enums together doesn't create a new enum value, so when compiling
with warnings you will get warnings like:
warning: case value 96 not in enumerated type
for PED_EXCEPTION_IGNORE_CANCEL
This moved the defines into the enum as new values so that they are
recognized as valid members of the enum with the values staying the
same.
NOTE: PED_EXCEPTION_OPTION_LAST *MUST* be the last of the individual
options, not the combined options.
Thanks to D. Hugh Redelmeier for this patch.
---
include/parted/exception.in.h | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/include/parted/exception.in.h b/include/parted/exception.in.h
index 20abb08..3b131fe 100644
--- a/include/parted/exception.in.h
+++ b/include/parted/exception.in.h
@@ -46,6 +46,7 @@ typedef enum _PedExceptionType PedExceptionType;
* Option for resolving the exception
*/
enum _PedExceptionOption {
+ /* individual options */
PED_EXCEPTION_UNHANDLED=0,
PED_EXCEPTION_FIX=1,
PED_EXCEPTION_YES=2,
@@ -54,19 +55,23 @@ enum _PedExceptionOption {
PED_EXCEPTION_RETRY=16,
PED_EXCEPTION_IGNORE=32,
PED_EXCEPTION_CANCEL=64,
+
+ /* combinations of individual options */
+ PED_EXCEPTION_OK_CANCEL = PED_EXCEPTION_OK + PED_EXCEPTION_CANCEL,
+ PED_EXCEPTION_YES_NO = PED_EXCEPTION_YES + PED_EXCEPTION_NO,
+ PED_EXCEPTION_YES_NO_CANCEL =
+ PED_EXCEPTION_YES_NO + PED_EXCEPTION_CANCEL,
+ PED_EXCEPTION_IGNORE_CANCEL =
+ PED_EXCEPTION_IGNORE + PED_EXCEPTION_CANCEL,
+ PED_EXCEPTION_RETRY_CANCEL = PED_EXCEPTION_RETRY + PED_EXCEPTION_CANCEL,
+ PED_EXCEPTION_RETRY_IGNORE_CANCEL =
+ PED_EXCEPTION_RETRY + PED_EXCEPTION_IGNORE_CANCEL,
};
-typedef enum _PedExceptionOption PedExceptionOption;
-#define PED_EXCEPTION_OK_CANCEL (PED_EXCEPTION_OK + PED_EXCEPTION_CANCEL)
-#define PED_EXCEPTION_YES_NO (PED_EXCEPTION_YES + PED_EXCEPTION_NO)
-#define PED_EXCEPTION_YES_NO_CANCEL (PED_EXCEPTION_YES_NO \
- + PED_EXCEPTION_CANCEL)
-#define PED_EXCEPTION_IGNORE_CANCEL (PED_EXCEPTION_IGNORE \
- + PED_EXCEPTION_CANCEL)
-#define PED_EXCEPTION_RETRY_CANCEL (PED_EXCEPTION_RETRY + PED_EXCEPTION_CANCEL)
-#define PED_EXCEPTION_RETRY_IGNORE_CANCEL (PED_EXCEPTION_RETRY \
- + PED_EXCEPTION_IGNORE_CANCEL)
+
#define PED_EXCEPTION_OPTION_FIRST PED_EXCEPTION_FIX
-#define PED_EXCEPTION_OPTION_LAST PED_EXCEPTION_CANCEL
+#define PED_EXCEPTION_OPTION_LAST PED_EXCEPTION_CANCEL /* last individual option */
+
+typedef enum _PedExceptionOption PedExceptionOption;
/**
* Structure with information about exception
--
2.31.1

View File

@ -1,133 +0,0 @@
From f8dd8c2c255a3c5c398a62ffdc1bcf5468becccd Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 10 Aug 2021 13:14:26 -0700
Subject: [PATCH 26/30] libparted: Add swap flag to msdos disklabel
Previously you had to set the filesystem type to one of the linux-swap
options at creation time. With this change you can now toggle the
partition swap type using the 'swap' partition flag in the same way that
you can on gpt disklabels.
Thanks to Arvin Schnell for this patch.
---
doc/parted.texi | 4 ++--
libparted/labels/dos.c | 24 ++++++++++++++++++++++--
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/doc/parted.texi b/doc/parted.texi
index 33212f0..0da68e9 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -897,8 +897,8 @@ MS Windows ME based operating systems to use Linear (LBA) mode.
to be used by Linux.
@item swap
-(Mac) - this flag should be enabled if the partition is the swap
-device to be used by Linux.
+(MS-DOS, GPT, Mac) - this flag should be enabled if the partition is the
+swap device to be used by Linux.
@item hidden
(MS-DOS, PC98) - this flag can be enabled to hide partitions from
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index e2aa5e0..b44ccaf 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -160,6 +160,7 @@ typedef struct {
int msftres;
int raid;
int lvm;
+ int swap;
int lba;
int palo;
int prep;
@@ -958,6 +959,7 @@ raw_part_parse (const PedDisk* disk, const DosRawPartition* raw_part,
dos_data->raid = raw_part->type == PARTITION_LINUX_RAID;
dos_data->lvm = raw_part->type == PARTITION_LINUX_LVM_OLD
|| raw_part->type == PARTITION_LINUX_LVM;
+ dos_data->swap = raw_part->type == PARTITION_LINUX_SWAP;
dos_data->lba = raw_part_is_lba (raw_part);
dos_data->palo = raw_part->type == PARTITION_PALO;
dos_data->prep = raw_part->type == PARTITION_PREP;
@@ -1380,6 +1382,7 @@ msdos_partition_duplicate (const PedPartition* part)
new_dos_data->msftres = old_dos_data->msftres;
new_dos_data->raid = old_dos_data->raid;
new_dos_data->lvm = old_dos_data->lvm;
+ new_dos_data->swap = old_dos_data->swap;
new_dos_data->lba = old_dos_data->lba;
new_dos_data->palo = old_dos_data->palo;
new_dos_data->prep = old_dos_data->prep;
@@ -1437,6 +1440,7 @@ msdos_partition_set_system (PedPartition* part,
dos_data->diag = 0;
dos_data->raid = 0;
dos_data->lvm = 0;
+ dos_data->swap = 0;
dos_data->palo = 0;
dos_data->prep = 0;
dos_data->irst = 0;
@@ -1464,6 +1468,10 @@ msdos_partition_set_system (PedPartition* part,
dos_data->system = PARTITION_LINUX_LVM;
return 1;
}
+ if (dos_data->swap) {
+ dos_data->system = PARTITION_LINUX_SWAP;
+ return 1;
+ }
if (dos_data->raid) {
dos_data->system = PARTITION_LINUX_RAID;
return 1;
@@ -1510,9 +1518,10 @@ msdos_partition_set_system (PedPartition* part,
dos_data->system = PARTITION_UDF;
else if (!strcmp (fs_type->name, "sun-ufs"))
dos_data->system = PARTITION_SUN_UFS;
- else if (is_linux_swap (fs_type->name))
+ else if (is_linux_swap (fs_type->name)) {
dos_data->system = PARTITION_LINUX_SWAP;
- else
+ dos_data->swap = 1;
+ } else
dos_data->system = PARTITION_LINUX;
return 1;
@@ -1525,6 +1534,7 @@ clear_flags (DosPartitionData *dos_data)
dos_data->hidden = 0;
dos_data->msftres = 0;
dos_data->lvm = 0;
+ dos_data->swap = 0;
dos_data->palo = 0;
dos_data->prep = 0;
dos_data->irst = 0;
@@ -1604,6 +1614,12 @@ msdos_partition_set_flag (PedPartition* part,
dos_data->lvm = state;
return ped_partition_set_system (part, part->fs_type);
+ case PED_PARTITION_SWAP:
+ if (state)
+ clear_flags (dos_data);
+ dos_data->swap = state;
+ return ped_partition_set_system (part, part->fs_type);
+
case PED_PARTITION_LBA:
dos_data->lba = state;
return ped_partition_set_system (part, part->fs_type);
@@ -1677,6 +1693,9 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
case PED_PARTITION_LVM:
return dos_data->lvm;
+ case PED_PARTITION_SWAP:
+ return dos_data->swap;
+
case PED_PARTITION_LBA:
return dos_data->lba;
@@ -1720,6 +1739,7 @@ msdos_partition_is_flag_available (const PedPartition* part,
case PED_PARTITION_BOOT:
case PED_PARTITION_RAID:
case PED_PARTITION_LVM:
+ case PED_PARTITION_SWAP:
case PED_PARTITION_LBA:
case PED_PARTITION_PALO:
case PED_PARTITION_PREP:
--
2.31.1

View File

@ -1,31 +0,0 @@
From b5e17a613d2ea9894fcc090499dcc73e3ea07f61 Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@arm.com>
Date: Mon, 9 Aug 2021 15:25:50 +0100
Subject: [PATCH 27/30] tests: add aarch64 and mips64 as a valid 64-bit
machines
require_64_bit_ in t-lib-helpers.sh has a hard-coded list of uname
machines that are 64-bit, so add aarch64 and mips64 to cover the major
architectures.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
tests/t-lib-helpers.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh
index 9312343..dddb44e 100644
--- a/tests/t-lib-helpers.sh
+++ b/tests/t-lib-helpers.sh
@@ -411,7 +411,7 @@ device_mapper_required_()
require_64bit_()
{
case $(uname -m) in
- x86_64|ppc64)
+ aarch64|mips64|ppc64|x86_64)
return 0;;
*)
skip_ "This test requires a 64 bit system"
--
2.31.1

View File

@ -1,43 +0,0 @@
From 8e97e5f7ad7cc8a1e6233306a45fcdbf08c959bd Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@arm.com>
Date: Mon, 9 Aug 2021 15:25:51 +0100
Subject: [PATCH 28/30] tests: add a helper to check the kernel knows about a
file system
Some tests need both the file system tools (eg mkfs.vfat) and kernel
support (eg vfat kernel module) to pass.
There are already helpers such as require_fat_ which check for mkfs.vfat,
but if the kernel doesn't support the filesystem then mounting the disk
image will fail.
Add require_filesystem_, which checks for either the filesystem name in
/proc/filesystems (so it's built-in, or already loaded) or if the name
is a valid module (so can be loaded on demand).
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
tests/t-lib-helpers.sh | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh
index dddb44e..33151bb 100644
--- a/tests/t-lib-helpers.sh
+++ b/tests/t-lib-helpers.sh
@@ -418,3 +418,13 @@ require_64bit_()
;;
esac
}
+
+# Check if the specified filesystem is either built into the kernel, or can be loaded
+# as a module
+# Usage: has_filesystem vfat
+# Ruturns 0 if the filesystem is available, otherwise skips the test
+require_filesystem_()
+{
+ grep -q $1 /proc/filesystems && return 0
+ modprobe --quiet --dry-run $1 || skip_ "this test requires kernel support for $1"
+}
--
2.31.1

View File

@ -1,46 +0,0 @@
From 231a1e1d3ab525272b44bd20f703f9253fd1ed5c Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@arm.com>
Date: Mon, 9 Aug 2021 15:25:52 +0100
Subject: [PATCH 29/30] tests: check for vfat kernel support and tools
t1100-busy-label.sh and t1101-busy-partition.sh create and mount VFAT
partitions, so check for both the tools and the kernel support.
Fixes bug#49594.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
tests/t1100-busy-label.sh | 3 +++
tests/t1101-busy-partition.sh | 2 ++
2 files changed, 5 insertions(+)
diff --git a/tests/t1100-busy-label.sh b/tests/t1100-busy-label.sh
index 71b847c..a77a70f 100755
--- a/tests/t1100-busy-label.sh
+++ b/tests/t1100-busy-label.sh
@@ -19,6 +19,9 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
require_root_
require_scsi_debug_module_
+require_fat_
+require_filesystem_ vfat
+
ss=$sector_size_
scsi_debug_setup_ sector_size=$ss dev_size_mb=10 > dev-name ||
diff --git a/tests/t1101-busy-partition.sh b/tests/t1101-busy-partition.sh
index 5e37814..c936718 100755
--- a/tests/t1101-busy-partition.sh
+++ b/tests/t1101-busy-partition.sh
@@ -22,6 +22,8 @@ test "$VERBOSE" = yes && parted --version
require_root_
require_scsi_debug_module_
+require_fat_
+require_filesystem_ vfat
# create memory-backed device
scsi_debug_setup_ dev_size_mb=10 > dev-name ||
--
2.31.1

View File

@ -1,91 +0,0 @@
From 33f7bb2f9967856afac2411831ef16dcf95746ab Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 10 Aug 2021 15:49:48 -0700
Subject: [PATCH 30/30] parted: Escape colons and backslashes in machine output
The device path, device model, and partition name could all contain
colons or backslashes. This escapes all of these with a backslash.
Thanks to Arvin Schnell for the patch.
---
parted/parted.c | 42 ++++++++++++++++++++++++++++++++++++++----
1 file changed, 38 insertions(+), 4 deletions(-)
diff --git a/parted/parted.c b/parted/parted.c
index 22b5818..65b5ab2 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -985,6 +985,32 @@ _print_disk_geometry (const PedDevice *dev)
free (cyl_size);
}
+static char *
+_escape_machine_string (const char *str)
+{
+ size_t i, j;
+ char *dest;
+
+ dest = ped_malloc (2 * strlen(str) + 1);
+ if (!dest)
+ return NULL;
+
+ for (i = 0, j = 0; str[i] != '\0'; i++, j++) {
+ switch (str[i]) {
+ case ':':
+ case '\\':
+ dest[j++] = '\\';
+ /* fallthrough */
+ default:
+ dest[j] = str[i];
+ break;
+ }
+ }
+ dest[j] = '\0';
+
+ return dest;
+}
+
static void
_print_disk_info (const PedDevice *dev, const PedDisk *diskp)
{
@@ -1005,6 +1031,9 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
char *disk_flags = disk_print_flags (diskp);
if (opt_machine_mode) {
+ char *escaped_path = _escape_machine_string (dev->path);
+ char *escaped_model = _escape_machine_string (dev->model);
+
switch (default_unit) {
case PED_UNIT_CHS: puts ("CHS;");
break;
@@ -1015,9 +1044,11 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
}
printf ("%s:%s:%s:%lld:%lld:%s:%s:%s;\n",
- dev->path, end, transport[dev->type],
+ escaped_path, end, transport[dev->type],
dev->sector_size, dev->phys_sector_size,
- pt_name, dev->model, disk_flags);
+ pt_name, escaped_model, disk_flags);
+ free (escaped_path);
+ free (escaped_model);
} else {
printf (_("Model: %s (%s)\n"),
dev->model, transport[dev->type]);
@@ -1289,8 +1320,11 @@ do_print (PedDevice** dev, PedDisk** diskp)
putchar (':');
if (has_name)
- printf ("%s:", ped_partition_get_name (part));
- else
+ {
+ char *escaped_name = _escape_machine_string (ped_partition_get_name (part));
+ printf ("%s:", escaped_name);
+ free (escaped_name);
+ } else
putchar (':');
char *flags = partition_print_flags (part);
--
2.31.1

View File

@ -1,32 +0,0 @@
From 9e194581edf31ddd2474e7be5393578542b4ef8d Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Fri, 9 Jul 2021 10:54:51 -0700
Subject: [PATCH] libparted: Tell libdevmapper to retry remove when BUSY
This sets the libdevmapper retry remove flag, which will retry a remove
command if it is BUSY.
parted already has it's own BUSY retry code, but when run with
device-mapper an error can be printed by libdevmapper which can be
confusing to the user.
Resolves: rhbz#1980697
---
libparted/arch/linux.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index aacc94f..758d36a 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2855,6 +2855,7 @@ _dm_remove_partition(PedDisk* disk, int partno)
if (!task)
goto err;
dm_task_set_name (task, part_name);
+ dm_task_retry_remove(task);
if (!dm_task_set_cookie (task, &cookie, 0))
goto err;
rc = _dm_task_run_wait (task, cookie);
--
2.31.1

View File

@ -1,26 +0,0 @@
From 74636ce7f34081e92c5680f34588217978306488 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 19 Aug 2021 13:56:31 -0700
Subject: [PATCH 32/34] libparted: Check devpath before passing to strlen
---
libparted/arch/linux.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 758d36a..430d02e 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2453,6 +2453,9 @@ _device_get_part_path (PedDevice const *dev, int num)
#else
devpath = dev->path;
#endif
+ if (!devpath)
+ return NULL;
+
path_len = strlen (devpath);
/* Check for devfs-style /disc => /partN transformation
unconditionally; the system might be using udev with devfs rules,
--
2.31.1

View File

@ -1,125 +0,0 @@
From 72faef8673b5b1d00059608f0729e93cb21a7664 Mon Sep 17 00:00:00 2001
From: Arvin Schnell <aschnell@suse.com>
Date: Fri, 13 Aug 2021 13:02:27 +0000
Subject: [PATCH 33/34] parted: Allow empty string for partition name
This makes it possible to pass an empty string in script mode e.g. to
set no partition name (on GPT):
parted -s ./disk.img mklabel gpt mkpart '""' ext2 1 100M
Includes a new test for this feature.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
parted/ui.c | 9 +++++++--
tests/Makefile.am | 1 +
tests/t0290-gpt-name.sh | 41 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+), 2 deletions(-)
create mode 100755 tests/t0290-gpt-name.sh
diff --git a/parted/ui.c b/parted/ui.c
index b5948d3..25ad4f1 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -16,7 +16,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <config.h>
#include <config.h>
@@ -727,6 +726,7 @@ void
command_line_push_line (const char* line, int multi_word)
{
int quoted = 0;
+ int quotes_empty = 0;
char quote_char = 0;
char this_word [256];
int i;
@@ -754,6 +754,9 @@ command_line_push_line (const char* line, int multi_word)
if (quoted && *line == quote_char) {
quoted = 0;
+ /* allow empty partition name in script mode */
+ if (!i)
+ quotes_empty = 1;
continue;
}
@@ -761,9 +764,11 @@ command_line_push_line (const char* line, int multi_word)
if (quoted && line[0] == '\\' && line[1])
line++;
+ quotes_empty = 0;
this_word [i++] = *line;
}
- if (i || !multi_word) {
+ if (i || !multi_word || quotes_empty) {
+ quotes_empty = 0;
this_word [i] = 0;
command_line_push_word (this_word);
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3473e6b..9c4a79d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -33,6 +33,7 @@ TESTS = \
t0281-gpt-grow.sh \
t0282-gpt-move-backup.sh \
t0283-overlap-partitions.sh \
+ t0290-gpt-name.sh \
t0300-dos-on-gpt.sh \
t0301-overwrite-gpt-pmbr.sh \
t0350-mac-PT-increases-sector-size.sh \
diff --git a/tests/t0290-gpt-name.sh b/tests/t0290-gpt-name.sh
new file mode 100755
index 0000000..26041b6
--- /dev/null
+++ b/tests/t0290-gpt-name.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# Test setting empty GPT partition name in non-interactive mode
+
+# Copyright (C) 2021 SUSE LLC
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+dev=loop-file
+
+truncate --size 50MiB "$dev" || fail=1
+
+# create partition with empty name
+parted --script "$dev" mklabel gpt mkpart '""' ext4 1MiB 49MiB > out 2>&1 || fail=1
+parted --script --machine "$dev" unit MiB print > out 2>&1 || fail=1
+grep 'MiB:::;' out || fail=1
+
+# set a non-empty name
+parted --script "$dev" name 1 "test" > out 2>&1 || fail=1
+parted --script --machine "$dev" unit MiB print > out 2>&1 || fail=1
+grep 'MiB::test:;' out || fail=1
+
+# set empty name
+parted --script "$dev" name 1 "''" > out 2>&1 || fail=1
+parted --script --machine "$dev" unit MiB print > out 2>&1 || fail=1
+grep 'MiB:::;' out || fail=1
+
+Exit $fail
--
2.31.1

View File

@ -1,917 +0,0 @@
From 36d16c57d4ff6cf9903bfe65671c7f90879e004f Mon Sep 17 00:00:00 2001
From: Arvin Schnell <aschnell@suse.com>
Date: Tue, 17 Aug 2021 11:05:38 +0000
Subject: [PATCH 34/34] parted: Add --json cmdline switch to output JSON
This outputs the disk's details as a JSON object. eg. a disk image with
a single partition from 1M to 100M:
{
"disk": {
"path": "/root/disk1.img",
"size": "2097152s",
"model": "",
"transport": "file",
"logical-sector-size": 512,
"physical-sector-size": 512,
"label": "gpt",
"max-partitions": 128,
"partitions": [
{
"number": 0,
"start": "34s",
"end": "2047s",
"size": "2014s",
"type": "free"
},{
"number": 1,
"start": "2048s",
"end": "200703s",
"size": "198656s",
"type": "primary",
"name": "root"
},{
"number": 0,
"start": "200704s",
"end": "2097118s",
"size": "1896415s",
"type": "free"
}
]
}
}
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
doc/C/parted.8 | 3 +
doc/parted.texi | 8 ++
parted/Makefile.am | 2 +
parted/jsonwrt.c | 225 ++++++++++++++++++++++++++++++++++++++
parted/jsonwrt.h | 46 ++++++++
parted/parted.c | 170 ++++++++++++++++++++++++++--
tests/Makefile.am | 2 +
tests/t0800-json-gpt.sh | 94 ++++++++++++++++
tests/t0801-json-msdos.sh | 86 +++++++++++++++
9 files changed, 624 insertions(+), 12 deletions(-)
create mode 100644 parted/jsonwrt.c
create mode 100644 parted/jsonwrt.h
create mode 100755 tests/t0800-json-gpt.sh
create mode 100755 tests/t0801-json-msdos.sh
diff --git a/doc/C/parted.8 b/doc/C/parted.8
index d8e556e..46b30ad 100644
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
@@ -24,6 +24,9 @@ lists partition layout on all block devices
.B -m, --machine
displays machine parseable output
.TP
+.B -m, --json
+displays JSON output
+.TP
.B -s, --script
never prompts for user intervention
.TP
diff --git a/doc/parted.texi b/doc/parted.texi
index 0da68e9..57ceb55 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -402,6 +402,14 @@ Options:
@itemx --help
display a help message
+@item -m
+@itemx --machine
+display output in machine parseable format
+
+@item -j
+@itemx --json
+display output in JSON format
+
@item -s
@itemx --script
never prompt the user
diff --git a/parted/Makefile.am b/parted/Makefile.am
index e7bba2e..e5f3288 100644
--- a/parted/Makefile.am
+++ b/parted/Makefile.am
@@ -13,6 +13,8 @@ parted_SOURCES = command.c \
strlist.h \
ui.c \
ui.h \
+ jsonwrt.c \
+ jsonwrt.h \
table.c \
table.h
diff --git a/parted/jsonwrt.c b/parted/jsonwrt.c
new file mode 100644
index 0000000..1560224
--- /dev/null
+++ b/parted/jsonwrt.c
@@ -0,0 +1,225 @@
+/*
+ * JSON output formatting functions.
+ *
+ * No copyright is claimed. This code is in the public domain; do with
+ * it what you wish.
+ *
+ * Written by Karel Zak <kzak@redhat.com>
+ */
+
+#include "config.h"
+#include <stdio.h>
+#include <inttypes.h>
+#include <ctype.h>
+#include <c-ctype.h>
+#include <assert.h>
+#include "jsonwrt.h"
+
+/*
+ * Requirements enumerated via testing (V8, Firefox, IE11):
+ *
+ * var charsToEscape = [];
+ * for (var i = 0; i < 65535; i += 1) {
+ * try {
+ * JSON.parse('{"sample": "' + String.fromCodePoint(i) + '"}');
+ * } catch (e) {
+ * charsToEscape.push(i);
+ * }
+ * }
+ */
+static void fputs_quoted_case_json(const char *data, FILE *out, int dir)
+{
+ const char *p;
+
+ fputc('"', out);
+ for (p = data; p && *p; p++) {
+
+ const unsigned int c = (unsigned int) *p;
+
+ /* From http://www.json.org
+ *
+ * The double-quote and backslashes would break out a string or
+ * init an escape sequence if not escaped.
+ *
+ * Note that single-quotes and forward slashes, while they're
+ * in the JSON spec, don't break double-quoted strings.
+ */
+ if (c == '"' || c == '\\') {
+ fputc('\\', out);
+ fputc(c, out);
+ continue;
+ }
+
+ /* All non-control characters OK; do the case swap as required. */
+ if (c >= 0x20) {
+ /*
+ * Don't use locale sensitive ctype.h functions for regular
+ * ASCII chars, because for example with Turkish locale
+ * (aka LANG=tr_TR.UTF-8) toupper('I') returns 'I'.
+ */
+ if (c <= 127)
+ fputc(dir == 1 ? c_toupper(c) :
+ dir == -1 ? c_tolower(c) : *p, out);
+ else
+ fputc(dir == 1 ? toupper(c) :
+ dir == -1 ? tolower(c) : *p, out);
+ continue;
+ }
+
+ /* In addition, all chars under ' ' break Node's/V8/Chrome's, and
+ * Firefox's JSON.parse function
+ */
+ switch (c) {
+ /* Handle short-hand cases to reduce output size. C
+ * has most of the same stuff here, so if there's an
+ * "Escape for C" function somewhere in the STL, we
+ * should probably be using it.
+ */
+ case '\b':
+ fputs("\\b", out);
+ break;
+ case '\t':
+ fputs("\\t", out);
+ break;
+ case '\n':
+ fputs("\\n", out);
+ break;
+ case '\f':
+ fputs("\\f", out);
+ break;
+ case '\r':
+ fputs("\\r", out);
+ break;
+ default:
+ /* Other assorted control characters */
+ fprintf(out, "\\u00%02x", c);
+ break;
+ }
+ }
+ fputc('"', out);
+}
+
+#define fputs_quoted_json(_d, _o) fputs_quoted_case_json(_d, _o, 0)
+#define fputs_quoted_json_upper(_d, _o) fputs_quoted_case_json(_d, _o, 1)
+#define fputs_quoted_json_lower(_d, _o) fputs_quoted_case_json(_d, _o, -1)
+
+void ul_jsonwrt_init(struct ul_jsonwrt *fmt, FILE *out, int indent)
+{
+ fmt->out = out;
+ fmt->indent = indent;
+ fmt->after_close = 0;
+}
+
+void ul_jsonwrt_indent(struct ul_jsonwrt *fmt)
+{
+ int i;
+
+ for (i = 0; i < fmt->indent; i++)
+ fputs(" ", fmt->out);
+}
+
+void ul_jsonwrt_open(struct ul_jsonwrt *fmt, const char *name, int type)
+{
+ if (name) {
+ if (fmt->after_close)
+ fputs(",\n", fmt->out);
+ ul_jsonwrt_indent(fmt);
+ fputs_quoted_json_lower(name, fmt->out);
+ } else {
+ if (fmt->after_close)
+ fputs(",", fmt->out);
+ else
+ ul_jsonwrt_indent(fmt);
+ }
+
+ switch (type) {
+ case UL_JSON_OBJECT:
+ fputs(name ? ": {\n" : "{\n", fmt->out);
+ fmt->indent++;
+ break;
+ case UL_JSON_ARRAY:
+ fputs(name ? ": [\n" : "[\n", fmt->out);
+ fmt->indent++;
+ break;
+ case UL_JSON_VALUE:
+ fputs(name ? ": " : " ", fmt->out);
+ break;
+ }
+ fmt->after_close = 0;
+}
+
+void ul_jsonwrt_close(struct ul_jsonwrt *fmt, int type)
+{
+ if (fmt->indent == 1) {
+ fputs("\n}\n", fmt->out);
+ fmt->indent--;
+ fmt->after_close = 1;
+ return;
+ }
+ assert(fmt->indent > 0);
+
+ switch (type) {
+ case UL_JSON_OBJECT:
+ fmt->indent--;
+ fputc('\n', fmt->out);
+ ul_jsonwrt_indent(fmt);
+ fputs("}", fmt->out);
+ break;
+ case UL_JSON_ARRAY:
+ fmt->indent--;
+ fputc('\n', fmt->out);
+ ul_jsonwrt_indent(fmt);
+ fputs("]", fmt->out);
+ break;
+ case UL_JSON_VALUE:
+ break;
+ }
+
+ fmt->after_close = 1;
+}
+
+void ul_jsonwrt_value_raw(struct ul_jsonwrt *fmt,
+ const char *name, const char *data)
+{
+ ul_jsonwrt_value_open(fmt, name);
+ if (data && *data)
+ fputs(data, fmt->out);
+ else
+ fputs("null", fmt->out);
+ ul_jsonwrt_value_close(fmt);
+}
+
+void ul_jsonwrt_value_s(struct ul_jsonwrt *fmt,
+ const char *name, const char *data)
+{
+ ul_jsonwrt_value_open(fmt, name);
+ if (data)
+ fputs_quoted_json(data, fmt->out);
+ else
+ fputs("null", fmt->out);
+ ul_jsonwrt_value_close(fmt);
+}
+
+void ul_jsonwrt_value_u64(struct ul_jsonwrt *fmt,
+ const char *name, uint64_t data)
+{
+ ul_jsonwrt_value_open(fmt, name);
+ fprintf(fmt->out, "%"PRIu64, data);
+ ul_jsonwrt_value_close(fmt);
+}
+
+void ul_jsonwrt_value_boolean(struct ul_jsonwrt *fmt,
+ const char *name, int data)
+{
+ ul_jsonwrt_value_open(fmt, name);
+ fputs(data ? "true" : "false", fmt->out);
+ ul_jsonwrt_value_close(fmt);
+}
+
+void ul_jsonwrt_value_null(struct ul_jsonwrt *fmt,
+ const char *name)
+{
+ ul_jsonwrt_value_open(fmt, name);
+ fputs("null", fmt->out);
+ ul_jsonwrt_value_close(fmt);
+}
diff --git a/parted/jsonwrt.h b/parted/jsonwrt.h
new file mode 100644
index 0000000..4587b60
--- /dev/null
+++ b/parted/jsonwrt.h
@@ -0,0 +1,46 @@
+#ifndef UTIL_LINUX_JSONWRT_H
+#define UTIL_LINUX_JSONWRT_H
+
+enum {
+ UL_JSON_OBJECT,
+ UL_JSON_ARRAY,
+ UL_JSON_VALUE
+};
+
+struct ul_jsonwrt {
+ FILE *out;
+ int indent;
+
+ unsigned int after_close :1;
+};
+
+void ul_jsonwrt_init(struct ul_jsonwrt *fmt, FILE *out, int indent);
+void ul_jsonwrt_indent(struct ul_jsonwrt *fmt);
+void ul_jsonwrt_open(struct ul_jsonwrt *fmt, const char *name, int type);
+void ul_jsonwrt_close(struct ul_jsonwrt *fmt, int type);
+
+#define ul_jsonwrt_root_open(_f) ul_jsonwrt_open(_f, NULL, UL_JSON_OBJECT)
+#define ul_jsonwrt_root_close(_f) ul_jsonwrt_close(_f, UL_JSON_OBJECT)
+
+#define ul_jsonwrt_array_open(_f, _n) ul_jsonwrt_open(_f, _n, UL_JSON_ARRAY)
+#define ul_jsonwrt_array_close(_f) ul_jsonwrt_close(_f, UL_JSON_ARRAY)
+
+#define ul_jsonwrt_object_open(_f, _n) ul_jsonwrt_open(_f, _n, UL_JSON_OBJECT)
+#define ul_jsonwrt_object_close(_f) ul_jsonwrt_close(_f, UL_JSON_OBJECT)
+
+#define ul_jsonwrt_value_open(_f, _n) ul_jsonwrt_open(_f, _n, UL_JSON_VALUE)
+#define ul_jsonwrt_value_close(_f) ul_jsonwrt_close(_f, UL_JSON_VALUE)
+
+
+void ul_jsonwrt_value_raw(struct ul_jsonwrt *fmt,
+ const char *name, const char *data);
+void ul_jsonwrt_value_s(struct ul_jsonwrt *fmt,
+ const char *name, const char *data);
+void ul_jsonwrt_value_u64(struct ul_jsonwrt *fmt,
+ const char *name, uint64_t data);
+void ul_jsonwrt_value_boolean(struct ul_jsonwrt *fmt,
+ const char *name, int data);
+void ul_jsonwrt_value_null(struct ul_jsonwrt *fmt,
+ const char *name);
+
+#endif /* UTIL_LINUX_JSONWRT_H */
diff --git a/parted/parted.c b/parted/parted.c
index 65b5ab2..975700c 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -57,6 +57,7 @@
#include "c-ctype.h"
#include "c-strcase.h"
#include "xalloc.h"
+#include "jsonwrt.h"
#ifdef ENABLE_MTRACE
#include <mcheck.h>
@@ -79,6 +80,14 @@ enum
PRETEND_INPUT_TTY = CHAR_MAX + 1,
};
+/* Output modes */
+enum
+{
+ HUMAN,
+ MACHINE,
+ JSON
+};
+
enum
{
ALIGNMENT_NONE = 2,
@@ -115,6 +124,7 @@ static struct option const options[] = {
{"help", 0, NULL, 'h'},
{"list", 0, NULL, 'l'},
{"machine", 0, NULL, 'm'},
+ {"json", 0, NULL, 'j'},
{"script", 0, NULL, 's'},
{"fix", 0, NULL, 'f'},
{"version", 0, NULL, 'v'},
@@ -127,6 +137,7 @@ static const char *const options_help [][2] = {
{"help", N_("displays this help message")},
{"list", N_("lists partition layout on all block devices")},
{"machine", N_("displays machine parseable output")},
+ {"json", N_("displays JSON output")},
{"script", N_("never prompts for user intervention")},
{"fix", N_("in script mode, fix instead of abort when asked")},
{"version", N_("displays the version")},
@@ -137,7 +148,7 @@ static const char *const options_help [][2] = {
int opt_script_mode = 0;
int opt_fix_mode = 0;
int pretend_input_tty = 0;
-int opt_machine_mode = 0;
+int opt_output_mode = HUMAN;
int disk_is_modified = 0;
int is_toggle_mode = 0;
int alignment = ALIGNMENT_OPTIMAL;
@@ -184,6 +195,8 @@ static Command* commands [256] = {NULL};
static PedTimer* g_timer;
static TimerContext timer_context;
+static struct ul_jsonwrt json;
+
static int _print_list ();
static void _done (PedDevice* dev, PedDisk *diskp);
static bool partition_align_check (PedDisk const *disk,
@@ -931,6 +944,32 @@ partition_print_flags (PedPartition const *part)
return res;
}
+static void
+partition_print_flags_json (PedPartition const *part)
+{
+ if (!part)
+ return;
+
+ int did_open_array = 0;
+
+ PedPartitionFlag flag;
+ for (flag = ped_partition_flag_next (0); flag;
+ flag = ped_partition_flag_next (flag))
+ {
+ if (ped_partition_get_flag (part, flag))
+ {
+ if (!did_open_array)
+ ul_jsonwrt_array_open (&json, "flags");
+ did_open_array = 1;
+
+ ul_jsonwrt_value_s (&json, NULL, ped_partition_flag_get_name (flag));
+ }
+ }
+
+ if (did_open_array)
+ ul_jsonwrt_array_close (&json);
+}
+
static int
partition_print (PedPartition* part)
{
@@ -964,6 +1003,32 @@ disk_print_flags (PedDisk const *disk)
return res;
}
+static void
+disk_print_flags_json (PedDisk const *disk)
+{
+ if (!disk)
+ return;
+
+ int did_open_array = 0;
+
+ PedDiskFlag flag;
+ for (flag = ped_disk_flag_next (0); flag;
+ flag = ped_disk_flag_next (flag))
+ {
+ if (ped_disk_get_flag (disk, flag))
+ {
+ if (!did_open_array)
+ ul_jsonwrt_array_open (&json, "flags");
+ did_open_array = 1;
+
+ ul_jsonwrt_value_s (&json, NULL, ped_disk_flag_get_name (flag));
+ }
+ }
+
+ if (did_open_array)
+ ul_jsonwrt_array_close (&json);
+}
+
static void
_print_disk_geometry (const PedDevice *dev)
{
@@ -973,9 +1038,14 @@ _print_disk_geometry (const PedDevice *dev)
chs->heads * chs->sectors,
PED_UNIT_KILOBYTE);
- if (opt_machine_mode) {
+ if (opt_output_mode == MACHINE) {
printf ("%d:%d:%d:%s;\n",
chs->cylinders, chs->heads, chs->sectors, cyl_size);
+ } else if (opt_output_mode == JSON) {
+ char* tmp = ped_malloc (128);
+ snprintf (tmp, 128, "%d,%d,%d %s", chs->cylinders, chs->heads, chs->sectors, cyl_size);
+ ul_jsonwrt_value_s (&json, "geometry", tmp);
+ free (tmp);
} else {
printf (_("BIOS cylinder,head,sector geometry: %d,%d,%d. "
"Each cylinder is %s.\n"),
@@ -1030,7 +1100,7 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
const char* pt_name = diskp ? diskp->type->name : "unknown";
char *disk_flags = disk_print_flags (diskp);
- if (opt_machine_mode) {
+ if (opt_output_mode == MACHINE) {
char *escaped_path = _escape_machine_string (dev->path);
char *escaped_model = _escape_machine_string (dev->model);
@@ -1049,6 +1119,20 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
pt_name, escaped_model, disk_flags);
free (escaped_path);
free (escaped_model);
+ } else if (opt_output_mode == JSON) {
+ ul_jsonwrt_value_s (&json, "path", dev->path);
+ ul_jsonwrt_value_s (&json, "size", end);
+ ul_jsonwrt_value_s (&json, "model", dev->model);
+ ul_jsonwrt_value_s (&json, "transport", transport[dev->type]);
+ ul_jsonwrt_value_u64 (&json, "logical-sector-size", dev->sector_size);
+ ul_jsonwrt_value_u64 (&json, "physical-sector-size", dev->phys_sector_size);
+ ul_jsonwrt_value_s (&json, "label", pt_name);
+ if (diskp) {
+ if (diskp->type->ops->get_max_primary_partition_count)
+ ul_jsonwrt_value_u64 (&json, "max-partitions",
+ diskp->type->ops->get_max_primary_partition_count(diskp));
+ disk_print_flags_json (diskp);
+ }
} else {
printf (_("Model: %s (%s)\n"),
dev->model, transport[dev->type]);
@@ -1064,7 +1148,7 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
|| ped_unit_get_default () == PED_UNIT_CYLINDER)
_print_disk_geometry (dev);
- if (!opt_machine_mode) {
+ if (opt_output_mode == HUMAN) {
printf (_("Partition Table: %s\n"), pt_name);
printf (_("Disk Flags: %s\n"), disk_flags);
}
@@ -1170,10 +1254,16 @@ do_print (PedDevice** dev, PedDisk** diskp)
return status;
}
+ if (opt_output_mode == JSON) {
+ ul_jsonwrt_init (&json, stdout, 0);
+ ul_jsonwrt_root_open (&json);
+ ul_jsonwrt_object_open (&json, "disk");
+ }
+
_print_disk_info (*dev, *diskp);
if (!*diskp)
goto nopt;
- if (!opt_machine_mode)
+ if (opt_output_mode == HUMAN)
putchar ('\n');
has_extended = ped_disk_type_check_feature ((*diskp)->type,
@@ -1182,7 +1272,7 @@ do_print (PedDevice** dev, PedDisk** diskp)
PED_DISK_TYPE_PARTITION_NAME);
PedPartition* part;
- if (!opt_machine_mode) {
+ if (opt_output_mode == HUMAN) {
StrList *row1;
if (ped_unit_get_default() == PED_UNIT_CHS) {
@@ -1283,6 +1373,57 @@ do_print (PedDevice** dev, PedDisk** diskp)
table_destroy (table);
str_list_destroy (row1);
+ } else if (opt_output_mode == JSON) {
+
+ ul_jsonwrt_array_open (&json, "partitions");
+
+ for (part = ped_disk_next_partition (*diskp, NULL); part;
+ part = ped_disk_next_partition (*diskp, part)) {
+
+ if ((!has_free_arg && !ped_partition_is_active(part)) ||
+ part->type & PED_PARTITION_METADATA)
+ continue;
+
+ ul_jsonwrt_object_open (&json, NULL);
+
+ ul_jsonwrt_value_u64 (&json, "number", part->num >= 0 ? part->num : 0);
+
+ tmp = ped_unit_format (*dev, part->geom.start);
+ ul_jsonwrt_value_s (&json, "start", tmp);
+ free (tmp);
+
+ tmp = ped_unit_format_byte (*dev, (part->geom.end + 1) * (*dev)->sector_size - 1);
+ ul_jsonwrt_value_s (&json, "end", tmp);
+ free (tmp);
+
+ if (ped_unit_get_default() != PED_UNIT_CHS) {
+ tmp = ped_unit_format (*dev, part->geom.length);
+ ul_jsonwrt_value_s (&json, "size", tmp);
+ free (tmp);
+ }
+
+ name = ped_partition_type_get_name (part->type);
+ ul_jsonwrt_value_s (&json, "type", name);
+
+ if (!(part->type & PED_PARTITION_FREESPACE)) {
+
+ if (has_name) {
+ name = ped_partition_get_name (part);
+ if (strcmp (name, "") != 0)
+ ul_jsonwrt_value_s (&json, "name", ped_partition_get_name (part));
+ }
+
+ if (part->fs_type)
+ ul_jsonwrt_value_s (&json, "filesystem", part->fs_type->name);
+
+ partition_print_flags_json (part);
+ }
+
+ ul_jsonwrt_object_close (&json);
+ }
+
+ ul_jsonwrt_array_close (&json);
+
} else {
for (part = ped_disk_next_partition (*diskp, NULL); part;
@@ -1337,9 +1478,13 @@ do_print (PedDevice** dev, PedDisk** diskp)
}
}
- return ok;
-
nopt:
+
+ if (opt_output_mode == JSON) {
+ ul_jsonwrt_object_close (&json);
+ ul_jsonwrt_root_close (&json);
+ }
+
return ok;
}
@@ -2232,7 +2377,7 @@ int opt, help = 0, list = 0, version = 0, wrong = 0;
while (1)
{
- opt = getopt_long (*argc_ptr, *argv_ptr, "hlmsfva:",
+ opt = getopt_long (*argc_ptr, *argv_ptr, "hlmjsfva:",
options, NULL);
if (opt == -1)
break;
@@ -2240,7 +2385,8 @@ while (1)
switch (opt) {
case 'h': help = 1; break;
case 'l': list = 1; break;
- case 'm': opt_machine_mode = 1; break;
+ case 'm': opt_output_mode = MACHINE; break;
+ case 'j': opt_output_mode = JSON; break;
case 's': opt_script_mode = 1; break;
case 'f': opt_fix_mode = 1; break;
case 'v': version = 1; break;
@@ -2289,7 +2435,7 @@ _choose_device (int* argc_ptr, char*** argv_ptr)
{
PedDevice* dev;
-/* specified on comand line? */
+/* specified on command line? */
if (*argc_ptr) {
dev = ped_device_get ((*argv_ptr) [0]);
if (!dev)
@@ -2377,7 +2523,7 @@ _done (PedDevice* dev, PedDisk* diskp)
"rebooting. Read section 4 of the Parted User "
"documentation for more information."));
}
- if (!opt_script_mode && !opt_machine_mode && disk_is_modified) {
+ if (!opt_script_mode && opt_output_mode == HUMAN && disk_is_modified) {
ped_exception_throw (
PED_EXCEPTION_INFORMATION, PED_EXCEPTION_OK,
_("You may need to update /etc/fstab.\n"));
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9c4a79d..f9340aa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -40,6 +40,8 @@ TESTS = \
t0400-loop-clobber-infloop.sh \
t0500-dup-clobber.sh \
t0501-duplicate.sh \
+ t0800-json-gpt.sh \
+ t0801-json-msdos.sh \
t1100-busy-label.sh \
t1101-busy-partition.sh \
t1102-loop-label.sh \
diff --git a/tests/t0800-json-gpt.sh b/tests/t0800-json-gpt.sh
new file mode 100755
index 0000000..8dd1862
--- /dev/null
+++ b/tests/t0800-json-gpt.sh
@@ -0,0 +1,94 @@
+#!/bin/sh
+
+# Test JSON output with GPT label
+
+# Copyright (C) 2021 SUSE LLC
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+require_512_byte_sector_size_
+
+dev=loop-file
+
+# create device
+truncate --size 50MiB "$dev" || fail=1
+
+# create gpt label and some partitions
+parted --script "$dev" mklabel gpt > out 2>&1 || fail=1
+parted --script "$dev" disk_set pmbr_boot on > out 2>&1 || fail=1
+parted --script "$dev" mkpart "test1" ext4 10% 20% > out 2>&1 || fail=1
+parted --script "$dev" mkpart "test2" xfs 20% 60% > out 2>&1 || fail=1
+parted --script "$dev" set 2 raid on > out 2>&1 || fail=1
+
+# print with json format
+parted --script --json "$dev" unit s print free > out 2>&1 || fail=1
+
+cat <<EOF > exp || fail=1
+{
+ "disk": {
+ "path": "loop-file",
+ "size": "102400s",
+ "model": "",
+ "transport": "file",
+ "logical-sector-size": 512,
+ "physical-sector-size": 512,
+ "label": "gpt",
+ "max-partitions": 128,
+ "flags": [
+ "pmbr_boot"
+ ],
+ "partitions": [
+ {
+ "number": 0,
+ "start": "34s",
+ "end": "10239s",
+ "size": "10206s",
+ "type": "free"
+ },{
+ "number": 1,
+ "start": "10240s",
+ "end": "20479s",
+ "size": "10240s",
+ "type": "primary",
+ "name": "test1"
+ },{
+ "number": 2,
+ "start": "20480s",
+ "end": "61439s",
+ "size": "40960s",
+ "type": "primary",
+ "name": "test2",
+ "flags": [
+ "raid"
+ ]
+ },{
+ "number": 0,
+ "start": "61440s",
+ "end": "102366s",
+ "size": "40927s",
+ "type": "free"
+ }
+ ]
+ }
+}
+EOF
+
+# remove full path of device from actual output
+mv out o2 && sed "s,\"/.*/$dev\",\"$dev\"," o2 > out || fail=1
+
+# check for expected output
+compare exp out || fail=1
+
+Exit $fail
diff --git a/tests/t0801-json-msdos.sh b/tests/t0801-json-msdos.sh
new file mode 100755
index 0000000..a14a5af
--- /dev/null
+++ b/tests/t0801-json-msdos.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+# Test JSON output with MS-DOS label
+
+# Copyright (C) 2021 SUSE LLC
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+require_512_byte_sector_size_
+
+dev=loop-file
+
+# create device
+truncate --size 50MiB "$dev" || fail=1
+
+# create msdos label and some partitions
+parted --script "$dev" mklabel msdos > out 2>&1 || fail=1
+parted --script "$dev" mkpart primary ext4 10% 20% > out 2>&1 || fail=1
+parted --script "$dev" mkpart extended 20% 60% > out 2>&1 || fail=1
+parted --script "$dev" mkpart logical ext4 20% 40% > out 2>&1 || fail=1
+parted --script "$dev" set 5 lvm on > out 2>&1 || fail=1
+
+# print with json format
+parted --script --json "$dev" unit MiB print > out 2>&1 || fail=1
+
+cat <<EOF > exp || fail=1
+{
+ "disk": {
+ "path": "loop-file",
+ "size": "50.0MiB",
+ "model": "",
+ "transport": "file",
+ "logical-sector-size": 512,
+ "physical-sector-size": 512,
+ "label": "msdos",
+ "max-partitions": 4,
+ "partitions": [
+ {
+ "number": 1,
+ "start": "5.00MiB",
+ "end": "10.0MiB",
+ "size": "5.00MiB",
+ "type": "primary"
+ },{
+ "number": 2,
+ "start": "10.0MiB",
+ "end": "30.0MiB",
+ "size": "20.0MiB",
+ "type": "extended",
+ "flags": [
+ "lba"
+ ]
+ },{
+ "number": 5,
+ "start": "10.0MiB",
+ "end": "20.0MiB",
+ "size": "10.0MiB",
+ "type": "logical",
+ "flags": [
+ "lvm"
+ ]
+ }
+ ]
+ }
+}
+EOF
+
+# remove full path of device from actual output
+mv out o2 && sed "s,\"/.*/$dev\",\"$dev\"," o2 > out || fail=1
+
+# check for expected output
+compare exp out || fail=1
+
+Exit $fail
--
2.31.1

View File

@ -1,29 +0,0 @@
From dde6702f20b7c34b091b25580ab19009c9d91b30 Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@ubuntu.com>
Date: Thu, 26 Nov 2020 21:59:39 +0100
Subject: [PATCH 35/38] hurd: Fix partition paths
We have always had an 's' to separate drive number from partition
number.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/arch/gnu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libparted/arch/gnu.c b/libparted/arch/gnu.c
index d7204cc..507a5ff 100644
--- a/libparted/arch/gnu.c
+++ b/libparted/arch/gnu.c
@@ -805,7 +805,7 @@ gnu_partition_get_path (const PedPartition* part)
result = (char*) ped_malloc (result_len);
if (!result)
return NULL;
- snprintf (result, result_len, "%s%d", dev_path, part->num);
+ snprintf (result, result_len, "%ss%d", dev_path, part->num);
return result;
}
--
2.31.1

View File

@ -1,33 +0,0 @@
From e0a83f3bdf6cfb4b2b6d3631a5ab157291bfbdfa Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Sun, 29 Nov 2020 23:20:17 +0100
Subject: [PATCH 36/38] hurd: Support rumpdisk-based device names
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/arch/gnu.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/libparted/arch/gnu.c b/libparted/arch/gnu.c
index 507a5ff..0797115 100644
--- a/libparted/arch/gnu.c
+++ b/libparted/arch/gnu.c
@@ -786,6 +786,15 @@ probe_standard_devices ()
_ped_device_probe ("/dev/hd6");
_ped_device_probe ("/dev/hd7");
+ _ped_device_probe ("/dev/wd0");
+ _ped_device_probe ("/dev/wd1");
+ _ped_device_probe ("/dev/wd2");
+ _ped_device_probe ("/dev/wd3");
+ _ped_device_probe ("/dev/wd4");
+ _ped_device_probe ("/dev/wd5");
+ _ped_device_probe ("/dev/wd6");
+ _ped_device_probe ("/dev/wd7");
+
return 1;
}
--
2.31.1

View File

@ -1,135 +0,0 @@
From c16cb23bf91cf3255e2cf8ea596fe5e1b4ea1ad5 Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@ubuntu.com>
Date: Sun, 29 Nov 2020 23:19:23 +0100
Subject: [PATCH 37/38] hurd: Implement partition table rereading
We have to tell both the device for the drive itself, it case it
implements the partitioned devices, and tell the partition devices
to go away, in case they are implemented on their own by using parted.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/arch/gnu.c | 84 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 78 insertions(+), 6 deletions(-)
diff --git a/libparted/arch/gnu.c b/libparted/arch/gnu.c
index 0797115..b040c45 100644
--- a/libparted/arch/gnu.c
+++ b/libparted/arch/gnu.c
@@ -185,7 +185,7 @@ _init_device (const char *path)
if (!dev->arch_specific)
goto error_free_path;
- dev->type = PED_DEVICE_FILE; /* FIXME? */
+ dev->type = PED_DEVICE_UNKNOWN; /* It's deprecated anyway */
dev->open_count = 0;
dev->read_only = 0;
dev->external_mode = 0;
@@ -204,11 +204,83 @@ error:
return NULL;
}
+/* Ask the kernel and translators to reload the partition table.
+ XXX: Will probably be replaced by some RPC to partfs when it's finished. In
+ the meantime, gnumach's glue layer will pass BLKRRPART to the Linux drivers.
+ */
+#define BLKRRPART 0x125F
static int
-_kernel_reread_part_table (PedDevice* dev)
+_reread_part_table (PedDevice* dev)
{
- /* XXX: We must wait for partfs to be finished. */
- return 1;
+ struct store *store = GNU_SPECIFIC (dev)->store;
+ int retry_count = 9;
+ int len = strlen (dev->path);
+ char path[len + 3 + 1];
+ int i;
+ int done = 1;
+
+ sync ();
+
+ if(strcmp (store->class->name, "device") == 0) {
+ while (device_set_status (store->port, BLKRRPART, NULL, 0)) {
+ retry_count--;
+ sync ();
+ if (retry_count == 3)
+ sleep (1); /* Pause to allow system to settle */
+
+ if (!retry_count) {
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE,
+ _("WARNING: the kernel failed to re-read the "
+ "partition table on %s (%s). As a result, "
+ "it may not reflect all of your changes "
+ "until after reboot."),
+ dev->path, strerror (errno));
+ return 0;
+ }
+ }
+ }
+
+ i = 1;
+ while (1) {
+ file_t node;
+ error_t err;
+
+ /* Throw away all active parted-based translators */
+ snprintf (path, sizeof (path), "%ss%u", dev->path, i);
+ node = file_name_lookup (path, O_NOTRANS, 0666);
+ if (node == MACH_PORT_NULL) {
+ if (errno == ENOENT)
+ /* Finished looping over them */
+ break;
+
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE,
+ _("Warning: unable to open %s (%s). As a "
+ "result, it may not reflect all of your "
+ "changes until after reboot."),
+ path, strerror (errno));
+ done = 0;
+ }
+
+ err = file_set_translator (node, 0, FS_TRANS_SET,
+ 0, 0, 0, MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND);
+ if (err) {
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE,
+ _("Warning: failed to make translator go away "
+ "on %s (%s). As a result, it may not reflect "
+ "all of your changes until after reboot."),
+ dev->path, strerror (errno));
+ done = 0;
+ }
+ i++;
+ }
+
+ return done;
}
/* Free the memory associated with a PedDevice structure. */
@@ -355,7 +427,7 @@ gnu_close (PedDevice* dev)
_flush_cache (dev);
if (dev->dirty && dev->type != PED_DEVICE_FILE) {
- if (_kernel_reread_part_table (dev))
+ if (_reread_part_table (dev))
dev->dirty = 0;
}
@@ -827,7 +899,7 @@ gnu_partition_is_busy (const PedPartition* part)
static int
gnu_disk_commit (PedDisk* disk)
{
- return 1;
+ return _reread_part_table (disk->dev);
}
static PedDeviceArchOps gnu_dev_ops = {
--
2.31.1

View File

@ -1,283 +0,0 @@
From 9d1ac5015340aa7a4cc71cb7f63bae8c1718b8ee Mon Sep 17 00:00:00 2001
From: Arvin Schnell <aschnell@suse.com>
Date: Thu, 23 Sep 2021 16:31:42 +0000
Subject: [PATCH 38/38] keep GUID specific attributes
Keep GUID specific attributes when writing GPT.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/labels/gpt.c | 30 +++++------------
tests/Makefile.am | 3 +-
tests/gpt-attrs | 72 ++++++++++++++++++++++++++++++++++++++++
tests/t0215-gpt-attrs.sh | 46 +++++++++++++++++++++++++
4 files changed, 129 insertions(+), 22 deletions(-)
create mode 100755 tests/gpt-attrs
create mode 100644 tests/t0215-gpt-attrs.sh
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 9b987c1..ba9a71a 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -297,18 +297,17 @@ typedef struct _GPTPartitionData
efi_guid_t uuid;
efi_char16_t name[37];
char *translated_name;
+ GuidPartitionEntryAttributes_t attributes;
int lvm;
int swap;
int raid;
int boot;
int bios_grub;
int hp_service;
- int hidden;
int msftres;
int msftdata;
int atvrecv;
int msftrecv;
- int legacy_boot;
int prep;
int irst;
int chromeos_kernel;
@@ -826,25 +825,20 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
gpt_part_data->name[i] = (efi_char16_t) pte->PartitionName[i];
gpt_part_data->name[i] = 0;
gpt_part_data->translated_name = 0;
+ gpt_part_data->attributes = pte->Attributes;
gpt_part_data->lvm = gpt_part_data->swap
= gpt_part_data->raid
= gpt_part_data->boot = gpt_part_data->hp_service
- = gpt_part_data->hidden = gpt_part_data->msftres
+ = gpt_part_data->msftres
= gpt_part_data->msftdata
= gpt_part_data->msftrecv
- = gpt_part_data->legacy_boot
= gpt_part_data->prep
= gpt_part_data->irst
= gpt_part_data->chromeos_kernel
= gpt_part_data->bls_boot
= gpt_part_data->bios_grub = gpt_part_data->atvrecv = 0;
- if (pte->Attributes.RequiredToFunction & 0x1)
- gpt_part_data->hidden = 1;
- if (pte->Attributes.LegacyBIOSBootable & 0x1)
- gpt_part_data->legacy_boot = 1;
-
if (!guid_cmp (gpt_part_data->type, PARTITION_SYSTEM_GUID))
gpt_part_data->boot = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_BIOS_GRUB_GUID))
@@ -1241,12 +1235,7 @@ _partition_generate_part_entry (PedPartition *part, GuidPartitionEntry_t *pte)
pte->UniquePartitionGuid = gpt_part_data->uuid;
pte->StartingLBA = PED_CPU_TO_LE64 (part->geom.start);
pte->EndingLBA = PED_CPU_TO_LE64 (part->geom.end);
- memset (&pte->Attributes, 0, sizeof (GuidPartitionEntryAttributes_t));
-
- if (gpt_part_data->hidden)
- pte->Attributes.RequiredToFunction = 1;
- if (gpt_part_data->legacy_boot)
- pte->Attributes.LegacyBIOSBootable = 1;
+ pte->Attributes = gpt_part_data->attributes;
for (i = 0; i < 36; i++)
pte->PartitionName[i] = gpt_part_data->name[i];
@@ -1388,12 +1377,10 @@ gpt_partition_new (const PedDisk *disk,
gpt_part_data->boot = 0;
gpt_part_data->bios_grub = 0;
gpt_part_data->hp_service = 0;
- gpt_part_data->hidden = 0;
gpt_part_data->msftres = 0;
gpt_part_data->msftdata = 0;
gpt_part_data->msftrecv = 0;
gpt_part_data->atvrecv = 0;
- gpt_part_data->legacy_boot = 0;
gpt_part_data->prep = 0;
gpt_part_data->translated_name = 0;
gpt_part_data->irst = 0;
@@ -1402,6 +1389,7 @@ gpt_partition_new (const PedDisk *disk,
uuid_generate ((unsigned char *) &gpt_part_data->uuid);
swap_uuid_and_efi_guid (&gpt_part_data->uuid);
memset (gpt_part_data->name, 0, sizeof gpt_part_data->name);
+ memset (&gpt_part_data->attributes, 0, sizeof gpt_part_data->attributes);
return part;
error_free_part:
@@ -1911,10 +1899,10 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
= gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_HIDDEN:
- gpt_part_data->hidden = state;
+ gpt_part_data->attributes.RequiredToFunction = state;
return 1;
case PED_PARTITION_LEGACY_BOOT:
- gpt_part_data->legacy_boot = state;
+ gpt_part_data->attributes.LegacyBIOSBootable = state;
return 1;
case PED_PARTITION_ROOT:
case PED_PARTITION_LBA:
@@ -1953,9 +1941,9 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
case PED_PARTITION_APPLE_TV_RECOVERY:
return gpt_part_data->atvrecv;
case PED_PARTITION_HIDDEN:
- return gpt_part_data->hidden;
+ return gpt_part_data->attributes.RequiredToFunction;
case PED_PARTITION_LEGACY_BOOT:
- return gpt_part_data->legacy_boot;
+ return gpt_part_data->attributes.LegacyBIOSBootable;
case PED_PARTITION_PREP:
return gpt_part_data->prep;
case PED_PARTITION_IRST:
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('<L', header, 88, crc2)
+
+ # compute crc of header
+ pack_into('<L', header, 16, 0)
+ crc1 = crc32(header[:92]) & 0xFFFFFFFF
+ pack_into('<L', header, 16, crc1)
+
+ def read(self, name):
+ self.name = name
+
+ file = open(name, 'rb+')
+
+ file.seek(512)
+ self.primary_header = array.array('B', file.read(512))
+ self.primary_entries = array.array('B', file.read(32 * 512))
+
+ file.seek(-33 * 512, 2)
+ self.secondary_entries = array.array('B', file.read(32 * 512))
+ self.secondary_header = array.array('B', file.read(512))
+
+ def write(self):
+ file = open(self.name, 'rb+')
+
+ self.calc_crcs(self.primary_header, self.primary_entries)
+ file.seek(512)
+ file.write(self.primary_header)
+ file.write(self.primary_entries)
+
+ self.calc_crcs(self.secondary_header, self.secondary_entries)
+ file.seek(-33 * 512, 2)
+ file.write(self.secondary_entries)
+ file.write(self.secondary_header)
+
+
+gpt = Gpt()
+
+gpt.read(sys.argv[1])
+
+if sys.argv[2] == "show":
+ attrs = unpack_from('<Q', gpt.primary_entries, 48)[0]
+ print(hex(attrs))
+
+if sys.argv[2] == "set":
+ attrs = int(sys.argv[3], 0)
+ pack_into('<Q', gpt.primary_entries, 48, attrs)
+ pack_into('<Q', gpt.secondary_entries, 48, attrs)
+ gpt.write()
diff --git a/tests/t0215-gpt-attrs.sh b/tests/t0215-gpt-attrs.sh
new file mode 100644
index 0000000..216a966
--- /dev/null
+++ b/tests/t0215-gpt-attrs.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# Test that GUID specific bits are preserved
+
+# Copyright (C) 2021 SUSE LLC
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${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 <<EOF > exp || fail=1
+0x100000000000000
+EOF
+
+# check guid specific bit
+gpt-attrs "$dev" show > out || fail=1
+compare exp out || fail=1
+
+Exit $fail
--
2.31.1

View File

@ -1,566 +0,0 @@
From 15c49ec04f7eaff014d2e1eddd0aecf4150db63d Mon Sep 17 00:00:00 2001
From: Arvin Schnell <aschnell@suse.com>
Date: Mon, 27 Sep 2021 08:35:31 +0000
Subject: [PATCH 39/43] gpt: Map PED_PARTITON_ flags to GUID values
Drop the 14 flags from _GPTPartitionData that correspond to a
partition type/uuid. Use the type/uuid directly instead.
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
libparted/labels/gpt.c | 477 +++++------------------------------------
1 file changed, 54 insertions(+), 423 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index ba9a71a..3ba3cee 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -165,6 +165,43 @@ typedef struct
PED_CPU_TO_LE16 (0x4262), 0xa3, 0x52, \
{ 0xb2, 0x75, 0xfd, 0x6f, 0x71, 0x72 }})
+struct flag_uuid_mapping_t
+{
+ enum _PedPartitionFlag flag;
+ efi_guid_t type_uuid;
+};
+
+static const struct flag_uuid_mapping_t flag_uuid_mapping[] =
+{
+ { PED_PARTITION_APPLE_TV_RECOVERY, PARTITION_APPLE_TV_RECOVERY_GUID },
+ { PED_PARTITION_BIOS_GRUB, PARTITION_BIOS_GRUB_GUID },
+ { PED_PARTITION_BLS_BOOT, PARTITION_BLS_BOOT_GUID },
+ { PED_PARTITION_BOOT, PARTITION_SYSTEM_GUID },
+ { PED_PARTITION_CHROMEOS_KERNEL, PARTITION_CHROMEOS_KERNEL_GUID },
+ { PED_PARTITION_DIAG, PARTITION_MSFT_RECOVERY },
+ { PED_PARTITION_ESP, PARTITION_SYSTEM_GUID },
+ { PED_PARTITION_HPSERVICE, PARTITION_HPSERVICE_GUID },
+ { PED_PARTITION_IRST, PARTITION_IRST_GUID },
+ { PED_PARTITION_LVM, PARTITION_LVM_GUID },
+ { PED_PARTITION_MSFT_DATA, PARTITION_BASIC_DATA_GUID },
+ { PED_PARTITION_MSFT_RESERVED, PARTITION_MSFT_RESERVED_GUID },
+ { PED_PARTITION_PREP, PARTITION_PREP_GUID },
+ { PED_PARTITION_RAID, PARTITION_RAID_GUID },
+ { PED_PARTITION_SWAP, PARTITION_SWAP_GUID },
+};
+
+static const struct flag_uuid_mapping_t* _GL_ATTRIBUTE_CONST
+gpt_find_flag_uuid_mapping (PedPartitionFlag flag)
+{
+ int n = sizeof(flag_uuid_mapping) / sizeof(flag_uuid_mapping[0]);
+
+ for (int i = 0; i < n; ++i)
+ if (flag_uuid_mapping[i].flag == flag)
+ return &flag_uuid_mapping[i];
+
+ return NULL;
+}
+
struct __attribute__ ((packed)) _GuidPartitionTableHeader_t
{
uint64_t Signature;
@@ -298,20 +335,6 @@ typedef struct _GPTPartitionData
efi_char16_t name[37];
char *translated_name;
GuidPartitionEntryAttributes_t attributes;
- int lvm;
- int swap;
- int raid;
- int boot;
- int bios_grub;
- int hp_service;
- int msftres;
- int msftdata;
- int atvrecv;
- int msftrecv;
- int prep;
- int irst;
- int chromeos_kernel;
- int bls_boot;
} GPTPartitionData;
static PedDiskType gpt_disk_type;
@@ -827,47 +850,6 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
gpt_part_data->translated_name = 0;
gpt_part_data->attributes = pte->Attributes;
- gpt_part_data->lvm = gpt_part_data->swap
- = gpt_part_data->raid
- = gpt_part_data->boot = gpt_part_data->hp_service
- = gpt_part_data->msftres
- = gpt_part_data->msftdata
- = gpt_part_data->msftrecv
- = gpt_part_data->prep
- = gpt_part_data->irst
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->bls_boot
- = gpt_part_data->bios_grub = gpt_part_data->atvrecv = 0;
-
- if (!guid_cmp (gpt_part_data->type, PARTITION_SYSTEM_GUID))
- gpt_part_data->boot = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_BIOS_GRUB_GUID))
- gpt_part_data->bios_grub = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_RAID_GUID))
- gpt_part_data->raid = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_LVM_GUID))
- gpt_part_data->lvm = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_SWAP_GUID))
- gpt_part_data->swap = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_HPSERVICE_GUID))
- gpt_part_data->hp_service = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RESERVED_GUID))
- gpt_part_data->msftres = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_BASIC_DATA_GUID))
- gpt_part_data->msftdata = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RECOVERY))
- gpt_part_data->msftrecv = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_APPLE_TV_RECOVERY_GUID))
- gpt_part_data->atvrecv = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_PREP_GUID))
- gpt_part_data->prep = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_IRST_GUID))
- gpt_part_data->irst = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_CHROMEOS_KERNEL_GUID))
- gpt_part_data->chromeos_kernel = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_BLS_BOOT_GUID))
- gpt_part_data->bls_boot = 1;
-
return part;
}
@@ -1371,21 +1353,7 @@ gpt_partition_new (const PedDisk *disk,
goto error_free_part;
gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
- gpt_part_data->lvm = 0;
- gpt_part_data->swap = 0;
- gpt_part_data->raid = 0;
- gpt_part_data->boot = 0;
- gpt_part_data->bios_grub = 0;
- gpt_part_data->hp_service = 0;
- gpt_part_data->msftres = 0;
- gpt_part_data->msftdata = 0;
- gpt_part_data->msftrecv = 0;
- gpt_part_data->atvrecv = 0;
- gpt_part_data->prep = 0;
gpt_part_data->translated_name = 0;
- gpt_part_data->irst = 0;
- gpt_part_data->chromeos_kernel = 0;
- gpt_part_data->bls_boot = 0;
uuid_generate ((unsigned char *) &gpt_part_data->uuid);
swap_uuid_and_efi_guid (&gpt_part_data->uuid);
memset (gpt_part_data->name, 0, sizeof gpt_part_data->name);
@@ -1457,77 +1425,6 @@ gpt_partition_set_system (PedPartition *part,
part->fs_type = fs_type;
- if (gpt_part_data->lvm)
- {
- gpt_part_data->type = PARTITION_LVM_GUID;
- return 1;
- }
- if (gpt_part_data->swap)
- {
- gpt_part_data->type = PARTITION_SWAP_GUID;
- return 1;
- }
- if (gpt_part_data->raid)
- {
- gpt_part_data->type = PARTITION_RAID_GUID;
- return 1;
- }
- if (gpt_part_data->prep)
- {
- gpt_part_data->type = PARTITION_PREP_GUID;
- return 1;
- }
- if (gpt_part_data->boot)
- {
- gpt_part_data->type = PARTITION_SYSTEM_GUID;
- return 1;
- }
- if (gpt_part_data->bios_grub)
- {
- gpt_part_data->type = PARTITION_BIOS_GRUB_GUID;
- return 1;
- }
- if (gpt_part_data->hp_service)
- {
- gpt_part_data->type = PARTITION_HPSERVICE_GUID;
- return 1;
- }
- if (gpt_part_data->msftres)
- {
- gpt_part_data->type = PARTITION_MSFT_RESERVED_GUID;
- return 1;
- }
- if (gpt_part_data->msftdata)
- {
- gpt_part_data->type = PARTITION_BASIC_DATA_GUID;
- return 1;
- }
- if (gpt_part_data->msftrecv)
- {
- gpt_part_data->type = PARTITION_MSFT_RECOVERY;
- return 1;
- }
- if (gpt_part_data->atvrecv)
- {
- gpt_part_data->type = PARTITION_APPLE_TV_RECOVERY_GUID;
- return 1;
- }
- if (gpt_part_data->irst)
- {
- gpt_part_data->type = PARTITION_IRST_GUID;
- return 1;
- }
- if (gpt_part_data->chromeos_kernel)
- {
- gpt_part_data->type = PARTITION_CHROMEOS_KERNEL_GUID;
- return 1;
- }
- if (gpt_part_data->bls_boot)
- {
- gpt_part_data->type = PARTITION_BLS_BOOT_GUID;
- return 1;
- }
-
if (fs_type)
{
if (strncmp (fs_type->name, "fat", 3) == 0
@@ -1657,247 +1554,18 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
PED_ASSERT (part->disk_specific != NULL);
gpt_part_data = part->disk_specific;
+ const struct flag_uuid_mapping_t* p = gpt_find_flag_uuid_mapping (flag);
+ if (p)
+ {
+ if (state)
+ gpt_part_data->type = p->type_uuid;
+ else if (guid_cmp (gpt_part_data->type, p->type_uuid) == 0)
+ gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
+ return 1;
+ }
+
switch (flag)
{
- case PED_PARTITION_ESP:
- case PED_PARTITION_BOOT:
- gpt_part_data->boot = state;
- if (state)
- gpt_part_data->raid
- = gpt_part_data->lvm
- = gpt_part_data->swap
- = gpt_part_data->bios_grub
- = gpt_part_data->hp_service
- = gpt_part_data->msftres
- = gpt_part_data->msftdata
- = gpt_part_data->msftrecv
- = gpt_part_data->prep
- = gpt_part_data->irst
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->bls_boot
- = gpt_part_data->atvrecv = 0;
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_BIOS_GRUB:
- gpt_part_data->bios_grub = state;
- if (state)
- gpt_part_data->raid
- = gpt_part_data->lvm
- = gpt_part_data->swap
- = gpt_part_data->boot
- = gpt_part_data->hp_service
- = gpt_part_data->msftres
- = gpt_part_data->msftdata
- = gpt_part_data->msftrecv
- = gpt_part_data->prep
- = gpt_part_data->irst
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->bls_boot
- = gpt_part_data->atvrecv = 0;
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_RAID:
- gpt_part_data->raid = state;
- if (state)
- gpt_part_data->boot
- = gpt_part_data->lvm
- = gpt_part_data->swap
- = gpt_part_data->bios_grub
- = gpt_part_data->hp_service
- = gpt_part_data->msftres
- = gpt_part_data->msftdata
- = gpt_part_data->msftrecv
- = gpt_part_data->prep
- = gpt_part_data->irst
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->bls_boot
- = gpt_part_data->atvrecv = 0;
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_LVM:
- gpt_part_data->lvm = state;
- if (state)
- gpt_part_data->boot
- = gpt_part_data->swap
- = gpt_part_data->raid
- = gpt_part_data->bios_grub
- = gpt_part_data->hp_service
- = gpt_part_data->msftres
- = gpt_part_data->msftdata
- = gpt_part_data->msftrecv
- = gpt_part_data->prep
- = gpt_part_data->irst
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->bls_boot
- = gpt_part_data->atvrecv = 0;
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_SWAP:
- gpt_part_data->swap = state;
- if (state)
- gpt_part_data->boot
- = gpt_part_data->lvm
- = gpt_part_data->raid
- = gpt_part_data->bios_grub
- = gpt_part_data->hp_service
- = gpt_part_data->msftres
- = gpt_part_data->msftdata
- = gpt_part_data->msftrecv
- = gpt_part_data->prep
- = gpt_part_data->irst
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->bls_boot
- = gpt_part_data->atvrecv = 0;
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_HPSERVICE:
- gpt_part_data->hp_service = state;
- if (state)
- gpt_part_data->boot
- = gpt_part_data->raid
- = gpt_part_data->lvm
- = gpt_part_data->swap
- = gpt_part_data->bios_grub
- = gpt_part_data->msftres
- = gpt_part_data->msftdata
- = gpt_part_data->msftrecv
- = gpt_part_data->prep
- = gpt_part_data->irst
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->bls_boot
- = gpt_part_data->atvrecv = 0;
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_MSFT_RESERVED:
- gpt_part_data->msftres = state;
- if (state)
- gpt_part_data->boot
- = gpt_part_data->raid
- = gpt_part_data->lvm
- = gpt_part_data->swap
- = gpt_part_data->bios_grub
- = gpt_part_data->hp_service
- = gpt_part_data->msftdata
- = gpt_part_data->msftrecv
- = gpt_part_data->prep
- = gpt_part_data->irst
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->bls_boot
- = gpt_part_data->atvrecv = 0;
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_MSFT_DATA:
- gpt_part_data->msftres = state;
- if (state) {
- gpt_part_data->boot
- = gpt_part_data->raid
- = gpt_part_data->lvm
- = gpt_part_data->swap
- = gpt_part_data->bios_grub
- = gpt_part_data->hp_service
- = gpt_part_data->msftres
- = gpt_part_data->msftrecv
- = gpt_part_data->prep
- = gpt_part_data->irst
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->bls_boot
- = gpt_part_data->atvrecv = 0;
- gpt_part_data->msftdata = 1;
- } else {
- gpt_part_data->msftdata = 0;
- }
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_DIAG:
- gpt_part_data->msftrecv = state;
- if (state)
- gpt_part_data->boot
- = gpt_part_data->raid
- = gpt_part_data->lvm
- = gpt_part_data->swap
- = gpt_part_data->bios_grub
- = gpt_part_data->hp_service
- = gpt_part_data->msftdata
- = gpt_part_data->msftres
- = gpt_part_data->prep
- = gpt_part_data->irst
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->atvrecv = 0;
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_APPLE_TV_RECOVERY:
- gpt_part_data->atvrecv = state;
- if (state)
- gpt_part_data->boot
- = gpt_part_data->raid
- = gpt_part_data->lvm
- = gpt_part_data->swap
- = gpt_part_data->bios_grub
- = gpt_part_data->hp_service
- = gpt_part_data->msftres
- = gpt_part_data->msftdata
- = gpt_part_data->prep
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->msftrecv = 0;
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_PREP:
- gpt_part_data->prep = state;
- if (state)
- gpt_part_data->boot
- = gpt_part_data->raid
- = gpt_part_data->lvm
- = gpt_part_data->swap
- = gpt_part_data->bios_grub
- = gpt_part_data->hp_service
- = gpt_part_data->msftres
- = gpt_part_data->irst
- = gpt_part_data->atvrecv
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->bls_boot
- = gpt_part_data->msftrecv = 0;
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_IRST:
- gpt_part_data->irst = state;
- if (state)
- gpt_part_data->boot
- = gpt_part_data->raid
- = gpt_part_data->lvm
- = gpt_part_data->swap
- = gpt_part_data->bios_grub
- = gpt_part_data->hp_service
- = gpt_part_data->msftres
- = gpt_part_data->msftdata
- = gpt_part_data->msftrecv
- = gpt_part_data->prep
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->bls_boot
- = gpt_part_data->atvrecv = 0;
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_CHROMEOS_KERNEL:
- gpt_part_data->chromeos_kernel = state;
- if (state)
- gpt_part_data->boot
- = gpt_part_data->bios_grub
- = gpt_part_data->raid
- = gpt_part_data->lvm
- = gpt_part_data->swap
- = gpt_part_data->hp_service
- = gpt_part_data->msftres
- = gpt_part_data->msftdata
- = gpt_part_data->msftrecv
- = gpt_part_data->atvrecv
- = gpt_part_data->prep
- = gpt_part_data->irst
- = gpt_part_data->bls_boot = 0;
- return gpt_partition_set_system (part, part->fs_type);
- case PED_PARTITION_BLS_BOOT:
- gpt_part_data->bls_boot = state;
- if (state)
- gpt_part_data->boot
- = gpt_part_data->raid
- = gpt_part_data->lvm
- = gpt_part_data->swap
- = gpt_part_data->bios_grub
- = gpt_part_data->hp_service
- = gpt_part_data->msftres
- = gpt_part_data->msftdata
- = gpt_part_data->msftrecv
- = gpt_part_data->prep
- = gpt_part_data->irst
- = gpt_part_data->chromeos_kernel
- = gpt_part_data->atvrecv = 0;
- return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_HIDDEN:
gpt_part_data->attributes.RequiredToFunction = state;
return 1;
@@ -1919,41 +1587,16 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
PED_ASSERT (part->disk_specific != NULL);
gpt_part_data = part->disk_specific;
+ const struct flag_uuid_mapping_t* p = gpt_find_flag_uuid_mapping (flag);
+ if (p)
+ return guid_cmp (gpt_part_data->type, p->type_uuid) == 0;
+
switch (flag)
{
- case PED_PARTITION_RAID:
- return gpt_part_data->raid;
- case PED_PARTITION_LVM:
- return gpt_part_data->lvm;
- case PED_PARTITION_ESP:
- case PED_PARTITION_BOOT:
- return gpt_part_data->boot;
- case PED_PARTITION_BIOS_GRUB:
- return gpt_part_data->bios_grub;
- case PED_PARTITION_HPSERVICE:
- return gpt_part_data->hp_service;
- case PED_PARTITION_MSFT_RESERVED:
- return gpt_part_data->msftres;
- case PED_PARTITION_MSFT_DATA:
- return gpt_part_data->msftdata;
- case PED_PARTITION_DIAG:
- return gpt_part_data->msftrecv;
- case PED_PARTITION_APPLE_TV_RECOVERY:
- return gpt_part_data->atvrecv;
case PED_PARTITION_HIDDEN:
return gpt_part_data->attributes.RequiredToFunction;
case PED_PARTITION_LEGACY_BOOT:
return gpt_part_data->attributes.LegacyBIOSBootable;
- case PED_PARTITION_PREP:
- return gpt_part_data->prep;
- case PED_PARTITION_IRST:
- return gpt_part_data->irst;
- case PED_PARTITION_BLS_BOOT:
- return gpt_part_data->bls_boot;
- case PED_PARTITION_SWAP:
- return gpt_part_data->swap;
- case PED_PARTITION_CHROMEOS_KERNEL:
- return gpt_part_data->chromeos_kernel;
case PED_PARTITION_LBA:
case PED_PARTITION_ROOT:
default:
@@ -1966,25 +1609,13 @@ static int
gpt_partition_is_flag_available (const PedPartition *part,
PedPartitionFlag flag)
{
+ if (gpt_find_flag_uuid_mapping (flag))
+ return 1;
+
switch (flag)
{
- case PED_PARTITION_RAID:
- case PED_PARTITION_LVM:
- case PED_PARTITION_SWAP:
- case PED_PARTITION_BOOT:
- case PED_PARTITION_BIOS_GRUB:
- case PED_PARTITION_HPSERVICE:
- case PED_PARTITION_MSFT_RESERVED:
- case PED_PARTITION_MSFT_DATA:
- case PED_PARTITION_DIAG:
- case PED_PARTITION_APPLE_TV_RECOVERY:
case PED_PARTITION_HIDDEN:
case PED_PARTITION_LEGACY_BOOT:
- case PED_PARTITION_PREP:
- case PED_PARTITION_IRST:
- case PED_PARTITION_ESP:
- case PED_PARTITION_CHROMEOS_KERNEL:
- case PED_PARTITION_BLS_BOOT:
return 1;
case PED_PARTITION_ROOT:
case PED_PARTITION_LBA:
--
2.31.1

View File

@ -1,72 +0,0 @@
From 6ef2f88d014f267157d9e9300b31c5f1ab4d5e42 Mon Sep 17 00:00:00 2001
From: Arvin Schnell <aschnell@suse.com>
Date: Thu, 30 Sep 2021 13:49:30 -0700
Subject: [PATCH 40/43] gpt: Add linux-home flag
This sets the partition GUID to the linux home type:
933AC7E1-2EB4-4F13-B844-0E14E2AEF915
Signed-off-by: Brian C. Lane <bcl@redhat.com>
---
include/parted/disk.in.h | 5 +++--
libparted/disk.c | 2 ++
libparted/labels/gpt.c | 5 +++++
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
index 7ca6453..303f59c 100644
--- a/include/parted/disk.in.h
+++ b/include/parted/disk.in.h
@@ -84,10 +84,11 @@ enum _PedPartitionFlag {
PED_PARTITION_IRST=17,
PED_PARTITION_ESP=18,
PED_PARTITION_CHROMEOS_KERNEL=19,
- PED_PARTITION_BLS_BOOT=20
+ PED_PARTITION_BLS_BOOT=20,
+ PED_PARTITION_LINUX_HOME=21,
};
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_BLS_BOOT
+#define PED_PARTITION_LAST_FLAG PED_PARTITION_LINUX_HOME
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
diff --git a/libparted/disk.c b/libparted/disk.c
index 345b9e7..8496fc0 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -2411,6 +2411,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
return N_("chromeos_kernel");
case PED_PARTITION_BLS_BOOT:
return N_("bls_boot");
+ case PED_PARTITION_LINUX_HOME:
+ return N_("linux-home");
default:
ped_exception_throw (
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 3ba3cee..8b345d5 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -164,6 +164,10 @@ typedef struct
((efi_guid_t) { PED_CPU_TO_LE32 (0xbc13c2ff), PED_CPU_TO_LE16 (0x59e6), \
PED_CPU_TO_LE16 (0x4262), 0xa3, 0x52, \
{ 0xb2, 0x75, 0xfd, 0x6f, 0x71, 0x72 }})
+#define PARTITION_LINUX_HOME_GUID \
+ ((efi_guid_t) { PED_CPU_TO_LE32 (0x933ac7e1), PED_CPU_TO_LE16 (0x2eb4), \
+ PED_CPU_TO_LE16 (0x4f13), 0xb8, 0x44, \
+ { 0x0e, 0x14, 0xe2, 0xae, 0xf9, 0x15 }})
struct flag_uuid_mapping_t
{
@@ -182,6 +186,7 @@ static const struct flag_uuid_mapping_t flag_uuid_mapping[] =
{ PED_PARTITION_ESP, PARTITION_SYSTEM_GUID },
{ PED_PARTITION_HPSERVICE, PARTITION_HPSERVICE_GUID },
{ PED_PARTITION_IRST, PARTITION_IRST_GUID },
+ { PED_PARTITION_LINUX_HOME, PARTITION_LINUX_HOME_GUID },
{ PED_PARTITION_LVM, PARTITION_LVM_GUID },
{ PED_PARTITION_MSFT_DATA, PARTITION_BASIC_DATA_GUID },
{ PED_PARTITION_MSFT_RESERVED, PARTITION_MSFT_RESERVED_GUID },
--
2.31.1

View File

@ -1,42 +0,0 @@
From 87d78ee78ca8d09de0d4850280cfd0ea9d9662fd Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 30 Sep 2021 13:46:40 -0700
Subject: [PATCH 41/43] doc: Document gpt linux-home flag
---
doc/C/parted.8 | 3 ++-
doc/parted.texi | 4 ++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/doc/C/parted.8 b/doc/C/parted.8
index 46b30ad..afca9f2 100644
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
@@ -118,7 +118,8 @@ or an LVM logical volume if necessary.
.B set \fIpartition\fP \fIflag\fP \fIstate\fP
Change the state of the \fIflag\fP on \fIpartition\fP to \fIstate\fP.
Supported flags are: "boot", "root", "swap", "hidden", "raid", "lvm", "lba",
-"legacy_boot", "irst", "msftres", "esp", "chromeos_kernel", "bls_boot" and "palo".
+"legacy_boot", "irst", "msftres", "esp", "chromeos_kernel", "bls_boot", "linux-home",
+and "palo".
\fIstate\fP should be either "on" or "off".
.TP
.B unit \fIunit\fP
diff --git a/doc/parted.texi b/doc/parted.texi
index 57ceb55..4344328 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -904,6 +904,10 @@ MS Windows ME based operating systems to use Linear (LBA) mode.
(Mac) - this flag should be enabled if the partition is the root device
to be used by Linux.
+@item linux-home
+(GPT) - Enable this to indicate that the selected partition is a
+Linux /home partition.
+
@item swap
(MS-DOS, GPT, Mac) - this flag should be enabled if the partition is the
swap device to be used by Linux.
--
2.31.1

View File

@ -1,144 +0,0 @@
From 10ad2aac0453f10b2e355a0df03618e0ebc593be Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Wed, 29 Sep 2021 15:57:50 -0700
Subject: [PATCH 42/43] tests: Add a test to make sure GPT GUIDs default to
filesystem
When no flag is set on a GPT partition the GUID should fall back to the
filesystem type for fat32, swap, and hfs+ and if no filesystem is found
it should default to linux filesystem data type, showing no filesystem
and no flags.
---
tests/Makefile.am | 1 +
tests/t3210-gpt-type-change.sh | 107 +++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+)
create mode 100755 tests/t3210-gpt-type-change.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3dc6e72..5cb7aa3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -60,6 +60,7 @@ TESTS = \
t3000-resize-fs.sh \
t3200-resize-partition.sh \
t3200-type-change.sh \
+ t3210-gpt-type-change.sh \
t3300-palo-prep.sh \
t3310-flags.sh \
t3400-whole-disk-FAT-partition.sh \
diff --git a/tests/t3210-gpt-type-change.sh b/tests/t3210-gpt-type-change.sh
new file mode 100755
index 0000000..57000d9
--- /dev/null
+++ b/tests/t3210-gpt-type-change.sh
@@ -0,0 +1,107 @@
+#!/bin/sh
+# Ensure parted changes GUID back to match its FS.
+
+# Copyright (C) 2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+require_root_
+require_scsi_debug_module_
+
+grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||
+ skip_ 'this system lacks a new-enough libblkid'
+
+# What filesystem tools are present?
+FSTYPES=""
+
+# Is mkfs.hfsplus available?
+mkfs.hfsplus 2>&1 | grep '^usage:' && FSTYPES="hfs+"
+
+# Is mkfs.vfat available?
+mkfs.vfat 2>&1 | grep '^Usage:' && FSTYPES="$FSTYPES fat32"
+
+# Is mkswap available?
+mkswap -V 2>&1 | grep '^mkswap' && FSTYPES="$FSTYPES linux-swap"
+
+[ -n "$FSTYPES" ] || skip_ "No supported filesystem tools (vfat, hfs+, swap) installed"
+
+
+# create memory-backed device
+scsi_debug_setup_ dev_size_mb=25 > dev-name ||
+ skip_ 'failed to create scsi_debug device'
+scsi_dev=$(cat dev-name)
+
+# Create a formatted partition.
+# Set a different partition type on it, eg. lvm, then unset it.
+# The partition flag should return to the detected filesystem type.
+
+for fs_type in $FSTYPES; do
+ echo "fs_type=$fs_type"
+
+
+ parted -s $scsi_dev mklabel gpt mkpart first $fs_type 1MB 25MB > out 2>&1 || fail=1
+ # expect no output
+ compare /dev/null out || fail=1
+
+ p1=${scsi_dev}1
+ wait_for_dev_to_appear_ $p1 || fail=1
+
+ case $fs_type in
+ fat32) mkfs.vfat $p1 || fail=1 ;;
+ hfs*) mkfs.hfsplus $p1 || fail=1;;
+ linux-swap) mkswap $p1 || fail=1;;
+ *) error "internal error: unhandled fs type: $fs_type";;
+ esac
+
+ # Confirm the filesystem and flags are as expected
+ parted -s $scsi_dev u s p > out || fail=1
+ case $fs_type in
+ fat32) grep 'fat16.*msftdata$' out || { fail=1; cat out; } ;;
+ hfs*) grep 'hfs+.*first$' out || { fail=1; cat out; } ;;
+ linux-swap) grep 'linux-swap.*swap$' out || { fail=1; cat out; } ;;
+ *) error "internal error: unhandled fs type: $fs_type";;
+ esac
+
+ # Set the lvm GUID on the partition
+ parted -s $scsi_dev set 1 lvm on > out 2>&1 || fail=1
+ # expect no output
+ compare /dev/null out || fail=1
+
+ # Confirm filesystem probe is the same, but flags are now lvm
+ parted -s $scsi_dev u s p > out || fail=1
+ case $fs_type in
+ fat32) grep 'fat16.*lvm$' out || { fail=1; cat out; } ;;
+ hfs*) grep 'hfs+.*lvm$' out || { fail=1; cat out; } ;;
+ linux-swap) grep 'linux-swap.*lvm$' out || { fail=1; cat out; } ;;
+ *) error "internal error: unhandled fs type: $fs_type";;
+ esac
+
+ # Unset the lvm GUID on both partitions
+ parted -s $scsi_dev set 1 lvm off > out 2>&1 || fail=1
+ # expect no output
+ compare /dev/null out || fail=1
+
+ # Confirm the filesystem and flags are as expected
+ parted -s $scsi_dev u s p > out || fail=1
+ case $fs_type in
+ fat32) grep 'fat16.*msftdata$' out || { fail=1; cat out; } ;;
+ hfs*) grep 'hfs+.*first$' out || { fail=1; cat out; } ;;
+ linux-swap) grep 'linux-swap.*swap$' out || { fail=1; cat out; } ;;
+ *) error "internal error: unhandled fs type: $fs_type";;
+ esac
+done
+
+Exit $fail
--
2.31.1

View File

@ -1,25 +0,0 @@
From a1f8bcde22bbd97ef7abae3c83ede77fc25a301c Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Thu, 30 Sep 2021 13:16:12 -0700
Subject: [PATCH 43/43] gpt: Revert to filesystem GUID when setting flag to off
---
libparted/labels/gpt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 8b345d5..c5d7bb3 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1565,7 +1565,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
if (state)
gpt_part_data->type = p->type_uuid;
else if (guid_cmp (gpt_part_data->type, p->type_uuid) == 0)
- gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
+ return gpt_partition_set_system (part, part->fs_type);
return 1;
}
--
2.31.1

View File

@ -1,459 +0,0 @@
From b20227adf5756617076c9e2ec267ee6794a21e22 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 28 Sep 2021 16:37:43 -0700
Subject: [PATCH] docs: Update documentation to be consistent
This fixes some missing commands in the parted.texi file used to
generate the web manual and info document. It also removes documentation
for the never-implemented 'print NUMBER' command which only returns 1.
The parted manpage has been updated to document the available print
options, disk_set, and disk_toggle commands.
---
doc/C/parted.8 | 16 ++++-
doc/parted.texi | 185 +++++++++++++++++++++++++++++++++++-------------
parted/parted.c | 4 +-
3 files changed, 149 insertions(+), 56 deletions(-)
diff --git a/doc/C/parted.8 b/doc/C/parted.8
index afca9f2..c742154 100644
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
@@ -1,4 +1,4 @@
-.TH PARTED 8 "2007 March 29" parted "GNU Parted Manual"
+.TH PARTED 8 "2021 September 28" parted "GNU Parted Manual"
.SH NAME
parted \- a partition manipulation program
.SH SYNOPSIS
@@ -24,7 +24,7 @@ lists partition layout on all block devices
.B -m, --machine
displays machine parseable output
.TP
-.B -m, --json
+.B -j, --json
displays JSON output
.TP
.B -s, --script
@@ -92,8 +92,9 @@ PC98, and GPT disklabels. The name can be placed in double quotes, if necessary.
And depending on the shell may need to also be wrapped in single quotes so that
the shell doesn't strip off the double quotes.
.TP
-.B print
+.B print \fIprint-type\fP
Display the partition table.
+\fIprint-type\fP is optional, and can be one of devices, free, list, or all.
.TP
.B quit
Exit from \fBparted\fP.
@@ -133,6 +134,15 @@ human-friendly form for output).
.B toggle \fIpartition\fP \fIflag\fP
Toggle the state of \fIflag\fP on \fIpartition\fP.
.TP
+.B disk_set \fIflag\fP \fIstate\fP
+Change a \fIflag\fP on the disk to \fIstate\fP. A flag can be either "on" or "off".
+Some or all of these flags will be available, depending on what disk label you
+are using. Supported flags are: "pmbr_boot" on GPT to enable the boot flag on the
+GPT's protective MBR partition.
+.TP
+.B disk_toggle \fIflag\fP
+Toggle the state of the disk \fIflag\fP.
+.TP
.B version
Display version information and a copyright message.
.RE
diff --git a/doc/parted.texi b/doc/parted.texi
index 4344328..bc981de 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -14,7 +14,7 @@ and manipulating partition tables.
@ifnottex @c texi2pdf don't understand copying and insertcopying ???
@c modifications must also be done in the titlepage
@copying
-Copyright @copyright{} 1999--2014, 2019--2021 Free Software Foundation, Inc.
+Copyright @copyright{} 1999--2021 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -46,7 +46,7 @@ Free Documentation License''.
@c @vskip 0pt plus 1filll
@c modifications must also be done in the copying block
-Copyright @copyright{} 1999-2011 Free Software Foundation, Inc.
+Copyright @copyright{} 1999-2021 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -117,9 +117,9 @@ power failure) and performs many safety checks. However, there could
be bugs in GNU Parted, so you should back up your important files before
running Parted.
-The GNU Parted homepage is @uref{http://www.gnu.org/software/parted}. The
+The GNU Parted homepage is @uref{https://www.gnu.org/software/parted}. The
library and frontend themselves can be downloaded from
-@uref{ftp://ftp.gnu.org/gnu/parted}.
+@uref{https://ftp.gnu.org/gnu/parted}.
You can also find a listing of mailing lists, notes for contributing and
more useful information on the web site.
@@ -129,7 +129,7 @@ Please include the output from these commands (for disk @file{/dev/hda}):
@example
@group
-# @kbd{parted /dev/hda print unit s print unit chs print}
+# @kbd{parted /dev/hda unit s print free}
@end group
@end example
@@ -157,6 +157,14 @@ installed:
@itemize @bullet
+@item GNU parted source is available either as a source tarball:
+
+ @uref{https://git.savannah.gnu.org/gitweb/?p=parted.git}
+
+or using git (See the README-hacking instructions):
+
+ @uref{https://git.savannah.gnu.org/gitweb/?p=parted.git}
+
@item libuuid, part of the e2fsprogs package. If you don't have this,
you can get it from:
@@ -167,7 +175,7 @@ If you want to compile Parted and e2fsprogs, note that you will need to
@item GNU Readline (optional), available from
- @uref{ftp://ftp.gnu.org/gnu/readline}
+ @uref{https://ftp.gnu.org/gnu/readline}
If you are compiling Parted, and you don't have readline, you can
disable Parted's readline support with the @kbd{--disable-readline}
@@ -176,7 +184,7 @@ option for @command{configure}.
@item GNU gettext (or compatible software) for compilation, if
internationalisation support is desired.
- @uref{ftp://ftp.gnu.org/gnu/gettext}
+ @uref{https://ftp.gnu.org/gnu/gettext}
@end itemize
@@ -259,7 +267,7 @@ disable writing (for debugging)
@subsection Introduction
If you want to run GNU Parted on a machine without GNU/Linux installed,
or you want to modify a root or boot partition, use GParted Live:
-@uref{http://gparted.sourceforge.net/livecd.php}.
+@uref{https://gparted.org/livecd.php}.
@node Using Parted
@chapter Using Parted
@@ -402,6 +410,10 @@ Options:
@itemx --help
display a help message
+@item -l
+@itemx --list
+lists partition layout on all block devices
+
@item -m
@itemx --machine
display output in machine parseable format
@@ -416,7 +428,7 @@ never prompt the user
@item -f
@itemx --fix
-automatically answer exceptions with "fix" in script mode, whcih is useful for:
+automatically answer exceptions with "fix" in script mode, which is useful for:
GPT header not including full disk size; moving the backup GPT table to the end of the disk;
MAC fix missing partition map entry; etc.
@@ -441,6 +453,7 @@ GNU Parted provides the following commands:
@menu
* align-check::
* disk_set::
+* disk_toggle::
* help::
* mklabel::
* mkpart::
@@ -452,6 +465,7 @@ GNU Parted provides the following commands:
* rm::
* select::
* set::
+* toggle::
* unit::
@end menu
@@ -515,6 +529,16 @@ in machine mode.
Set the PMBR's boot flag.
@end deffn
+@node disk_toggle
+@subsection disk_toggle
+@cindex disk_toggle, command description
+@cindex command description, disk_toggle
+
+@deffn Command disk_toggle @var{flag}
+
+Toggle the state of the disk flag.
+@end deffn
+
@node help
@subsection help
@cindex help, command description
@@ -551,9 +575,12 @@ thing: partition table, partition map.}
@var{label-type} must be one of these supported disk labels:
@itemize @bullet
+@item aix
+@item amiga
@item bsd
-@item loop (raw disk access)
+@item dvh
@item gpt
+@item loop (raw disk access)
@item mac
@item msdos
@item pc98
@@ -594,14 +621,19 @@ partition table.
@var{fs-type} must be one of these supported file systems:
@itemize @bullet
-@item ext2
+@item btrfs
+@item ext2, ext3, ext4
@item fat16, fat32
@item hfs, hfs+, hfsx
-@item linux-swap
-@item NTFS
+@item hp-ufs
+@item jfs
+@item linux-swap, linux-swap(new,old,v0,v1)
+@item nilfs2
+@item ntfs
@item reiserfs
+@item sun-ufs
@item ufs
-@item btrfs
+@item xfs
@end itemize
For example, the following creates a logical partition that will contain
@@ -671,29 +703,56 @@ Set the name of partition 2 to `Secret Documents'.
@cindex print, command description
@cindex command description, print
-@deffn Command print [@var{number}]
+@deffn Command print [@var{print-type}]
Displays the partition table on the device parted is editing, or
detailed information about a particular partition.
+@var{print-type} is optional, and can be one of @samp{devices},
+@samp{free}, @samp{list}, or @samp{all}.
+
+@table @code
+
+@item devices
+display all active block devices
+
+@item free
+display information about free unpartitioned space on the current block device
+
+@item list, all
+display the partition tables of all active block devices
+
+@end table
+
Example:
@example
@group
(parted) @kbd{print}
-Disk geometry for /dev/hda: 0.000-2445.679 megabytes
-Disk label type: msdos
-Minor Start End Type Filesystem Flags
-1 0.031 945.000 primary fat32 boot, lba
-2 945.000 2358.562 primary ext2
-3 2358.562 2445.187 primary linux-swap
-(parted) @kbd{print 1}
-Minor: 1
-Flags: boot, lba
-File System: fat32
-Size: 945.000Mb (0%)
-Minimum size: 84.361Mb (0%)
-Maximum size: 2445.679Mb (100%)
+Model: ATA Samsung SSD 850 (scsi)
+Disk /dev/sda: 2684MB
+Sector size (logical/physical): 512B/512B
+Partition Table: msdos
+Disk Flags:
+
+Number Start End Size Type File system Flags
+ 1 1049kB 1000MB 999MB primary boot, lba
+ 2 1000MB 2300MB 1299MB primary ext2 lba
+ 3 2300MB 2500MB 200MB primary linux-swap(v1) lba
+(parted) @kbd{print free}
+Model: ATA Samsung SSD 850 (scsi)
+Disk /dev/sda: 2684MB
+Sector size (logical/physical): 512B/512B
+Partition Table: msdos
+Disk Flags:
+
+Number Start End Size Type File system Flags
+ 16.4kB 1049kB 1032kB Free Space
+ 1 1049kB 1000MB 999MB primary boot, lba
+ 2 1000MB 2300MB 1299MB primary ext2 lba
+ 3 2300MB 2500MB 200MB primary linux-swap(v1) lba
+ 2500MB 2684MB 185MB Free Space
+
@end group
@end example
@end deffn
@@ -728,43 +787,58 @@ may delay this.
Rescue a lost partition that used to be located approximately between
@var{start} and @var{end}. If such a partition is found, Parted will
ask you if you want to create a partition for it. This is useful if you
-accidently deleted a partition with parted's rm command, for example.
+accidentally deleted a partition with parted's rm command, for example.
Example:
@example
(parted) @kbd{print}
@group
-Disk geometry for /dev/hdc: 0.000-8063.507 megabytes
-Disk label type: msdos
-Minor Start End Type Filesystem Flags
-1 0.031 8056.032 primary ext3
+Model: ATA Samsung SSD 850 (scsi)
+Disk /dev/sda: 2684MB
+Sector size (logical/physical): 512B/512B
+Partition Table: msdos
+Disk Flags:
+
+Number Start End Size Type File system Flags
+ 1 1049kB 1000MB 999MB primary boot, lba
+ 2 1000MB 2300MB 1299MB primary ext4 lba
@end group
(parted) @kbd{rm}
-Partition number? 1
+Partition number? 2
(parted) @kbd{print}
@group
-Disk geometry for /dev/hdc: 0.000-8063.507 megabytes
-Disk label type: msdos
-Minor Start End Type Filesystem Flags
+Model: ATA Samsung SSD 850 (scsi)
+Disk /dev/sda: 2684MB
+Sector size (logical/physical): 512B/512B
+Partition Table: msdos
+Disk Flags:
+
+Number Start End Size Type File system Flags
+ 1 1049kB 1000MB 999MB primary boot, lba
@end group
@end example
-OUCH! We deleted our ext3 partition!!! Parted comes to the rescue...
+OUCH! We deleted our ext4 partition!!! Parted comes to the rescue...
@example
(parted) @kbd{rescue}
-Start? 0
-End? 8056
-Information: A ext3 primary partition was found at 0.031MB ->
-8056.030MB. Do you want to add it to the partition table?
+Start? 1000
+End? 2684
+Information: A ext4 primary partition was found at 1000MB ->
+2300MB. Do you want to add it to the partition table?
Yes/No/Cancel? @kbd{y}
(parted) @kbd{print}
@group
-Disk geometry for /dev/hdc: 0.000-8063.507 megabytes
-Disk label type: msdos
-Minor Start End Type Filesystem Flags
-1 0.031 8056.032 primary ext3
+Model: ATA Samsung SSD 850 (scsi)
+Disk /dev/sda: 2684MB
+Sector size (logical/physical): 512B/512B
+Partition Table: msdos
+Disk Flags:
+
+Number Start End Size Type File system Flags
+ 1 1049kB 1000MB 999MB primary boot, lba
+ 2 1000MB 2300MB 1299MB primary ext4 lba
@end group
@end example
@@ -795,7 +869,7 @@ but when shrinking, you need to shrink the filesystem before the partition.
@deffn Command rm @var{number}
-Removes the partition with number @var{number}. If you accidently delete
+Removes the partition with number @var{number}. If you accidentally delete
a partition with this command, use mkpart to
recover it. Also, you can use the gpart program (@pxref{Related information})
to recover damaged disk labels.
@@ -824,8 +898,8 @@ Remove partition 3.
@deffn Command select @var{device}
Selects the device, @var{device}, for Parted to edit. The device can
-be a Linux hard disk device, a partition, a software RAID device or
-LVM logical volume.
+be a Linux hard disk device, a partition, a software RAID device,
+LVM logical volume, or disk image file.
Example:
@@ -949,6 +1023,17 @@ Example:
Set the @samp{boot} flag on partition 1.
@end deffn
+@node toggle
+@subsection toggle
+@cindex toggle, command description
+@cindex command description, toggle
+
+@deffn Command toggle @var{number} @var{flag}
+
+Toggle the state of @var{flag} on partition @var{number}.
+
+@end deffn
+
@node unit
@subsection unit
@cindex unit, command description
@@ -1121,7 +1206,7 @@ software
This manual was based on the file @kbd{USER} included in GNU Parted version
1.4.22 source distribution. The GNU Parted source distribution is
-available at @uref{ftp.gnu.org/gnu/parted}.
+available at @uref{https://ftp.gnu.org/gnu/parted}.
Initial Texinfo formatting by Richard M. Kreuter, 2002.
diff --git a/parted/parted.c b/parted/parted.c
index 975700c..310f011 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -2222,7 +2222,7 @@ command_register (commands, command_create (
str_list_create_unique ("print", _("print"), NULL),
do_print,
str_list_create (
-_("print [devices|free|list,all|NUMBER] display the partition table, "
+_("print [devices|free|list,all] display the partition table, "
"available devices, free space, all found partitions, or a particular "
"partition"),
NULL),
@@ -2233,8 +2233,6 @@ _(" devices : display all active block devices\n"),
_(" free : display information about free unpartitioned space on the "
"current block device\n"),
_(" list, all : display the partition tables of all active block devices\n"),
-_(" NUMBER : display more detailed information about this particular "
- "partition\n"),
NULL), 1));
command_register (commands, command_create (
--
2.31.1

View File

@ -1,542 +0,0 @@
From f6b9e09e7207f54a491de827640bb08501d91f91 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Thu, 17 Feb 2022 15:34:41 -0800
Subject: [PATCH] gnulib: Use newer cdefs.h from gnulib
This uses the one from gnulib commit 9f48fb992a3d7e96 on 2022-02-14
This is a temporary workaround for gcc 12 problems on ppc64le, the build
will be filled with errors that look like:
/usr/include/bits/stdio-ldbl.h:86:1: error: storage class specified for parameter '__sprintf_chk'
86 | __LDBL_REDIR2_DECL (sprintf_chk)
without it.
---
lib/cdefs.h | 307 +++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 232 insertions(+), 75 deletions(-)
diff --git a/lib/cdefs.h b/lib/cdefs.h
index 1a2805d..44d3826 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -1,17 +1,18 @@
-/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2022 Free Software Foundation, Inc.
+ Copyright The GNU Toolchain Authors.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public
+ modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
+ version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU General Public
+ You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
@@ -25,7 +26,7 @@
/* The GNU libc does not support any K&R compilers or the traditional mode
of ISO C compilers anymore. Check for some of the combinations not
- anymore supported. */
+ supported anymore. */
#if defined __GNUC__ && !defined __STDC__
# error "You need a ISO C conforming compiler to use the glibc headers"
#endif
@@ -34,31 +35,26 @@
#undef __P
#undef __PMT
-/* Compilers that are not clang may object to
- #if defined __clang__ && __has_attribute(...)
- even though they do not need to evaluate the right-hand side of the &&. */
-#if defined __clang__ && defined __has_attribute
-# define __glibc_clang_has_attribute(name) __has_attribute (name)
+/* Compilers that lack __has_attribute may object to
+ #if defined __has_attribute && __has_attribute (...)
+ even though they do not need to evaluate the right-hand side of the &&.
+ Similarly for __has_builtin, etc. */
+#if (defined __has_attribute \
+ && (!defined __clang_minor__ \
+ || 3 < __clang_major__ + (5 <= __clang_minor__)))
+# define __glibc_has_attribute(attr) __has_attribute (attr)
#else
-# define __glibc_clang_has_attribute(name) 0
+# define __glibc_has_attribute(attr) 0
#endif
-
-/* Compilers that are not clang may object to
- #if defined __clang__ && __has_builtin(...)
- even though they do not need to evaluate the right-hand side of the &&. */
-#if defined __clang__ && defined __has_builtin
-# define __glibc_clang_has_builtin(name) __has_builtin (name)
+#ifdef __has_builtin
+# define __glibc_has_builtin(name) __has_builtin (name)
#else
-# define __glibc_clang_has_builtin(name) 0
+# define __glibc_has_builtin(name) 0
#endif
-
-/* Compilers that are not clang may object to
- #if defined __clang__ && __has_extension(...)
- even though they do not need to evaluate the right-hand side of the &&. */
-#if defined __clang__ && defined __has_extension
-# define __glibc_clang_has_extension(ext) __has_extension (ext)
+#ifdef __has_extension
+# define __glibc_has_extension(ext) __has_extension (ext)
#else
-# define __glibc_clang_has_extension(ext) 0
+# define __glibc_has_extension(ext) 0
#endif
#if defined __GNUC__ || defined __clang__
@@ -74,22 +70,26 @@
# endif
/* GCC can always grok prototypes. For C++ programs we add throw()
- to help it optimize the function calls. But this works only with
+ to help it optimize the function calls. But this only works with
gcc 2.8.x and egcs. For gcc 3.4 and up we even mark C functions
as non-throwing using a function attribute since programs can use
the -fexceptions options for C code as well. */
# if !defined __cplusplus \
- && (__GNUC_PREREQ (3, 4) || __glibc_clang_has_attribute (__nothrow__))
+ && (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__))
# define __THROW __attribute__ ((__nothrow__ __LEAF))
# define __THROWNL __attribute__ ((__nothrow__))
# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
# else
# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
-# define __THROW throw ()
-# define __THROWNL throw ()
-# define __NTH(fct) __LEAF_ATTR fct throw ()
-# define __NTHNL(fct) fct throw ()
+# if __cplusplus >= 201103L
+# define __THROW noexcept (true)
+# else
+# define __THROW throw ()
+# endif
+# define __THROWNL __THROW
+# define __NTH(fct) __LEAF_ATTR fct __THROW
+# define __NTHNL(fct) fct __THROW
# else
# define __THROW
# define __THROWNL
@@ -142,24 +142,68 @@
#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
#define __bos0(ptr) __builtin_object_size (ptr, 0)
+/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
+#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
+ || __GNUC_PREREQ (12, 0))
+# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
+# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
+#else
+# define __glibc_objsize0(__o) __bos0 (__o)
+# define __glibc_objsize(__o) __bos (__o)
+#endif
+
+/* Compile time conditions to choose between the regular, _chk and _chk_warn
+ variants. These conditions should get evaluated to constant and optimized
+ away. */
+
+#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
+#define __glibc_unsigned_or_positive(__l) \
+ ((__typeof (__l)) 0 < (__typeof (__l)) -1 \
+ || (__builtin_constant_p (__l) && (__l) > 0))
+
+/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
+ condition can be folded to a constant and if it is true. The -1 check is
+ redundant because since it implies that __glibc_safe_len_cond is true. */
+#define __glibc_safe_or_unknown_len(__l, __s, __osz) \
+ (__glibc_unsigned_or_positive (__l) \
+ && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
+ __s, __osz)) \
+ && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
+
+/* Conversely, we know at compile time that the length is unsafe if the
+ __L * __S <= __OBJSZ condition can be folded to a constant and if it is
+ false. */
+#define __glibc_unsafe_len(__l, __s, __osz) \
+ (__glibc_unsigned_or_positive (__l) \
+ && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
+ __s, __osz)) \
+ && !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
+
+/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be
+ declared. */
+
+#define __glibc_fortify(f, __l, __s, __osz, ...) \
+ (__glibc_safe_or_unknown_len (__l, __s, __osz) \
+ ? __ ## f ## _alias (__VA_ARGS__) \
+ : (__glibc_unsafe_len (__l, __s, __osz) \
+ ? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \
+ : __ ## f ## _chk (__VA_ARGS__, __osz))) \
+
+/* Fortify function f, where object size argument passed to f is the number of
+ elements and not total size. */
+
+#define __glibc_fortify_n(f, __l, __s, __osz, ...) \
+ (__glibc_safe_or_unknown_len (__l, __s, __osz) \
+ ? __ ## f ## _alias (__VA_ARGS__) \
+ : (__glibc_unsafe_len (__l, __s, __osz) \
+ ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
+ : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
+
#if __GNUC_PREREQ (4,3)
-# define __warndecl(name, msg) \
- extern void name (void) __attribute__((__warning__ (msg)))
# define __warnattr(msg) __attribute__((__warning__ (msg)))
# define __errordecl(name, msg) \
extern void name (void) __attribute__((__error__ (msg)))
-#elif __glibc_clang_has_attribute (__diagnose_if__) && 0
-/* These definitions are not enabled, because they produce bogus warnings
- in the glibc Fortify functions. These functions are written in a style
- that works with GCC. In order to work with clang, these functions would
- need to be modified. */
-# define __warndecl(name, msg) \
- extern void name (void) __attribute__((__diagnose_if__ (1, msg, "warning")))
-# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
-# define __errordecl(name, msg) \
- extern void name (void) __attribute__((__diagnose_if__ (1, msg, "error")))
#else
-# define __warndecl(name, msg) extern void name (void)
# define __warnattr(msg)
# define __errordecl(name, msg) extern void name (void)
#endif
@@ -233,7 +277,7 @@
/* At some point during the gcc 2.96 development the `malloc' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
-#if __GNUC_PREREQ (2,96) || __glibc_clang_has_attribute (__malloc__)
+#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__)
# define __attribute_malloc__ __attribute__ ((__malloc__))
#else
# define __attribute_malloc__ /* Ignore */
@@ -248,26 +292,41 @@
# define __attribute_alloc_size__(params) /* Ignore. */
#endif
+/* Tell the compiler which argument to an allocation function
+ indicates the alignment of the allocation. */
+#if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__)
+# define __attribute_alloc_align__(param) \
+ __attribute__ ((__alloc_align__ param))
+#else
+# define __attribute_alloc_align__(param) /* Ignore. */
+#endif
+
/* At some point during the gcc 2.96 development the `pure' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
-#if __GNUC_PREREQ (2,96) || __glibc_clang_has_attribute (__pure__)
+#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__)
# define __attribute_pure__ __attribute__ ((__pure__))
#else
# define __attribute_pure__ /* Ignore */
#endif
/* This declaration tells the compiler that the value is constant. */
-#if __GNUC_PREREQ (2,5) || __glibc_clang_has_attribute (__const__)
+#if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
# define __attribute_const__ __attribute__ ((__const__))
#else
# define __attribute_const__ /* Ignore */
#endif
+#if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
+# define __attribute_maybe_unused__ __attribute__ ((__unused__))
+#else
+# define __attribute_maybe_unused__ /* Ignore */
+#endif
+
/* At some point during the gcc 3.1 development the `used' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
-#if __GNUC_PREREQ (3,1) || __glibc_clang_has_attribute (__used__)
+#if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__)
# define __attribute_used__ __attribute__ ((__used__))
# define __attribute_noinline__ __attribute__ ((__noinline__))
#else
@@ -276,7 +335,7 @@
#endif
/* Since version 3.2, gcc allows marking deprecated functions. */
-#if __GNUC_PREREQ (3,2) || __glibc_clang_has_attribute (__deprecated__)
+#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
# define __attribute_deprecated__ __attribute__ ((__deprecated__))
#else
# define __attribute_deprecated__ /* Ignore */
@@ -285,8 +344,8 @@
/* Since version 4.5, gcc also allows one to specify the message printed
when a deprecated function is used. clang claims to be gcc 4.2, but
may also support this feature. */
-#if __GNUC_PREREQ (4,5) || \
- __glibc_clang_has_extension (__attribute_deprecated_with_message__)
+#if __GNUC_PREREQ (4,5) \
+ || __glibc_has_extension (__attribute_deprecated_with_message__)
# define __attribute_deprecated_msg__(msg) \
__attribute__ ((__deprecated__ (msg)))
#else
@@ -299,7 +358,7 @@
If several `format_arg' attributes are given for the same function, in
gcc-3.0 and older, all but the last one are ignored. In newer gccs,
all designated arguments are considered. */
-#if __GNUC_PREREQ (2,8) || __glibc_clang_has_attribute (__format_arg__)
+#if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__)
# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
#else
# define __attribute_format_arg__(x) /* Ignore */
@@ -309,7 +368,7 @@
attribute for functions was introduced. We don't want to use it
unconditionally (although this would be possible) since it
generates warnings. */
-#if __GNUC_PREREQ (2,97) || __glibc_clang_has_attribute (__format__)
+#if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__)
# define __attribute_format_strfmon__(a,b) \
__attribute__ ((__format__ (__strfmon__, a, b)))
#else
@@ -317,19 +376,33 @@
#endif
/* The nonnull function attribute marks pointer parameters that
- must not be NULL. Do not define __nonnull if it is already defined,
- for portability when this file is used in Gnulib. */
+ must not be NULL. This has the name __nonnull in glibc,
+ and __attribute_nonnull__ in files shared with Gnulib to avoid
+ collision with a different __nonnull in DragonFlyBSD 5.9. */
+#ifndef __attribute_nonnull__
+# if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
+# define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params))
+# else
+# define __attribute_nonnull__(params)
+# endif
+#endif
#ifndef __nonnull
-# if __GNUC_PREREQ (3,3) || __glibc_clang_has_attribute (__nonnull__)
-# define __nonnull(params) __attribute__ ((__nonnull__ params))
+# define __nonnull(params) __attribute_nonnull__ (params)
+#endif
+
+/* The returns_nonnull function attribute marks the return type of the function
+ as always being non-null. */
+#ifndef __returns_nonnull
+# if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__)
+# define __returns_nonnull __attribute__ ((__returns_nonnull__))
# else
-# define __nonnull(params)
+# define __returns_nonnull
# endif
#endif
/* If fortification mode, we warn about unused results of certain
function calls which can lead to problems. */
-#if __GNUC_PREREQ (3,4) || __glibc_clang_has_attribute (__warn_unused_result__)
+#if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)
# define __attribute_warn_unused_result__ \
__attribute__ ((__warn_unused_result__))
# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
@@ -343,7 +416,7 @@
#endif
/* Forces a function to be always inlined. */
-#if __GNUC_PREREQ (3,2) || __glibc_clang_has_attribute (__always_inline__)
+#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
it conflicts with this definition. Therefore undefine it first to
allow either header to be included first. */
@@ -356,7 +429,7 @@
/* Associate error messages with the source location of the call site rather
than with the source location inside the function. */
-#if __GNUC_PREREQ (4,3) || __glibc_clang_has_attribute (__artificial__)
+#if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__)
# define __attribute_artificial__ __attribute__ ((__artificial__))
#else
# define __attribute_artificial__ /* Ignore */
@@ -433,7 +506,7 @@
# endif
#endif
-#if (__GNUC__ >= 3) || __glibc_clang_has_builtin (__builtin_expect)
+#if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect)
# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
# define __glibc_likely(cond) __builtin_expect ((cond), 1)
#else
@@ -441,12 +514,6 @@
# define __glibc_likely(cond) (cond)
#endif
-#ifdef __has_attribute
-# define __glibc_has_attribute(attr) __has_attribute (attr)
-#else
-# define __glibc_has_attribute(attr) 0
-#endif
-
#if (!defined _Noreturn \
&& (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
&& !(__GNUC_PREREQ (4,7) \
@@ -467,6 +534,16 @@
# define __attribute_nonstring__
#endif
+/* Undefine (also defined in libc-symbols.h). */
+#undef __attribute_copy__
+#if __GNUC_PREREQ (9, 0)
+/* Copies attributes from the declaration or type referenced by
+ the argument. */
+# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
+#else
+# define __attribute_copy__(arg)
+#endif
+
#if (!defined _Static_assert && !defined __cplusplus \
&& (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
&& (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
@@ -476,14 +553,44 @@
[!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
#endif
-/* The #ifndef lets Gnulib avoid including these on non-glibc
- platforms, where the includes typically do not exist. */
-#ifndef __WORDSIZE
+/* Gnulib avoids including these, as they don't work on non-glibc or
+ older glibc platforms. */
+#ifndef __GNULIB_CDEFS
# include <bits/wordsize.h>
# include <bits/long-double.h>
#endif
-#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
+#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
+# ifdef __REDIRECT
+
+/* Alias name defined automatically. */
+# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
+# define __LDBL_REDIR_DECL(name) \
+ extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
+
+/* Alias name defined automatically, with leading underscores. */
+# define __LDBL_REDIR2_DECL(name) \
+ extern __typeof (__##name) __##name \
+ __asm (__ASMNAME ("__" #name "ieee128"));
+
+/* Alias name defined manually. */
+# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
+# define __LDBL_REDIR1_DECL(name, alias) \
+ extern __typeof (name) name __asm (__ASMNAME (#alias));
+
+# define __LDBL_REDIR1_NTH(name, proto, alias) \
+ __REDIRECT_NTH (name, proto, alias)
+# define __REDIRECT_NTH_LDBL(name, proto, alias) \
+ __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
+
+/* Unused. */
+# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
+# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
+
+# else
+_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
+# endif
+#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
# define __LDBL_COMPAT 1
# ifdef __REDIRECT
# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
@@ -492,6 +599,8 @@
# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
# define __LDBL_REDIR_NTH(name, proto) \
__LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
+# define __LDBL_REDIR2_DECL(name) \
+ extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
# define __LDBL_REDIR1_DECL(name, alias) \
extern __typeof (name) name __asm (__ASMNAME (#alias));
# define __LDBL_REDIR_DECL(name) \
@@ -502,11 +611,13 @@
__LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
# endif
#endif
-#if !defined __LDBL_COMPAT || !defined __REDIRECT
+#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
+ || !defined __REDIRECT
# define __LDBL_REDIR1(name, proto, alias) name proto
# define __LDBL_REDIR(name, proto) name proto
# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
+# define __LDBL_REDIR2_DECL(name)
# define __LDBL_REDIR_DECL(name)
# ifdef __REDIRECT
# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
@@ -537,7 +648,7 @@
check is required to enable the use of generic selection. */
#if !defined __cplusplus \
&& (__GNUC_PREREQ (4, 9) \
- || __glibc_clang_has_extension (c_generic_selections) \
+ || __glibc_has_extension (c_generic_selections) \
|| (!defined __GNUC__ && defined __STDC_VERSION__ \
&& __STDC_VERSION__ >= 201112L))
# define __HAVE_GENERIC_SELECTION 1
@@ -545,4 +656,50 @@
# define __HAVE_GENERIC_SELECTION 0
#endif
+#if __GNUC_PREREQ (10, 0)
+/* Designates a 1-based positional argument ref-index of pointer type
+ that can be used to access size-index elements of the pointed-to
+ array according to access mode, or at least one element when
+ size-index is not provided:
+ access (access-mode, <ref-index> [, <size-index>]) */
+# define __attr_access(x) __attribute__ ((__access__ x))
+/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may
+ use the access attribute to get object sizes from function definition
+ arguments, so we can't use them on functions we fortify. Drop the object
+ size hints for such functions. */
+# if __USE_FORTIFY_LEVEL == 3
+# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
+# else
+# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
+# endif
+# if __GNUC_PREREQ (11, 0)
+# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
+# else
+# define __attr_access_none(argno)
+# endif
+#else
+# define __fortified_attr_access(a, o, s)
+# define __attr_access(x)
+# define __attr_access_none(argno)
+#endif
+
+#if __GNUC_PREREQ (11, 0)
+/* Designates dealloc as a function to call to deallocate objects
+ allocated by the declared function. */
+# define __attr_dealloc(dealloc, argno) \
+ __attribute__ ((__malloc__ (dealloc, argno)))
+# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
+#else
+# define __attr_dealloc(dealloc, argno)
+# define __attr_dealloc_free
+#endif
+
+/* Specify that a function such as setjmp or vfork may return
+ twice. */
+#if __GNUC_PREREQ (4, 1)
+# define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
+#else
+# define __attribute_returns_twice__ /* Ignore. */
+#endif
+
#endif /* sys/cdefs.h */
--
2.34.1

View File

@ -1,61 +1,16 @@
Summary: The GNU disk partition manipulation program
Name: parted
Version: 3.4
Release: 12%{?dist}
Version: 3.4.64
Release: 1%{?dist}
License: GPLv3+
URL: http://www.gnu.org/software/parted
Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
Source1: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz.sig
Source0: https://alpha.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
Source1: https://alpha.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz.sig
Source2: pubkey.phillip.susi
Source3: pubkey.brian.lane
# Upstream patches since v3.4 release
Patch0001: 0001-parted-add-fix-to-fix-in-script-mode.patch
Patch0002: 0002-doc-Document-fix-flag.patch
Patch0003: 0003-tests-Add-tests-for-fix.patch
Patch0004: 0004-tests-Fix-test-t1700-probe-fs.patch
Patch0005: 0005-tests-Fix-t9041-undetected-in-use-16th-partition.patch
Patch0006: 0006-libparted-Fix-fd-check-in-_flush_cache.patch
Patch0007: 0007-libparted-Fix-potential-memory-leak-in-sdmmc_get_pro.patch
Patch0008: 0008-fs-Fix-copy-paste-error-in-HFS-journal-code.patch
Patch0009: 0009-parted-Fix-end_input-leak-in-do_mkpart.patch
Patch0010: 0010-parted-Free-tmp-usage-inside-do_print.patch
Patch0011: 0011-parted-Fix-memory-leaks-in-do_resizepart.patch
Patch0012: 0012-libparted-Fix-warning-about-buffer-size-in-Atari-lab.patch
Patch0013: 0013-libparted-Fix-potential-memory-leak-in-gpt_write.patch
Patch0014: 0014-tests-t0400-Work-around-a-mkswap-bug-by-using-dev-ze.patch
Patch0015: 0015-tests-t9050-Use-dev-zero-for-temporary-file-and-mksw.patch
Patch0016: 0016-tests-t1100-Change-dev_size_mb-to-10.patch
Patch0017: 0017-tests-t1101-Change-dev_size_mb-to-10.patch
Patch0018: 0018-tests-t1102-Change-dev_size_mb-to-10.patch
Patch0019: 0019-tests-t1701-Change-dev_size_mb-to-10.patch
Patch0020: 0020-tests-t3000-Change-dev_size_mb-to-267.patch
Patch0021: 0021-tests-t3200-Change-dev_size_mb-to-10.patch
Patch0022: 0022-tests-t6006-Change-dev_size_mb-to-10.patch
Patch0023: 0023-tests-t3000-Check-for-hfs-and-vfat-support-separatel.patch
Patch0024: 0024-tests-t3000-Use-mkfs.hfsplus-and-fsck.hfsplus-for-re.patch
Patch0025: 0025-Move-Exception-Option-values-into-enum.patch
Patch0026: 0026-libparted-Add-swap-flag-to-msdos-disklabel.patch
Patch0027: 0027-tests-add-aarch64-and-mips64-as-a-valid-64-bit-machi.patch
Patch0028: 0028-tests-add-a-helper-to-check-the-kernel-knows-about-a.patch
Patch0029: 0029-tests-check-for-vfat-kernel-support-and-tools.patch
Patch0030: 0030-parted-Escape-colons-and-backslashes-in-machine-outp.patch
Patch0031: 0031-libparted-Tell-libdevmapper-to-retry-remove-when-BUS.patch
Patch0032: 0032-libparted-Check-devpath-before-passing-to-strlen.patch
Patch0033: 0033-parted-Allow-empty-string-for-partition-name.patch
Patch0034: 0034-parted-Add-json-cmdline-switch-to-output-JSON.patch
Patch0035: 0035-hurd-Fix-partition-paths.patch
Patch0036: 0036-hurd-Support-rumpdisk-based-device-names.patch
Patch0037: 0037-hurd-Implement-partition-table-rereading.patch
Patch0038: 0038-keep-GUID-specific-attributes.patch
Patch0039: 0039-gpt-Map-PED_PARTITON_-flags-to-GUID-values.patch
Patch0040: 0040-gpt-Add-linux-home-flag.patch
Patch0041: 0041-doc-Document-gpt-linux-home-flag.patch
Patch0042: 0042-tests-Add-a-test-to-make-sure-GPT-GUIDs-default-to-f.patch
Patch0043: 0043-gpt-Revert-to-filesystem-GUID-when-setting-flag-to-o.patch
Patch0044: 0044-docs-Update-documentation-to-be-consistent.patch
Patch0045: 0045-gnulib-Use-newer-cdefs.h-from-gnulib.patch
# Upstream patches since v3.5 release
BuildRequires: gcc
@ -145,9 +100,9 @@ make check
%{_mandir}/man8/parted.8*
%{_mandir}/man8/partprobe.8*
%{_libdir}/libparted.so.2
%{_libdir}/libparted.so.2.0.3
%{_libdir}/libparted.so.2.0.4
%{_libdir}/libparted-fs-resize.so.0
%{_libdir}/libparted-fs-resize.so.0.0.3
%{_libdir}/libparted-fs-resize.so.0.0.4
%{_infodir}/parted.info*
%files devel
@ -160,6 +115,11 @@ make check
%changelog
* Wed Mar 30 2022 Brian C. Lane <bcl@redhat.com> - 3.4.64-1
- Upstream 3.4.64 Alpha release
- Dropped all patches included in new upstream release
- Bumped minor version on libparted.so and libparted-fs-resize.so
* Thu Feb 17 2022 Brian C. Lane <bcl@redhat.com> - 3.4-12
- gnulib: Use newer cdefs.h from gnulib (bcl)
- Update parted.spec to allow flatpak builds

View File

@ -1,2 +1,2 @@
SHA512 (parted-3.4.tar.xz) = e69bd1b610778e980d4595d04892f2ea1faf4ae9bfc98cd62abfc70066423f08ddaa396f9461c7beb1330d023232274606b6b26091a0458aeedd0f3f57536690
SHA512 (parted-3.4.tar.xz.sig) = 6b11812267e66470ba2908ee1cc78b232b0bc2519787f5a17b92cd5f8ba904b1a836833f19c5244b23d4c7810437eeb26fbbd68fac819391b342709682345472
SHA512 (parted-3.4.64.tar.xz) = db5fd8a7f3aa253b1c934837d519f561603c4af72c9fc273fecd2fd79ec6cac3dd5a318fcd99dee762d984df73a5316a392d77cc310818a60e426890d9d3c4c9
SHA512 (parted-3.4.64.tar.xz.sig) = ae48682796dc6a03d61097514773eb7f48e25092f5d2a56800f02de0ac44b00f325b977899be49f83e6d74d728209328bbfff2979cec043c98ffbdc8f32a8a20