ext2: report ext2/3/4 fs name depending on available features

Should help with #12157.

Change-Id: I7ea0310957c06606bc66a289afe8c3a78540a803
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2610
Reviewed-by: Kyle Ambroff-Kao <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
Adrien Destugues
2020-05-09 08:36:12 +00:00
committed by Jérôme Duval
parent 4bd6250035
commit 8d9eff5881
3 changed files with 10 additions and 3 deletions
@@ -401,8 +401,7 @@ Volume::Mount(const char* deviceName, uint32 flags)
TRACE("Volume::Mount(): Initialized block cache: %p\n", fBlockCache);
// initialize journal if mounted read-write
if (!IsReadOnly() &&
(fSuperBlock.CompatibleFeatures() & EXT2_FEATURE_HAS_JOURNAL) != 0) {
if (!IsReadOnly() && HasJournalFeature()) {
// TODO: There should be a mount option to ignore the existent journal
if (fSuperBlock.JournalInode() != 0) {
fJournalInode = new(std::nothrow) Inode(this,
@@ -80,6 +80,9 @@ public:
bool IndexedDirectories() const
{ return (fSuperBlock.CompatibleFeatures()
& EXT2_FEATURE_DIRECTORY_INDEX) != 0; }
bool HasJournalFeature() const
{ return (fSuperBlock.CompatibleFeatures()
& EXT2_FEATURE_HAS_JOURNAL) != 0; }
bool Has64bitFeature() const
{ return (fSuperBlock.IncompatibleFeatures()
& EXT2_INCOMPATIBLE_FEATURE_64BIT) != 0; }
@@ -175,7 +175,12 @@ ext2_read_fs_info(fs_volume* _volume, struct fs_info* info)
strlcpy(info->volume_name, volume->Name(), sizeof(info->volume_name));
// File system name
strlcpy(info->fsh_name, "ext2", sizeof(info->fsh_name));
if (volume->HasExtentsFeature())
strlcpy(info->fsh_name, "ext4", sizeof(info->fsh_name));
else if (volume->HasJournalFeature())
strlcpy(info->fsh_name, "ext3", sizeof(info->fsh_name));
else
strlcpy(info->fsh_name, "ext2", sizeof(info->fsh_name));
return B_OK;
}