diff options
author | Petr Uzel <petr.uzel@suse.cz> | 2010-05-26 14:29:01 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2010-05-26 19:15:52 +0200 |
commit | 52e07a55b46900212e9219d4da35005b7c87e30b (patch) | |
tree | 60ef18d8538d7336248dae534664b2c9d1634cca /parted | |
parent | c0ca1f474d843a071fdc908d66bbe36eac3be0c4 (diff) | |
download | parted-52e07a55b46900212e9219d4da35005b7c87e30b.tar.gz |
parted: make align-check work in interactive mode
* parted/parted.c (do_align_check): rework the function so that
it reports partition alignment in interactive mode as described in
documentation.
Diffstat (limited to 'parted')
-rw-r--r-- | parted/parted.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/parted/parted.c b/parted/parted.c index 830075b..7723d18 100644 --- a/parted/parted.c +++ b/parted/parted.c @@ -2078,18 +2078,29 @@ do_align_check (PedDevice **dev) { PedDisk *disk = ped_disk_new (*dev); if (!disk) - return 0; + goto error; enum AlignmentType align_type = PA_OPTIMUM; PedPartition *part = NULL; - bool aligned = - (command_line_get_align_type (_("alignment type(min/opt)"), &align_type) - && command_line_get_partition (_("Partition number?"), disk, &part) - && partition_align_check (disk, part, align_type)); + + if (!command_line_get_align_type (_("alignment type(min/opt)"), &align_type)) + goto error_destroy_disk; + if (!command_line_get_partition (_("Partition number?"), disk, &part)) + goto error_destroy_disk; + + bool aligned = partition_align_check (disk, part, align_type); + if (!opt_script_mode) + printf(aligned ? _("%d aligned\n") : _("%d not aligned\n"), part->num); ped_disk_destroy (disk); + /* FIXME: perhaps we should always return 1 when in interactive mode??? */ return aligned ? 1 : 0; + +error_destroy_disk: + ped_disk_destroy (disk); +error: + return 0; } static int |