diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:16:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:16:34 +0000 |
commit | a398d2c2b5fd6ab0545d8bb019f9a970b2309404 (patch) | |
tree | 272fc7ab226258d7ceddee12c8c682c8e711c2b0 /tests/print-align.c | |
parent | Initial commit. (diff) | |
download | parted-upstream.tar.xz parted-upstream.zip |
Adding upstream version 3.6.upstream/3.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/print-align.c')
-rw-r--r-- | tests/print-align.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/print-align.c b/tests/print-align.c new file mode 100644 index 0000000..e012fb3 --- /dev/null +++ b/tests/print-align.c @@ -0,0 +1,50 @@ +#include <config.h> +#include <parted/parted.h> +#include <stdio.h> +#include <stdlib.h> + +#include "closeout.h" +#include "progname.h" + +int +main (int argc, char **argv) +{ + atexit (close_stdout); + set_program_name (argv[0]); + + if (argc != 2) + return EXIT_FAILURE; + + char const *dev_name = argv[1]; + PedDevice *dev = ped_device_get (dev_name); + if (dev == NULL) + return EXIT_FAILURE; + + PedAlignment *pa_min = ped_device_get_minimum_alignment (dev); + if (pa_min) + printf ("minimum: %lld %lld\n", pa_min->offset, pa_min->grain_size); + else + printf ("minimum: - -\n"); + free (pa_min); + + PedAlignment *pa_opt = ped_device_get_optimum_alignment (dev); + if (pa_opt) + printf ("optimal: %lld %lld\n", pa_opt->offset, pa_opt->grain_size); + else + printf ("optimal: - -\n"); + free (pa_opt); + + PedDisk *disk = ped_disk_new (dev); + if (disk == NULL) + return EXIT_FAILURE; + + PedAlignment *part_align = ped_disk_get_partition_alignment (disk); + if (part_align == NULL) + return EXIT_FAILURE; + + printf ("partition alignment: %lld %lld\n", + part_align->offset, part_align->grain_size); + + ped_device_destroy (dev); + return EXIT_SUCCESS; +} |