diff --git a/src/add-ons/kernel/file_systems/reiserfs/Volume.cpp b/src/add-ons/kernel/file_systems/reiserfs/Volume.cpp index 0a877c3bdd..7b86d7fa10 100644 --- a/src/add-ons/kernel/file_systems/reiserfs/Volume.cpp +++ b/src/add-ons/kernel/file_systems/reiserfs/Volume.cpp @@ -78,6 +78,7 @@ Volume::Volume() fSettings(NULL), fNegativeEntries() { + fVolumeName[0] = '\0'; } // destructor @@ -86,6 +87,7 @@ Volume::~Volume() Unmount(); } + // Identify status_t Volume::Identify(int fd, partition_data *partition) @@ -131,6 +133,10 @@ Volume::Mount(fs_volume *fsVolume, const char *path) // read and analyze super block if (error == B_OK) error = _ReadSuperBlock(); + + if (error == B_OK) + UpdateName(fsVolume->partition); + // create and init block cache if (error == B_OK) { fBlockCache = new(nothrow) BlockCache; @@ -248,9 +254,21 @@ Volume::CountFreeBlocks() const const char * Volume::GetName() const { - return fSettings->GetVolumeName(); + return fVolumeName; } + +// UpdateName +void +Volume::UpdateName(partition_id partitionID) +{ + if (get_default_partition_content_name(partitionID, "ReiserFS", + fVolumeName, sizeof(fVolumeName)) != B_OK) { + strlcpy(fVolumeName, "ReiserFS Volume", sizeof(fVolumeName)); + } +} + + // GetDeviceName const char * Volume::GetDeviceName() const @@ -658,4 +676,3 @@ Volume::_InitNegativeEntries() } } } - diff --git a/src/add-ons/kernel/file_systems/reiserfs/Volume.h b/src/add-ons/kernel/file_systems/reiserfs/Volume.h index b2acd7077b..230d6b8108 100644 --- a/src/add-ons/kernel/file_systems/reiserfs/Volume.h +++ b/src/add-ons/kernel/file_systems/reiserfs/Volume.h @@ -53,6 +53,7 @@ public: off_t CountBlocks() const; off_t CountFreeBlocks() const; const char *GetName() const; + void UpdateName(partition_id partitionID); const char *GetDeviceName() const; BlockCache *GetBlockCache() const { return fBlockCache; } @@ -102,6 +103,7 @@ private: char *fDeviceName; Settings *fSettings; List fNegativeEntries; + char fVolumeName[B_OS_NAME_LENGTH]; }; #endif // VOLUME_H diff --git a/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp index f25057774b..7ec24a373c 100644 --- a/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp @@ -1,6 +1,6 @@ // kernel_interface.cpp // -// Copyright (c) 2003-2004, Ingo Weinhold (bonefish@cs.tu-berlin.de) +// Copyright (c) 2003-2008, Ingo Weinhold (bonefish@cs.tu-berlin.de) // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -88,8 +88,10 @@ reiserfs_scan_partition(int fd, partition_data *partition, void *_cookie) partition->content_size = volume->CountBlocks() * volume->GetBlockSize(); partition->block_size = volume->GetBlockSize(); - // TODO: Construct name from partition layout? - partition->content_name = strdup("Untitled ReiserFS"); + + volume->UpdateName(partition->id); + // must be done after setting the content size + partition->content_name = strdup(volume->GetName()); if (partition->content_name == NULL) return B_NO_MEMORY; @@ -163,9 +165,9 @@ reiserfs_read_fs_info(fs_volume* fs, struct fs_info *info) info->io_size = kOptimalIOSize; info->total_blocks = volume->CountBlocks(); info->free_blocks = volume->CountFreeBlocks(); - strncpy(info->device_name, volume->GetDeviceName(), + strlcpy(info->device_name, volume->GetDeviceName(), sizeof(info->device_name)); - strncpy(info->volume_name, volume->GetName(), sizeof(info->volume_name)); + strlcpy(info->volume_name, volume->GetName(), sizeof(info->volume_name)); return B_OK; }