* support for setting volume label (bug #7100).
* minor cleanup git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40243 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -83,7 +83,7 @@ ExtentStream::FindBlock(off_t offset, fsblock_t& block, uint32 *_count)
|
|||||||
int32 high = stream->extent_header.NumEntries() - 1;
|
int32 high = stream->extent_header.NumEntries() - 1;
|
||||||
int32 middle = 0;
|
int32 middle = 0;
|
||||||
while (low <= high) {
|
while (low <= high) {
|
||||||
middle = (high + low) / 2;
|
middle = (high + low) >> 1;
|
||||||
if (stream->extent_entries[middle].LogicalBlock() == index)
|
if (stream->extent_entries[middle].LogicalBlock() == index)
|
||||||
break;
|
break;
|
||||||
if (stream->extent_entries[middle].LogicalBlock() < index)
|
if (stream->extent_entries[middle].LogicalBlock() < index)
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ struct HTreeRoot {
|
|||||||
|
|
||||||
HTreeCountLimit count_limit[0];
|
HTreeCountLimit count_limit[0];
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
// Implemented in HTree.cpp
|
// Implemented in HTree.cpp
|
||||||
} _PACKED;
|
} _PACKED;
|
||||||
|
|
||||||
|
|||||||
@@ -266,6 +266,13 @@ Volume::Name() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Volume::SetName(const char* name)
|
||||||
|
{
|
||||||
|
strlcpy(fSuperBlock.name, name, sizeof(fSuperBlock.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Volume::Mount(const char* deviceName, uint32 flags)
|
Volume::Mount(const char* deviceName, uint32 flags)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
bool IsValidSuperBlock();
|
bool IsValidSuperBlock();
|
||||||
bool IsReadOnly() const
|
bool IsReadOnly() const
|
||||||
{ return (fFlags & VOLUME_READ_ONLY) != 0; }
|
{ return (fFlags & VOLUME_READ_ONLY) != 0; }
|
||||||
|
mutex& Lock();
|
||||||
bool HasExtendedAttributes() const;
|
bool HasExtendedAttributes() const;
|
||||||
|
|
||||||
Inode* RootNode() const { return fRootNode; }
|
Inode* RootNode() const { return fRootNode; }
|
||||||
@@ -44,6 +44,7 @@ public:
|
|||||||
{ return fFSVolume ? fFSVolume->id : -1; }
|
{ return fFSVolume ? fFSVolume->id : -1; }
|
||||||
fs_volume* FSVolume() const { return fFSVolume; }
|
fs_volume* FSVolume() const { return fFSVolume; }
|
||||||
const char* Name() const;
|
const char* Name() const;
|
||||||
|
void SetName(const char* name);
|
||||||
|
|
||||||
uint32 NumInodes() const
|
uint32 NumInodes() const
|
||||||
{ return fNumInodes; }
|
{ return fNumInodes; }
|
||||||
@@ -174,4 +175,11 @@ private:
|
|||||||
Inode* fRootNode;
|
Inode* fRootNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline mutex&
|
||||||
|
Volume::Lock()
|
||||||
|
{
|
||||||
|
return fLock;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // VOLUME_H
|
#endif // VOLUME_H
|
||||||
|
|||||||
@@ -177,6 +177,28 @@ ext2_read_fs_info(fs_volume* _volume, struct fs_info* info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static status_t
|
||||||
|
ext2_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;
|
||||||
|
|
||||||
|
MutexLocker locker(volume->Lock());
|
||||||
|
|
||||||
|
status_t status = B_BAD_VALUE;
|
||||||
|
|
||||||
|
if (mask & FS_WRITE_FSINFO_NAME) {
|
||||||
|
Transaction transaction(volume->GetJournal());
|
||||||
|
volume->SetName(info->volume_name);
|
||||||
|
status = volume->WriteSuperBlock(transaction);
|
||||||
|
transaction.Done();
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
ext2_sync(fs_volume* _volume)
|
ext2_sync(fs_volume* _volume)
|
||||||
{
|
{
|
||||||
@@ -1629,7 +1651,7 @@ ext2_remove_attr(fs_volume* _volume, fs_vnode* vnode,
|
|||||||
fs_volume_ops gExt2VolumeOps = {
|
fs_volume_ops gExt2VolumeOps = {
|
||||||
&ext2_unmount,
|
&ext2_unmount,
|
||||||
&ext2_read_fs_info,
|
&ext2_read_fs_info,
|
||||||
NULL, // write_fs_info()
|
&ext2_write_fs_info,
|
||||||
&ext2_sync,
|
&ext2_sync,
|
||||||
&ext2_get_vnode,
|
&ext2_get_vnode,
|
||||||
};
|
};
|
||||||
@@ -1717,7 +1739,8 @@ static file_system_module_info sExt2FileSystem = {
|
|||||||
|
|
||||||
"ext2", // short_name
|
"ext2", // short_name
|
||||||
"Ext2 File System", // pretty_name
|
"Ext2 File System", // pretty_name
|
||||||
B_DISK_SYSTEM_SUPPORTS_WRITING, // DDM flags
|
B_DISK_SYSTEM_SUPPORTS_WRITING
|
||||||
|
| B_DISK_SYSTEM_SUPPORTS_CONTENT_NAME, // DDM flags
|
||||||
|
|
||||||
// scanning
|
// scanning
|
||||||
ext2_identify_partition,
|
ext2_identify_partition,
|
||||||
|
|||||||
Reference in New Issue
Block a user