diff --git a/src/add-ons/kernel/file_systems/ext2/Volume.cpp b/src/add-ons/kernel/file_systems/ext2/Volume.cpp index dff0520458..cce2cba784 100644 --- a/src/add-ons/kernel/file_systems/ext2/Volume.cpp +++ b/src/add-ons/kernel/file_systems/ext2/Volume.cpp @@ -168,6 +168,16 @@ Volume::Mount(const char* deviceName, uint32 flags) if (!_VerifySuperBlock()) 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) fBlockShift = fSuperBlock.BlockShift(); if (fBlockShift < 10 || fBlockShift > 16) diff --git a/src/add-ons/kernel/file_systems/ext2/ext2.h b/src/add-ons/kernel/file_systems/ext2/ext2.h index 3b4e4f0a06..a307bb8ed6 100644 --- a/src/add-ons/kernel/file_systems/ext2/ext2.h +++ b/src/add-ons/kernel/file_systems/ext2/ext2.h @@ -171,9 +171,9 @@ struct ext2_super_block { #define EXT2_MAX_REVISION EXT2_DYNAMIC_REVISION -#define EXT2_FS_STATE_VALID 1 // File system was cleanly unmounted -#define EXT2_FS_STATE_ERROR 2 // File system has errors -#define EXT2_FS_STATE_ORPHAN 3 // Orphans are being recovered +#define EXT2_FS_STATE_VALID 0x1 // File system was cleanly unmounted +#define EXT2_FS_STATE_ERROR 0x2 // File system has errors +#define EXT2_FS_STATE_ORPHAN 0x4 // Orphans are being recovered // compatible features #define EXT2_FEATURE_DIRECTORY_PREALLOCATION 0x0001