main - make: generate
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b318c9c20f40be1583e...
Commit: b318c9c20f40be1583e7d0751a733f77be173012
Parent: efd083f66883e674a6f24370d8c7cc06aa4fafe7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Aug 5 10:31:08 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 11 11:10:11 2022 +0200
make: generate
---
conf/example.conf.in | 6 ++++++
man/lvchange.8_pregen | 10 ++++++----
man/lvcreate.8_pregen | 10 ++++++----
man/lvextend.8_pregen | 10 ++++++----
man/lvm-fullreport.8_pregen | 8 +++++---
man/lvreduce.8_pregen | 8 +++++---
man/lvremove.8_pregen | 8 +++++---
man/lvrename.8_pregen | 8 +++++---
man/lvresize.8_pregen | 10 ++++++----
man/lvs.8_pregen | 8 +++++---
man/lvscan.8_pregen | 8 +++++---
man/pvchange.8_pregen | 8 +++++---
man/pvcreate.8_pregen | 8 +++++---
man/pvdisplay.8_pregen | 8 +++++---
man/pvmove.8_pregen | 8 +++++---
man/pvremove.8_pregen | 8 +++++---
man/pvresize.8_pregen | 8 +++++---
man/pvs.8_pregen | 8 +++++---
man/pvscan.8_pregen | 14 ++++++++------
man/vgcfgbackup.8_pregen | 8 +++++---
man/vgchange.8_pregen | 18 ++++++++++--------
man/vgck.8_pregen | 8 +++++---
man/vgconvert.8_pregen | 8 +++++---
man/vgcreate.8_pregen | 8 +++++---
man/vgexport.8_pregen | 8 +++++---
man/vgextend.8_pregen | 8 +++++---
man/vgimport.8_pregen | 8 +++++---
man/vgimportdevices.8_pregen | 8 +++++---
man/vgmknodes.8_pregen | 8 +++++---
man/vgreduce.8_pregen | 10 ++++++----
man/vgremove.8_pregen | 8 +++++---
man/vgrename.8_pregen | 8 +++++---
man/vgs.8_pregen | 8 +++++---
man/vgscan.8_pregen | 8 +++++---
34 files changed, 184 insertions(+), 112 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 5fadeac12..10810d8b8 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1951,6 +1951,12 @@ activation {
# name for identification.
# json
# JSON format.
+ # json_std
+ # JSON format that is more compliant with JSON standard.
+ # Compared to original "json" format:
+ # - it does not use double quotes around numeric values,
+ # - it uses 'null' for undefined numeric values,
+ # - it prints string list as proper JSON array of strings instead of a single string.
# This configuration option has an automatic default value.
# output_format = "basic"
diff --git a/man/lvchange.8_pregen b/man/lvchange.8_pregen
index e46a3b9b2..90aec5483 100644
--- a/man/lvchange.8_pregen
+++ b/man/lvchange.8_pregen
@@ -111,7 +111,7 @@ lvchange \(em Change the attributes of logical volume(s)
.br
\fB--refresh\fP
.br
- \fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
\fB--resync\fP
.br
@@ -397,7 +397,7 @@ Common options for command:
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.ad b
.RE
.P
@@ -847,14 +847,16 @@ if something has gone wrong, or if some form of manual LV
sharing is being used.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB--resync\fP
diff --git a/man/lvcreate.8_pregen b/man/lvcreate.8_pregen
index 3940aa77e..cde896b7a 100644
--- a/man/lvcreate.8_pregen
+++ b/man/lvcreate.8_pregen
@@ -129,7 +129,7 @@ lvcreate \(em Create a logical volume
.br
\fB-R\fP|\fB--regionsize\fP \fISize\fP[m|UNIT]
.br
- \fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
\fB-k\fP|\fB--setactivationskip\fP \fBy\fP|\fBn\fP
.br
@@ -781,7 +781,7 @@ Common options for command:
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--setautoactivation\fP \fBy\fP|\fBn\fP ]
.ad b
@@ -1299,14 +1299,16 @@ Size of each raid or mirror synchronization region.
configure a default.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-k\fP|\fB--setactivationskip\fP \fBy\fP|\fBn\fP
diff --git a/man/lvextend.8_pregen b/man/lvextend.8_pregen
index 445afc25e..3c2bfa6bf 100644
--- a/man/lvextend.8_pregen
+++ b/man/lvextend.8_pregen
@@ -63,7 +63,7 @@ lvextend \(em Add space to a logical volume
.br
\fB-q\fP|\fB--quiet\fP
.br
- \fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
\fB-r\fP|\fB--resizefs\fP
.br
@@ -219,7 +219,7 @@ Common options for command:
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--type\fP \c
.nh
@@ -471,14 +471,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-r\fP|\fB--resizefs\fP
diff --git a/man/lvm-fullreport.8_pregen b/man/lvm-fullreport.8_pregen
index 4bcfba4f8..7e9348e1d 100644
--- a/man/lvm-fullreport.8_pregen
+++ b/man/lvm-fullreport.8_pregen
@@ -55,7 +55,7 @@ if information changes between commands.
.br
[ \fB--readonly\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--rows\fP ]
.br
@@ -308,14 +308,16 @@ device-mapper kernel driver, so this option is unable to report whether
or not LVs are actually in use.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB--rows\fP
diff --git a/man/lvreduce.8_pregen b/man/lvreduce.8_pregen
index e8953bc8f..4f6615449 100644
--- a/man/lvreduce.8_pregen
+++ b/man/lvreduce.8_pregen
@@ -50,7 +50,7 @@ the options section.
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -245,14 +245,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-r\fP|\fB--resizefs\fP
diff --git a/man/lvremove.8_pregen b/man/lvremove.8_pregen
index f47181213..7ae83f1bb 100644
--- a/man/lvremove.8_pregen
+++ b/man/lvremove.8_pregen
@@ -56,7 +56,7 @@ former LV completely.
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -229,14 +229,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-S\fP|\fB--select\fP \fIString\fP
diff --git a/man/lvrename.8_pregen b/man/lvrename.8_pregen
index 278e8e989..2c0c4e1b9 100644
--- a/man/lvrename.8_pregen
+++ b/man/lvrename.8_pregen
@@ -42,7 +42,7 @@ Common options for command:
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.ad b
.RE
.P
@@ -200,14 +200,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-t\fP|\fB--test\fP
diff --git a/man/lvresize.8_pregen b/man/lvresize.8_pregen
index 625fed0a1..1671741ce 100644
--- a/man/lvresize.8_pregen
+++ b/man/lvresize.8_pregen
@@ -61,7 +61,7 @@ lvresize \(em Resize a logical volume
.br
\fB-q\fP|\fB--quiet\fP
.br
- \fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
\fB-r\fP|\fB--resizefs\fP
.br
@@ -177,7 +177,7 @@ Common options for command:
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--type\fP \c
.nh
@@ -424,14 +424,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-r\fP|\fB--resizefs\fP
diff --git a/man/lvs.8_pregen b/man/lvs.8_pregen
index d055851f5..3f35dc652 100644
--- a/man/lvs.8_pregen
+++ b/man/lvs.8_pregen
@@ -55,7 +55,7 @@ lvs produces formatted output about LVs.
.br
[ \fB--readonly\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--rows\fP ]
.br
@@ -318,14 +318,16 @@ device-mapper kernel driver, so this option is unable to report whether
or not LVs are actually in use.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB--rows\fP
diff --git a/man/lvscan.8_pregen b/man/lvscan.8_pregen
index 012479618..e2938dee4 100644
--- a/man/lvscan.8_pregen
+++ b/man/lvscan.8_pregen
@@ -33,7 +33,7 @@ comprehensive information about LVs.
.br
[ \fB--readonly\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -207,14 +207,16 @@ device-mapper kernel driver, so this option is unable to report whether
or not LVs are actually in use.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-t\fP|\fB--test\fP
diff --git a/man/pvchange.8_pregen b/man/pvchange.8_pregen
index 57d1570c4..0b35a2013 100644
--- a/man/pvchange.8_pregen
+++ b/man/pvchange.8_pregen
@@ -79,7 +79,7 @@ Common options for command:
.br
[ \fB-u\fP|\fB--uuid\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.ad b
.RE
.P
@@ -265,14 +265,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-S\fP|\fB--select\fP \fIString\fP
diff --git a/man/pvcreate.8_pregen b/man/pvcreate.8_pregen
index 67b5c27d0..3445898d0 100644
--- a/man/pvcreate.8_pregen
+++ b/man/pvcreate.8_pregen
@@ -124,7 +124,7 @@ pe_start value.
.br
[ \fB--setphysicalvolumesize\fP \fISize\fP[m|UNIT] ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--restorefile\fP \fIString\fP ]
.br
@@ -353,14 +353,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB--restorefile\fP \fIString\fP
diff --git a/man/pvdisplay.8_pregen b/man/pvdisplay.8_pregen
index e7767d0c4..92dda936f 100644
--- a/man/pvdisplay.8_pregen
+++ b/man/pvdisplay.8_pregen
@@ -61,7 +61,7 @@ and more, using a more compact and configurable output format.
.br
[ \fB--readonly\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--separator\fP \fIString\fP ]
.br
@@ -322,14 +322,16 @@ device-mapper kernel driver, so this option is unable to report whether
or not LVs are actually in use.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-S\fP|\fB--select\fP \fIString\fP
diff --git a/man/pvmove.8_pregen b/man/pvmove.8_pregen
index 28b0ea4e8..53f8a2ac6 100644
--- a/man/pvmove.8_pregen
+++ b/man/pvmove.8_pregen
@@ -54,7 +54,7 @@ Move PV extents.
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -296,14 +296,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-t\fP|\fB--test\fP
diff --git a/man/pvremove.8_pregen b/man/pvremove.8_pregen
index a086724b8..0d4802187 100644
--- a/man/pvremove.8_pregen
+++ b/man/pvremove.8_pregen
@@ -29,7 +29,7 @@ an existing VG. Normally, \fBvgreduce\fP(8) should be used instead.
.ad l
[ \fB-f\fP|\fB--force\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -181,14 +181,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-t\fP|\fB--test\fP
diff --git a/man/pvresize.8_pregen b/man/pvresize.8_pregen
index 708b7d72a..fda57a246 100644
--- a/man/pvresize.8_pregen
+++ b/man/pvresize.8_pregen
@@ -24,7 +24,7 @@ LVs allocated on it.
.ad l
[ \fB--setphysicalvolumesize\fP \fISize\fP[m|UNIT] ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -170,14 +170,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB--setphysicalvolumesize\fP \fISize\fP[m|UNIT]
diff --git a/man/pvs.8_pregen b/man/pvs.8_pregen
index 485e651a7..d08e92818 100644
--- a/man/pvs.8_pregen
+++ b/man/pvs.8_pregen
@@ -53,7 +53,7 @@ pvs produces formatted output about PVs.
.br
[ \fB--readonly\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--rows\fP ]
.br
@@ -308,14 +308,16 @@ device-mapper kernel driver, so this option is unable to report whether
or not LVs are actually in use.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB--rows\fP
diff --git a/man/pvscan.8_pregen b/man/pvscan.8_pregen
index cb837b8ca..20aec7267 100644
--- a/man/pvscan.8_pregen
+++ b/man/pvscan.8_pregen
@@ -66,7 +66,7 @@ pvscan \(em List all physical volumes
.br
\fB-q\fP|\fB--quiet\fP
.br
- \fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
\fB-s\fP|\fB--short\fP
.br
@@ -157,7 +157,7 @@ Display PV information.
.br
[ \fB--ignorelockingfailure\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -176,7 +176,7 @@ Record that a PV is online or offline.
.br
[ \fB--ignorelockingfailure\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--minor\fP \fINumber\fP ]
.br
@@ -202,7 +202,7 @@ Record that a PV is online and autoactivate the VG if complete.
.br
[ \fB--ignorelockingfailure\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--minor\fP \fINumber\fP ]
.br
@@ -499,14 +499,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-s\fP|\fB--short\fP
diff --git a/man/vgcfgbackup.8_pregen b/man/vgcfgbackup.8_pregen
index e732a7d43..62707ed1f 100644
--- a/man/vgcfgbackup.8_pregen
+++ b/man/vgcfgbackup.8_pregen
@@ -46,7 +46,7 @@ It may also be useful to regularly back up the files in
.br
[ \fB--readonly\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -224,14 +224,16 @@ device-mapper kernel driver, so this option is unable to report whether
or not LVs are actually in use.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-t\fP|\fB--test\fP
diff --git a/man/vgchange.8_pregen b/man/vgchange.8_pregen
index d70f1e5ac..9df1ef733 100644
--- a/man/vgchange.8_pregen
+++ b/man/vgchange.8_pregen
@@ -97,7 +97,7 @@ vgchange \(em Change volume group attributes
.br
\fB--refresh\fP
.br
- \fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
\fB-x\fP|\fB--resizeable\fP \fBy\fP|\fBn\fP
.br
@@ -184,7 +184,7 @@ required, after which the others are optional.
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -218,7 +218,7 @@ Start or stop monitoring LVs from dmeventd.
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -248,7 +248,7 @@ Start or stop processing LV conversions.
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -294,7 +294,7 @@ Activate or deactivate LVs.
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -328,7 +328,7 @@ Reactivate LVs using the latest metadata.
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -780,14 +780,16 @@ if something has gone wrong, or if some form of manual LV
sharing is being used.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-x\fP|\fB--resizeable\fP \fBy\fP|\fBn\fP
diff --git a/man/vgck.8_pregen b/man/vgck.8_pregen
index 23bd7ea6d..d0fe0403e 100644
--- a/man/vgck.8_pregen
+++ b/man/vgck.8_pregen
@@ -26,7 +26,7 @@ Read and display information about a VG.
.br
.RS 4
.ad l
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -186,14 +186,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-t\fP|\fB--test\fP
diff --git a/man/vgconvert.8_pregen b/man/vgconvert.8_pregen
index cdeee39fa..41baaf9ad 100644
--- a/man/vgconvert.8_pregen
+++ b/man/vgconvert.8_pregen
@@ -35,7 +35,7 @@ convert VGs from the LVM1 format to LVM2.
.br
[ \fB--metadatasize\fP \fISize\fP[m|UNIT] ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -234,14 +234,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-t\fP|\fB--test\fP
diff --git a/man/vgcreate.8_pregen b/man/vgcreate.8_pregen
index 2c0c548b5..07fc9e485 100644
--- a/man/vgcreate.8_pregen
+++ b/man/vgcreate.8_pregen
@@ -63,7 +63,7 @@ device.
.br
[ \fB--\fP[\fBvg\fP]\fBmetadatacopies\fP \fBall\fP|\fBunmanaged\fP|\fINumber\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--dataalignment\fP \fISize\fP[k|UNIT] ]
.br
@@ -351,14 +351,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB--setautoactivation\fP \fBy\fP|\fBn\fP
diff --git a/man/vgexport.8_pregen b/man/vgexport.8_pregen
index 25f767bc8..4fa6eadbf 100644
--- a/man/vgexport.8_pregen
+++ b/man/vgexport.8_pregen
@@ -63,7 +63,7 @@ Common options for command:
.
.RS 4
.ad l
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.ad b
.RE
.P
@@ -211,14 +211,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-S\fP|\fB--select\fP \fIString\fP
diff --git a/man/vgextend.8_pregen b/man/vgextend.8_pregen
index af5679118..a1ed2f3e3 100644
--- a/man/vgextend.8_pregen
+++ b/man/vgextend.8_pregen
@@ -51,7 +51,7 @@ will initialize them. In this case pvcreate options can be used, e.g.
.br
[ \fB--dataalignmentoffset\fP \fISize\fP[k|UNIT] ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--restoremissing\fP ]
.br
@@ -265,14 +265,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB--restoremissing\fP
diff --git a/man/vgimport.8_pregen b/man/vgimport.8_pregen
index fee109849..f23f8f4f1 100644
--- a/man/vgimport.8_pregen
+++ b/man/vgimport.8_pregen
@@ -51,7 +51,7 @@ Common options for command:
.ad l
[ \fB-f\fP|\fB--force\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.ad b
.RE
.P
@@ -206,14 +206,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-S\fP|\fB--select\fP \fIString\fP
diff --git a/man/vgimportdevices.8_pregen b/man/vgimportdevices.8_pregen
index c030c01a5..1cce85766 100644
--- a/man/vgimportdevices.8_pregen
+++ b/man/vgimportdevices.8_pregen
@@ -56,7 +56,7 @@ Common options for command:
.ad l
[ \fB--foreign\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.ad b
.RE
.P
@@ -210,14 +210,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-S\fP|\fB--select\fP \fIString\fP
diff --git a/man/vgmknodes.8_pregen b/man/vgmknodes.8_pregen
index 511d579bd..60e693571 100644
--- a/man/vgmknodes.8_pregen
+++ b/man/vgmknodes.8_pregen
@@ -31,7 +31,7 @@ interoperating correctly.
.br
[ \fB--refresh\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -194,14 +194,16 @@ if something has gone wrong, or if some form of manual LV
sharing is being used.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-t\fP|\fB--test\fP
diff --git a/man/vgreduce.8_pregen b/man/vgreduce.8_pregen
index 278aa0fac..ca6ab6786 100644
--- a/man/vgreduce.8_pregen
+++ b/man/vgreduce.8_pregen
@@ -50,7 +50,7 @@ vgreduce \(em Remove physical volume(s) from a volume group
.br
\fB--removemissing\fP
.br
- \fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
\fB-t\fP|\fB--test\fP
.br
@@ -116,7 +116,7 @@ Common options for command:
.br
[ \fB-f\fP|\fB--force\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.ad b
.RE
.P
@@ -296,14 +296,16 @@ If LVs spanned several disks, including ones that are lost, salvaging
some data first may be possible by activating LVs in partial mode.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-t\fP|\fB--test\fP
diff --git a/man/vgremove.8_pregen b/man/vgremove.8_pregen
index 9e6051ade..df6588115 100644
--- a/man/vgremove.8_pregen
+++ b/man/vgremove.8_pregen
@@ -35,7 +35,7 @@ without confirmation.
.br
[ \fB--noudevsync\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -195,14 +195,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-S\fP|\fB--select\fP \fIString\fP
diff --git a/man/vgrename.8_pregen b/man/vgrename.8_pregen
index 932a51103..d55b6a0f9 100644
--- a/man/vgrename.8_pregen
+++ b/man/vgrename.8_pregen
@@ -55,7 +55,7 @@ Common options for command:
.br
[ \fB-f\fP|\fB--force\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.ad b
.RE
.P
@@ -211,14 +211,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-t\fP|\fB--test\fP
diff --git a/man/vgs.8_pregen b/man/vgs.8_pregen
index 0c89c5b5e..8b1f69c4f 100644
--- a/man/vgs.8_pregen
+++ b/man/vgs.8_pregen
@@ -51,7 +51,7 @@ vgs produces formatted output about VGs.
.br
[ \fB--readonly\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ \fB--rows\fP ]
.br
@@ -305,14 +305,16 @@ device-mapper kernel driver, so this option is unable to report whether
or not LVs are actually in use.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB--rows\fP
diff --git a/man/vgscan.8_pregen b/man/vgscan.8_pregen
index 600c2c978..7b4ffb615 100644
--- a/man/vgscan.8_pregen
+++ b/man/vgscan.8_pregen
@@ -27,7 +27,7 @@ vgscan scans all supported LVM block devices in the system for VGs.
.br
[ \fB--notifydbus\fP ]
.br
-[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP ]
+[ \fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP ]
.br
[ COMMON_OPTIONS ]
.ad b
@@ -192,14 +192,16 @@ Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer 'no'.
.
.HP
-\fB--reportformat\fP \fBbasic\fP|\fBjson\fP
+\fB--reportformat\fP \fBbasic\fP|\fBjson\fP|\fBjson_std\fP
.br
Overrides current output format for reports which is defined globally by
the report/output_format setting in \fBlvm.conf\fP(5).
\fBbasic\fP is the original format with columns and rows.
If there is more than one report per command, each report is prefixed
with the report name for identification. \fBjson\fP produces report
-output in JSON format. See \fBlvmreport\fP(7) for more information.
+output in JSON format. \fBjson_std\fP produces report output in
+JSON format which is more compliant with JSON standard.
+See \fBlvmreport\fP(7) for more information.
.
.HP
\fB-t\fP|\fB--test\fP
1 year, 8 months
main - man: update lvmreport man page about json_std format
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=efd083f66883e674a6f...
Commit: efd083f66883e674a6f24370d8c7cc06aa4fafe7
Parent: aa7cec61edae849c5fab7e1319684b43fdc439de
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Aug 4 16:52:22 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 11 11:10:11 2022 +0200
man: update lvmreport man page about json_std format
---
man/lvmreport.7_main | 36 ++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)
diff --git a/man/lvmreport.7_main b/man/lvmreport.7_main
index f0f04ad1c..1ef5d25db 100644
--- a/man/lvmreport.7_main
+++ b/man/lvmreport.7_main
@@ -1303,9 +1303,19 @@ binary_values_as_numeric=1
.
LVM can output reports in different formats - use \fBreport/output_format\fP
configuration setting (or \fB--reportformat\fP command line option) to swith
-the report output format. Currently, LVM supports \fB"basic"\fP (all the examples
-we used above used this format) and \fB"JSON"\fP output format.
+the report output format.
+
.P
+Currently, LVM supports these outpout formats:
+.RS
+- \fB"basic"\fP (all the examples we used above used this format),
+.br
+- \fB"json"\fP,
+.br
+- \fB"json_std"\fP.
+.RE
+.P
+For example:
.nf
# lvs -o lv_name,lv_size --reportformat json
{
@@ -1320,13 +1330,23 @@ we used above used this format) and \fB"JSON"\fP output format.
}
.fi
.P
+The \fBjson_std\fP output format is more compliant with JSON standard and
+compared to the original \fBjson\fP format:
+.RS
+- it does not use double quotes around numeric values,
+.br
+- it uses 'null' for undefined numeric values,
+.br
+- it prints string list as proper JSON array of strings instead of a single string.
+.RE
+.P
Note that some configuration settings and command line options have no
-effect with certain report formats. For example, with \fBJSON\fP output,
-it doesn't have any meaning to use \fBreport/aligned\fP (\fB--aligned\fP),
-\fBreport/noheadings\fP (\fB--noheadings\fP), \fBreport/columns_as_rows\fP
-(\fB--rows\fP) or \fBreport/buffered\fP (\fB--unbuffered\fP). All these
-configuration settings and command line options are ignored if using the
-\fBJSON\fP report output format.
+effect with certain report formats. For example, with \fBjson\fP or
+\fBjson_std\fP output, it doesn't have any meaning to use \fBreport/aligned\fP
+(\fB--aligned\fP), \fBreport/noheadings\fP (\fB--noheadings\fP),
+\fBreport/columns_as_rows\fP (\fB--rows\fP) or \fBreport/buffered\fP
+(\fB--unbuffered\fP). All these configuration settings and command line options
+are ignored if using the \fBjson\fP or \fBjson_std\fP report output format.
.
.SS Selection
.
1 year, 8 months
main - args: recognize 'json_std' for --reportformat cmd line arg
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=aa7cec61edae849c5fa...
Commit: aa7cec61edae849c5fab7e1319684b43fdc439de
Parent: 6cba28a335284de9dd68d84b4dd660f6e744eba5
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Aug 4 16:50:01 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 11 11:10:11 2022 +0200
args: recognize 'json_std' for --reportformat cmd line arg
---
tools/args.h | 4 +++-
tools/lvmcmdline.c | 3 ++-
tools/vals.h | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index 2f94d4535..9229b8764 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -677,7 +677,9 @@ arg(reportformat_ARG, '\0', "reportformat", reportformat_VAL, 0, 0,
"\\fBbasic\\fP is the original format with columns and rows.\n"
"If there is more than one report per command, each report is prefixed\n"
"with the report name for identification. \\fBjson\\fP produces report\n"
- "output in JSON format. See \\fBlvmreport\\fP(7) for more information.\n")
+ "output in JSON format. \\fBjson_std\\fP produces report output in\n"
+ "JSON format which is more compliant with JSON standard.\n"
+ "See \\fBlvmreport\\fP(7) for more information.\n")
arg(restorefile_ARG, '\0', "restorefile", string_VAL, 0, 0,
"In conjunction with --uuid, this reads the file (produced by\n"
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index b052d698f..4fb21074f 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1058,7 +1058,8 @@ int syncaction_arg(struct cmd_context *cmd, struct arg_values *av)
int reportformat_arg(struct cmd_context *cmd, struct arg_values *av)
{
if (!strcmp(av->value, "basic") ||
- !strcmp(av->value, "json"))
+ !strcmp(av->value, "json") ||
+ !strcmp(av->value, "json_std"))
return 1;
return 0;
}
diff --git a/tools/vals.h b/tools/vals.h
index addbea2f2..590755a1e 100644
--- a/tools/vals.h
+++ b/tools/vals.h
@@ -138,7 +138,7 @@ val(metadatacopies_VAL, metadatacopies_arg, "unused", "unused")
val(polloperation_VAL, polloperation_arg, "PollOp", "pvmove|convert|merge|merge_thin")
val(writemostly_VAL, writemostly_arg, "WriteMostlyPV", "PV[:t|n|y]")
val(syncaction_VAL, syncaction_arg, "SyncAction", "check|repair")
-val(reportformat_VAL, reportformat_arg, "ReportFmt", "basic|json")
+val(reportformat_VAL, reportformat_arg, "ReportFmt", "basic|json|json_std")
val(configreport_VAL, configreport_arg, "ConfigReport", "log|vg|lv|pv|pvseg|seg")
val(configtype_VAL, configtype_arg, "ConfigType", "current|default|diff|full|list|missing|new|profilable|profilable-command|profilable-metadata")
val(repairtype_VAL, repairtype_arg, "RepairType", "pv_header|metadata|label_header")
1 year, 8 months
main - config: recognize 'json_std' for report/output_format config setting
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6cba28a335284de9dd6...
Commit: 6cba28a335284de9dd68d84b4dd660f6e744eba5
Parent: 73ec3c954b21522352b6f5cce9a700d6bf30ccf4
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Aug 4 16:42:54 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 11 11:10:11 2022 +0200
config: recognize 'json_std' for report/output_format config setting
---
lib/config/config_settings.h | 9 ++++++++-
tools/reporter.c | 8 ++++++--
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index d2811df2b..b172c7c5f 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1806,7 +1806,14 @@ cfg(report_output_format_CFG, "output_format", report_CFG_SECTION, CFG_PROFILABL
" one report per command, each report is prefixed with report's\n"
" name for identification.\n"
" json\n"
- " JSON format.\n")
+ " JSON format.\n"
+ " json_std\n"
+ " JSON format that is more compliant with JSON standard.\n"
+ " Compared to original \"json\" format:\n"
+ " - it does not use double quotes around numeric values,\n"
+ " - it uses 'null' for undefined numeric values,\n"
+ " - it prints string list as proper JSON array of strings instead of a single string."
+ "\n")
cfg(report_compact_output_CFG, "compact_output", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_REP_COMPACT_OUTPUT, vsn(2, 2, 115), NULL, 0, NULL,
"Do not print empty values for all report fields.\n"
diff --git a/tools/reporter.c b/tools/reporter.c
index eafba4fec..b31f1891e 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -1455,6 +1455,7 @@ int devtypes(struct cmd_context *cmd, int argc, char **argv)
#define REPORT_FORMAT_NAME_BASIC "basic"
#define REPORT_FORMAT_NAME_JSON "json"
+#define REPORT_FORMAT_NAME_JSON_STD "json_std"
int report_format_init(struct cmd_context *cmd)
{
@@ -1475,11 +1476,14 @@ int report_format_init(struct cmd_context *cmd)
: DM_REPORT_GROUP_SINGLE;
} else if (!strcmp(format_str, REPORT_FORMAT_NAME_JSON)) {
args.report_group_type = DM_REPORT_GROUP_JSON;
+ } else if (!strcmp(format_str, REPORT_FORMAT_NAME_JSON_STD)) {
+ args.report_group_type = DM_REPORT_GROUP_JSON_STD;
} else {
log_error("%s: unknown report format.", format_str);
- log_error("Supported report formats: %s, %s.",
+ log_error("Supported report formats: %s, %s, %s.",
REPORT_FORMAT_NAME_BASIC,
- REPORT_FORMAT_NAME_JSON);
+ REPORT_FORMAT_NAME_JSON,
+ REPORT_FORMAT_NAME_JSON_STD);
return 0;
}
1 year, 8 months
main - libdm: report: use proper JSON array for string list output in JSON_STD format
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=73ec3c954b21522352b...
Commit: 73ec3c954b21522352b6f5cce9a700d6bf30ccf4
Parent: fbee18f6e5c0e70c9b6cb75b67d0e15c99604135
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Aug 4 16:14:44 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 11 11:10:11 2022 +0200
libdm: report: use proper JSON array for string list output in JSON_STD format
In JSON format, we print string list this way:
"key" = "item1,item2,...,itemN"
while in JSON_STD format, we print string list this way:
"key" = ["item1","item2",...,"itemN"]
---
device_mapper/libdm-report.c | 88 ++++++++++++++++++++++++++++++++++++++++++--
libdm/libdm-report.c | 88 ++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 168 insertions(+), 8 deletions(-)
diff --git a/device_mapper/libdm-report.c b/device_mapper/libdm-report.c
index c7d4e18b9..d4cd06002 100644
--- a/device_mapper/libdm-report.c
+++ b/device_mapper/libdm-report.c
@@ -4569,12 +4569,21 @@ bad:
return 0;
}
-static int _safe_repstr_output(struct dm_report *rh, const char *repstr)
+static int _safe_repstr_output(struct dm_report *rh, const char *repstr, size_t len)
{
const char *p_repstr;
+ const char *repstr_end = repstr + len;
/* Escape any JSON_QUOTE that may appear in reported string. */
- while ((p_repstr = strstr(repstr, JSON_QUOTE))) {
+ while (1) {
+ if (len) {
+ if (!(p_repstr = memchr(repstr, JSON_QUOTE[0], repstr_end - repstr)))
+ break;
+ } else {
+ if (!(p_repstr = strstr(repstr, JSON_QUOTE)))
+ break;
+ }
+
if (p_repstr > repstr) {
if (!dm_pool_grow_object(rh->mem, repstr, p_repstr - repstr)) {
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
@@ -4589,7 +4598,7 @@ static int _safe_repstr_output(struct dm_report *rh, const char *repstr)
repstr = p_repstr + 1;
}
- if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
+ if (!dm_pool_grow_object(rh->mem, repstr, repstr_end - repstr)) {
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
return 0;
}
@@ -4600,6 +4609,8 @@ static int _safe_repstr_output(struct dm_report *rh, const char *repstr)
static int _output_field_json_fmt(struct dm_report *rh, struct dm_report_field *field)
{
const char *repstr;
+ size_t list_size, i;
+ struct pos_len *pos_len;
if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
!dm_pool_grow_object(rh->mem, _get_field_id(rh, field), 0) ||
@@ -4609,6 +4620,75 @@ static int _output_field_json_fmt(struct dm_report *rh, struct dm_report_field *
return 0;
}
+ if (field->props->flags & DM_REPORT_FIELD_TYPE_STRING_LIST) {
+ if (!_is_json_std_report(rh)) {
+
+ /* string list in JSON - report whole list as simple string in quotes */
+
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ if (!_safe_repstr_output(rh, field->report_string, 0))
+ return_0;
+
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ return 1;
+ }
+
+ /* string list in JSON_STD - report list as proper JSON array */
+
+ if (!dm_pool_grow_object(rh->mem, JSON_ARRAY_START, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ if (*field->report_string != 0) {
+ pos_len = (struct pos_len *) (field->report_string +
+ ((struct str_list_sort_value *) field->sort_value)->items[0].len + 1);
+ list_size = pos_len->pos;
+ } else
+ list_size = 0;
+
+ for (i = 0; i < list_size; i++) {
+ pos_len++;
+
+ if (i != 0) {
+ if (!dm_pool_grow_object(rh->mem, JSON_SEPARATOR, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+ }
+
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ if (!_safe_repstr_output(rh, field->report_string + pos_len->pos, pos_len->len))
+ return_0;
+
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+ }
+
+ if (!dm_pool_grow_object(rh->mem, JSON_ARRAY_END, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ return 1;
+ }
+
+ /* all other types than string list - handle both JSON and JSON_STD */
+
if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
@@ -4621,7 +4701,7 @@ static int _output_field_json_fmt(struct dm_report *rh, struct dm_report_field *
else
repstr = field->report_string;
- if (!_safe_repstr_output(rh, repstr))
+ if (!_safe_repstr_output(rh, repstr, 0))
return_0;
if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 848961ced..fc71ca5df 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -4568,12 +4568,21 @@ bad:
return 0;
}
-static int _safe_repstr_output(struct dm_report *rh, const char *repstr)
+static int _safe_repstr_output(struct dm_report *rh, const char *repstr, size_t len)
{
const char *p_repstr;
+ const char *repstr_end = repstr + len;
/* Escape any JSON_QUOTE that may appear in reported string. */
- while ((p_repstr = strstr(repstr, JSON_QUOTE))) {
+ while (1) {
+ if (len) {
+ if (!(p_repstr = memchr(repstr, JSON_QUOTE[0], repstr_end - repstr)))
+ break;
+ } else {
+ if (!(p_repstr = strstr(repstr, JSON_QUOTE)))
+ break;
+ }
+
if (p_repstr > repstr) {
if (!dm_pool_grow_object(rh->mem, repstr, p_repstr - repstr)) {
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
@@ -4588,7 +4597,7 @@ static int _safe_repstr_output(struct dm_report *rh, const char *repstr)
repstr = p_repstr + 1;
}
- if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
+ if (!dm_pool_grow_object(rh->mem, repstr, repstr_end - repstr)) {
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
return 0;
}
@@ -4599,6 +4608,8 @@ static int _safe_repstr_output(struct dm_report *rh, const char *repstr)
static int _output_field_json_fmt(struct dm_report *rh, struct dm_report_field *field)
{
const char *repstr;
+ size_t list_size, i;
+ struct pos_len *pos_len;
if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
!dm_pool_grow_object(rh->mem, _get_field_id(rh, field), 0) ||
@@ -4608,6 +4619,75 @@ static int _output_field_json_fmt(struct dm_report *rh, struct dm_report_field *
return 0;
}
+ if (field->props->flags & DM_REPORT_FIELD_TYPE_STRING_LIST) {
+ if (!_is_json_std_report(rh)) {
+
+ /* string list in JSON - report whole list as simple string in quotes */
+
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ if (!_safe_repstr_output(rh, field->report_string, 0))
+ return_0;
+
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ return 1;
+ }
+
+ /* string list in JSON_STD - report list as proper JSON array */
+
+ if (!dm_pool_grow_object(rh->mem, JSON_ARRAY_START, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ if (*field->report_string != 0) {
+ pos_len = (struct pos_len *) (field->report_string +
+ ((struct str_list_sort_value *) field->sort_value)->items[0].len + 1);
+ list_size = pos_len->pos;
+ } else
+ list_size = 0;
+
+ for (i = 0; i < list_size; i++) {
+ pos_len++;
+
+ if (i != 0) {
+ if (!dm_pool_grow_object(rh->mem, JSON_SEPARATOR, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+ }
+
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ if (!_safe_repstr_output(rh, field->report_string + pos_len->pos, pos_len->len))
+ return_0;
+
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+ }
+
+ if (!dm_pool_grow_object(rh->mem, JSON_ARRAY_END, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ return 1;
+ }
+
+ /* all other types than string list - handle both JSON and JSON_STD */
+
if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
@@ -4620,7 +4700,7 @@ static int _output_field_json_fmt(struct dm_report *rh, struct dm_report_field *
else
repstr = field->report_string;
- if (!_safe_repstr_output(rh, repstr))
+ if (!_safe_repstr_output(rh, repstr, 0))
return_0;
if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
1 year, 8 months
main - libdm: report: separate basic and JSON+JSON_STD format in _output_field
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fbee18f6e5c0e70c9b6...
Commit: fbee18f6e5c0e70c9b6cb75b67d0e15c99604135
Parent: 31cd8346ae92fcc32ce4f2f60f7962e620a7b12f
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jun 29 21:59:12 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 11 11:10:11 2022 +0200
libdm: report: separate basic and JSON+JSON_STD format in _output_field
Use separate functions to handle basic and JSON+JSON_STD format.
It's clearer this way than interleaving both in the same function.
---
device_mapper/libdm-report.c | 165 ++++++++++++++++++++++++-------------------
libdm/libdm-report.c | 165 ++++++++++++++++++++++++-------------------
2 files changed, 188 insertions(+), 142 deletions(-)
diff --git a/device_mapper/libdm-report.c b/device_mapper/libdm-report.c
index aab7bdd63..c7d4e18b9 100644
--- a/device_mapper/libdm-report.c
+++ b/device_mapper/libdm-report.c
@@ -4462,38 +4462,24 @@ static int _is_pure_numeric_field(struct dm_report_field *field)
return field->props->flags & (DM_REPORT_FIELD_TYPE_NUMBER | DM_REPORT_FIELD_TYPE_PERCENT);
}
-/*
- * Produce report output
- */
-static int _output_field(struct dm_report *rh, struct dm_report_field *field)
+static const char *_get_field_id(struct dm_report *rh, struct dm_report_field *field)
{
const struct dm_report_field_type *fields = field->props->implicit ? _implicit_report_fields
: rh->fields;
+
+ return fields[field->props->field_num].id;
+}
+
+static int _output_field_basic_fmt(struct dm_report *rh, struct dm_report_field *field)
+{
char *field_id;
int32_t width;
uint32_t align;
- const char *repstr;
- const char *p1_repstr, *p2_repstr;
char *buf = NULL;
size_t buf_size = 0;
- if (_is_json_report(rh)) {
- if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
- !dm_pool_grow_object(rh->mem, fields[field->props->field_num].id, 0) ||
- !dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
- !dm_pool_grow_object(rh->mem, JSON_PAIR, 1)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- goto bad;
- }
-
- if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
- if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- goto bad;
- }
- }
- } else if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
- if (!(field_id = strdup(fields[field->props->field_num].id))) {
+ if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
+ if (!(field_id = strdup(_get_field_id(rh, field)))) {
log_error("dm_report: Failed to copy field name");
return 0;
}
@@ -4524,48 +4510,14 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
}
}
- if (_is_json_std_report(rh) && _is_pure_numeric_field(field) && !*field->report_string)
- repstr = JSON_NULL;
- else
- repstr = field->report_string;
-
- width = field->props->width;
-
- if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
- if (_is_json_report(rh)) {
- /* Escape any JSON_QUOTE that may appear in reported string. */
- p1_repstr = repstr;
- while ((p2_repstr = strstr(p1_repstr, JSON_QUOTE))) {
- if (p2_repstr > p1_repstr) {
- if (!dm_pool_grow_object(rh->mem, p1_repstr, p2_repstr - p1_repstr)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- return 0;
- }
- }
- if (!dm_pool_grow_object(rh->mem, JSON_ESCAPE_CHAR, 1) ||
- !dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- return 0;
- }
- p1_repstr = p2_repstr + 1;
- }
-
- if (!dm_pool_grow_object(rh->mem, p1_repstr, 0)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- return 0;
- }
- } else {
- if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- return 0;
- }
- }
- } else {
+ if (rh->flags & DM_REPORT_OUTPUT_ALIGNED) {
if (!(align = field->props->flags & DM_REPORT_FIELD_ALIGN_MASK))
align = ((field->props->flags & DM_REPORT_FIELD_TYPE_NUMBER) ||
- (field->props->flags & DM_REPORT_FIELD_TYPE_SIZE)) ?
+ (field->props->flags & DM_REPORT_FIELD_TYPE_SIZE)) ?
DM_REPORT_FIELD_ALIGN_RIGHT : DM_REPORT_FIELD_ALIGN_LEFT;
+ width = field->props->width;
+
/* Including trailing '\0'! */
buf_size = width + 1;
if (!(buf = malloc(buf_size))) {
@@ -4575,7 +4527,7 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
if (align & DM_REPORT_FIELD_ALIGN_LEFT) {
if (dm_snprintf(buf, buf_size, "%-*.*s",
- width, width, repstr) < 0) {
+ width, width, field->report_string) < 0) {
log_error("dm_report: left-aligned snprintf() failed");
goto bad;
}
@@ -4585,7 +4537,7 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
}
} else if (align & DM_REPORT_FIELD_ALIGN_RIGHT) {
if (dm_snprintf(buf, buf_size, "%*.*s",
- width, width, repstr) < 0) {
+ width, width, field->report_string) < 0) {
log_error("dm_report: right-aligned snprintf() failed");
goto bad;
}
@@ -4594,6 +4546,11 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
goto bad;
}
}
+ } else {
+ if (!dm_pool_grow_object(rh->mem, field->report_string, 0)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
}
if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
@@ -4603,23 +4560,89 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
goto bad;
}
}
- } else if (_is_json_report(rh)) {
- if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
- if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- goto bad;
- }
- }
}
free(buf);
return 1;
-
bad:
free(buf);
return 0;
}
+static int _safe_repstr_output(struct dm_report *rh, const char *repstr)
+{
+ const char *p_repstr;
+
+ /* Escape any JSON_QUOTE that may appear in reported string. */
+ while ((p_repstr = strstr(repstr, JSON_QUOTE))) {
+ if (p_repstr > repstr) {
+ if (!dm_pool_grow_object(rh->mem, repstr, p_repstr - repstr)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+ }
+ if (!dm_pool_grow_object(rh->mem, JSON_ESCAPE_CHAR, 1) ||
+ !dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+ repstr = p_repstr + 1;
+ }
+
+ if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ return 1;
+}
+
+static int _output_field_json_fmt(struct dm_report *rh, struct dm_report_field *field)
+{
+ const char *repstr;
+
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
+ !dm_pool_grow_object(rh->mem, _get_field_id(rh, field), 0) ||
+ !dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
+ !dm_pool_grow_object(rh->mem, JSON_PAIR, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+ }
+
+ if (_is_json_std_report(rh) && _is_pure_numeric_field(field) && !*field->report_string)
+ repstr = JSON_NULL;
+ else
+ repstr = field->report_string;
+
+ if (!_safe_repstr_output(rh, repstr))
+ return_0;
+
+ if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * Produce report output
+ */
+static int _output_field(struct dm_report *rh, struct dm_report_field *field)
+{
+ return _is_json_report(rh) ? _output_field_json_fmt(rh, field)
+ : _output_field_basic_fmt(rh, field);
+}
+
static void _destroy_rows(struct dm_report *rh)
{
/*
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 9fac341a4..848961ced 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -4461,38 +4461,24 @@ static int _is_pure_numeric_field(struct dm_report_field *field)
return field->props->flags & (DM_REPORT_FIELD_TYPE_NUMBER | DM_REPORT_FIELD_TYPE_PERCENT);
}
-/*
- * Produce report output
- */
-static int _output_field(struct dm_report *rh, struct dm_report_field *field)
+static const char *_get_field_id(struct dm_report *rh, struct dm_report_field *field)
{
const struct dm_report_field_type *fields = field->props->implicit ? _implicit_report_fields
: rh->fields;
+
+ return fields[field->props->field_num].id;
+}
+
+static int _output_field_basic_fmt(struct dm_report *rh, struct dm_report_field *field)
+{
char *field_id;
int32_t width;
uint32_t align;
- const char *repstr;
- const char *p1_repstr, *p2_repstr;
char *buf = NULL;
size_t buf_size = 0;
- if (_is_json_report(rh)) {
- if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
- !dm_pool_grow_object(rh->mem, fields[field->props->field_num].id, 0) ||
- !dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
- !dm_pool_grow_object(rh->mem, JSON_PAIR, 1)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- goto bad;
- }
-
- if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
- if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- goto bad;
- }
- }
- } else if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
- if (!(field_id = dm_strdup(fields[field->props->field_num].id))) {
+ if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
+ if (!(field_id = strdup(_get_field_id(rh, field)))) {
log_error("dm_report: Failed to copy field name");
return 0;
}
@@ -4523,48 +4509,14 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
}
}
- if (_is_json_std_report(rh) && _is_pure_numeric_field(field) && !*field->report_string)
- repstr = JSON_NULL;
- else
- repstr = field->report_string;
-
- width = field->props->width;
-
- if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
- if (_is_json_report(rh)) {
- /* Escape any JSON_QUOTE that may appear in reported string. */
- p1_repstr = repstr;
- while ((p2_repstr = strstr(p1_repstr, JSON_QUOTE))) {
- if (p2_repstr > p1_repstr) {
- if (!dm_pool_grow_object(rh->mem, p1_repstr, p2_repstr - p1_repstr)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- return 0;
- }
- }
- if (!dm_pool_grow_object(rh->mem, JSON_ESCAPE_CHAR, 1) ||
- !dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- return 0;
- }
- p1_repstr = p2_repstr + 1;
- }
-
- if (!dm_pool_grow_object(rh->mem, p1_repstr, 0)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- return 0;
- }
- } else {
- if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- return 0;
- }
- }
- } else {
+ if (rh->flags & DM_REPORT_OUTPUT_ALIGNED) {
if (!(align = field->props->flags & DM_REPORT_FIELD_ALIGN_MASK))
align = ((field->props->flags & DM_REPORT_FIELD_TYPE_NUMBER) ||
- (field->props->flags & DM_REPORT_FIELD_TYPE_SIZE)) ?
+ (field->props->flags & DM_REPORT_FIELD_TYPE_SIZE)) ?
DM_REPORT_FIELD_ALIGN_RIGHT : DM_REPORT_FIELD_ALIGN_LEFT;
+ width = field->props->width;
+
/* Including trailing '\0'! */
buf_size = width + 1;
if (!(buf = dm_malloc(buf_size))) {
@@ -4574,7 +4526,7 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
if (align & DM_REPORT_FIELD_ALIGN_LEFT) {
if (dm_snprintf(buf, buf_size, "%-*.*s",
- width, width, repstr) < 0) {
+ width, width, field->report_string) < 0) {
log_error("dm_report: left-aligned snprintf() failed");
goto bad;
}
@@ -4584,7 +4536,7 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
}
} else if (align & DM_REPORT_FIELD_ALIGN_RIGHT) {
if (dm_snprintf(buf, buf_size, "%*.*s",
- width, width, repstr) < 0) {
+ width, width, field->report_string) < 0) {
log_error("dm_report: right-aligned snprintf() failed");
goto bad;
}
@@ -4593,6 +4545,11 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
goto bad;
}
}
+ } else {
+ if (!dm_pool_grow_object(rh->mem, field->report_string, 0)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
}
if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
@@ -4602,23 +4559,89 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
goto bad;
}
}
- } else if (_is_json_report(rh)) {
- if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
- if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- goto bad;
- }
- }
}
dm_free(buf);
return 1;
-
bad:
dm_free(buf);
return 0;
}
+static int _safe_repstr_output(struct dm_report *rh, const char *repstr)
+{
+ const char *p_repstr;
+
+ /* Escape any JSON_QUOTE that may appear in reported string. */
+ while ((p_repstr = strstr(repstr, JSON_QUOTE))) {
+ if (p_repstr > repstr) {
+ if (!dm_pool_grow_object(rh->mem, repstr, p_repstr - repstr)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+ }
+ if (!dm_pool_grow_object(rh->mem, JSON_ESCAPE_CHAR, 1) ||
+ !dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+ repstr = p_repstr + 1;
+ }
+
+ if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ return 1;
+}
+
+static int _output_field_json_fmt(struct dm_report *rh, struct dm_report_field *field)
+{
+ const char *repstr;
+
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
+ !dm_pool_grow_object(rh->mem, _get_field_id(rh, field), 0) ||
+ !dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
+ !dm_pool_grow_object(rh->mem, JSON_PAIR, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+ }
+
+ if (_is_json_std_report(rh) && _is_pure_numeric_field(field) && !*field->report_string)
+ repstr = JSON_NULL;
+ else
+ repstr = field->report_string;
+
+ if (!_safe_repstr_output(rh, repstr))
+ return_0;
+
+ if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * Produce report output
+ */
+static int _output_field(struct dm_report *rh, struct dm_report_field *field)
+{
+ return _is_json_report(rh) ? _output_field_json_fmt(rh, field)
+ : _output_field_basic_fmt(rh, field);
+}
+
static void _destroy_rows(struct dm_report *rh)
{
/*
1 year, 8 months
main - libdm: report: enhance the way string list is stored internally
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=31cd8346ae92fcc32ce...
Commit: 31cd8346ae92fcc32ce4f2f60f7962e620a7b12f
Parent: 1e31621cebfb38f652233e2f80dd081cca5e8374
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jun 28 17:00:00 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 11 11:10:11 2022 +0200
libdm: report: enhance the way string list is stored internally
Before, we stored only the report string itself for a string list
in field->report_string. The field->report_string has either
sorted items or not, depending on what we need for a field -
some report fields have sorted output, some don't...
The field->sort_value.value then contains pointer to the exact
field->report_string. The field->sort_value.items ALWAYS keeps
sorted array of individual items, represented as '[position,length]'
pairs pointing to the field->sort_value.value string.
This approach was fine as far as we didn't need to apply further
formatting to field->report_string. However, if we need to apply
further formatting to field->report_string content, taking into
account individual items, we also need to know where each item
starts and what is its length. Before, we only knew this when
items in report string were sorted, but not in the unsorted version.
We can't rely on the delimiter (default ",") only to separate items
back out of report string, because that delimiter can be contained
in the item value itself.
So this patch enhances the field->report_string for a string list so
it also contains '[position,length]' pairs for each individual item
inside field->report_string. We store this array right beyond the
string itself and we encode it in the same manner we already did for
field->sort_value.items before.
If field->report_string has sorted items, the field->sort_value.items
just points to the array of items we store beyond the report string.
If field->report_string has unsorted items, we store separate array
of items for both field->report_string and field->sort_value.
This patch also cleans up the _report_field_string_list function a bit
so it's easier and more straightforward to follow than the original
version.
Example. If we have "abc", "xy", "defgh" as list on input with ","
as delimiter, then:
- field->report_string will have:
- if we need field->report_string unsorted:
abc,xy,defgh\0{[3,12],[0,3],[4,2],[7,5]}
|____________||________________________|
string array of [pos,len] pairs
|____||________________|
#items items
- if we need field->report_string sorted:
repstr_extra
|
V
abc,defgh,xy\0{[3,12],[0,3],[4,5],[10,2]}
|____________||________________________|
string array of [pos,len] pairs
|____||________________|
#items items
- field->sort_value will have:
- if field->report_string is unsorted:
field->sort_value.value = field->report_string
field->sort_value.items = {[0,3],[0,3],[7,5],[4,2]}
(that is 'abc,defgh,xy')
- if field->report_string is sorted already:
field->sort_value.value = field->report_string
field->sort_value.items = repstr_extra
(that is also 'abc,defgh,xy')
---
device_mapper/libdm-report.c | 306 +++++++++++++++++++++++++++----------------
libdm/libdm-report.c | 306 +++++++++++++++++++++++++++----------------
2 files changed, 380 insertions(+), 232 deletions(-)
diff --git a/device_mapper/libdm-report.c b/device_mapper/libdm-report.c
index 3c4b01127..aab7bdd63 100644
--- a/device_mapper/libdm-report.c
+++ b/device_mapper/libdm-report.c
@@ -384,172 +384,246 @@ int dm_report_field_percent(struct dm_report *rh,
return 1;
}
-struct str_list_sort_value_item {
+struct pos_len {
unsigned pos;
size_t len;
};
-struct str_list_sort_value {
- const char *value;
- struct str_list_sort_value_item *items;
+struct str_pos_len {
+ const char *str;
+ struct pos_len item;
};
-struct str_list_sort_item {
- const char *str;
- struct str_list_sort_value_item item;
+struct str_list_sort_value {
+ const char *value;
+ struct pos_len *items;
};
-static int _str_list_sort_item_cmp(const void *a, const void *b)
+static int _str_sort_cmp(const void *a, const void *b)
{
- const struct str_list_sort_item *slsi_a = (const struct str_list_sort_item *) a;
- const struct str_list_sort_item *slsi_b = (const struct str_list_sort_item *) b;
-
- return strcmp(slsi_a->str, slsi_b->str);
+ return strcmp(((const struct str_pos_len *) a)->str, ((const struct str_pos_len *) b)->str);
}
+#define FIELD_STRING_LIST_DEFAULT_DELIMITER ","
+
static int _report_field_string_list(struct dm_report *rh,
struct dm_report_field *field,
const struct dm_list *data,
const char *delimiter,
- int sort)
+ int sort_repstr)
{
- static const char _string_list_grow_object_failed_msg[] = "dm_report_field_string_list: dm_pool_grow_object_failed";
- struct str_list_sort_value *sort_value = NULL;
- unsigned int list_size, pos, i;
- struct str_list_sort_item *arr = NULL;
+ static const char _error_msg_prefix[] = "_report_field_string_list: ";
+ unsigned int list_size, i, pos;
+ struct str_pos_len *arr = NULL;
struct dm_str_list *sl;
- size_t delimiter_len, len;
- void *object;
+ size_t delimiter_len, repstr_str_len, repstr_size;
+ char *repstr = NULL;
+ struct pos_len *repstr_extra;
+ struct str_list_sort_value *sortval = NULL;
int r = 0;
- if (!(sort_value = dm_pool_zalloc(rh->mem, sizeof(struct str_list_sort_value)))) {
- log_error("dm_report_field_string_list: dm_pool_zalloc failed for sort_value");
- return 0;
- }
-
- list_size = dm_list_size(data);
-
/*
- * Sort value stores the pointer to the report_string and then
- * position and length for each list element withing the report_string.
- * The first element stores number of elements in 'len' (therefore
- * list_size + 1 is used below for the extra element).
- * For example, with this input:
- * sort = 0; (we don't want to report sorted)
- * report_string = "abc,xy,defgh"; (this is reported)
+ * The 'field->report_string' has 2 parts:
+ *
+ * - string representing the whole string list
+ * (terminated by '\0' at its end as usual)
+ *
+ * - extra info beyond the end of the string representing
+ * position and length of each list item within the
+ * field->report_string (array of 'struct pos_len')
+ *
+ * We can use the extra info to unambiguously identify list items,
+ * the delimiter is not enough here as it's not assured it won't appear
+ * in list item itself. We will make use of this extra info in case
+ * we need to apply further formatting to the list in dm_report_output
+ * where the pure field->report_string is not enough for printout.
+ *
+ *
+ * The 'field->sort_value' contains a value of type 'struct
+ * str_list_sort_value' ('sortval'). This one has a pointer to the
+ * 'field->report_string' string ('sortval->value') and info
+ * about position and length of each list item within the string
+ * (array of 'struct pos_len').
+ *
+ *
+ * The 'field->report_string' is either in sorted or unsorted form,
+ * depending on 'sort_repstr' arg.
*
- * ...we end up with:
- * sort_value->value = report_string; (we'll use the original report_string for indices)
- * sort_value->items[0] = {0,3}; (we have 3 items)
- * sort_value->items[1] = {0,3}; ("abc")
- * sort_value->items[2] = {7,5}; ("defgh")
- * sort_value->items[3] = {4,2}; ("xy")
+ * The 'field->sort_value.items' is always in sorted form because
+ * we need that for effective sorting and selection.
*
- * The items alone are always sorted while in report_string they can be
- * sorted or not (based on "sort" arg) - it depends on how we prefer to
- * display the list. Having items sorted internally helps with searching
- * through them.
+ * If 'field->report_string' is sorted, then field->report_string
+ * and field->sort_value.items share the same array of
+ * 'struct pos_len' (because they're both sorted the same way),
+ * otherwise, each one has its own array.
+ *
+ * The very first item in the array of 'struct pos_len' is always
+ * a pair denoting '[list_size,strlen(field->report_string)]'. The
+ * rest of items denote start and lenght of each item in the list.
+ *
+ *
+ * For example, if we have a list with "abc", "xy", "defgh"
+ * as input and delimiter is ",", we end up with either:
+ *
+ * A) if we don't want the report string sorted ('sort_repstr == 0'):
+ *
+ * - field->report_string = repstr
+ *
+ * repstr repstr_extra
+ * | |
+ * V V
+ * abc,xy,defgh\0{[3,12],[0,3],[4,2],[7,5]}
+ * |____________||________________________|
+ * string array of struct pos_len
+ * |____||________________|
+ * #items items
+ *
+ * - field->sort_value = sortval
+ *
+ * sortval->value = repstr
+ * sortval->items = {[3,12],[0,3],[7,5],[4,2]}
+ * (that is 'abc,defgh,xy')
+ *
+ *
+ * B) if we want the report string sorted ('sort_repstr == 1'):
+ *
+ * - field->report_string = repstr
+ *
+ * repstr repstr_extra
+ * | |
+ * V V
+ * abc,defgh,xy\0{[3,12],[0,3],[4,5],[10,2]}
+ * |____________||________________________|
+ * string array of struct pos_len
+ * |____||________________|
+ * #items items
+ *
+ * - field->sort_value = sortval
+ *
+ * sortval->value = repstr
+ * sortval->items = repstr_extra
+ * (that is 'abc,defgh,xy')
*/
- if (!(sort_value->items = dm_pool_zalloc(rh->mem, (list_size + 1) * sizeof(struct str_list_sort_value_item)))) {
- log_error("dm_report_fiel_string_list: dm_pool_zalloc failed for sort value items");
+
+ if (!delimiter)
+ delimiter = FIELD_STRING_LIST_DEFAULT_DELIMITER;
+ delimiter_len = strlen(delimiter);
+ list_size = dm_list_size(data);
+
+ if (!(sortval = dm_pool_alloc(rh->mem, sizeof(struct str_list_sort_value)))) {
+ log_error("%s failed to allocate sort value structure", _error_msg_prefix);
goto out;
}
- sort_value->items[0].len = list_size;
/* zero items */
- if (!list_size) {
- sort_value->value = field->report_string = "";
- field->sort_value = sort_value;
+ if (list_size == 0) {
+ field->report_string = sortval->value = "";
+ sortval->items = NULL;
+ field->sort_value = sortval;
return 1;
}
/* one item */
if (list_size == 1) {
sl = (struct dm_str_list *) dm_list_first(data);
- if (!sl ||
- !(sort_value->value = field->report_string = dm_pool_strdup(rh->mem, sl->str))) {
- log_error("dm_report_field_string_list: dm_pool_strdup failed");
+
+ repstr_str_len = strlen(sl->str);
+ repstr_size = repstr_str_len + 1 + (2 * sizeof(struct pos_len));
+
+ if (!(repstr = dm_pool_alloc(rh->mem, repstr_size))) {
+ log_error("%s failed to allocate report string structure", _error_msg_prefix);
goto out;
}
- sort_value->items[1].pos = 0;
- sort_value->items[1].len = strlen(sl->str);
- field->sort_value = sort_value;
- return 1;
- }
+ repstr_extra = (struct pos_len *) (repstr + repstr_str_len + 1);
- /* more than one item - sort the list */
- if (!(arr = malloc(sizeof(struct str_list_sort_item) * list_size))) {
- log_error("dm_report_field_string_list: malloc failed");
- goto out;
+ memcpy(repstr, sl->str, repstr_str_len + 1);
+ memcpy(repstr_extra, &((struct pos_len) {.pos = 1, .len = repstr_str_len}), sizeof(struct pos_len));
+ memcpy(repstr_extra + 1, &((struct pos_len) {.pos = 0, .len = repstr_str_len}), sizeof(struct pos_len));
+
+ sortval->value = field->report_string = repstr;
+ sortval->items = repstr_extra;
+ field->sort_value = sortval;
+ return 1;
}
- if (!(dm_pool_begin_object(rh->mem, 256))) {
- log_error(_string_list_grow_object_failed_msg);
+ /* more than one item - allocate temporary array for string list items for further processing */
+ if (!(arr = malloc(list_size * sizeof(struct str_pos_len)))) {
+ log_error("%s failed to allocate temporary array for processing", _error_msg_prefix);
goto out;
}
- if (!delimiter)
- delimiter = ",";
- delimiter_len = strlen(delimiter);
-
- i = pos = 0;
+ i = 0;
+ repstr_size = 0;
dm_list_iterate_items(sl, data) {
arr[i].str = sl->str;
- if (!sort) {
- /* sorted outpud not required - report the list as it is */
- len = strlen(sl->str);
- if (!dm_pool_grow_object(rh->mem, arr[i].str, len) ||
- (i+1 != list_size && !dm_pool_grow_object(rh->mem, delimiter, delimiter_len))) {
- log_error(_string_list_grow_object_failed_msg);
- goto out;
- }
- arr[i].item.pos = pos;
- arr[i].item.len = len;
- pos = i+1 == list_size ? pos+len : pos+len+delimiter_len;
- }
+ repstr_size += (arr[i].item.len = strlen(sl->str));
i++;
}
- qsort(arr, i, sizeof(struct str_list_sort_item), _str_list_sort_item_cmp);
+ /*
+ * At this point, repstr_size contains sum of lengths of all string list items.
+ * Now, add these to the repstr_size:
+ *
+ * --> sum of character count used by all delimiters: + ((list_size - 1) * delimiter_len)
+ *
+ * --> '\0' used at the end of the string list: + 1
+ *
+ * --> sum of structures used to keep info about pos and length of each string list item:
+ * [0, <list_size>] [<pos1>,<size1>] [<pos2>,<size2>] ...
+ * That is: + ((list_size + 1) * sizeof(struct pos_len))
+ */
+ repstr_size += ((list_size - 1) * delimiter_len);
+ repstr_str_len = repstr_size;
+ repstr_size += 1 + ((list_size + 1) * sizeof(struct pos_len));
+
+ if (sort_repstr)
+ qsort(arr, list_size, sizeof(struct str_pos_len), _str_sort_cmp);
+ if (!(repstr = dm_pool_alloc(rh->mem, repstr_size))) {
+ log_error("%s failed to allocate report string structure", _error_msg_prefix);
+ goto out;
+ }
+ repstr_extra = (struct pos_len *) (repstr + repstr_str_len + 1);
+
+ memcpy(repstr_extra, &(struct pos_len) {.pos = list_size, .len = repstr_str_len}, sizeof(struct pos_len));
for (i = 0, pos = 0; i < list_size; i++) {
- if (sort) {
- /* sorted output required - report the list as sorted */
- len = strlen(arr[i].str);
- if (!dm_pool_grow_object(rh->mem, arr[i].str, len) ||
- (i+1 != list_size && !dm_pool_grow_object(rh->mem, delimiter, delimiter_len))) {
- log_error(_string_list_grow_object_failed_msg);
- goto out;
- }
- /*
- * Save position and length of the string
- * element in report_string for sort_value.
- * Use i+1 here since items[0] stores list size!!!
- */
- sort_value->items[i+1].pos = pos;
- sort_value->items[i+1].len = len;
- pos = i+1 == list_size ? pos+len : pos+len+delimiter_len;
- } else {
- sort_value->items[i+1].pos = arr[i].item.pos;
- sort_value->items[i+1].len = arr[i].item.len;
+ arr[i].item.pos = pos;
+
+ memcpy(repstr + pos, arr[i].str, arr[i].item.len);
+ memcpy(repstr_extra + i + 1, &arr[i].item, sizeof(struct pos_len));
+
+ pos += arr[i].item.len;
+ if (i + 1 < list_size) {
+ memcpy(repstr + pos, delimiter, delimiter_len);
+ pos += delimiter_len;
}
}
+ *(repstr + pos) = '\0';
- if (!dm_pool_grow_object(rh->mem, "\0", 1)) {
- log_error(_string_list_grow_object_failed_msg);
- goto out;
+ sortval->value = repstr;
+ if (sort_repstr)
+ sortval->items = repstr_extra;
+ else {
+ if (!(sortval->items = dm_pool_alloc(rh->mem, (list_size + 1) * sizeof(struct pos_len)))) {
+ log_error("%s failed to allocate array of items inside sort value structure",
+ _error_msg_prefix);
+ goto out;
+ }
+
+ qsort(arr, list_size, sizeof(struct str_pos_len), _str_sort_cmp);
+
+ sortval->items[0] = (struct pos_len) {.pos = list_size, .len = repstr_str_len};
+ for (i = 0; i < list_size; i++)
+ sortval->items[i+1] = arr[i].item;
}
- object = dm_pool_end_object(rh->mem);
- sort_value->value = object;
- field->sort_value = sort_value;
- field->report_string = object;
+ field->report_string = repstr;
+ field->sort_value = sortval;
r = 1;
out:
- if (!r && sort_value)
- dm_pool_free(rh->mem, sort_value);
+ if (!r && sortval)
+ dm_pool_free(rh->mem, sortval);
free(arr);
-
return r;
}
@@ -1688,7 +1762,7 @@ static int _cmp_field_string_list_strict_all(const struct str_list_sort_value *v
struct dm_str_list *sel_item;
unsigned int i = 1;
- if (!val->items[0].len) {
+ if (!val->items) {
if (sel_list_size == 1) {
/* match blank string list with selection defined as blank string only */
sel_item = dm_list_item(dm_list_first(&sel->str_list.list), struct dm_str_list);
@@ -1698,7 +1772,7 @@ static int _cmp_field_string_list_strict_all(const struct str_list_sort_value *v
}
/* if item count differs, it's clear the lists do not match */
- if (val->items[0].len != sel_list_size)
+ if (val->items[0].pos != sel_list_size)
return 0;
/* both lists are sorted so they either match 1:1 or not */
@@ -1721,7 +1795,7 @@ static int _cmp_field_string_list_subset_all(const struct str_list_sort_value *v
unsigned int i, last_found = 1;
int r = 0;
- if (!val->items[0].len) {
+ if (!val->items) {
if (sel_list_size == 1) {
/* match blank string list with selection defined as blank string only */
sel_item = dm_list_item(dm_list_first(&sel->str_list.list), struct dm_str_list);
@@ -1733,7 +1807,7 @@ static int _cmp_field_string_list_subset_all(const struct str_list_sort_value *v
/* check selection is a subset of the value */
dm_list_iterate_items(sel_item, &sel->str_list.list) {
r = 0;
- for (i = last_found; i <= val->items[0].len; i++) {
+ for (i = last_found; i <= val->items[0].pos; i++) {
if ((strlen(sel_item->str) == val->items[i].len) &&
!strncmp(sel_item->str, val->value + val->items[i].pos, val->items[i].len)) {
last_found = i;
@@ -1755,7 +1829,7 @@ static int _cmp_field_string_list_any(const struct str_list_sort_value *val,
unsigned int i;
/* match blank string list with selection that contains blank string */
- if (!val->items[0].len) {
+ if (!val->items) {
dm_list_iterate_items(sel_item, &sel->str_list.list) {
if (!strcmp(sel_item->str, ""))
return 1;
@@ -1768,7 +1842,7 @@ static int _cmp_field_string_list_any(const struct str_list_sort_value *val,
* TODO: Optimize this so we don't need to compare the whole lists' content.
* Make use of the fact that the lists are sorted!
*/
- for (i = 1; i <= val->items[0].len; i++) {
+ for (i = 1; i <= val->items[0].pos; i++) {
if ((strlen(sel_item->str) == val->items[i].len) &&
!strncmp(sel_item->str, val->value + val->items[i].pos, val->items[i].len))
return 1;
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index df52ee088..9fac341a4 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -383,172 +383,246 @@ int dm_report_field_percent(struct dm_report *rh,
return 1;
}
-struct str_list_sort_value_item {
+struct pos_len {
unsigned pos;
size_t len;
};
-struct str_list_sort_value {
- const char *value;
- struct str_list_sort_value_item *items;
+struct str_pos_len {
+ const char *str;
+ struct pos_len item;
};
-struct str_list_sort_item {
- const char *str;
- struct str_list_sort_value_item item;
+struct str_list_sort_value {
+ const char *value;
+ struct pos_len *items;
};
-static int _str_list_sort_item_cmp(const void *a, const void *b)
+static int _str_sort_cmp(const void *a, const void *b)
{
- const struct str_list_sort_item *slsi_a = (const struct str_list_sort_item *) a;
- const struct str_list_sort_item *slsi_b = (const struct str_list_sort_item *) b;
-
- return strcmp(slsi_a->str, slsi_b->str);
+ return strcmp(((const struct str_pos_len *) a)->str, ((const struct str_pos_len *) b)->str);
}
+#define FIELD_STRING_LIST_DEFAULT_DELIMITER ","
+
static int _report_field_string_list(struct dm_report *rh,
struct dm_report_field *field,
const struct dm_list *data,
const char *delimiter,
- int sort)
+ int sort_repstr)
{
- static const char _string_list_grow_object_failed_msg[] = "dm_report_field_string_list: dm_pool_grow_object_failed";
- struct str_list_sort_value *sort_value = NULL;
- unsigned int list_size, pos, i;
- struct str_list_sort_item *arr = NULL;
+ static const char _error_msg_prefix[] = "_report_field_string_list: ";
+ unsigned int list_size, i, pos;
+ struct str_pos_len *arr = NULL;
struct dm_str_list *sl;
- size_t delimiter_len, len;
- void *object;
+ size_t delimiter_len, repstr_str_len, repstr_size;
+ char *repstr = NULL;
+ struct pos_len *repstr_extra;
+ struct str_list_sort_value *sortval = NULL;
int r = 0;
- if (!(sort_value = dm_pool_zalloc(rh->mem, sizeof(struct str_list_sort_value)))) {
- log_error("dm_report_field_string_list: dm_pool_zalloc failed for sort_value");
- return 0;
- }
-
- list_size = dm_list_size(data);
-
/*
- * Sort value stores the pointer to the report_string and then
- * position and length for each list element withing the report_string.
- * The first element stores number of elements in 'len' (therefore
- * list_size + 1 is used below for the extra element).
- * For example, with this input:
- * sort = 0; (we don't want to report sorted)
- * report_string = "abc,xy,defgh"; (this is reported)
+ * The 'field->report_string' has 2 parts:
+ *
+ * - string representing the whole string list
+ * (terminated by '\0' at its end as usual)
+ *
+ * - extra info beyond the end of the string representing
+ * position and length of each list item within the
+ * field->report_string (array of 'struct pos_len')
+ *
+ * We can use the extra info to unambiguously identify list items,
+ * the delimiter is not enough here as it's not assured it won't appear
+ * in list item itself. We will make use of this extra info in case
+ * we need to apply further formatting to the list in dm_report_output
+ * where the pure field->report_string is not enough for printout.
+ *
+ *
+ * The 'field->sort_value' contains a value of type 'struct
+ * str_list_sort_value' ('sortval'). This one has a pointer to the
+ * 'field->report_string' string ('sortval->value') and info
+ * about position and length of each list item within the string
+ * (array of 'struct pos_len').
+ *
+ *
+ * The 'field->report_string' is either in sorted or unsorted form,
+ * depending on 'sort_repstr' arg.
*
- * ...we end up with:
- * sort_value->value = report_string; (we'll use the original report_string for indices)
- * sort_value->items[0] = {0,3}; (we have 3 items)
- * sort_value->items[1] = {0,3}; ("abc")
- * sort_value->items[2] = {7,5}; ("defgh")
- * sort_value->items[3] = {4,2}; ("xy")
+ * The 'field->sort_value.items' is always in sorted form because
+ * we need that for effective sorting and selection.
*
- * The items alone are always sorted while in report_string they can be
- * sorted or not (based on "sort" arg) - it depends on how we prefer to
- * display the list. Having items sorted internally helps with searching
- * through them.
+ * If 'field->report_string' is sorted, then field->report_string
+ * and field->sort_value.items share the same array of
+ * 'struct pos_len' (because they're both sorted the same way),
+ * otherwise, each one has its own array.
+ *
+ * The very first item in the array of 'struct pos_len' is always
+ * a pair denoting '[list_size,strlen(field->report_string)]'. The
+ * rest of items denote start and lenght of each item in the list.
+ *
+ *
+ * For example, if we have a list with "abc", "xy", "defgh"
+ * as input and delimiter is ",", we end up with either:
+ *
+ * A) if we don't want the report string sorted ('sort_repstr == 0'):
+ *
+ * - field->report_string = repstr
+ *
+ * repstr repstr_extra
+ * | |
+ * V V
+ * abc,xy,defgh\0{[3,12],[0,3],[4,2],[7,5]}
+ * |____________||________________________|
+ * string array of struct pos_len
+ * |____||________________|
+ * #items items
+ *
+ * - field->sort_value = sortval
+ *
+ * sortval->value = repstr
+ * sortval->items = {[3,12],[0,3],[7,5],[4,2]}
+ * (that is 'abc,defgh,xy')
+ *
+ *
+ * B) if we want the report string sorted ('sort_repstr == 1'):
+ *
+ * - field->report_string = repstr
+ *
+ * repstr repstr_extra
+ * | |
+ * V V
+ * abc,defgh,xy\0{[3,12],[0,3],[4,5],[10,2]}
+ * |____________||________________________|
+ * string array of struct pos_len
+ * |____||________________|
+ * #items items
+ *
+ * - field->sort_value = sortval
+ *
+ * sortval->value = repstr
+ * sortval->items = repstr_extra
+ * (that is 'abc,defgh,xy')
*/
- if (!(sort_value->items = dm_pool_zalloc(rh->mem, (list_size + 1) * sizeof(struct str_list_sort_value_item)))) {
- log_error("dm_report_fiel_string_list: dm_pool_zalloc failed for sort value items");
+
+ if (!delimiter)
+ delimiter = FIELD_STRING_LIST_DEFAULT_DELIMITER;
+ delimiter_len = strlen(delimiter);
+ list_size = dm_list_size(data);
+
+ if (!(sortval = dm_pool_alloc(rh->mem, sizeof(struct str_list_sort_value)))) {
+ log_error("%s failed to allocate sort value structure", _error_msg_prefix);
goto out;
}
- sort_value->items[0].len = list_size;
/* zero items */
- if (!list_size) {
- sort_value->value = field->report_string = "";
- field->sort_value = sort_value;
+ if (list_size == 0) {
+ field->report_string = sortval->value = "";
+ sortval->items = NULL;
+ field->sort_value = sortval;
return 1;
}
/* one item */
if (list_size == 1) {
sl = (struct dm_str_list *) dm_list_first(data);
- if (!sl ||
- !(sort_value->value = field->report_string = dm_pool_strdup(rh->mem, sl->str))) {
- log_error("dm_report_field_string_list: dm_pool_strdup failed");
+
+ repstr_str_len = strlen(sl->str);
+ repstr_size = repstr_str_len + 1 + (2 * sizeof(struct pos_len));
+
+ if (!(repstr = dm_pool_alloc(rh->mem, repstr_size))) {
+ log_error("%s failed to allocate report string structure", _error_msg_prefix);
goto out;
}
- sort_value->items[1].pos = 0;
- sort_value->items[1].len = strlen(sl->str);
- field->sort_value = sort_value;
- return 1;
- }
+ repstr_extra = (struct pos_len *) (repstr + repstr_str_len + 1);
- /* more than one item - sort the list */
- if (!(arr = dm_malloc(sizeof(struct str_list_sort_item) * list_size))) {
- log_error("dm_report_field_string_list: dm_malloc failed");
- goto out;
+ memcpy(repstr, sl->str, repstr_str_len + 1);
+ memcpy(repstr_extra, &((struct pos_len) {.pos = 1, .len = repstr_str_len}), sizeof(struct pos_len));
+ memcpy(repstr_extra + 1, &((struct pos_len) {.pos = 0, .len = repstr_str_len}), sizeof(struct pos_len));
+
+ sortval->value = field->report_string = repstr;
+ sortval->items = repstr_extra;
+ field->sort_value = sortval;
+ return 1;
}
- if (!(dm_pool_begin_object(rh->mem, 256))) {
- log_error(_string_list_grow_object_failed_msg);
+ /* more than one item - allocate temporary array for string list items for further processing */
+ if (!(arr = dm_malloc(list_size * sizeof(struct str_pos_len)))) {
+ log_error("%s failed to allocate temporary array for processing", _error_msg_prefix);
goto out;
}
- if (!delimiter)
- delimiter = ",";
- delimiter_len = strlen(delimiter);
-
- i = pos = 0;
+ i = 0;
+ repstr_size = 0;
dm_list_iterate_items(sl, data) {
arr[i].str = sl->str;
- if (!sort) {
- /* sorted outpud not required - report the list as it is */
- len = strlen(sl->str);
- if (!dm_pool_grow_object(rh->mem, arr[i].str, len) ||
- (i+1 != list_size && !dm_pool_grow_object(rh->mem, delimiter, delimiter_len))) {
- log_error(_string_list_grow_object_failed_msg);
- goto out;
- }
- arr[i].item.pos = pos;
- arr[i].item.len = len;
- pos = i+1 == list_size ? pos+len : pos+len+delimiter_len;
- }
+ repstr_size += (arr[i].item.len = strlen(sl->str));
i++;
}
- qsort(arr, i, sizeof(struct str_list_sort_item), _str_list_sort_item_cmp);
+ /*
+ * At this point, repstr_size contains sum of lengths of all string list items.
+ * Now, add these to the repstr_size:
+ *
+ * --> sum of character count used by all delimiters: + ((list_size - 1) * delimiter_len)
+ *
+ * --> '\0' used at the end of the string list: + 1
+ *
+ * --> sum of structures used to keep info about pos and length of each string list item:
+ * [0, <list_size>] [<pos1>,<size1>] [<pos2>,<size2>] ...
+ * That is: + ((list_size + 1) * sizeof(struct pos_len))
+ */
+ repstr_size += ((list_size - 1) * delimiter_len);
+ repstr_str_len = repstr_size;
+ repstr_size += 1 + ((list_size + 1) * sizeof(struct pos_len));
+
+ if (sort_repstr)
+ qsort(arr, list_size, sizeof(struct str_pos_len), _str_sort_cmp);
+ if (!(repstr = dm_pool_alloc(rh->mem, repstr_size))) {
+ log_error("%s failed to allocate report string structure", _error_msg_prefix);
+ goto out;
+ }
+ repstr_extra = (struct pos_len *) (repstr + repstr_str_len + 1);
+
+ memcpy(repstr_extra, &(struct pos_len) {.pos = list_size, .len = repstr_str_len}, sizeof(struct pos_len));
for (i = 0, pos = 0; i < list_size; i++) {
- if (sort) {
- /* sorted output required - report the list as sorted */
- len = strlen(arr[i].str);
- if (!dm_pool_grow_object(rh->mem, arr[i].str, len) ||
- (i+1 != list_size && !dm_pool_grow_object(rh->mem, delimiter, delimiter_len))) {
- log_error(_string_list_grow_object_failed_msg);
- goto out;
- }
- /*
- * Save position and length of the string
- * element in report_string for sort_value.
- * Use i+1 here since items[0] stores list size!!!
- */
- sort_value->items[i+1].pos = pos;
- sort_value->items[i+1].len = len;
- pos = i+1 == list_size ? pos+len : pos+len+delimiter_len;
- } else {
- sort_value->items[i+1].pos = arr[i].item.pos;
- sort_value->items[i+1].len = arr[i].item.len;
+ arr[i].item.pos = pos;
+
+ memcpy(repstr + pos, arr[i].str, arr[i].item.len);
+ memcpy(repstr_extra + i + 1, &arr[i].item, sizeof(struct pos_len));
+
+ pos += arr[i].item.len;
+ if (i + 1 < list_size) {
+ memcpy(repstr + pos, delimiter, delimiter_len);
+ pos += delimiter_len;
}
}
+ *(repstr + pos) = '\0';
- if (!dm_pool_grow_object(rh->mem, "\0", 1)) {
- log_error(_string_list_grow_object_failed_msg);
- goto out;
+ sortval->value = repstr;
+ if (sort_repstr)
+ sortval->items = repstr_extra;
+ else {
+ if (!(sortval->items = dm_pool_alloc(rh->mem, (list_size + 1) * sizeof(struct pos_len)))) {
+ log_error("%s failed to allocate array of items inside sort value structure",
+ _error_msg_prefix);
+ goto out;
+ }
+
+ qsort(arr, list_size, sizeof(struct str_pos_len), _str_sort_cmp);
+
+ sortval->items[0] = (struct pos_len) {.pos = list_size, .len = repstr_str_len};
+ for (i = 0; i < list_size; i++)
+ sortval->items[i+1] = arr[i].item;
}
- object = dm_pool_end_object(rh->mem);
- sort_value->value = object;
- field->sort_value = sort_value;
- field->report_string = object;
+ field->report_string = repstr;
+ field->sort_value = sortval;
r = 1;
out:
- if (!r && sort_value)
- dm_pool_free(rh->mem, sort_value);
+ if (!r && sortval)
+ dm_pool_free(rh->mem, sortval);
dm_free(arr);
-
return r;
}
@@ -1687,7 +1761,7 @@ static int _cmp_field_string_list_strict_all(const struct str_list_sort_value *v
struct dm_str_list *sel_item;
unsigned int i = 1;
- if (!val->items[0].len) {
+ if (!val->items) {
if (sel_list_size == 1) {
/* match blank string list with selection defined as blank string only */
sel_item = dm_list_item(dm_list_first(&sel->str_list.list), struct dm_str_list);
@@ -1697,7 +1771,7 @@ static int _cmp_field_string_list_strict_all(const struct str_list_sort_value *v
}
/* if item count differs, it's clear the lists do not match */
- if (val->items[0].len != sel_list_size)
+ if (val->items[0].pos != sel_list_size)
return 0;
/* both lists are sorted so they either match 1:1 or not */
@@ -1720,7 +1794,7 @@ static int _cmp_field_string_list_subset_all(const struct str_list_sort_value *v
unsigned int i, last_found = 1;
int r = 0;
- if (!val->items[0].len) {
+ if (!val->items) {
if (sel_list_size == 1) {
/* match blank string list with selection defined as blank string only */
sel_item = dm_list_item(dm_list_first(&sel->str_list.list), struct dm_str_list);
@@ -1732,7 +1806,7 @@ static int _cmp_field_string_list_subset_all(const struct str_list_sort_value *v
/* check selection is a subset of the value */
dm_list_iterate_items(sel_item, &sel->str_list.list) {
r = 0;
- for (i = last_found; i <= val->items[0].len; i++) {
+ for (i = last_found; i <= val->items[0].pos; i++) {
if ((strlen(sel_item->str) == val->items[i].len) &&
!strncmp(sel_item->str, val->value + val->items[i].pos, val->items[i].len)) {
last_found = i;
@@ -1754,7 +1828,7 @@ static int _cmp_field_string_list_any(const struct str_list_sort_value *val,
unsigned int i;
/* match blank string list with selection that contains blank string */
- if (!val->items[0].len) {
+ if (!val->items) {
dm_list_iterate_items(sel_item, &sel->str_list.list) {
if (!strcmp(sel_item->str, ""))
return 1;
@@ -1767,7 +1841,7 @@ static int _cmp_field_string_list_any(const struct str_list_sort_value *val,
* TODO: Optimize this so we don't need to compare the whole lists' content.
* Make use of the fact that the lists are sorted!
*/
- for (i = 1; i <= val->items[0].len; i++) {
+ for (i = 1; i <= val->items[0].pos; i++) {
if ((strlen(sel_item->str) == val->items[i].len) &&
!strncmp(sel_item->str, val->value + val->items[i].pos, val->items[i].len))
return 1;
1 year, 8 months
main - libdm: report: use 'null' for undefined numeric values in JSON_STD output
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1e31621cebfb38f6522...
Commit: 1e31621cebfb38f652233e2f80dd081cca5e8374
Parent: 99299eb728d29b996a5ddacef7bafff2029e7d2e
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jun 29 16:00:25 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 11 11:10:11 2022 +0200
libdm: report: use 'null' for undefined numeric values in JSON_STD output
For JSON_STD format, use 'null' if a field has no value at all.
In JSON format, we print undefined numeric values this way:
"key" = ""
while in JSON_STD format, we print undefined numeric values this way:
"key" = null
(Keep in mind that 'null' is different from 0 (zero value) which is
a defined value.)
---
device_mapper/libdm-report.c | 8 +++++++-
libdm/libdm-report.c | 8 +++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/device_mapper/libdm-report.c b/device_mapper/libdm-report.c
index 866ad454e..3c4b01127 100644
--- a/device_mapper/libdm-report.c
+++ b/device_mapper/libdm-report.c
@@ -4360,6 +4360,7 @@ static int _sort_rows(struct dm_report *rh)
#define JSON_ARRAY_START "["
#define JSON_ARRAY_END "]"
#define JSON_ESCAPE_CHAR "\\"
+#define JSON_NULL "null"
#define UNABLE_TO_EXTEND_OUTPUT_LINE_MSG "dm_report: Unable to extend output line"
@@ -4449,8 +4450,13 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
}
}
- repstr = field->report_string;
+ if (_is_json_std_report(rh) && _is_pure_numeric_field(field) && !*field->report_string)
+ repstr = JSON_NULL;
+ else
+ repstr = field->report_string;
+
width = field->props->width;
+
if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
if (_is_json_report(rh)) {
/* Escape any JSON_QUOTE that may appear in reported string. */
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 122a911c8..df52ee088 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -4359,6 +4359,7 @@ static int _sort_rows(struct dm_report *rh)
#define JSON_ARRAY_START "["
#define JSON_ARRAY_END "]"
#define JSON_ESCAPE_CHAR "\\"
+#define JSON_NULL "null"
#define UNABLE_TO_EXTEND_OUTPUT_LINE_MSG "dm_report: Unable to extend output line"
@@ -4448,8 +4449,13 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
}
}
- repstr = field->report_string;
+ if (_is_json_std_report(rh) && _is_pure_numeric_field(field) && !*field->report_string)
+ repstr = JSON_NULL;
+ else
+ repstr = field->report_string;
+
width = field->props->width;
+
if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
if (_is_json_report(rh)) {
/* Escape any JSON_QUOTE that may appear in reported string. */
1 year, 8 months
main - libdm: report: remove double quotes around numeric values in JSON_STD output
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=99299eb728d29b996a5...
Commit: 99299eb728d29b996a5ddacef7bafff2029e7d2e
Parent: 02f015990b2d077f304e19c9ff11728d4480bee8
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jun 27 09:29:55 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 11 11:10:11 2022 +0200
libdm: report: remove double quotes around numeric values in JSON_STD output
In JSON format, we print numeric values this way:
"key" = "N"
while in JSON_STD format, we print numeric value this way:
"key" = N
(Where N is a numeric value.)
---
device_mapper/libdm-report.c | 27 ++++++++++++++++++++-------
libdm/libdm-report.c | 27 ++++++++++++++++++++-------
2 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/device_mapper/libdm-report.c b/device_mapper/libdm-report.c
index 2e1f443f6..866ad454e 100644
--- a/device_mapper/libdm-report.c
+++ b/device_mapper/libdm-report.c
@@ -4382,6 +4382,11 @@ static int _is_json_report(struct dm_report *rh)
rh->group_item->group->type == DM_REPORT_GROUP_JSON_STD);
}
+static int _is_pure_numeric_field(struct dm_report_field *field)
+{
+ return field->props->flags & (DM_REPORT_FIELD_TYPE_NUMBER | DM_REPORT_FIELD_TYPE_PERCENT);
+}
+
/*
* Produce report output
*/
@@ -4401,10 +4406,16 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
!dm_pool_grow_object(rh->mem, fields[field->props->field_num].id, 0) ||
!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
- !dm_pool_grow_object(rh->mem, JSON_PAIR, 1) ||
- !dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
- log_error("dm_report: Unable to extend output line");
- return 0;
+ !dm_pool_grow_object(rh->mem, JSON_PAIR, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
+
+ if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
}
} else if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
if (!(field_id = strdup(fields[field->props->field_num].id))) {
@@ -4513,9 +4524,11 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
}
}
} else if (_is_json_report(rh)) {
- if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- goto bad;
+ if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
}
}
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index b43ac4298..122a911c8 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -4381,6 +4381,11 @@ static int _is_json_report(struct dm_report *rh)
rh->group_item->group->type == DM_REPORT_GROUP_JSON_STD);
}
+static int _is_pure_numeric_field(struct dm_report_field *field)
+{
+ return field->props->flags & (DM_REPORT_FIELD_TYPE_NUMBER | DM_REPORT_FIELD_TYPE_PERCENT);
+}
+
/*
* Produce report output
*/
@@ -4400,10 +4405,16 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
!dm_pool_grow_object(rh->mem, fields[field->props->field_num].id, 0) ||
!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
- !dm_pool_grow_object(rh->mem, JSON_PAIR, 1) ||
- !dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
- log_error("dm_report: Unable to extend output line");
- return 0;
+ !dm_pool_grow_object(rh->mem, JSON_PAIR, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
+
+ if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
}
} else if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
if (!(field_id = dm_strdup(fields[field->props->field_num].id))) {
@@ -4512,9 +4523,11 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
}
}
} else if (_is_json_report(rh)) {
- if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- goto bad;
+ if (!(_is_json_std_report(rh) && _is_pure_numeric_field(field))) {
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
}
}
1 year, 8 months
main - libdm: report: add DM_REPORT_GROUP_JSON_STD group
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=02f015990b2d077f304...
Commit: 02f015990b2d077f304e19c9ff11728d4480bee8
Parent: 2fc52b6c41172fc4ae15e736fae095aa681ff03a
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Aug 4 15:06:58 2022 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Aug 11 11:10:11 2022 +0200
libdm: report: add DM_REPORT_GROUP_JSON_STD group
The original JSON formatting will be still available using the original
DM_REPORT_GROUP_JSON identifier. Subsequent patches will add enhancements
to JSON formatting code so that it adheres more to JSON standard - this
will be identified by new DM_REPORT_GROUP_JSON_STD identifier.
---
device_mapper/all.h | 3 ++-
device_mapper/libdm-report.c | 13 +++++++++++--
libdm/libdevmapper.h | 3 ++-
libdm/libdm-report.c | 13 +++++++++++--
4 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/device_mapper/all.h b/device_mapper/all.h
index 34d65885e..b70a8f29c 100644
--- a/device_mapper/all.h
+++ b/device_mapper/all.h
@@ -1983,7 +1983,8 @@ struct dm_report_group;
typedef enum {
DM_REPORT_GROUP_SINGLE,
DM_REPORT_GROUP_BASIC,
- DM_REPORT_GROUP_JSON
+ DM_REPORT_GROUP_JSON,
+ DM_REPORT_GROUP_JSON_STD
} dm_report_group_type_t;
struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void *data);
diff --git a/device_mapper/libdm-report.c b/device_mapper/libdm-report.c
index 13a8e46b1..2e1f443f6 100644
--- a/device_mapper/libdm-report.c
+++ b/device_mapper/libdm-report.c
@@ -4369,10 +4369,17 @@ static int _is_basic_report(struct dm_report *rh)
(rh->group_item->group->type == DM_REPORT_GROUP_BASIC);
}
+static int _is_json_std_report(struct dm_report *rh)
+{
+ return rh->group_item &&
+ rh->group_item->group->type == DM_REPORT_GROUP_JSON_STD;
+}
+
static int _is_json_report(struct dm_report *rh)
{
return rh->group_item &&
- (rh->group_item->group->type == DM_REPORT_GROUP_JSON);
+ (rh->group_item->group->type == DM_REPORT_GROUP_JSON ||
+ rh->group_item->group->type == DM_REPORT_GROUP_JSON_STD);
}
/*
@@ -4983,6 +4990,7 @@ int dm_report_group_push(struct dm_report_group *group, struct dm_report *report
goto_bad;
break;
case DM_REPORT_GROUP_JSON:
+ case DM_REPORT_GROUP_JSON_STD:
if (!_report_group_push_json(item, data))
goto_bad;
break;
@@ -5046,6 +5054,7 @@ int dm_report_group_pop(struct dm_report_group *group)
return_0;
break;
case DM_REPORT_GROUP_JSON:
+ case DM_REPORT_GROUP_JSON_STD:
if (!_report_group_pop_json(item))
return_0;
break;
@@ -5082,7 +5091,7 @@ int dm_report_group_output_and_pop_all(struct dm_report_group *group)
return_0;
}
- if (group->type == DM_REPORT_GROUP_JSON) {
+ if (group->type == DM_REPORT_GROUP_JSON || group->type == DM_REPORT_GROUP_JSON_STD) {
_json_output_start(group);
log_print(JSON_OBJECT_END);
group->indent -= JSON_INDENT_UNIT;
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index e9412da7d..c1c6cb40e 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -3170,7 +3170,8 @@ struct dm_report_group;
typedef enum dm_report_group_type_e {
DM_REPORT_GROUP_SINGLE,
DM_REPORT_GROUP_BASIC,
- DM_REPORT_GROUP_JSON
+ DM_REPORT_GROUP_JSON,
+ DM_REPORT_GROUP_JSON_STD
} dm_report_group_type_t;
struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void *data);
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index f3bf628a5..b43ac4298 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -4368,10 +4368,17 @@ static int _is_basic_report(struct dm_report *rh)
(rh->group_item->group->type == DM_REPORT_GROUP_BASIC);
}
+static int _is_json_std_report(struct dm_report *rh)
+{
+ return rh->group_item &&
+ rh->group_item->group->type == DM_REPORT_GROUP_JSON_STD;
+}
+
static int _is_json_report(struct dm_report *rh)
{
return rh->group_item &&
- (rh->group_item->group->type == DM_REPORT_GROUP_JSON);
+ (rh->group_item->group->type == DM_REPORT_GROUP_JSON ||
+ rh->group_item->group->type == DM_REPORT_GROUP_JSON_STD);
}
/*
@@ -4982,6 +4989,7 @@ int dm_report_group_push(struct dm_report_group *group, struct dm_report *report
goto_bad;
break;
case DM_REPORT_GROUP_JSON:
+ case DM_REPORT_GROUP_JSON_STD:
if (!_report_group_push_json(item, data))
goto_bad;
break;
@@ -5045,6 +5053,7 @@ int dm_report_group_pop(struct dm_report_group *group)
return_0;
break;
case DM_REPORT_GROUP_JSON:
+ case DM_REPORT_GROUP_JSON_STD:
if (!_report_group_pop_json(item))
return_0;
break;
@@ -5081,7 +5090,7 @@ int dm_report_group_output_and_pop_all(struct dm_report_group *group)
return_0;
}
- if (group->type == DM_REPORT_GROUP_JSON) {
+ if (group->type == DM_REPORT_GROUP_JSON || group->type == DM_REPORT_GROUP_JSON_STD) {
_json_output_start(group);
log_print(JSON_OBJECT_END);
group->indent -= JSON_INDENT_UNIT;
1 year, 8 months