mbox series

[v3,0/5] dumpe2fs: add JSON output format

Message ID 20180220095950.23462-1-viktor.prutyanov@virtuozzo.com
Headers show
Series dumpe2fs: add JSON output format | expand

Message

Viktor Prutyanov Feb. 20, 2018, 9:59 a.m. UTC
v3: range object format changed from {begin, end} to {start, len}

v2: added JSON indentation, ranges and offsets are represented by objects

This collection of patches adds support of JSON format.
First patch adds helpers for creating structured objects and printing such objects in JSON format.
Others use these helpers for all info from existing operation modes.

After these patches, for example, using jq utility, we can easily print "blocks" field from specific group:

dumpe2fs /dev/sdb2 -j | jq -r '.desc[] | select(.num == "5") | {blocks:.blocks}'

{
  "blocks": {
    "start": "163840",
    "len": "32768"
  }
}

Helpers can later be easily extended to support new output formats (not only JSON).

Viktor Prutyanov (5):
  libsupport: add JSON output helpers
  dumpe2fs: add JSON output of block groups
  dumpe2fs: add JSON output of superblock
  dumpe2fs: add JSON output of journal
  dumpe2fs: add JSON output of bad blocks

 debugfs/Makefile.in     |   4 +-
 lib/e2p/e2p.h           |   8 ++
 lib/e2p/ljs.c           |  57 ++++++++
 lib/e2p/ls.c            | 362 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/e2p/pe.c            |  18 +++
 lib/e2p/ps.c            |  10 ++
 lib/support/Makefile.in |   7 +-
 lib/support/json-out.c  | 326 +++++++++++++++++++++++++++++++++++++++++++
 lib/support/json-out.h  |  69 +++++++++
 misc/Makefile.in        |   8 +-
 misc/dumpe2fs.8.in      |   3 +
 misc/dumpe2fs.c         | 323 ++++++++++++++++++++++++++++++++++++++++--
 12 files changed, 1173 insertions(+), 22 deletions(-)
 create mode 100644 lib/support/json-out.c
 create mode 100644 lib/support/json-out.h

Comments

Viktor Prutyanov March 11, 2018, 3:06 p.m. UTC | #1
ping

В Tue, 20 Feb 2018 12:59:45 +0300
Viktor Prutyanov <viktor.prutyanov@virtuozzo.com> пишет:

> v3: range object format changed from {begin, end} to {start, len}
> 
> v2: added JSON indentation, ranges and offsets are represented by
> objects
> 
> This collection of patches adds support of JSON format.
> First patch adds helpers for creating structured objects and printing
> such objects in JSON format. Others use these helpers for all info
> from existing operation modes.
> 
> After these patches, for example, using jq utility, we can easily
> print "blocks" field from specific group:
> 
> dumpe2fs /dev/sdb2 -j | jq -r '.desc[] | select(.num == "5") |
> {blocks:.blocks}'
> 
> {
>   "blocks": {
>     "start": "163840",
>     "len": "32768"
>   }
> }
> 
> Helpers can later be easily extended to support new output formats
> (not only JSON).
> 
> Viktor Prutyanov (5):
>   libsupport: add JSON output helpers
>   dumpe2fs: add JSON output of block groups
>   dumpe2fs: add JSON output of superblock
>   dumpe2fs: add JSON output of journal
>   dumpe2fs: add JSON output of bad blocks
> 
>  debugfs/Makefile.in     |   4 +-
>  lib/e2p/e2p.h           |   8 ++
>  lib/e2p/ljs.c           |  57 ++++++++
>  lib/e2p/ls.c            | 362
> ++++++++++++++++++++++++++++++++++++++++++++++++
> lib/e2p/pe.c            |  18 +++ lib/e2p/ps.c            |  10 ++
>  lib/support/Makefile.in |   7 +-
>  lib/support/json-out.c  | 326
> +++++++++++++++++++++++++++++++++++++++++++ lib/support/json-out.h
> |  69 +++++++++ misc/Makefile.in        |   8 +-
>  misc/dumpe2fs.8.in      |   3 +
>  misc/dumpe2fs.c         | 323
> ++++++++++++++++++++++++++++++++++++++++-- 12 files changed, 1173
> insertions(+), 22 deletions(-) create mode 100644
> lib/support/json-out.c create mode 100644 lib/support/json-out.h
>
Viktor Prutyanov April 5, 2018, 3:21 p.m. UTC | #2
On Tue, 20 Feb 2018 12:59:45 +0300
Viktor Prutyanov <viktor.prutyanov@virtuozzo.com> wrote:

ping

> v3: range object format changed from {begin, end} to {start, len}
> 
> v2: added JSON indentation, ranges and offsets are represented by
> objects
> 
> This collection of patches adds support of JSON format.
> First patch adds helpers for creating structured objects and printing
> such objects in JSON format. Others use these helpers for all info
> from existing operation modes.
> 
> After these patches, for example, using jq utility, we can easily
> print "blocks" field from specific group:
> 
> dumpe2fs /dev/sdb2 -j | jq -r '.desc[] | select(.num == "5") |
> {blocks:.blocks}'
> 
> {
>   "blocks": {
>     "start": "163840",
>     "len": "32768"
>   }
> }
> 
> Helpers can later be easily extended to support new output formats
> (not only JSON).
> 
> Viktor Prutyanov (5):
>   libsupport: add JSON output helpers
>   dumpe2fs: add JSON output of block groups
>   dumpe2fs: add JSON output of superblock
>   dumpe2fs: add JSON output of journal
>   dumpe2fs: add JSON output of bad blocks
> 
>  debugfs/Makefile.in     |   4 +-
>  lib/e2p/e2p.h           |   8 ++
>  lib/e2p/ljs.c           |  57 ++++++++
>  lib/e2p/ls.c            | 362
> ++++++++++++++++++++++++++++++++++++++++++++++++
> lib/e2p/pe.c            |  18 +++ lib/e2p/ps.c            |  10 ++
>  lib/support/Makefile.in |   7 +-
>  lib/support/json-out.c  | 326
> +++++++++++++++++++++++++++++++++++++++++++ lib/support/json-out.h
> |  69 +++++++++ misc/Makefile.in        |   8 +-
>  misc/dumpe2fs.8.in      |   3 +
>  misc/dumpe2fs.c         | 323
> ++++++++++++++++++++++++++++++++++++++++-- 12 files changed, 1173
> insertions(+), 22 deletions(-) create mode 100644
> lib/support/json-out.c create mode 100644 lib/support/json-out.h
>
Theodore Ts'o April 19, 2018, 3:49 p.m. UTC | #3
These patches are in my git tree.  Unfortunately since they break
builds with shared library enabled, I didn't want to merge them into
the primary master or next branches just yet.

So I've resurrected something which we haven't used for a while, which
is the "proposed updates", or pu branch.  The pu branch is a rewinding
branch, like linux-next[1], so developers should not try to base any
of their branches on it.  It's there so people can see what is "on
deck" for merging into the next branch.  In my internal tree I have
one or more topic branches (in this case, it's "vp/json-dumpe2fs")
which get merged into the pu branch, which is based off of the next
branch when I rebuild it.

[1] https://www.kernel.org/doc/man-pages/linux-next.html

The pu branch is based on the workflow[2] used by the git developers.

[2] https://git-scm.com/docs/gitworkflows

See my other e-mail about my proposal regarding moving the json
support functions to libe2p and what that would require/imply.

						- Ted