[parted-devel] [PATCH 0/5] Add --readonly flag to parted

Brian C. Lane bcl at redhat.com
Fri Feb 10 01:18:56 GMT 2023


Patches are also on GitHub - https://github.com/bcl/parted/pull/13

The benefit of this is that you can now easily read the device without
triggering any udev events with:

parted --script --readonly /dev/sda u s p free


After looking at the various options, I came up with a new one :)
Despite my aversion to adding new flags, I think this is the best way to
go about it. It doesn't depend on guessing the user's intent or
switching modes in the middle of operations.

It builds on the patch from Konstantin, and adds a --readonly flag that
opens it as read only, and leaves it as read only. This is slightly
different from previous behavior and use of read_only in that if
something else triggers read only mode it will not revert to write until
closed and exited. Which is fine, unexpected problems shouldn't really
keep trying write mode.

Let me know what you think.

Brian


Brian C. Lane (4):
  tests: Add a libparted test for reading the disk with read_only=1
  parted: Add --readonly cmdline option
  libparted: Leave device in read_only mode
  tests: Add tests for --readonly flag

Konstantin Kharlamov (1):
  arch: allow to open devices in read-only mode

 libparted/arch/beos.c              |   4 +-
 libparted/arch/gnu.c               |   2 -
 libparted/arch/linux.c             |   4 +-
 libparted/tests/Makefile.am        |   6 +-
 libparted/tests/read_only.c        | 133 +++++++++++++++++++++++++++++
 libparted/tests/t1002-read_only.sh |  23 +++++
 parted/parted.c                    |  70 +++++++++------
 tests/Makefile.am                  |   2 +
 tests/t0102-print-readonly.sh      |  30 +++++++
 tests/t1105-mklabel-readonly.sh    |  33 +++++++
 10 files changed, 270 insertions(+), 37 deletions(-)
 create mode 100644 libparted/tests/read_only.c
 create mode 100755 libparted/tests/t1002-read_only.sh
 create mode 100644 tests/t0102-print-readonly.sh
 create mode 100644 tests/t1105-mklabel-readonly.sh

-- 
2.39.1




More information about the parted-devel mailing list