From c6bc0bdd73a9394d1a3abbb3181e7b2e82edab5e Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 20 Jul 2010 08:44:30 +0000 Subject: [PATCH] When opening the device read-write failed, retry read-only. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37614 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../system/kernel/file_corruption/fs/Volume.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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;