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 <christoph@c8h4.io>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Christoph Heiss 2023-08-13 11:44:59 +02:00 committed by David Sterba
parent 7c983d2352
commit da440e66fb
2 changed files with 49 additions and 0 deletions

View File

@ -41,9 +41,34 @@
#include "common/open-utils.h" #include "common/open-utils.h"
#include "common/string-utils.h" #include "common/string-utils.h"
#include "common/units.h" #include "common/units.h"
#include "common/format-output.h"
#include "cmds/commands.h" #include "cmds/commands.h"
#include "cmds/qgroup.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, static int wait_for_subvolume_cleaning(int fd, size_t count, uint64_t *ids,
int sleep_interval) int sleep_interval)
{ {

24
cmds/subvolume.h Normal file
View File

@ -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