cow.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef __COW_H__
  2. #define __COW_H__
  3. #include <asm/types.h>
  4. #if defined(__KERNEL__)
  5. # include <asm/byteorder.h>
  6. # if defined(__BIG_ENDIAN)
  7. # define ntohll(x) (x)
  8. # define htonll(x) (x)
  9. # elif defined(__LITTLE_ENDIAN)
  10. # define ntohll(x) be64_to_cpu(x)
  11. # define htonll(x) cpu_to_be64(x)
  12. # else
  13. # error "Could not determine byte order"
  14. # endif
  15. #else
  16. /* For the definition of ntohl, htonl and __BYTE_ORDER */
  17. #include <endian.h>
  18. #include <netinet/in.h>
  19. #if defined(__BYTE_ORDER)
  20. # if __BYTE_ORDER == __BIG_ENDIAN
  21. # define ntohll(x) (x)
  22. # define htonll(x) (x)
  23. # elif __BYTE_ORDER == __LITTLE_ENDIAN
  24. # define ntohll(x) bswap_64(x)
  25. # define htonll(x) bswap_64(x)
  26. # else
  27. # error "Could not determine byte order: __BYTE_ORDER uncorrectly defined"
  28. # endif
  29. #else /* ! defined(__BYTE_ORDER) */
  30. # error "Could not determine byte order: __BYTE_ORDER not defined"
  31. #endif
  32. #endif /* ! defined(__KERNEL__) */
  33. extern int init_cow_file(int fd, char *cow_file, char *backing_file,
  34. int sectorsize, int alignment, int *bitmap_offset_out,
  35. unsigned long *bitmap_len_out, int *data_offset_out);
  36. extern int file_reader(__u64 offset, char *buf, int len, void *arg);
  37. extern int read_cow_header(int (*reader)(__u64, char *, int, void *),
  38. void *arg, __u32 *version_out,
  39. char **backing_file_out, time_t *mtime_out,
  40. unsigned long long *size_out, int *sectorsize_out,
  41. __u32 *align_out, int *bitmap_offset_out);
  42. extern int write_cow_header(char *cow_file, int fd, char *backing_file,
  43. int sectorsize, int alignment,
  44. unsigned long long *size);
  45. extern void cow_sizes(int version, __u64 size, int sectorsize, int align,
  46. int bitmap_offset, unsigned long *bitmap_len_out,
  47. int *data_offset_out);
  48. #endif
  49. /*
  50. * ---------------------------------------------------------------------------
  51. * Local variables:
  52. * c-file-style: "linux"
  53. * End:
  54. */