summaryrefslogtreecommitdiff
path: root/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
commitf6a88938c6ccc1c3d7398764bcbc4e08c2cb6738 (patch)
treec4c15b57ae92efd459c793d7f345918e8023a4b1 /ctree.h
parentb2e2afd7b4f10536f10771bd6ba2b0a98357d481 (diff)
struct item endian fixes
Diffstat (limited to 'ctree.h')
-rw-r--r--ctree.h34
1 files changed, 30 insertions, 4 deletions
diff --git a/ctree.h b/ctree.h
index 58e03e90..b03df154 100644
--- a/ctree.h
+++ b/ctree.h
@@ -98,10 +98,10 @@ struct ctree_super_block {
* the key flags parameter. offset and size tell us where to find
* the item in the leaf (relative to the start of the data area)
*/
-struct item {
+struct btrfs_item {
struct btrfs_disk_key key;
- u16 offset;
- u16 size;
+ __le16 offset;
+ __le16 size;
} __attribute__ ((__packed__));
/*
@@ -115,7 +115,8 @@ struct item {
struct leaf {
struct btrfs_header header;
union {
- struct item items[LEAF_DATA_SIZE/sizeof(struct item)];
+ struct btrfs_item items[LEAF_DATA_SIZE/
+ sizeof(struct btrfs_item)];
u8 data[CTREE_BLOCKSIZE-sizeof(struct btrfs_header)];
};
} __attribute__ ((__packed__));
@@ -152,6 +153,31 @@ struct ctree_path {
int slots[MAX_LEVEL];
};
+static inline u16 btrfs_item_offset(struct btrfs_item *item)
+{
+ return le16_to_cpu(item->offset);
+}
+
+static inline void btrfs_set_item_offset(struct btrfs_item *item, u16 val)
+{
+ item->offset = cpu_to_le16(val);
+}
+
+static inline u16 btrfs_item_end(struct btrfs_item *item)
+{
+ return le16_to_cpu(item->offset) + le16_to_cpu(item->size);
+}
+
+static inline u16 btrfs_item_size(struct btrfs_item *item)
+{
+ return le16_to_cpu(item->size);
+}
+
+static inline void btrfs_set_item_size(struct btrfs_item *item, u16 val)
+{
+ item->size = cpu_to_le16(val);
+}
+
static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu,
struct btrfs_disk_key *disk)
{