c45765537f
- parted: when printing, also print the new disk flags - tests: update tests for new disk flags output - tests: add test for GPT PMBR pmbr_boot flag - doc: update parted documentation
98 lines
3.2 KiB
Diff
98 lines
3.2 KiB
Diff
From acb972e2dffecdb5e464236978d22bc6387a2f69 Mon Sep 17 00:00:00 2001
|
|
From: "Brian C. Lane" <bcl@redhat.com>
|
|
Date: Fri, 27 Jan 2012 16:59:03 -0800
|
|
Subject: [PATCH 2/5] parted: when printing, also print the new disk flags
|
|
|
|
This adds a 'Disk Flags:' line the displays the active disk flags.
|
|
In machine mode this is appended to the disk info line, after the
|
|
device model.
|
|
|
|
* parted/parted.c (disk_print_flags): New function
|
|
(_print_disk_info): Add Disk Flags information.
|
|
---
|
|
parted/parted.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
|
|
1 files changed, 42 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/parted/parted.c b/parted/parted.c
|
|
index 4220265..38daf81 100644
|
|
--- a/parted/parted.c
|
|
+++ b/parted/parted.c
|
|
@@ -825,6 +825,43 @@ partition_print (PedPartition* part)
|
|
return 1;
|
|
}
|
|
|
|
+static char*
|
|
+disk_print_flags (PedDisk const *disk)
|
|
+{
|
|
+ PedDiskFlag flag;
|
|
+ int first_flag;
|
|
+ const char* name;
|
|
+ char* res = ped_malloc(1);
|
|
+ void* _res = res;
|
|
+
|
|
+ *res = '\0';
|
|
+ if (!disk)
|
|
+ return res;
|
|
+
|
|
+ first_flag = 1;
|
|
+ for (flag = ped_disk_flag_next (0); flag;
|
|
+ flag = ped_disk_flag_next (flag)) {
|
|
+ if (ped_disk_get_flag (disk, flag)) {
|
|
+ if (first_flag)
|
|
+ first_flag = 0;
|
|
+ else {
|
|
+ _res = res;
|
|
+ ped_realloc (&_res, strlen (res) + 1 + 2);
|
|
+ res = _res;
|
|
+ strncat (res, ", ", 2);
|
|
+ }
|
|
+
|
|
+ name = _(ped_disk_flag_get_name (flag));
|
|
+ _res = res;
|
|
+ ped_realloc (&_res, strlen (res) + 1 + strlen (name));
|
|
+ res = _res;
|
|
+ strcat(res, name);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return res;
|
|
+}
|
|
+
|
|
static void
|
|
_print_disk_geometry (const PedDevice *dev)
|
|
{
|
|
@@ -862,6 +899,7 @@ _print_disk_info (const PedDevice *dev, const PedDisk *disk)
|
|
default_unit == PED_UNIT_CYLINDER));
|
|
|
|
const char* pt_name = disk ? disk->type->name : "unknown";
|
|
+ char *disk_flags = disk_print_flags (disk);
|
|
|
|
if (opt_machine_mode) {
|
|
switch (default_unit) {
|
|
@@ -873,10 +911,10 @@ _print_disk_info (const PedDevice *dev, const PedDisk *disk)
|
|
break;
|
|
|
|
}
|
|
- printf ("%s:%s:%s:%lld:%lld:%s:%s;\n",
|
|
+ printf ("%s:%s:%s:%lld:%lld:%s:%s:%s;\n",
|
|
dev->path, end, transport[dev->type],
|
|
dev->sector_size, dev->phys_sector_size,
|
|
- pt_name, dev->model);
|
|
+ pt_name, dev->model, disk_flags);
|
|
} else {
|
|
printf (_("Model: %s (%s)\n"),
|
|
dev->model, transport[dev->type]);
|
|
@@ -894,7 +932,9 @@ _print_disk_info (const PedDevice *dev, const PedDisk *disk)
|
|
|
|
if (!opt_machine_mode) {
|
|
printf (_("Partition Table: %s\n"), pt_name);
|
|
+ printf (_("Disk Flags: %s\n"), disk_flags);
|
|
}
|
|
+ free (disk_flags);
|
|
}
|
|
|
|
static int
|
|
--
|
|
1.7.6.5
|
|
|