xref: /haiku/src/add-ons/kernel/file_systems/xfs/Node.h (revision 6f80a9801fedbe7355c4360bd204ba746ec3ec2d)
1 /*
2  * Copyright 2020, Shubham Bhagat, shubhambhagat111@yahoo.com
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef _NODE_H_
6 #define _NODE_H_
7 
8 
9 #include "Extent.h"
10 #include "LeafDirectory.h"
11 
12 
13 #define XFS_DIR2_LEAFN_MAGIC (0xd2ff)
14 #define XFS_DA_NODE_MAGIC (0xfebe)
15 
16 
17 //xfs_da_node_hdr
18 struct NodeHeader {
19 			BlockInfo			info;
20 			uint16				count;
21 			uint16				level;
22 };
23 
24 
25 //xfs_da_node_entry
26 struct NodeEntry {
27 			uint32				hashval;
28 			uint32				before;
29 };
30 
31 
32 class NodeDirectory {
33 public:
34 								NodeDirectory(Inode* inode);
35 								~NodeDirectory();
36 			status_t			Init();
37 			bool				IsNodeType();
38 			void				FillMapEntry(int num, ExtentMapEntry* map);
39 			status_t			FillBuffer(int type, char* buffer,
40 									int howManyBlocksFurther);
41 			void				SearchAndFillDataMap(uint64 blockNo);
42 			uint32				FindHashInNode(uint32 hashVal);
43 			uint32				GetOffsetFromAddress(uint32 address);
44 			int					EntrySize(int len) const;
45 			status_t			GetNext(char* name, size_t* length,
46 									xfs_ino_t* ino);
47 			status_t			Lookup(const char* name, size_t length,
48 									xfs_ino_t* id);
49 private:
50 			Inode*				fInode;
51 			ExtentMapEntry*		fDataMap;
52 			ExtentMapEntry*		fLeafMap;
53 			uint32				fOffset;
54 			char*				fDataBuffer;
55 				// This isn't inode data. It holds the directory block.
56 			char*				fLeafBuffer;
57 			uint32				fCurBlockNumber;
58 			uint8				fCurLeafMapNumber;
59 			uint8				fCurLeafBufferNumber;
60 };
61 
62 #endif