#3091 PR open: Let is_write_protected() report devices without device node as not write protected

Labels: enhancement, bug, cleanup

jsmeix opened issue at 2023-11-23 10:00:

  • Type: Bug Fix / Enhancement

  • Impact: Normal

  • Reference to related issue (URL):
    https://github.com/rear/rear/issues/3085

  • How was this pull request tested?
    I don't know how I could test it.
    I cannot reproduce the matching issue
    because I don't have a system with /sys/block/nvme0c0n1
    or something similar - i.e. where a /sys/block/device
    does not have a matching /dev/device.

  • Description of the changes in this pull request:

Let the is_write_protected function
report candidate devices without device node
as not write protected
because not all /sys/block devices have a "dev" file
e.g. /sys/block/nvme0c0n1 has no /dev/nvme0c0n1 device node, see
https://github.com/rear/rear/issues/3085

Because the is_write_protected function is meant
to identify write-protected disks and partitions
only candidate devices with a device node
are considered for write protection.

jsmeix commented at 2023-11-23 10:17:

@pcahyna
could you please have a look here (as time permits)
because I don't know how to test it as I don't have a system
with /sys/block/nvme0c0n1 or something similar
i.e. where a /sys/block/device does not have a matching /dev/device

jsmeix commented at 2023-11-23 16:21:

Oops - I did it again ;-)

Because I got confused by the former helper functions
where all used $device but with changed meanings
I needed to clean up things so that at least I can
better understand what goes on to be able to fix
issues that I can neither reproduce nor test
with a higher probability that my fix actually works.

jsmeix commented at 2023-11-23 16:23:

I did some tests on my test system
and things worked so far at least for me
so it is now (hopefully) not totally broken.

I will test more tomorrow.


[Export of Github issue for rear/rear.]