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

Labels: enhancement, bug, cleanup, fixed / solved / done

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

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.

jsmeix commented at 2024-01-18 10:34:

I wanted to test it more but I don't find time for that so
https://github.com/rear/rear/pull/3091#issuecomment-1824689599
must suffice and I like to merge it tomorrow afternoon
unless there are objections from other @rear/contributors


[Export of Github issue for rear/rear.]