* Added the new incompatible features of ext4.

* Now correctly only check for the incompatible features we do understand,
  not for the ones we don't. Ie. we won't mount ext4 partitions anymore that
  are using extents.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29510 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-03-14 11:04:12 +00:00
parent 2ade87ffe7
commit 431a51cc91
3 changed files with 42 additions and 20 deletions

View File

@ -269,11 +269,8 @@ Volume::Mount(const char* deviceName, uint32 flags)
return B_BAD_VALUE; return B_BAD_VALUE;
} }
if ((fSuperBlock.IncompatibleFeatures() if (_UnsupportedIncompatibleFeatures(fSuperBlock) != 0)
& EXT2_INCOMPATIBLE_FEATURE_COMPRESSION) != 0) {
dprintf("ext2: compression not supported.\n");
return B_NOT_SUPPORTED; return B_NOT_SUPPORTED;
}
// initialize short hands to the super block (to save byte swapping) // initialize short hands to the super block (to save byte swapping)
fBlockShift = fSuperBlock.BlockShift(); fBlockShift = fSuperBlock.BlockShift();
@ -372,6 +369,25 @@ Volume::InodeBlockIndex(ino_t id) const
} }
/*static*/ uint32
Volume::_UnsupportedIncompatibleFeatures(ext2_super_block& superBlock)
{
uint32 supportedIncompatible = EXT2_INCOMPATIBLE_FEATURE_FILE_TYPE
| EXT2_INCOMPATIBLE_FEATURE_RECOVER
| EXT2_INCOMPATIBLE_FEATURE_JOURNAL
/*| EXT2_INCOMPATIBLE_FEATURE_META_GROUP*/;
if ((superBlock.IncompatibleFeatures() & ~supportedIncompatible) != 0) {
dprintf("ext2: incompatible features not supported: %lx (extents %x)\n",
superBlock.IncompatibleFeatures() & ~supportedIncompatible,
EXT2_INCOMPATIBLE_FEATURE_EXTENTS);
return superBlock.IncompatibleFeatures() & ~supportedIncompatible;
}
return 0;
}
off_t off_t
Volume::_GroupBlockOffset(uint32 blockIndex) Volume::_GroupBlockOffset(uint32 blockIndex)
{ {
@ -437,6 +453,6 @@ Volume::Identify(int fd, ext2_super_block* superBlock)
if (!superBlock->IsValid()) if (!superBlock->IsValid())
return B_BAD_VALUE; return B_BAD_VALUE;
return B_OK; return _UnsupportedIncompatibleFeatures(*superBlock) == 0;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2008, Axel Dörfler, axeld@pinc-software.de. * Copyright 2008-2009, Axel Dörfler, axeld@pinc-software.de.
* This file may be used under the terms of the MIT License. * This file may be used under the terms of the MIT License.
*/ */
#ifndef VOLUME_H #ifndef VOLUME_H
@ -52,6 +52,8 @@ public:
static status_t Identify(int fd, ext2_super_block* superBlock); static status_t Identify(int fd, ext2_super_block* superBlock);
private: private:
static uint32 _UnsupportedIncompatibleFeatures(
ext2_super_block& superBlock);
off_t _GroupBlockOffset(uint32 blockIndex); off_t _GroupBlockOffset(uint32 blockIndex);
private: private:

View File

@ -97,24 +97,28 @@ struct ext2_super_block {
#define EXT2_DYNAMIC_REVISION 1 #define EXT2_DYNAMIC_REVISION 1
// compatible features // compatible features
#define EXT2_FEATURE_DIRECTORY_PREALLOCATION 0x01 #define EXT2_FEATURE_DIRECTORY_PREALLOCATION 0x0001
#define EXT2_FEATURE_IMAGIC_INODES 0x02 #define EXT2_FEATURE_IMAGIC_INODES 0x0002
#define EXT2_FEATURE_HAS_JOURNAL 0x04 #define EXT2_FEATURE_HAS_JOURNAL 0x0004
#define EXT2_FEATURE_EXT_ATTR 0x08 #define EXT2_FEATURE_EXT_ATTR 0x0008
#define EXT2_FEATURE_RESIZE_INODE 0x10 #define EXT2_FEATURE_RESIZE_INODE 0x0010
#define EXT2_FEATURE_DIRECTORY_INDEX 0x20 #define EXT2_FEATURE_DIRECTORY_INDEX 0x0020
// read-only compatible features // read-only compatible features
#define EXT2_READ_ONLY_FEATURE_SPARSE_SUPER 0x01 #define EXT2_READ_ONLY_FEATURE_SPARSE_SUPER 0x0001
#define EXT2_READ_ONLY_FEATURE_LARGE_FILE 0x02 #define EXT2_READ_ONLY_FEATURE_LARGE_FILE 0x0002
#define EXT2_READ_ONLY_FEATURE_BTREE_DIRECTORY 0x04 #define EXT2_READ_ONLY_FEATURE_BTREE_DIRECTORY 0x0004
// incompatible features // incompatible features
#define EXT2_INCOMPATIBLE_FEATURE_COMPRESSION 0x01 #define EXT2_INCOMPATIBLE_FEATURE_COMPRESSION 0x0001
#define EXT2_INCOMPATIBLE_FEATURE_FILE_TYPE 0x02 #define EXT2_INCOMPATIBLE_FEATURE_FILE_TYPE 0x0002
#define EXT2_INCOMPATIBLE_FEATURE_RECOVER 0x04 #define EXT2_INCOMPATIBLE_FEATURE_RECOVER 0x0004
#define EXT2_INCOMPATIBLE_FEATURE_JOURNAL 0x08 #define EXT2_INCOMPATIBLE_FEATURE_JOURNAL 0x0008
#define EXT2_INCOMPATIBLE_FEATURE_META_GROUP 0x10 #define EXT2_INCOMPATIBLE_FEATURE_META_GROUP 0x0010
#define EXT2_INCOMPATIBLE_FEATURE_EXTENTS 0x0040
#define EXT2_INCOMPATIBLE_FEATURE_64BIT 0x0080
#define EXT2_INCOMPATIBLE_FEATURE_MMP 0x0100
#define EXT2_INCOMPATIBLE_FEATURE_FLEX_GROUP 0x0200
// states // states
#define EXT2_STATE_VALID 0x01 #define EXT2_STATE_VALID 0x01