1 /* Inode - emulation for the B+Tree torture test 2 ** 3 ** Initial version by Axel Dörfler, axeld@pinc-software.de 4 ** This file may be used under the terms of the MIT License. 5 */ 6 7 8 #include "Inode.h" 9 #include "Volume.h" 10 #include "Journal.h" 11 12 13 Inode::Inode(const char *name,int32 mode) 14 : 15 fMode(mode) 16 { 17 rw_lock_init(&fLock, "inode lock"); 18 fFile.SetTo(name,B_CREATE_FILE | B_READ_WRITE | B_ERASE_FILE); 19 fSize = 0; 20 fVolume = new Volume(&fFile); 21 } 22 23 24 Inode::~Inode() 25 { 26 delete fVolume; 27 } 28 29 30 status_t 31 Inode::FindBlockRun(off_t pos, block_run &run, off_t &offset) 32 { 33 // the whole file data is covered by this one block_run structure... 34 run.SetTo(0,0,1); 35 offset = 0; 36 return B_OK; 37 } 38 39 40 status_t 41 Inode::Append(Transaction& transaction, off_t bytes) 42 { 43 return SetFileSize(transaction, Size() + bytes); 44 } 45 46 47 status_t 48 Inode::SetFileSize(Transaction&, off_t bytes) 49 { 50 //printf("set size = %ld\n",bytes); 51 fSize = bytes; 52 return fFile.SetSize(bytes); 53 } 54 55