xref: /haiku/src/add-ons/kernel/file_systems/ext2/InodeAllocator.h (revision ce4e12ca3e341178e3df50ef67cf7c1d724e9559)
1 /*
2  * Copyright 2001-2010, Haiku Inc. All rights reserved.
3  * This file may be used under the terms of the MIT License.
4  *
5  * Authors:
6  *		Janito V. Ferreira Filho
7  */
8 #ifndef INODEALLOCATOR_H
9 #define INODEALLOCATOR_H
10 
11 #include <lock.h>
12 
13 #include "ext2.h"
14 #include "Transaction.h"
15 
16 
17 class Inode;
18 class Volume;
19 
20 
21 class InodeAllocator {
22 public:
23 						InodeAllocator(Volume* volume);
24 	virtual				~InodeAllocator();
25 
26 	virtual	status_t	New(Transaction& transaction, Inode* parent,
27 							int32 mode, ino_t& id);
28 	virtual	status_t	Free(Transaction& transaction, ino_t id,
29 							bool isDirectory);
30 
31 private:
32 			status_t	_Allocate(Transaction& transaction,
33 							uint32 preferredBlockGroup, bool isDirectory,
34 							ino_t& id);
35 			status_t	_AllocateInGroup(Transaction& transaction,
36 							uint32 blockGroup, bool isDirectory,
37 							ino_t& id, uint32 numInodes);
38 			status_t	_MarkInBitmap(Transaction& transaction,
39 							fsblock_t bitmapBlock, uint32 blockGroup,
40 							uint32 numInodes, uint32& pos, uint32& checksum);
41 			status_t	_UnmarkInBitmap(Transaction& transaction,
42 							fsblock_t bitmapBlock, uint32 numInodes, ino_t id,
43 							uint32& checksum);
44 			status_t	_InitGroup(Transaction& transaction,
45 							ext2_block_group* group, fsblock_t bitmapBlock,
46 							uint32 numInodes);
47 			void		_SetInodeBitmapChecksum(ext2_block_group* group,
48 							uint32 checksum);
49 
50 			Volume*		fVolume;
51 			mutex		fLock;
52 };
53 
54 #endif	// INODEALLOCATOR_H
55