udfend.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef __UDF_ENDIAN_H
  2. #define __UDF_ENDIAN_H
  3. #include <asm/byteorder.h>
  4. #include <linux/string.h>
  5. static inline kernel_lb_addr lelb_to_cpu(lb_addr in)
  6. {
  7. 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 lb_addr cpu_to_lelb(kernel_lb_addr in)
  13. {
  14. 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 kernel_timestamp lets_to_cpu(timestamp in)
  20. {
  21. kernel_timestamp out;
  22. memcpy(&out, &in, sizeof(timestamp));
  23. out.typeAndTimezone = le16_to_cpu(in.typeAndTimezone);
  24. out.year = le16_to_cpu(in.year);
  25. return out;
  26. }
  27. static inline short_ad lesa_to_cpu(short_ad in)
  28. {
  29. short_ad out;
  30. out.extLength = le32_to_cpu(in.extLength);
  31. out.extPosition = le32_to_cpu(in.extPosition);
  32. return out;
  33. }
  34. static inline short_ad cpu_to_lesa(short_ad in)
  35. {
  36. short_ad out;
  37. out.extLength = cpu_to_le32(in.extLength);
  38. out.extPosition = cpu_to_le32(in.extPosition);
  39. return out;
  40. }
  41. static inline kernel_long_ad lela_to_cpu(long_ad in)
  42. {
  43. kernel_long_ad out;
  44. out.extLength = le32_to_cpu(in.extLength);
  45. out.extLocation = lelb_to_cpu(in.extLocation);
  46. return out;
  47. }
  48. static inline long_ad cpu_to_lela(kernel_long_ad in)
  49. {
  50. long_ad out;
  51. out.extLength = cpu_to_le32(in.extLength);
  52. out.extLocation = cpu_to_lelb(in.extLocation);
  53. return out;
  54. }
  55. static inline kernel_extent_ad leea_to_cpu(extent_ad in)
  56. {
  57. kernel_extent_ad out;
  58. out.extLength = le32_to_cpu(in.extLength);
  59. out.extLocation = le32_to_cpu(in.extLocation);
  60. return out;
  61. }
  62. static inline timestamp cpu_to_lets(kernel_timestamp in)
  63. {
  64. timestamp out;
  65. memcpy(&out, &in, sizeof(timestamp));
  66. out.typeAndTimezone = cpu_to_le16(in.typeAndTimezone);
  67. out.year = cpu_to_le16(in.year);
  68. return out;
  69. }
  70. #endif /* __UDF_ENDIAN_H */