read_fs_info() hook for xfs

xfs: read_fs_info() hook.

Change-Id: I817b1ca2cd37d1dc894cdeefac967f659cfcb502
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2416
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
CruxBox
2020-06-03 11:35:13 +00:00
committed by Adrien Destugues
parent 68ea01249e
commit 0ba51bc88f
3 changed files with 51 additions and 3 deletions
@@ -7,6 +7,8 @@
#include "Volume.h" #include "Volume.h"
#define XFS_IO_SIZE 65536
struct identify_cookie struct identify_cookie
{ {
/* super_block_struct super_block; /* super_block_struct super_block;
@@ -108,7 +110,20 @@ xfs_unmount(fs_volume *_volume)
static status_t static status_t
xfs_read_fs_info(fs_volume *_volume, struct fs_info *info) xfs_read_fs_info(fs_volume *_volume, struct fs_info *info)
{ {
return B_NOT_SUPPORTED; Volume* volume = (Volume*)_volume->private_volume;
info->flags = B_FS_IS_READONLY
| B_FS_HAS_ATTR | B_FS_IS_PERSISTENT;
info->io_size = XFS_IO_SIZE;
info->block_size = volume->SuperBlock().BlockSize();
info->total_blocks = volume->SuperBlock().TotalBlocks();
info->free_blocks = volume->SuperBlock().FreeBlocks();
strlcpy(info->volume_name, volume->Name(), sizeof(info->volume_name));
strlcpy(info->fsh_name, "xfs", sizeof(info->fsh_name));
return B_OK;
} }
+29 -1
View File
@@ -11,7 +11,7 @@ XfsSuperBlock::IsValid()
{ {
if (sb_magicnum != XFS_SB_MAGIC) return false; if (sb_magicnum != XFS_SB_MAGIC) return false;
if (BBLOCKSIZE <= sb_blocksize){ if (BBLOCKSIZE > sb_blocksize){
ERROR("Basic block is less than 512 bytes!"); ERROR("Basic block is less than 512 bytes!");
return false; return false;
} }
@@ -34,6 +34,34 @@ XfsSuperBlock::Size()
} }
xfs_rfsblock_t
XfsSuperBlock::TotalBlocks()
{
return sb_dblocks;
}
xfs_rfsblock_t
XfsSuperBlock::TotalBlocksWithLog()
{
return TotalBlocks() + sb_logblocks;
}
uint64
XfsSuperBlock::FreeBlocks()
{
return sb_fdblocks;
}
uint64
XfsSuperBlock::UsedBlocks()
{
return TotalBlocks() - FreeBlocks();
}
char* char*
XfsSuperBlock::Name() XfsSuperBlock::Name()
{ {
+6 -1
View File
@@ -29,6 +29,10 @@ public:
bool IsValid(); bool IsValid();
char* Name(); char* Name();
uint32 BlockSize(); uint32 BlockSize();
xfs_rfsblock_t TotalBlocks();
xfs_rfsblock_t TotalBlocksWithLog();
uint64 FreeBlocks();
uint64 UsedBlocks();
uint32 Size(); uint32 Size();
void SwapEndian(); void SwapEndian();
@@ -149,6 +153,7 @@ for reverse-mapped B+Trees. I have spare0/1 defined here instead.
#define XFS_AG_MAGICNUM 0x58414746 #define XFS_AG_MAGICNUM 0x58414746
class AGFreeSpace{ class AGFreeSpace{
public: public:
//TODO:
void SwapEndian(); void SwapEndian();
private: private:
uint32 magicnum; uint32 magicnum;
@@ -172,7 +177,7 @@ class AGFreeSpace{
*/ */
uint32 btreeblks; uint32 btreeblks;
} };
#endif #endif