Blame view
fs/befs/endian.h
3.12 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 |
/* * linux/fs/befs/endian.h * * Copyright (C) 2001 Will Dyson <will_dyson@pobox.com> * * Partially based on similar funtions in the sysv driver. */ #ifndef LINUX_BEFS_ENDIAN #define LINUX_BEFS_ENDIAN |
9a6ab769b byteorder: don't ... |
11 |
#include <asm/byteorder.h> |
1da177e4c Linux-2.6.12-rc2 |
12 13 |
static inline u64 |
1151895f8 [PATCH] befs: int... |
14 |
fs64_to_cpu(const struct super_block *sb, fs64 n) |
1da177e4c Linux-2.6.12-rc2 |
15 16 |
{ if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE) |
1151895f8 [PATCH] befs: int... |
17 |
return le64_to_cpu((__force __le64)n); |
1da177e4c Linux-2.6.12-rc2 |
18 |
else |
1151895f8 [PATCH] befs: int... |
19 |
return be64_to_cpu((__force __be64)n); |
1da177e4c Linux-2.6.12-rc2 |
20 |
} |
1151895f8 [PATCH] befs: int... |
21 |
static inline fs64 |
1da177e4c Linux-2.6.12-rc2 |
22 23 24 |
cpu_to_fs64(const struct super_block *sb, u64 n) { if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE) |
1151895f8 [PATCH] befs: int... |
25 |
return (__force fs64)cpu_to_le64(n); |
1da177e4c Linux-2.6.12-rc2 |
26 |
else |
1151895f8 [PATCH] befs: int... |
27 |
return (__force fs64)cpu_to_be64(n); |
1da177e4c Linux-2.6.12-rc2 |
28 29 30 |
} static inline u32 |
1151895f8 [PATCH] befs: int... |
31 |
fs32_to_cpu(const struct super_block *sb, fs32 n) |
1da177e4c Linux-2.6.12-rc2 |
32 33 |
{ if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE) |
1151895f8 [PATCH] befs: int... |
34 |
return le32_to_cpu((__force __le32)n); |
1da177e4c Linux-2.6.12-rc2 |
35 |
else |
1151895f8 [PATCH] befs: int... |
36 |
return be32_to_cpu((__force __be32)n); |
1da177e4c Linux-2.6.12-rc2 |
37 |
} |
1151895f8 [PATCH] befs: int... |
38 |
static inline fs32 |
1da177e4c Linux-2.6.12-rc2 |
39 40 41 |
cpu_to_fs32(const struct super_block *sb, u32 n) { if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE) |
1151895f8 [PATCH] befs: int... |
42 |
return (__force fs32)cpu_to_le32(n); |
1da177e4c Linux-2.6.12-rc2 |
43 |
else |
1151895f8 [PATCH] befs: int... |
44 |
return (__force fs32)cpu_to_be32(n); |
1da177e4c Linux-2.6.12-rc2 |
45 46 47 |
} static inline u16 |
1151895f8 [PATCH] befs: int... |
48 |
fs16_to_cpu(const struct super_block *sb, fs16 n) |
1da177e4c Linux-2.6.12-rc2 |
49 50 |
{ if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE) |
1151895f8 [PATCH] befs: int... |
51 |
return le16_to_cpu((__force __le16)n); |
1da177e4c Linux-2.6.12-rc2 |
52 |
else |
1151895f8 [PATCH] befs: int... |
53 |
return be16_to_cpu((__force __be16)n); |
1da177e4c Linux-2.6.12-rc2 |
54 |
} |
1151895f8 [PATCH] befs: int... |
55 |
static inline fs16 |
1da177e4c Linux-2.6.12-rc2 |
56 57 58 |
cpu_to_fs16(const struct super_block *sb, u16 n) { if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE) |
1151895f8 [PATCH] befs: int... |
59 |
return (__force fs16)cpu_to_le16(n); |
1da177e4c Linux-2.6.12-rc2 |
60 |
else |
1151895f8 [PATCH] befs: int... |
61 |
return (__force fs16)cpu_to_be16(n); |
1da177e4c Linux-2.6.12-rc2 |
62 63 64 65 66 |
} /* Composite types below here */ static inline befs_block_run |
a9721f315 [PATCH] befs: end... |
67 |
fsrun_to_cpu(const struct super_block *sb, befs_disk_block_run n) |
1da177e4c Linux-2.6.12-rc2 |
68 69 70 71 |
{ befs_block_run run; if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE) { |
a9721f315 [PATCH] befs: end... |
72 73 74 |
run.allocation_group = le32_to_cpu((__force __le32)n.allocation_group); run.start = le16_to_cpu((__force __le16)n.start); run.len = le16_to_cpu((__force __le16)n.len); |
1da177e4c Linux-2.6.12-rc2 |
75 |
} else { |
a9721f315 [PATCH] befs: end... |
76 77 78 |
run.allocation_group = be32_to_cpu((__force __be32)n.allocation_group); run.start = be16_to_cpu((__force __be16)n.start); run.len = be16_to_cpu((__force __be16)n.len); |
1da177e4c Linux-2.6.12-rc2 |
79 80 81 |
} return run; } |
a9721f315 [PATCH] befs: end... |
82 |
static inline befs_disk_block_run |
1da177e4c Linux-2.6.12-rc2 |
83 84 |
cpu_to_fsrun(const struct super_block *sb, befs_block_run n) { |
a9721f315 [PATCH] befs: end... |
85 |
befs_disk_block_run run; |
1da177e4c Linux-2.6.12-rc2 |
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE) { run.allocation_group = cpu_to_le32(n.allocation_group); run.start = cpu_to_le16(n.start); run.len = cpu_to_le16(n.len); } else { run.allocation_group = cpu_to_be32(n.allocation_group); run.start = cpu_to_be16(n.start); run.len = cpu_to_be16(n.len); } return run; } static inline befs_data_stream |
e0e3d32bb befs: don't pass ... |
100 |
fsds_to_cpu(const struct super_block *sb, const befs_disk_data_stream *n) |
1da177e4c Linux-2.6.12-rc2 |
101 102 103 104 105 |
{ befs_data_stream data; int i; for (i = 0; i < BEFS_NUM_DIRECT_BLOCKS; ++i) |
e0e3d32bb befs: don't pass ... |
106 |
data.direct[i] = fsrun_to_cpu(sb, n->direct[i]); |
1da177e4c Linux-2.6.12-rc2 |
107 |
|
e0e3d32bb befs: don't pass ... |
108 109 110 111 |
data.max_direct_range = fs64_to_cpu(sb, n->max_direct_range); data.indirect = fsrun_to_cpu(sb, n->indirect); data.max_indirect_range = fs64_to_cpu(sb, n->max_indirect_range); data.double_indirect = fsrun_to_cpu(sb, n->double_indirect); |
1da177e4c Linux-2.6.12-rc2 |
112 |
data.max_double_indirect_range = fs64_to_cpu(sb, |
e0e3d32bb befs: don't pass ... |
113 |
n-> |
1da177e4c Linux-2.6.12-rc2 |
114 |
max_double_indirect_range); |
e0e3d32bb befs: don't pass ... |
115 |
data.size = fs64_to_cpu(sb, n->size); |
1da177e4c Linux-2.6.12-rc2 |
116 117 118 119 120 |
return data; } #endif //LINUX_BEFS_ENDIAN |