#ifndef CBD_H #define CBD_H /* Kernel compatibility */ #include #include #include #include #ifndef BITS_PER_BYTE #define BITS_PER_BYTE 8 #endif #ifndef SECTOR_SHIFT #define SECTOR_SHIFT 9 #endif #ifndef SECTOR_SIZE #define SECTOR_SIZE (1 << SECTOR_SHIFT) #endif #ifndef PAGE_SHIFT #define PAGE_SHIFT 12 #endif #ifndef PAGE_SIZE #define PAGE_SIZE (1 << PAGE_SHIFT) #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 #include #define CBD_DEFAULT_COMPRESSION_FACTOR 2.0 #define CBD_DEFAULT_PHYSICAL_BLOCK_SHIFT 3 #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, uint16_t flags, enum cbd_alg alg, uint level, uint8_t pshift, uint8_t lshift, uint8_t pbatshift, uint64_t psize, uint64_t lsize, bool full_init); int cbd_open(const char* dev, const char* name, uint64_t cache_pages, bool sync); int cbd_close(const char* name); int cbd_stats(const char* dev, struct cbd_stats* stats); int cbd_check(const char* dev, bool force, tristate_t auto_response, bool full_check); int cbd_resize(const char* dev, uint64_t lsize); #endif