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