xref: /linux/arch/um/drivers/cow.h (revision 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2)
1*1da177e4SLinus Torvalds #ifndef __COW_H__
2*1da177e4SLinus Torvalds #define __COW_H__
3*1da177e4SLinus Torvalds 
4*1da177e4SLinus Torvalds #include <asm/types.h>
5*1da177e4SLinus Torvalds 
6*1da177e4SLinus Torvalds #if __BYTE_ORDER == __BIG_ENDIAN
7*1da177e4SLinus Torvalds # define ntohll(x) (x)
8*1da177e4SLinus Torvalds # define htonll(x) (x)
9*1da177e4SLinus Torvalds #elif __BYTE_ORDER == __LITTLE_ENDIAN
10*1da177e4SLinus Torvalds # define ntohll(x)  bswap_64(x)
11*1da177e4SLinus Torvalds # define htonll(x)  bswap_64(x)
12*1da177e4SLinus Torvalds #else
13*1da177e4SLinus Torvalds #error "__BYTE_ORDER not defined"
14*1da177e4SLinus Torvalds #endif
15*1da177e4SLinus Torvalds 
16*1da177e4SLinus Torvalds extern int init_cow_file(int fd, char *cow_file, char *backing_file,
17*1da177e4SLinus Torvalds 			 int sectorsize, int alignment, int *bitmap_offset_out,
18*1da177e4SLinus Torvalds 			 unsigned long *bitmap_len_out, int *data_offset_out);
19*1da177e4SLinus Torvalds 
20*1da177e4SLinus Torvalds extern int file_reader(__u64 offset, char *buf, int len, void *arg);
21*1da177e4SLinus Torvalds extern int read_cow_header(int (*reader)(__u64, char *, int, void *),
22*1da177e4SLinus Torvalds 			   void *arg, __u32 *version_out,
23*1da177e4SLinus Torvalds 			   char **backing_file_out, time_t *mtime_out,
24*1da177e4SLinus Torvalds 			   unsigned long long *size_out, int *sectorsize_out,
25*1da177e4SLinus Torvalds 			   __u32 *align_out, int *bitmap_offset_out);
26*1da177e4SLinus Torvalds 
27*1da177e4SLinus Torvalds extern int write_cow_header(char *cow_file, int fd, char *backing_file,
28*1da177e4SLinus Torvalds 			    int sectorsize, int alignment,
29*1da177e4SLinus Torvalds 			    unsigned long long *size);
30*1da177e4SLinus Torvalds 
31*1da177e4SLinus Torvalds extern void cow_sizes(int version, __u64 size, int sectorsize, int align,
32*1da177e4SLinus Torvalds 		      int bitmap_offset, unsigned long *bitmap_len_out,
33*1da177e4SLinus Torvalds 		      int *data_offset_out);
34*1da177e4SLinus Torvalds 
35*1da177e4SLinus Torvalds #endif
36*1da177e4SLinus Torvalds 
37*1da177e4SLinus Torvalds /*
38*1da177e4SLinus Torvalds  * ---------------------------------------------------------------------------
39*1da177e4SLinus Torvalds  * Local variables:
40*1da177e4SLinus Torvalds  * c-file-style: "linux"
41*1da177e4SLinus Torvalds  * End:
42*1da177e4SLinus Torvalds  */
43