Il giorno lun 23 ago 2021 alle ore 02:37 Denys Vlasenko <
vda.li...@googlemail.com> ha scritto:

>
> So, unit-linux _does_ fall back to RO if -o rw is specified?
>

Quick answer: yes and not, it depends by remount

== util-linux mount ==

tc@box:~$ sudo /usr/local/bin/mount -o remount,rw /mnt/sr0
mount: /mnt/sr0: cannot remount /dev/sr0 read-write, is write-protected.
tc@box:~$ echo $?
32
tc@box:~$ sudo /usr/local/bin/mount -o remount,rwqwerty /mnt/sr0
mount: /mnt/sr0: cannot remount /dev/sr0 read-write, is write-protected.
tc@box:~$ echo $?
32

tc@box:~$ sudo /usr/local/bin/mount -o rw /dev/sr0 /mnt/sda2/
mount: /mnt/sda2: WARNING: source write-protected, mounted read-only.
tc@box:~$ echo $?
0
tc@box:~$ sudo umount /mnt/sda2/
tc@box:~$ sudo /usr/local/bin/mount -o rwqwerty /dev/sr0 /mnt/sda2/
mount: /mnt/sda2: WARNING: source write-protected, mounted read-only.
tc@box:~$ echo $?
0

== patched busybox mount ==

tc@box:~$ sudo /bin/mount -o remount,rwqwerty /mnt/sr0
tc@box:~$ echo $?
0
tc@box:~$ sudo /bin/mount -o remount,rw /mnt/sr0
mount: mounting /dev/sr0 on /mnt/sr0 failed: Read-only file system
tc@box:~$ echo $?
255

tc@box:~$ sudo /bin/mount -o rw /dev/sr0 /mnt/sda2/
tc@box:~$ echo $?
0
tc@box:~$ sudo /bin/mount -o rw /dev/sr0 /mnt/sda2/
tc@box:~$ echo $?
0


> Then this is wrong:
>
> +            if(!explicit_rw) {
> +                if (!strncasecmp("rw", newopts, 2)) {
> +                    explicit_rw = 1;
> +                }
> +            }
>
> (as well as buggy, it would think that "-o rwqwerty" is "rw").
>

It behaves almost like util-linux mount but not when "rwqwerty" is
defined instead of rw.
However, util-linux does not complain for "rwqwerty" nor busybox patched
mount.
When the option is wrong, it is not granted the behaviour: acceptable.
So, it is fine despite it seems not.



> +static bool explicit_rw = 0;
> ...
> +    if (opt & OPT_w) {
> +        explicit_rw = 1;
> +        append_mount_options(&cmdopts, "rw"); // -w
> +    }
>
> Global variable option_mask32 already exists, and already has
> the flag bit set for you. Let's just use it.
>

The global variable do not take in account when RW flag is UP by default
but not RW has explicitly defined.
If the user do not explicitly asked for rw, then fallback to ro it is fine
otherwise not.


>
> Fixed in git. Thank you for the bug report.
>

Please consider my patch as-is for what I wrote above.

 Thank you,
-- 
Roberto A. Foglietta
+39.349.33.30.697
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to