[parted-devel] [PATCH] fix for 'parted --list' option -- does not generate an exception in non superuser mode
Rakesh Pandit
rakesh.pandit at gmail.com
Mon May 5 02:50:37 UTC 2008
2008/5/5 Rakesh Pandit <rakesh.pandit at gmail.com>:
> There where two convention errors in spacing. Corrected.
>
> Attached is the patch.
>
> -
> Rakesh Pandit
>
Sorry for trouble, I mistakenly attached my patch and was scrubbed.
So, correct patch is below:
diff --git a/parted/parted.c b/parted/parted.c
index 0f6768b..15c2d23 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -181,6 +181,17 @@ _timer_handler (PedTimer* timer, void* context)
}
}
+static void
+_superuser_warn ()
+{
+#ifdef HAVE_GETUID
+ if (getuid() != 0 && !opt_script_mode) {
+ puts (_("WARNING: You are not superuser. Watch out for "
+ "permissions."));
+ }
+#endif
+}
+
static int
_partition_warn_busy (PedPartition* part)
{
@@ -1573,11 +1584,23 @@ _print_list ()
{
PedDevice *current_dev = NULL;
- ped_device_probe_all();
+ _superuser_warn ();
+retry:
+ ped_device_probe_all ();
+ current_dev = ped_device_get_next (NULL);
+
+ if (!current_dev) {
+ if (ped_exception_throw (PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_CANCEL,
+ _("No device found"))
+ == PED_EXCEPTION_RETRY)
+ goto retry;
+ }
- while ((current_dev = ped_device_get_next(current_dev))) {
+ while (current_dev) {
do_print (¤t_dev);
putchar ('\n');
+ current_dev = ped_device_get_next (current_dev);
}
return 1;
@@ -2429,12 +2452,7 @@ _init_commands ();
if (!_parse_options (argc_ptr, argv_ptr))
goto error_done_commands;
-#ifdef HAVE_GETUID
- if (getuid() != 0 && !opt_script_mode) {
- puts (_("WARNING: You are not superuser. Watch out for "
- "permissions."));
- }
-#endif
+_superuser_warn ();
dev = _choose_device (argc_ptr, argv_ptr);
if (!dev)
More information about the parted-devel
mailing list