Btrfs-progs: check, fix false error reports for shared prealloc extents
[platform/upstream/btrfs-progs.git] / image / sanitize.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public
4  * License v2 as published by the Free Software Foundation.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9  * General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the
13  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
14  * Boston, MA 021110-1307, USA.
15  */
16
17 #ifndef __BTRFS_IMAGE_SANITIZE_H__
18 #define __BTRFS_IMAGE_SANITIZE_H__
19
20 #include "kerncompat.h"
21 #include "image/metadump.h"
22
23 struct name {
24         struct rb_node n;
25         char *val;
26         char *sub;
27         u32 len;
28 };
29
30 /*
31  * Filenames and xattrs can be obfuscated so they don't appear in the image
32  * dump. In basic mode (NAMES) a random string will be generated but such names
33  * do not match the direntry hashes. The advanced mode (COLLISIONS) tries to
34  * generate names that appear random but also match the hashes. This however
35  * may take significantly more time than the basic mode. And may not even
36  * succeed.
37  */
38 enum sanitize_mode {
39         SANITIZE_NONE,
40         SANITIZE_NAMES,
41         SANITIZE_COLLISIONS
42 };
43
44 void sanitize_name(enum sanitize_mode sanitize, struct rb_root *name_tree,
45                 u8 *dst, struct extent_buffer *src, struct btrfs_key *key,
46                 int slot);
47
48 #endif