]> sourceware.org Git - lvm2.git/commitdiff
Show available fields if report given invalid field. (e.g. lvs -o list)
authorAlasdair Kergon <agk@redhat.com>
Mon, 2 Oct 2006 16:46:27 +0000 (16:46 +0000)
committerAlasdair Kergon <agk@redhat.com>
Mon, 2 Oct 2006 16:46:27 +0000 (16:46 +0000)
WHATS_NEW
lib/report/report.c

index 703b11d521474675ffd69b1f9dc7a0814ba57b8f..963d58629e7db99cf5dc3e4da88c70050b3725cb 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.11 - 
 =====================================
+  Show available fields if report given invalid field. (e.g. lvs -o list)
   Add timestamp functions with --disable-realtime configure option.
   Add %VG, %LV and %FREE suffices to lvcreate/lvresize --extents arg.
   Fix two potential NULL pointer derefs in error cases in vg_read().
index 02e0ce018cdaea5283b66d72928426e246e9c5b7..e9361553a475a88e59bb9e9402edce63b5e9f566 100644 (file)
@@ -948,6 +948,44 @@ static struct {
 
 const unsigned int _num_fields = sizeof(_fields) / sizeof(_fields[0]);
 
+static void _display_fields(void)
+{
+       uint32_t f;
+       const char *type, *last_type = "";
+
+       for (f = 0; f < _num_fields; f++) {
+               switch (_fields[f].type) {
+               case PVS:
+                       type = "Physical Volume";
+                       break;
+               case LVS:
+                       type = "Logical Volume";
+                       break;
+               case VGS:
+                       type = "Volume Group";
+                       break;
+               case SEGS:
+                       type = "Logical Volume Segment";
+                       break;
+               case PVSEGS:
+                       type = "Physical Volume Segment";
+                       break;
+               default:
+                       type = " ";
+               }
+
+               if (type != last_type) {
+                       if (*last_type)
+                               log_print(" ");
+                       log_print("%s Fields", type);
+               }
+
+               log_print("- %s", _fields[f].id);
+
+               last_type = type;
+       }
+}
+
 /*
  * Initialise report handle
  */
@@ -1080,6 +1118,8 @@ static int _parse_options(struct report_handle *rh, const char *format)
                while (*we && *we != ',')
                        we++;
                if (!_field_match(rh, ws, (size_t) (we - ws))) {
+                       _display_fields();
+                       log_print(" ");
                        log_error("Unrecognised field: %.*s", (int) (we - ws),
                                  ws);
                        return 0;
This page took 0.039689 seconds and 5 git commands to generate.