diff mbox

[1/4] Btrfs-progs: provide method to check if filter is set

Message ID 1350627837-27639-2-git-send-email-Anand.Jain@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anand Jain Oct. 19, 2012, 6:23 a.m. UTC
From: Anand Jain <anand.jain@oracle.com>

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 btrfs-list.c |   11 +++++++++++
 btrfs-list.h |    2 ++
 2 files changed, 13 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/btrfs-list.c b/btrfs-list.c
index 9cfdb35..462e049 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -1181,6 +1181,17 @@  void btrfs_list_free_filter_set(struct btrfs_list_filter_set *filter_set)
 	free(filter_set);
 }
 
+int btrfs_list_is_filter_set(struct btrfs_list_filter_set *fset,
+			enum btrfs_list_filter_enum filter)
+{
+	int i;
+	for (i=0; i < fset->nfilters; i++) {
+		if (fset->filters[i].filter_func == all_filter_funcs[filter])
+			return i;
+	}
+	return -1;
+}
+
 int btrfs_list_setup_filter(struct btrfs_list_filter_set **filter_set,
 			    enum btrfs_list_filter_enum filter, u64 data)
 {
diff --git a/btrfs-list.h b/btrfs-list.h
index fc04f05..64d89e1 100644
--- a/btrfs-list.h
+++ b/btrfs-list.h
@@ -153,3 +153,5 @@  int btrfs_list_get_default_subvolume(int fd, u64 *default_id);
 char *btrfs_list_path_for_root(int fd, u64 root);
 u64 btrfs_list_get_path_rootid(int fd);
 int btrfs_get_a_subvol(int fd, struct root_info *the_ri);
+int btrfs_list_is_filter_set(struct btrfs_list_filter_set *fset,
+			enum btrfs_list_filter_enum filter);