btrfs-progs: make libbtrfs usable from C++
[platform/upstream/btrfs-progs.git] / send-utils.h
1 /*
2  * Copyright (C) 2012 Alexander Block.  All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public
6  * License v2 as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public
14  * License along with this program; if not, write to the
15  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16  * Boston, MA 021110-1307, USA.
17  */
18 #ifndef SEND_UTILS_H_
19 #define SEND_UTILS_H_
20
21 #include "ctree.h"
22 #include "rbtree.h"
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 enum subvol_search_type {
29         subvol_search_by_root_id,
30         subvol_search_by_uuid,
31         subvol_search_by_received_uuid,
32         subvol_search_by_path,
33 };
34
35 struct subvol_info {
36         struct rb_node rb_root_id_node;
37         struct rb_node rb_local_node;
38         struct rb_node rb_received_node;
39         struct rb_node rb_path_node;
40         u64 root_id;
41         u8 uuid[BTRFS_UUID_SIZE];
42         u8 parent_uuid[BTRFS_UUID_SIZE];
43         u8 received_uuid[BTRFS_UUID_SIZE];
44         u64 ctransid;
45         u64 otransid;
46         u64 stransid;
47         u64 rtransid;
48
49         char *path;
50 };
51
52 struct subvol_uuid_search {
53         struct rb_root root_id_subvols;
54         struct rb_root local_subvols;
55         struct rb_root received_subvols;
56         struct rb_root path_subvols;
57 };
58
59 int subvol_uuid_search_init(int mnt_fd, struct subvol_uuid_search *s);
60 struct subvol_info *subvol_uuid_search(struct subvol_uuid_search *s,
61                                        u64 root_id, const u8 *uuid, u64 transid,
62                                        const char *path,
63                                        enum subvol_search_type type);
64 void subvol_uuid_search_add(struct subvol_uuid_search *s,
65                             struct subvol_info *si);
66
67
68
69 char *path_cat(const char *p1, const char *p2);
70 char *path_cat3(const char *p1, const char *p2, const char *p3);
71
72 #ifdef __cplusplus
73 }
74 #endif
75
76 #endif /* SEND_UTILS_H_ */