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 1345af882dSJé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, 3345af882dSJérôme Duval uint32 preferredBlockGroup, bool isDirectory, 34a1b0ec30SJérôme Duval ino_t& id); 3579de91c1SJérôme Duval status_t _AllocateInGroup(Transaction& transaction, 3679de91c1SJérôme Duval uint32 blockGroup, bool isDirectory, 3779de91c1SJérôme Duval ino_t& id, uint32 numInodes); 38a1b0ec30SJérôme Duval status_t _MarkInBitmap(Transaction& transaction, 3945af882dSJérôme Duval fsblock_t bitmapBlock, uint32 blockGroup, 40*ce4e12caSJérôme Duval uint32 numInodes, uint32& pos, uint32& checksum); 41a1b0ec30SJérôme Duval status_t _UnmarkInBitmap(Transaction& transaction, 42*ce4e12caSJérôme Duval fsblock_t bitmapBlock, uint32 numInodes, ino_t id, 43*ce4e12caSJérôme Duval uint32& checksum); 44d482c34eSJérôme Duval status_t _InitGroup(Transaction& transaction, 45d482c34eSJérôme Duval ext2_block_group* group, fsblock_t bitmapBlock, 46d482c34eSJérôme Duval uint32 numInodes); 47*ce4e12caSJérôme Duval void _SetInodeBitmapChecksum(ext2_block_group* group, 48*ce4e12caSJérôme Duval uint32 checksum); 49a1b0ec30SJérôme Duval 50a1b0ec30SJérôme Duval Volume* fVolume; 51a1b0ec30SJérôme Duval mutex fLock; 52a1b0ec30SJérôme Duval }; 53a1b0ec30SJérôme Duval 54a1b0ec30SJérôme Duval #endif // INODEALLOCATOR_H 55