1
2
3#ifndef __BTRFS_COMPAT_H__
4#define __BTRFS_COMPAT_H__
5
6#include <linux/errno.h>
7#include <fs_internal.h>
8#include <uuid.h>
9
10
11
12
13#define error(fmt, ...) pr_err("BTRFS: " fmt "\n", ##__VA_ARGS__)
14
15#define ASSERT(c) assert(c)
16
17#define BTRFS_UUID_UNPARSED_SIZE 37
18
19
20#define XATTR_NAME_MAX 255
21#define PATH_MAX 4096
22
23
24
25
26
27
28#define le8_to_cpu(v) (v)
29#define cpu_to_le8(v) (v)
30#define __le8 u8
31
32
33
34
35
36
37#define le8_to_cpu(v) (v)
38#define cpu_to_le8(v) (v)
39#define __le8 u8
40
41#define get_unaligned_le8(p) (*((u8 *)(p)))
42#define get_unaligned_8(p) (*((u8 *)(p)))
43#define put_unaligned_le8(val,p) ((*((u8 *)(p))) = (val))
44#define put_unaligned_8(val,p) ((*((u8 *)(p))) = (val))
45
46
47
48
49
50
51
52
53
54static inline int __btrfs_devread(struct blk_desc *desc,
55 struct disk_partition *part,
56 void *buf, size_t size, u64 offset)
57{
58 lbaint_t sector;
59 int byte_offset;
60 int ret;
61
62 sector = offset >> desc->log2blksz;
63 byte_offset = offset % desc->blksz;
64
65
66 ret = fs_devread(desc, part, sector, byte_offset, size, buf);
67 if (!ret)
68 return -EIO;
69 return size;
70}
71
72static inline void uuid_unparse(const u8 *uuid, char *out)
73{
74 return uuid_bin_to_str((unsigned char *)uuid, out, 0);
75}
76
77static inline int is_power_of_2(unsigned long n)
78{
79 return (n != 0 && ((n & (n - 1)) == 0));
80}
81
82#endif
83