summaryrefslogtreecommitdiffstats
path: root/src/hdaccess.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-01-11 10:31:36 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2014-01-11 10:31:36 +0100
commitfd53b5603c81115a42e5b27e9aa0ab21ff2687b0 (patch)
treebeb15ce3a9570be5f4ea9597e36c6388ad613f41 /src/hdaccess.c
parent747a3b04d093d0eb4a11a82aee10d91cc48a32ac (diff)
Fix check before falling back in readonly mode
Diffstat (limited to 'src/hdaccess.c')
-rw-r--r--src/hdaccess.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/hdaccess.c b/src/hdaccess.c
index 2bf66e1..3cc8384 100644
--- a/src/hdaccess.c
+++ b/src/hdaccess.c
@@ -1404,14 +1404,11 @@ disk_t *file_test_availability(const char *device, const int verbose, int testdi
#endif
}
}
- if(try_readonly>0)
+ if(hd_h<0 && try_readonly>0)
{
testdisk_mode&=~TESTDISK_O_RDWR;
- if(hd_h<0)
- {
- mode=O_RDONLY|O_EXCL|mode_basic;
- hd_h = open(device, mode);
- }
+ mode=O_RDONLY|O_EXCL|mode_basic;
+ hd_h = open(device, mode);
if(hd_h<0 && (errno==EBUSY || errno==EINVAL))
{
mode=O_RDONLY|mode_basic;