cow.h 1.8 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5
#ifndef __COW_H__
#define __COW_H__

#include <asm/types.h>

6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#if defined(__KERNEL__)

# include <asm/byteorder.h>

# if defined(__BIG_ENDIAN)
#	define ntohll(x) (x)
#	define htonll(x) (x)
# elif defined(__LITTLE_ENDIAN)
#	define ntohll(x)  be64_to_cpu(x)
#	define htonll(x)  cpu_to_be64(x)
# else
#	error "Could not determine byte order"
# endif

#else
/* For the definition of ntohl, htonl and __BYTE_ORDER */
#include <endian.h>
#include <netinet/in.h>
#if defined(__BYTE_ORDER)

26
#if __BYTE_ORDER == __BIG_ENDIAN
L
Linus Torvalds 已提交
27 28
# define ntohll(x) (x)
# define htonll(x) (x)
29
#elif __BYTE_ORDER == __LITTLE_ENDIAN
L
Linus Torvalds 已提交
30 31 32
# define ntohll(x)  bswap_64(x)
# define htonll(x)  bswap_64(x)
#else
33 34 35 36 37
# error "Could not determine byte order: __BYTE_ORDER uncorrectly defined"
#endif

#else  /* ! defined(__BYTE_ORDER) */
#	error "Could not determine byte order: __BYTE_ORDER not defined"
L
Linus Torvalds 已提交
38
#endif
39
#endif /* ! defined(__KERNEL__) */
L
Linus Torvalds 已提交
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

extern int init_cow_file(int fd, char *cow_file, char *backing_file,
			 int sectorsize, int alignment, int *bitmap_offset_out,
			 unsigned long *bitmap_len_out, int *data_offset_out);

extern int file_reader(__u64 offset, char *buf, int len, void *arg);
extern int read_cow_header(int (*reader)(__u64, char *, int, void *),
			   void *arg, __u32 *version_out,
			   char **backing_file_out, time_t *mtime_out,
			   unsigned long long *size_out, int *sectorsize_out,
			   __u32 *align_out, int *bitmap_offset_out);

extern int write_cow_header(char *cow_file, int fd, char *backing_file,
			    int sectorsize, int alignment,
			    unsigned long long *size);

extern void cow_sizes(int version, __u64 size, int sectorsize, int align,
		      int bitmap_offset, unsigned long *bitmap_len_out,
		      int *data_offset_out);

#endif

/*
 * ---------------------------------------------------------------------------
 * Local variables:
 * c-file-style: "linux"
 * End:
 */