ext2: check volume state when mounting
we deny mounting read/write when not clean or with errors. Change-Id: Ie0188319618d9d8e7199b308c007fbaeacaed87c Reviewed-on: https://review.haiku-os.org/c/haiku/+/5400 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
parent
732f5f0f87
commit
caf0369a89
@ -168,6 +168,16 @@ Volume::Mount(const char* deviceName, uint32 flags)
|
|||||||
if (!_VerifySuperBlock())
|
if (!_VerifySuperBlock())
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
|
if ((fSuperBlock.State() & EXT2_FS_STATE_VALID) == 0
|
||||||
|
|| (fSuperBlock.State() & EXT2_FS_STATE_ERROR) != 0) {
|
||||||
|
if (!IsReadOnly()) {
|
||||||
|
FATAL("Volume::Mount(): can't mount R/W, volume not clean\n");
|
||||||
|
return B_NOT_ALLOWED;
|
||||||
|
} else {
|
||||||
|
FATAL("Volume::Mount(): warning: volume not clean\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// initialize short hands to the superblock (to save byte swapping)
|
// initialize short hands to the superblock (to save byte swapping)
|
||||||
fBlockShift = fSuperBlock.BlockShift();
|
fBlockShift = fSuperBlock.BlockShift();
|
||||||
if (fBlockShift < 10 || fBlockShift > 16)
|
if (fBlockShift < 10 || fBlockShift > 16)
|
||||||
|
@ -171,9 +171,9 @@ struct ext2_super_block {
|
|||||||
|
|
||||||
#define EXT2_MAX_REVISION EXT2_DYNAMIC_REVISION
|
#define EXT2_MAX_REVISION EXT2_DYNAMIC_REVISION
|
||||||
|
|
||||||
#define EXT2_FS_STATE_VALID 1 // File system was cleanly unmounted
|
#define EXT2_FS_STATE_VALID 0x1 // File system was cleanly unmounted
|
||||||
#define EXT2_FS_STATE_ERROR 2 // File system has errors
|
#define EXT2_FS_STATE_ERROR 0x2 // File system has errors
|
||||||
#define EXT2_FS_STATE_ORPHAN 3 // Orphans are being recovered
|
#define EXT2_FS_STATE_ORPHAN 0x4 // Orphans are being recovered
|
||||||
|
|
||||||
// compatible features
|
// compatible features
|
||||||
#define EXT2_FEATURE_DIRECTORY_PREALLOCATION 0x0001
|
#define EXT2_FEATURE_DIRECTORY_PREALLOCATION 0x0001
|
||||||
|
Loading…
Reference in New Issue
Block a user