vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / kernel / file_systems / ext2 / BlockAllocator.h
blob8062fdba7358f43a49a0dcdfe1b42ed7486a687f
1 /*
2 * Copyright 2001-2010, Haiku Inc. All rights reserved.
3 * This file may be used under the terms of the MIT License.
5 * Authors:
6 * Janito V. Ferreira Filho
7 */
8 #ifndef BLOCKALLOCATOR_H
9 #define BLOCKALLOCATOR_H
12 #include <lock.h>
14 #include "ext2.h"
15 #include "Transaction.h"
18 class AllocationBlockGroup;
19 class Inode;
20 class Volume;
23 class BlockAllocator {
24 public:
25 BlockAllocator(Volume* volume);
26 ~BlockAllocator();
28 status_t Initialize();
30 status_t AllocateBlocks(Transaction& transaction,
31 uint32 minimum, uint32 maximum, uint32& blockGroup,
32 fsblock_t& start, uint32& length);
33 status_t Allocate(Transaction& transaction, Inode* inode,
34 off_t numBlocks, uint32 minimum, fsblock_t& start,
35 uint32& length);
36 status_t Free(Transaction& transaction, fsblock_t start,
37 uint32 length);
39 uint32 FreeBlocks();
41 protected:
42 static status_t _Initialize(BlockAllocator* allocator);
45 Volume* fVolume;
46 mutex fLock;
48 AllocationBlockGroup* fGroups;
49 uint32 fBlocksPerGroup;
50 fsblock_t fNumBlocks;
51 uint32 fNumGroups;
52 fsblock_t fFirstBlock;
55 #endif // BLOCKALLOCATOR_H