1 /* 2 * Copyright 2020, Shubham Bhagat, shubhambhagat111@yahoo.com 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 6 #ifndef _VOLUME_H_ 7 #define _VOLUME_H_ 8 9 #include "xfs.h" 10 11 extern fs_volume_ops gxfsVolumeOps; 12 enum volume_flags { 13 VOLUME_READ_ONLY = 0x0001 14 }; 15 16 17 class Volume { 18 public: 19 Volume(fs_volume *volume); 20 ~Volume(); 21 22 status_t Mount(const char *device, uint32 flags); 23 status_t Unmount(); 24 status_t Initialize(int fd, const char *label, 25 uint32 blockSize, uint32 sectorSize); 26 27 bool IsValidSuperBlock(); 28 bool IsReadOnly() const 29 { return (fFlags & VOLUME_READ_ONLY) != 0; } 30 31 dev_t ID() const 32 { return fFSVolume ? fFSVolume->id : -1; } 33 fs_volume* FSVolume() const 34 { return fFSVolume; } 35 char* Name() 36 { return fSuperBlock.Name(); } 37 38 XfsSuperBlock& SuperBlock() { return fSuperBlock; } 39 int Device() const { return fDevice; } 40 41 static status_t Identify(int fd, XfsSuperBlock *superBlock); 42 43 #if 0 44 off_t NumBlocks() const 45 { return fSuperBlock.NumBlocks(); } 46 47 off_t Root() const { return fSuperBlock.rootino; } 48 49 static status_t Identify(int fd, SuperBlock *superBlock); 50 #endif 51 52 protected: 53 fs_volume* fFSVolume; 54 int fDevice; 55 XfsSuperBlock fSuperBlock; 56 char fName[32]; /* filesystem name */ 57 58 uint32 fDeviceBlockSize; 59 mutex fLock; 60 61 uint32 fFlags; 62 }; 63 64 #endif