68 lines
1.3 KiB
C
68 lines
1.3 KiB
C
#ifndef CBD_H
|
|
#define CBD_H
|
|
|
|
/* Kernel compatibility */
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <asm/byteorder.h>
|
|
|
|
#ifndef BITS_PER_BYTE
|
|
#define BITS_PER_BYTE 8
|
|
#endif
|
|
|
|
#ifndef min
|
|
#define min(a, b) ((a) < (b) ? (a) : (b))
|
|
#endif
|
|
|
|
#ifndef max
|
|
#define max(a, b) ((a) < (b) ? (b) : (a))
|
|
#endif
|
|
|
|
#ifndef ARRAY_SIZE
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
#endif
|
|
|
|
#ifndef DIV_ROUND_UP
|
|
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
|
#endif
|
|
|
|
#ifndef ROUND_UP
|
|
#define ROUND_UP(n, d) (DIV_ROUND_UP(n, d) * (n))
|
|
#endif
|
|
|
|
typedef uint8_t u8;
|
|
typedef uint16_t u16;
|
|
typedef uint32_t u32;
|
|
typedef uint64_t u64;
|
|
|
|
#include <linux/dm-compress.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#define CBD_DEFAULT_COMPRESSION_FACTOR 2.0
|
|
#define CBD_DEFAULT_LOGICAL_BLOCK_SHIFT 4
|
|
|
|
/* XXX: move to types.h */
|
|
typedef enum {
|
|
t_false,
|
|
t_true,
|
|
t_none
|
|
} tristate_t;
|
|
|
|
int cbd_format(const char* dev,
|
|
uint64_t psize, uint16_t pbatlen,
|
|
uint16_t lshift, uint64_t lsize,
|
|
enum cbd_alg alg, uint level);
|
|
int cbd_open(const char* dev,
|
|
const char* name);
|
|
int cbd_close(const char* name);
|
|
|
|
int cbd_stats(const char* name);
|
|
|
|
int cbd_check(const char* dev,
|
|
tristate_t auto_response);
|
|
int cbd_resize(const char* dev,
|
|
uint64_t lsize);
|
|
|
|
#endif
|