diff mbox

[06/11] Btrfs-progs: provide method to check if filter is set

Message ID 1357818083-15531-7-git-send-email-anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anand Jain Jan. 10, 2013, 11:41 a.m. UTC
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 cb458f1..308b54c 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_check_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 580d4d1..f5dbd47 100644
--- a/btrfs-list.h
+++ b/btrfs-list.h
@@ -152,3 +152,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_subvol(int fd, struct root_info *the_ri);
+int btrfs_list_check_filter_set(struct btrfs_list_filter_set *fset,
+			enum btrfs_list_filter_enum filter);