Rasmus Villemoes wrote:
It seems that busybox' "test" returns the wrong result when applied to a
R/O filesystem.
### Permissions "allow" write for root
# ls -ld /
drwxr-xr-x 15 root root 221 Apr 5 2011 /
The rw-permission bits do not matter if the effective user id is root.
Root has always rw-access (and x-access if any x-bit is set) if the
filesystem is not R/O.
### But the rootfs is (and can only be) mounted ro
# mount | grep ' / '
/dev/mmcblk0p5 on / type squashfs (ro,noatime,errors=continue)
### With coreutils test
# test -w / && echo Writable || echo Not writable
Not writable
### With busybox test
# busybox test -w / && echo Writable || echo Not writable
Writable
The 'test' implementation of gnu coreutils uses euidaccess() from
gnulib. This usually calls a kernel function faccessat(), eaccess() or
similar and only falls back to the traditional check (euid is root or
the relevant w-bit is set) if none of these are available. The busybox
implementation of euidaccess() only uses a simplified variant of the
latter method. This cannot detect R/O mounts but the kernel functions
possibly do.
https://github.com/coreutils/gnulib/blob/master/lib/euidaccess.c
BTW, the behavior of the builtin 'test' commands of various shells may
also differ if the filesystem is R/O.
--
Regards,
Christian
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox