1 /* 2 * Copyright 2020 Suhel Mehta, mehtasuhel@gmail.com 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef VOLUME_H 6 #define VOLUME_H 7 8 #include "ufs2.h" 9 10 extern fs_volume_ops gUfs2VolumeOps; 11 extern fs_vnode_ops gufs2VnodeOps; 12 13 enum volume_flags { 14 VOLUME_READ_ONLY = 0x0001 15 }; 16 17 class Inode; 18 19 class Volume { 20 public: 21 Volume(fs_volume* volume); 22 ~Volume(); 23 24 status_t Mount(const char* device, uint32 flags); 25 status_t Unmount(); 26 status_t Initialize(int fd, const char* name, 27 uint32 blockSize, uint32 flags); 28 29 bool IsValidSuperBlock(); 30 bool IsValidInodeBlock(off_t block) const; 31 bool IsReadOnly() const 32 { return (fFlags & VOLUME_READ_ONLY) != 0; } 33 const char* Name() const; 34 fs_volume* FSVolume() const { return fFSVolume; } 35 int Device() const { return fDevice; } 36 dev_t ID() const 37 { return fFSVolume ? fFSVolume->id : -1; } 38 ufs2_super_block& SuperBlock() { return fSuperBlock; } 39 status_t LoadSuperBlock(); 40 static status_t Identify(int fd, ufs2_super_block* superBlock); 41 42 private: 43 fs_volume* fFSVolume; 44 int fDevice; 45 ufs2_super_block fSuperBlock; 46 mutex fLock; 47 uint32 fFlags; 48 Inode* fRootNode; 49 }; 50 51 #endif // VOLUME_H 52