1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef __ZFS_COMMON__
23#define __ZFS_COMMON__
24
25#define SECTOR_SIZE 0x200
26#define SECTOR_BITS 9
27
28
29typedef enum zfs_endian {
30 UNKNOWN_ENDIAN = -2,
31 LITTLE_ENDIAN = -1,
32 BIG_ENDIAN = 0
33} zfs_endian_t;
34
35
36
37#define zfs_to_cpu16(x, a) (((a) == BIG_ENDIAN) ? be16_to_cpu(x) \
38 : le16_to_cpu(x))
39#define cpu_to_zfs16(x, a) (((a) == BIG_ENDIAN) ? cpu_to_be16(x) \
40 : cpu_to_le16(x))
41
42#define zfs_to_cpu32(x, a) (((a) == BIG_ENDIAN) ? be32_to_cpu(x) \
43 : le32_to_cpu(x))
44#define cpu_to_zfs32(x, a) (((a) == BIG_ENDIAN) ? cpu_to_be32(x) \
45 : cpu_to_le32(x))
46
47#define zfs_to_cpu64(x, a) (((a) == BIG_ENDIAN) ? be64_to_cpu(x) \
48 : le64_to_cpu(x))
49#define cpu_to_zfs64(x, a) (((a) == BIG_ENDIAN) ? cpu_to_be64(x) \
50 : cpu_to_le64(x))
51
52
53enum zfs_errors {
54 ZFS_ERR_NONE = 0,
55 ZFS_ERR_NOT_IMPLEMENTED_YET = -1,
56 ZFS_ERR_BAD_FS = -2,
57 ZFS_ERR_OUT_OF_MEMORY = -3,
58 ZFS_ERR_FILE_NOT_FOUND = -4,
59 ZFS_ERR_BAD_FILE_TYPE = -5,
60 ZFS_ERR_OUT_OF_RANGE = -6,
61};
62
63struct zfs_filesystem {
64
65
66 struct blk_desc *dev_desc;
67};
68
69struct device_s {
70 uint64_t part_length;
71};
72typedef struct device_s *device_t;
73
74struct zfs_file {
75 device_t device;
76 uint64_t size;
77 void *data;
78 uint64_t offset;
79};
80
81typedef struct zfs_file *zfs_file_t;
82
83struct zfs_dirhook_info {
84 int dir;
85 int mtimeset;
86 time_t mtime;
87 time_t mtime2;
88};
89
90
91
92
93struct zfs_filesystem *zfsget_fs(void);
94int zfs_open(zfs_file_t, const char *filename);
95uint64_t zfs_read(zfs_file_t, char *buf, uint64_t len);
96struct zfs_data *zfs_mount(device_t);
97int zfs_close(zfs_file_t);
98int zfs_ls(device_t dev, const char *path,
99 int (*hook) (const char *, const struct zfs_dirhook_info *));
100int zfs_devread(int sector, int byte_offset, int byte_len, char *buf);
101void zfs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info);
102void zfs_unmount(struct zfs_data *data);
103int lzjb_decompress(void *, void *, uint32_t, uint32_t);
104#endif
105