2 * Copyright (c) 2019 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@dragonflybsd.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #ifndef HAMMER2_HAMMER2_SUBS_H_
36 #define HAMMER2_HAMMER2_SUBS_H_
38 #include <sys/types.h>
41 #include <vfs/hammer2/hammer2_disk.h>
43 /* user-specifiable check modes only */
44 #define HAMMER2_CHECK_STRINGS { "none", "disabled", "crc32", \
45 "xxhash64", "sha192" }
46 #define HAMMER2_CHECK_STRINGS_COUNT 5
48 #define HAMMER2_COMP_STRINGS { "none", "autozero", "lz4", "zlib" }
49 #define HAMMER2_COMP_STRINGS_COUNT 4
51 typedef struct hammer2_volume
{
59 typedef struct hammer2_ondisk
{
62 hammer2_volume_t volumes
[HAMMER2_MAX_VOLUMES
];
63 hammer2_off_t total_size
;
64 hammer2_off_t free_size
;
72 int hammer2_ioctl_handle(const char *sel_path
);
73 const char *hammer2_time64_to_str(uint64_t htime64
, char **strp
);
74 const char *hammer2_uuid_to_str(const uuid_t
*uuid
, char **strp
);
75 const char *hammer2_iptype_to_str(uint8_t type
);
76 const char *hammer2_pfstype_to_str(uint8_t type
);
77 const char *hammer2_pfssubtype_to_str(uint8_t subtype
);
78 const char *hammer2_breftype_to_str(uint8_t type
);
79 const char *hammer2_compmode_to_str(uint8_t comp_algo
);
80 const char *hammer2_checkmode_to_str(uint8_t check_algo
);
81 const char *sizetostr(hammer2_off_t size
);
82 const char *counttostr(hammer2_off_t size
);
83 hammer2_off_t
check_volume(int fd
);
84 hammer2_key_t
dirhash(const char *aname
, size_t len
);
86 #define hammer2_icrc32(buf, size) iscsi_crc32((buf), (size))
87 #define hammer2_icrc32c(buf, size, crc) iscsi_crc32_ext((buf), (size), (crc))
88 uint32_t iscsi_crc32(const void *buf
, size_t size
);
89 uint32_t iscsi_crc32_ext(const void *buf
, size_t size
, uint32_t ocrc
);
91 char **get_hammer2_mounts(int *acp
);
92 void put_hammer2_mounts(int ac
, char **av
);
94 void hammer2_init_ondisk(hammer2_ondisk_t
*fsp
);
95 void hammer2_install_volume(hammer2_volume_t
*vol
, int fd
, int id
,
96 const char *path
, hammer2_off_t offset
, hammer2_off_t size
);
97 void hammer2_uninstall_volume(hammer2_volume_t
*vol
);
98 void hammer2_verify_volumes(hammer2_ondisk_t
*fsp
,
99 const hammer2_volume_data_t
*rootvoldata
);
100 void hammer2_print_volumes(const hammer2_ondisk_t
*fsp
);
101 void hammer2_init_volumes(const char *blkdevs
, int rdonly
);
102 void hammer2_cleanup_volumes(void);
104 hammer2_volume_t
*hammer2_get_volume(hammer2_off_t offset
);
105 int hammer2_get_volume_fd(hammer2_off_t offset
);
106 int hammer2_get_root_volume_fd(void);
107 int hammer2_get_volume_id(hammer2_off_t offset
);
108 int hammer2_get_root_volume_id(void);
109 const char *hammer2_get_volume_path(hammer2_off_t offset
);
110 const char *hammer2_get_root_volume_path(void);
111 hammer2_off_t
hammer2_get_volume_offset(hammer2_off_t offset
);
112 hammer2_off_t
hammer2_get_root_volume_offset(void);
113 hammer2_off_t
hammer2_get_volume_size(hammer2_off_t offset
);
114 hammer2_off_t
hammer2_get_root_volume_size(void);
116 hammer2_off_t
hammer2_get_total_size(void);
117 hammer2_volume_data_t
* hammer2_read_root_volume_header(void);
119 void *hammer2_decompress_LZ4(void *inbuf
, size_t insize
,
120 size_t outsize
, int *statusp
);
121 void *hammer2_decompress_ZLIB(void *inbuf
, size_t insize
,
122 size_t outsize
, int *statusp
);
125 #endif /* !HAMMER2_HAMMER2_SUBS_H_ */