daemon/parted: simplify print_partition_table() prototype

Since commit 994ca1f8eb ("daemon: Reimplement 'part_get_mbr_part_type'
API in OCaml.", 2018-05-02), we've not had any calls to
print_partition_table() that would pass a "false" argument for the
"add_m_option" parameter.

Remove the parameter, and inside part_get_mbr_part_type(), remove the dead
branch.

Relatedly, update the comment on the
"print_partition_table_machine_readable" OCaml function, originally from
commit 32e661f421 ("daemon: Reimplement ‘part_list’ API in OCaml.",
2017-07-27). Because print_partition_table() now passes "-m" to "parted"
unconditionally, and there are no use cases left that would *forbid* "-m",
"print_partition_table_machine_readable" is almost equivalent to
print_partition_table() -- modulo the enforcement of the "BYT;" header.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20211125094954.9713-4-lersek@redhat.com>
This commit is contained in:
Laszlo Ersek
2021-11-25 10:49:52 +01:00
committed by Richard W.M. Jones
parent e589faf92a
commit 08856ccda2
2 changed files with 8 additions and 15 deletions

View File

@@ -341,7 +341,7 @@ get_table_field (const char *line, int n)
}
static char *
print_partition_table (const char *device, bool add_m_option)
print_partition_table (const char *device)
{
char *out;
CLEANUP_FREE char *err = NULL;
@@ -349,14 +349,9 @@ print_partition_table (const char *device, bool add_m_option)
udev_settle ();
if (add_m_option)
r = command (&out, &err, "parted", "-m", "-s", "--", device,
"unit", "b",
"print", NULL);
else
r = command (&out, &err, "parted", "-s", "--", device,
"unit", "b",
"print", NULL);
r = command (&out, &err, "parted", "-m", "-s", "--", device,
"unit", "b",
"print", NULL);
udev_settle ();
@@ -383,7 +378,7 @@ do_part_get_bootable (const char *device, int partnum)
return -1;
}
CLEANUP_FREE char *out = print_partition_table (device, true);
CLEANUP_FREE char *out = print_partition_table (device);
if (!out)
return -1;
@@ -555,7 +550,7 @@ do_part_get_name (const char *device, int partnum)
return NULL;
if (STREQ (parttype, "gpt")) {
CLEANUP_FREE char *out = print_partition_table (device, true);
CLEANUP_FREE char *out = print_partition_table (device);
if (!out)
return NULL;

View File

@@ -57,10 +57,8 @@ let part_get_mbr_id device partnum =
(* It's printed in hex, possibly with a leading space. *)
sscanf out " %x" identity
(* This is not equivalent to print_partition_table in the C code, as
* it only deals with the -m option output, and it partially parses
* that. If we convert other functions that don't use the -m version
* we'll have to refactor this. XXX
(* This is almost equivalent to print_partition_table in the C code. The
* difference is that here we enforce the "BYT;" header internally.
*)
let print_partition_table_machine_readable device =
udev_settle ();