btrfs: implement btrfs_write_fs_info
Change-Id: I507fc4154f8a11235b6b6f8812c3b38924f533f7 Reviewed-on: https://review.haiku-os.org/c/haiku/+/1560 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
ba6665a3dd
commit
1519703abf
@ -59,6 +59,8 @@ public:
|
||||
|
||||
btrfs_super_block& SuperBlock() { return fSuperBlock; }
|
||||
|
||||
mutex& GetLock() { return fLock; }
|
||||
|
||||
status_t LoadSuperBlock();
|
||||
status_t WriteSuperBlock();
|
||||
|
||||
|
@ -20,6 +20,7 @@ typedef uint64 fsblock_t; // filesystem block number
|
||||
|
||||
#define BTRFS_NUM_ROOT_BACKUPS 4
|
||||
|
||||
#define BTRFS_CSUM_SIZE 32
|
||||
|
||||
struct btrfs_backup_roots {
|
||||
uint64 root;
|
||||
@ -218,7 +219,7 @@ struct btrfs_device {
|
||||
|
||||
|
||||
struct btrfs_super_block {
|
||||
uint8 checksum[32];
|
||||
uint8 checksum[BTRFS_CSUM_SIZE];
|
||||
uuid_t fsid;
|
||||
uint64 blocknum;
|
||||
uint64 flags;
|
||||
|
@ -175,6 +175,33 @@ btrfs_read_fs_info(fs_volume* _volume, struct fs_info* info)
|
||||
}
|
||||
|
||||
|
||||
static status_t
|
||||
btrfs_write_fs_info(fs_volume* _volume, const struct fs_info* info, uint32 mask)
|
||||
{
|
||||
Volume* volume = (Volume*)_volume->private_volume;
|
||||
if (volume->IsReadOnly())
|
||||
return B_READ_ONLY_DEVICE;
|
||||
|
||||
if (mask & ~FS_WFITE_FSINFO_NAME != 0)
|
||||
return B_NOT_SUPPORTED;
|
||||
|
||||
MutexLocker locker(volume->GetLock());
|
||||
status_t status = B_BAD_VALUE;
|
||||
|
||||
if (mask & FS_WRITE_FSINFO_NAME) {
|
||||
btrfs_super_block& superBlock = volume->SuperBlock();
|
||||
|
||||
strncpy(superBlock.label, info->volume_name,
|
||||
sizeof(superBlock.label) - 1);
|
||||
superBlock.label[sizeof(superBlock.label) - 1] = '\0';
|
||||
|
||||
status = volume->WriteSuperBlock();
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
@ -1119,7 +1146,7 @@ btrfs_std_ops(int32 op, ...)
|
||||
fs_volume_ops gBtrfsVolumeOps = {
|
||||
&btrfs_unmount,
|
||||
&btrfs_read_fs_info,
|
||||
NULL, // write_fs_info()
|
||||
&btrfs_write_fs_info,
|
||||
NULL, // fs_sync,
|
||||
&btrfs_get_vnode,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user