diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-12 20:12:07 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-12 20:12:07 -0400 |
commit | 0783fcfc4dc19b8bb99bd51b7afa669ba4cbd377 (patch) | |
tree | 0d7d68c33e8ff954e7614395f05d01d47d107f05 /fs/btrfs/ctree.h | |
parent | e2fa7227cdf132d72e7410dd0679dc573a1c2618 (diff) |
Btrfs: struct item endian fixes
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 58e03e90f23a..b03df154dcdb 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -98,10 +98,10 @@ struct ctree_super_block { | |||
98 | * the key flags parameter. offset and size tell us where to find | 98 | * the key flags parameter. offset and size tell us where to find |
99 | * the item in the leaf (relative to the start of the data area) | 99 | * the item in the leaf (relative to the start of the data area) |
100 | */ | 100 | */ |
101 | struct item { | 101 | struct btrfs_item { |
102 | struct btrfs_disk_key key; | 102 | struct btrfs_disk_key key; |
103 | u16 offset; | 103 | __le16 offset; |
104 | u16 size; | 104 | __le16 size; |
105 | } __attribute__ ((__packed__)); | 105 | } __attribute__ ((__packed__)); |
106 | 106 | ||
107 | /* | 107 | /* |
@@ -115,7 +115,8 @@ struct item { | |||
115 | struct leaf { | 115 | struct leaf { |
116 | struct btrfs_header header; | 116 | struct btrfs_header header; |
117 | union { | 117 | union { |
118 | struct item items[LEAF_DATA_SIZE/sizeof(struct item)]; | 118 | struct btrfs_item items[LEAF_DATA_SIZE/ |
119 | sizeof(struct btrfs_item)]; | ||
119 | u8 data[CTREE_BLOCKSIZE-sizeof(struct btrfs_header)]; | 120 | u8 data[CTREE_BLOCKSIZE-sizeof(struct btrfs_header)]; |
120 | }; | 121 | }; |
121 | } __attribute__ ((__packed__)); | 122 | } __attribute__ ((__packed__)); |
@@ -152,6 +153,31 @@ struct ctree_path { | |||
152 | int slots[MAX_LEVEL]; | 153 | int slots[MAX_LEVEL]; |
153 | }; | 154 | }; |
154 | 155 | ||
156 | static inline u16 btrfs_item_offset(struct btrfs_item *item) | ||
157 | { | ||
158 | return le16_to_cpu(item->offset); | ||
159 | } | ||
160 | |||
161 | static inline void btrfs_set_item_offset(struct btrfs_item *item, u16 val) | ||
162 | { | ||
163 | item->offset = cpu_to_le16(val); | ||
164 | } | ||
165 | |||
166 | static inline u16 btrfs_item_end(struct btrfs_item *item) | ||
167 | { | ||
168 | return le16_to_cpu(item->offset) + le16_to_cpu(item->size); | ||
169 | } | ||
170 | |||
171 | static inline u16 btrfs_item_size(struct btrfs_item *item) | ||
172 | { | ||
173 | return le16_to_cpu(item->size); | ||
174 | } | ||
175 | |||
176 | static inline void btrfs_set_item_size(struct btrfs_item *item, u16 val) | ||
177 | { | ||
178 | item->size = cpu_to_le16(val); | ||
179 | } | ||
180 | |||
155 | static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu, | 181 | static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu, |
156 | struct btrfs_disk_key *disk) | 182 | struct btrfs_disk_key *disk) |
157 | { | 183 | { |