[parted-devel] Re: Parted 2.0 plans
Debarshi 'Rishi' Ray
debarshi.ray at gmail.com
Wed Nov 22 21:46:18 CET 2006
> Hello David,
>
> as promised some information on the plans for GNU Parted 2.0.
>
> [SNIP]
>
> PARTED:
> -------
>
> Task #1 (bundle):
> =================
> * parted -l (direct interface to "print all" command)
I have implemented this feature. However I found '-a' and '--all' to
be a more reasonable choice than '-l'. However if you disagree, then
you can always change it.
Please find the patch attached.
Happy hacking,
Debarshi
--
I only work when I am not doing any assignments.
-------------- next part --------------
From 2cb34f420ae8104e845c937b7817f50a116954eb Mon Sep 17 00:00:00 2001
From: Debarshi Ray <rishi at gnu.org>
Date: Thu, 23 Nov 2006 02:13:26 +0000
Subject: Implement --all switch.
---
parted/parted.c | 45 ++++++++++++++++++++++++++++++---------------
1 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/parted/parted.c b/parted/parted.c
index 4c2c1c3..e948808 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -64,6 +64,7 @@ typedef struct {
static struct option options[] = {
/* name, has-arg, string-return-val, char-return-val */
+ {"all", 0, NULL, 'a'},
{"help", 0, NULL, 'h'},
{"interactive", 0, NULL, 'i'},
{"script", 0, NULL, 's'},
@@ -73,6 +74,7 @@ static struct option options[] = {
#endif
static char* options_help [][2] = {
+ {"all", N_("displays partition tables of all available devices")},
{"help", N_("displays this help message")},
{"interactive", N_("where necessary, prompts for user intervention")},
{"script", N_("never prompts for user intervention")},
@@ -124,6 +126,7 @@ static Command* commands [256] = {NULL};
static PedTimer* timer;
static TimerContext timer_context;
+static int print_all ();
static void _done (PedDevice* dev);
static void
@@ -1234,19 +1237,8 @@ do_print (PedDevice** dev)
return status;
}
- if (has_all_arg) {
- int first_device;
- PedDevice *current_dev = NULL;
-
- ped_device_probe_all();
-
- while ((current_dev = ped_device_get_next(current_dev))) {
- do_print (¤t_dev);
- printf ("\n");
- }
-
- return 1;
- }
+ if (has_all_arg)
+ return print_all();
start = ped_unit_format (*dev, 0);
end = ped_unit_format_byte (*dev, (*dev)->length * (*dev)->sector_size
@@ -1380,6 +1372,21 @@ error:
}
static int
+print_all (void)
+{
+ PedDevice *current_dev = NULL;
+
+ ped_device_probe_all();
+
+ while ((current_dev = ped_device_get_next(current_dev))) {
+ do_print (¤t_dev);
+ printf ("\n");
+ }
+
+ return 1;
+}
+
+static int
do_quit (PedDevice** dev)
{
_done (*dev);
@@ -2099,6 +2106,13 @@ #endif /* ENABLE_NLS */
}
void
+_print_all ()
+{
+ print_all();
+ exit(0);
+}
+
+void
_version ()
{
printf (prog_name);
@@ -2113,15 +2127,16 @@ int opt;
while (1)
{
#ifdef HAVE_GETOPT_H
- opt = getopt_long (*argc_ptr, *argv_ptr, "hisv",
+ opt = getopt_long (*argc_ptr, *argv_ptr, "ahisv",
options, NULL);
#else
- opt = getopt (*argc_ptr, *argv_ptr, "hisv");
+ opt = getopt (*argc_ptr, *argv_ptr, "ahisv");
#endif
if (opt == -1)
break;
switch (opt) {
+ case 'a': _print_all(); break;
case 'h': help_msg (); break;
case 'i': opt_script_mode = 0; break;
case 's': opt_script_mode = 1; break;
--
1.4.2.4
More information about the parted-devel
mailing list