Now that the device can be opened in read only mode on purpose, don't
set the read_only to 0 on success. If read_only happens because of an
actual problem with the device it's safer to leave it anyway, and this
makes parted return the proper error when trying a write operation:

  Error: Can't write to /root/disk.img, because it is opened read-only.
---
 libparted/arch/beos.c  | 2 --
 libparted/arch/gnu.c   | 2 --
 libparted/arch/linux.c | 2 --
 3 files changed, 6 deletions(-)

diff --git a/libparted/arch/beos.c b/libparted/arch/beos.c
index 497eb9c..0c3cb3b 100644
--- a/libparted/arch/beos.c
+++ b/libparted/arch/beos.c
@@ -360,8 +360,6 @@ retry:
                                dev->path, rw_error_msg, dev->path);
                        dev->read_only = 1;
                }
-       } else {
-               dev->read_only = 0;
        }
 
        _flush_cache (dev);
diff --git a/libparted/arch/gnu.c b/libparted/arch/gnu.c
index c6d6de7..6e9acce 100644
--- a/libparted/arch/gnu.c
+++ b/libparted/arch/gnu.c
@@ -361,8 +361,6 @@ gnu_new (const char* path)
                                dev->path, strerror (rw_err), dev->path);
                        dev->read_only = 1;
                }
-       } else {
-               dev->read_only = 0;
        }
 
        _flush_cache (dev);
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index e90d5b3..76f2a3a 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1745,8 +1745,6 @@ retry:
                                 dev->path, rw_error_msg, dev->path);
                         dev->read_only = 1;
                 }
-        } else {
-                dev->read_only = 0;
         }
 
         _flush_cache (dev);
-- 
2.39.1


Reply via email to