diff --git a/src/tests/system/kernel/file_corruption/fs/Volume.cpp b/src/tests/system/kernel/file_corruption/fs/Volume.cpp index bd879f47e0..8886207974 100644 --- a/src/tests/system/kernel/file_corruption/fs/Volume.cpp +++ b/src/tests/system/kernel/file_corruption/fs/Volume.cpp @@ -70,7 +70,17 @@ status_t Volume::Init(const char* device) { // open the device - fFD = open(device, IsReadOnly() ? O_RDONLY : O_RDWR); + if (!IsReadOnly()) { + fFD = open(device, O_RDWR); + + // If opening read-write fails, we retry read-only. + if (fFD < 0) + fFlags |= B_FS_IS_READONLY; + } + + if (IsReadOnly()) + fFD = open(device, O_RDONLY); + if (fFD < 0) return errno;