From da440e66fb76c50303e79c220ebd5f5ebd1a6895 Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Sun, 13 Aug 2023 11:44:59 +0200 Subject: [PATCH] btrfs-progs: subvol: introduce rowspec definition for json output List and export all fields that may be needed for any subvolume related json output. Signed-off-by: Christoph Heiss Signed-off-by: David Sterba --- cmds/subvolume.c | 25 +++++++++++++++++++++++++ cmds/subvolume.h | 24 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 cmds/subvolume.h diff --git a/cmds/subvolume.c b/cmds/subvolume.c index 65cff24b..cb863ac7 100644 --- a/cmds/subvolume.c +++ b/cmds/subvolume.c @@ -41,9 +41,34 @@ #include "common/open-utils.h" #include "common/string-utils.h" #include "common/units.h" +#include "common/format-output.h" #include "cmds/commands.h" #include "cmds/qgroup.h" +const struct rowspec btrfs_subvolume_rowspec[] = { + { .key = "ID", .fmt = "%llu", .out_json = "id" }, + { .key = "name", .fmt = "%s", .out_json = "name" }, + { .key = "gen", .fmt = "%llu", .out_json = "gen" }, + { .key = "cgen", .fmt = "%llu", .out_json = "cgen" }, + { .key = "parent", .fmt = "%llu", .out_json = "parent" }, + { .key = "top level", .fmt = "%llu", .out_json = "top_level" }, + { .key = "otime", .fmt = "time-long", .out_json = "otime" }, + { .key = "parent_uuid", .fmt = "uuid", .out_json = "parent_uuid" }, + { .key = "received_uuid", .fmt = "uuid", .out_json = "received_uuid" }, + { .key = "uuid", .fmt = "uuid", .out_json = "uuid" }, + { .key = "path", .fmt = "%s", .out_json = "path" }, + { .key = "flag-list-item", .fmt = "%s" }, + { .key = "stransid", .fmt = "%llu", .out_json = "stransid" }, + { .key = "stime", .fmt = "time-long", .out_json = "stime" }, + { .key = "rtransid", .fmt = "%llu", .out_json = "rtransid" }, + { .key = "rtime", .fmt = "time-long", .out_json = "rtime" }, + { .key = "snapshot-list-item", .fmt = "%s" }, + { .key = "quota-group", .fmt = "qgroupid", .out_json = "group" }, + { .key = "quota-ref", .fmt = "%llu", .out_json = "referenced" }, + { .key = "quota-excl", .fmt = "%llu", .out_json = "exclusive" }, + ROWSPEC_END +}; + static int wait_for_subvolume_cleaning(int fd, size_t count, uint64_t *ids, int sleep_interval) { diff --git a/cmds/subvolume.h b/cmds/subvolume.h new file mode 100644 index 00000000..aa999372 --- /dev/null +++ b/cmds/subvolume.h @@ -0,0 +1,24 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License v2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef __BTRFS_SUBVOLUME_H__ +#define __BTRFS_SUBVOLUME_H__ + +struct rowspec; + +extern const struct rowspec btrfs_subvolume_rowspec[]; + +#endif