From 10e652315921d90b1791ef09935ce438557c7f30 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 13 Jul 2015 18:08:53 +0200 Subject: [PATCH] bfs_tools: some more structs needed packing. --- src/bin/bfs_tools/lib/BPlusTree.h | 26 +++++++++++++------------- src/bin/bfs_tools/lib/bfs.h | 16 ++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/bin/bfs_tools/lib/BPlusTree.h b/src/bin/bfs_tools/lib/BPlusTree.h index 5a53683f42..d294dc7d0b 100644 --- a/src/bin/bfs_tools/lib/BPlusTree.h +++ b/src/bin/bfs_tools/lib/BPlusTree.h @@ -16,12 +16,12 @@ class BPositionIO; -//****************** on-disk structures ******************** +// ****************** on-disk structures ******************** #define BPLUSTREE_NULL -1LL #define BPLUSTREE_FREE -2LL -struct bplustree_header +struct __attribute__((packed)) bplustree_header { uint32 magic; uint32 node_size; @@ -30,7 +30,7 @@ struct bplustree_header off_t root_node_pointer; off_t free_node_pointer; off_t maximum_size; - + inline bool IsValidLink(off_t link); }; @@ -49,21 +49,21 @@ enum bplustree_types { BPLUSTREE_DOUBLE_TYPE = 6 }; -struct bplustree_node { +struct __attribute((packed)) bplustree_node { off_t left_link; off_t right_link; off_t overflow_link; uint16 all_key_count; uint16 all_key_length; - + inline uint16 *KeyLengths() const; inline off_t *Values() const; inline uint8 *Keys() const; inline int32 Used() const; - uint8 *KeyAt(int32 index,uint16 *keyLength) const; - - uint8 CountDuplicates(off_t offset,bool isFragment) const; - off_t DuplicateAt(off_t offset,bool isFragment,int8 index) const; + uint8 *KeyAt(int32 index, uint16 *keyLength) const; + + uint8 CountDuplicates(off_t offset, bool isFragment) const; + off_t DuplicateAt(off_t offset, bool isFragment, int8 index) const; static inline uint8 LinkType(off_t link); static inline off_t FragmentOffset(off_t link); @@ -73,12 +73,12 @@ struct bplustree_node { #define BPLUSTREE_DUPLICATE_NODE 2 #define BPLUSTREE_DUPLICATE_FRAGMENT 3 -//************************************** +// ************************************** enum bplustree_traversing { BPLUSTREE_FORWARD = 1, BPLUSTREE_BACKWARD = -1, - + BPLUSTREE_BEGIN = 0, BPLUSTREE_END = 1 }; @@ -89,10 +89,10 @@ class BPlusTree; class NodeCache : public Cache { public: NodeCache(BPlusTree *); - + virtual Cacheable *NewCacheable(off_t offset); bplustree_node *Get(off_t offset); -// void SetOffset(bplustree_node *,off_t offset); +// void SetOffset(bplustree_node *, off_t offset); protected: BPlusTree *fTree; diff --git a/src/bin/bfs_tools/lib/bfs.h b/src/bin/bfs_tools/lib/bfs.h index 490c90dda8..0d9dff9511 100644 --- a/src/bin/bfs_tools/lib/bfs.h +++ b/src/bin/bfs_tools/lib/bfs.h @@ -85,7 +85,7 @@ struct __attribute__((packed)) data_stream int64 size; }; -//************************************** +// ************************************** struct bfs_inode; @@ -95,7 +95,7 @@ struct __attribute__((packed)) small_data uint16 name_size; uint16 data_size; char name[0]; // name_size long, followed by data - + inline char *Name(); inline uint8 *Data(); inline small_data *Next(); @@ -104,10 +104,10 @@ struct __attribute__((packed)) small_data // the file name is part of the small_data structure #define FILE_NAME_TYPE 'CSTR' -#define FILE_NAME_NAME 0x13 -#define FILE_NAME_NAME_LENGTH 1 +#define FILE_NAME_NAME 0x13 +#define FILE_NAME_NAME_LENGTH 1 -//************************************** +// ************************************** #define SHORT_SYMLINK_NAME_LENGTH 144 // length incl. terminating '\0' @@ -124,17 +124,17 @@ struct __attribute__((packed)) bfs_inode inode_addr parent; inode_addr attributes; uint32 type; // attribute type - + int32 inode_size; uint32 etc; // for in-memory structures (unused in OpenBeOS' fs) - union { + union __attribute__((packed)) { data_stream data; char short_symlink[SHORT_SYMLINK_NAME_LENGTH]; }; int32 pad[4]; small_data small_data_start[0]; -}; +}; #define INODE_MAGIC1 0x3bbe0ad9 #define INODE_TIME_SHIFT 16