aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-03-12 20:12:07 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-03-12 20:12:07 -0400
commit0783fcfc4dc19b8bb99bd51b7afa669ba4cbd377 (patch)
tree0d7d68c33e8ff954e7614395f05d01d47d107f05 /fs/btrfs/ctree.h
parente2fa7227cdf132d72e7410dd0679dc573a1c2618 (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.h34
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 */
101struct item { 101struct 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 {
115struct leaf { 115struct 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
156static inline u16 btrfs_item_offset(struct btrfs_item *item)
157{
158 return le16_to_cpu(item->offset);
159}
160
161static inline void btrfs_set_item_offset(struct btrfs_item *item, u16 val)
162{
163 item->offset = cpu_to_le16(val);
164}
165
166static inline u16 btrfs_item_end(struct btrfs_item *item)
167{
168 return le16_to_cpu(item->offset) + le16_to_cpu(item->size);
169}
170
171static inline u16 btrfs_item_size(struct btrfs_item *item)
172{
173 return le16_to_cpu(item->size);
174}
175
176static inline void btrfs_set_item_size(struct btrfs_item *item, u16 val)
177{
178 item->size = cpu_to_le16(val);
179}
180
155static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu, 181static 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{