From: Anand jain <Anand.Jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 4/4] Btrfs-progs: list only snapshots of the given subvol
Date: Fri, 19 Oct 2012 14:23:57 +0800 [thread overview]
Message-ID: <1350627837-27639-5-git-send-email-Anand.Jain@oracle.com> (raw)
In-Reply-To: <1350627837-27639-1-git-send-email-Anand.Jain@oracle.com>
From: Anand Jain <anand.jain@oracle.com>
btrfs su list -s /btrfs
ID 258 gen 6 cgen 6 top level 5 otime 2012-10-18 17:01:56 uuid f648cdda-4efa-6f45-bd6b-041a8ae1538e path ss1
ID 260 gen 8 cgen 8 top level 5 otime 2012-10-18 17:02:20 uuid ea8fdf85-8d3f-8946-b3af-ede510cdcf19 path ss2
ID 261 gen 9 cgen 9 top level 5 otime 2012-10-19 13:37:42 uuid 44560e56-3879-2146-8b24-e9048871892f path ss3
btrfs su list -s /btrfs/sv1
ID 258 gen 6 cgen 6 top level 5 otime 2012-10-18 17:01:56 uuid f648cdda-4efa-6f45-bd6b-041a8ae1538e path ss1
ID 261 gen 9 cgen 9 top level 5 otime 2012-10-19 13:37:42 uuid 44560e56-3879-2146-8b24-e9048871892f path ss3
btrfs su list -s /btrfs/sv2
ID 260 gen 8 cgen 8 top level 5 otime 2012-10-18 17:02:20 uuid ea8fdf85-8d3f-8946-b3af-ede510cdcf19 path ss2
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
cmds-subvolume.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index f8beecc..c575720 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -307,6 +307,7 @@ static int cmd_subvol_list(int argc, char **argv)
int ret;
int c;
char *subvol, *mnt = NULL;
+ struct root_info ri;
int is_tab_result = 0;
int is_list_all = 0;
struct option long_options[] = {
@@ -314,6 +315,7 @@ static int cmd_subvol_list(int argc, char **argv)
{0, 0, 0, 0}
};
+ memset(&ri,'\0',sizeof(ri));
filter_set = btrfs_list_alloc_filter_set();
comparer_set = btrfs_list_alloc_comparer_set();
@@ -419,10 +421,32 @@ static int cmd_subvol_list(int argc, char **argv)
BTRFS_LIST_FILTER_TOPID_EQUAL,
top_id);
+ if (strcmp(subvol, mnt) != 0) {
+ if (btrfs_list_is_filter_set(filter_set, BTRFS_LIST_FILTER_SNAPSHOT_ONLY) >= 0) {
+ ri.full_path = subvol+strlen(mnt)+1;
+ if (btrfs_get_a_subvol(fd, &ri)) {
+ fprintf(stderr, "ERROR: can't find '%s'\n",
+ ri.full_path);
+ close(fd);
+ free(mnt);
+ return 13;
+ }
+ btrfs_list_setup_filter(&filter_set,
+ BTRFS_LIST_FILTER_BY_PARENT, (u64)&ri.uuid);
+ }
+ }
+
ret = btrfs_list_subvols(fd, filter_set, comparer_set,
is_tab_result);
free(mnt);
+ if (ri.path)
+ free(ri.path);
+ if (ri.name)
+ free(ri.name);
+ if (ri.full_path)
+ free(ri.full_path);
+
if (ret)
return 19;
return 0;
--
1.7.1
next prev parent reply other threads:[~2012-10-19 6:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-19 6:23 [PATCH 0/4] filter snapshot(s) by its parent uuid Anand jain
2012-10-19 6:23 ` [PATCH 1/4] Btrfs-progs: provide method to check if filter is set Anand jain
2012-10-19 6:23 ` [PATCH 2/4] Btrfs-progs: fix irrelevant string in the subvol path Anand jain
2012-10-19 8:59 ` Miao Xie
2012-10-19 6:23 ` [PATCH 3/4] Btrfs-progs: add method to filter snapshots by parent uuid Anand jain
2012-10-19 6:23 ` Anand jain [this message]
2012-10-19 7:38 ` [PATCH 0/4] filter snapshot(s) by its " Miao Xie
2012-10-19 8:37 ` Rory Campbell-Lange
2012-10-22 12:34 ` Lenz Grimmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1350627837-27639-5-git-send-email-Anand.Jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).