udfend.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef __UDF_ENDIAN_H
  2. #define __UDF_ENDIAN_H
  3. #include <asm/byteorder.h>
  4. #include <linux/string.h>
  5. static inline struct kernel_lb_addr lelb_to_cpu(struct lb_addr in)
  6. {
  7. struct kernel_lb_addr out;
  8. out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum);
  9. out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum);
  10. return out;
  11. }
  12. static inline struct lb_addr cpu_to_lelb(struct kernel_lb_addr in)
  13. {
  14. struct lb_addr out;
  15. out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum);
  16. out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum);
  17. return out;
  18. }
  19. static inline struct short_ad lesa_to_cpu(struct short_ad in)
  20. {
  21. struct short_ad out;
  22. out.extLength = le32_to_cpu(in.extLength);
  23. out.extPosition = le32_to_cpu(in.extPosition);
  24. return out;
  25. }
  26. static inline struct short_ad cpu_to_lesa(struct short_ad in)
  27. {
  28. struct short_ad out;
  29. out.extLength = cpu_to_le32(in.extLength);
  30. out.extPosition = cpu_to_le32(in.extPosition);
  31. return out;
  32. }
  33. static inline struct kernel_long_ad lela_to_cpu(struct long_ad in)
  34. {
  35. struct kernel_long_ad out;
  36. out.extLength = le32_to_cpu(in.extLength);
  37. out.extLocation = lelb_to_cpu(in.extLocation);
  38. return out;
  39. }
  40. static inline struct long_ad cpu_to_lela(struct kernel_long_ad in)
  41. {
  42. struct long_ad out;
  43. out.extLength = cpu_to_le32(in.extLength);
  44. out.extLocation = cpu_to_lelb(in.extLocation);
  45. return out;
  46. }
  47. static inline struct kernel_extent_ad leea_to_cpu(struct extent_ad in)
  48. {
  49. struct kernel_extent_ad out;
  50. out.extLength = le32_to_cpu(in.extLength);
  51. out.extLocation = le32_to_cpu(in.extLocation);
  52. return out;
  53. }
  54. #endif /* __UDF_ENDIAN_H */