1 // Volume.h 2 // 3 // Copyright (c) 2003, Ingo Weinhold (bonefish@cs.tu-berlin.de) 4 // 5 // This program is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 2 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 // 19 // You can alternatively use *this file* under the terms of the the MIT 20 // license included in this package. 21 22 #ifndef VOLUME_H 23 #define VOLUME_H 24 25 #include <fs_interface.h> 26 #include <SupportDefs.h> 27 28 #include "hashes.h" 29 #include "List.h" 30 31 struct reiserfs_super_block; 32 33 class BlockCache; 34 class Tree; 35 class Settings; 36 class SuperBlock; 37 class VNode; 38 39 class Volume { 40 public: 41 Volume(); 42 ~Volume(); 43 44 status_t Identify(int fd, partition_data *partition); 45 46 status_t Mount(fs_volume *fsVolume, const char *path); 47 status_t Unmount(); 48 49 dev_t GetID() const { return fFSVolume->id; } 50 fs_volume *GetFSVolume() const { return fFSVolume; } 51 52 off_t GetBlockSize() const; 53 off_t CountBlocks() const; 54 off_t CountFreeBlocks() const; 55 const char *GetName() const; 56 void UpdateName(partition_id partitionID); 57 const char *GetDeviceName() const; 58 59 BlockCache *GetBlockCache() const { return fBlockCache; } 60 Tree *GetTree() const { return fTree; } 61 Settings *GetSettings() const { return fSettings; } 62 63 status_t GetKeyOffsetForName(const char * name, int len, uint64 *result); 64 65 VNode *GetRootVNode() const { return fRootVNode; } 66 67 status_t GetVNode(ino_t id, VNode **node); 68 status_t PutVNode(ino_t id); 69 70 status_t FindVNode(ino_t id, VNode *node); 71 status_t FindVNode(uint32 dirID, uint32 objectID, VNode *node); 72 73 status_t FindDirEntry(VNode *dir, const char *entryName, 74 VNode *foundNode, bool failIfHidden = false); 75 status_t ReadObject(VNode *node, off_t offset, void *buffer, 76 size_t bufferSize, size_t *bytesRead); 77 status_t ReadLink(VNode *node, char *buffer, size_t bufferSize, 78 size_t *bytesRead); 79 80 status_t FindEntry(const VNode *rootDir, const char *path, 81 VNode *foundNode); 82 83 bool IsNegativeEntry(ino_t id); 84 bool IsNegativeEntry(uint32 dirID, uint32 objectID); 85 86 bool GetHideEsoteric() const; 87 88 private: 89 status_t _ReadSuperBlock(); 90 void _InitHashFunction(); 91 uint32 _DetectHashFunction(); 92 bool _VerifyHashFunction(hash_function_t function); 93 void _InitNegativeEntries(); 94 95 private: 96 fs_volume *fFSVolume; 97 int fDevice; 98 BlockCache *fBlockCache; 99 Tree *fTree; 100 SuperBlock *fSuperBlock; 101 hash_function_t fHashFunction; 102 VNode *fRootVNode; 103 char *fDeviceName; 104 Settings *fSettings; 105 List<ino_t> fNegativeEntries; 106 char fVolumeName[B_OS_NAME_LENGTH]; 107 }; 108 109 #endif // VOLUME_H 110