[patch] rc.d/tmp (silly mkdir usage)

Vasil Dimov vd at datamax.bg
Tue Aug 2 13:08:14 GMT 2005


On Tue, Aug 02, 2005 at 01:15:35PM +0200, Joerg Sonnenberger wrote:
> On Tue, Aug 02, 2005 at 02:06:32PM +0300, Vasil Dimov wrote:
> > On Tue, Aug 02, 2005 at 12:52:34PM +0200, Dario Freni wrote:
> > > Vasil Dimov wrote:
> > > > Even we can use
> > > > if [ -d /tmp -a -w /tmp ] ; then
> > > > or (which is equivalent)
> > > > if [ -d /tmp ] && [ -w /tmp ] ; then
> > > > and save external commands (mkdir) execution and directory
> > > > creation/deletion at all.
> > > 
> > > You can't use test -w here. The script is checking if there is a
> > > read-only filesystem. -w checks only the file flags (according to the
> > > man page, at least).
> > > 
> > That's correct, -w cannot be used to check read-only filesystem.
> 
> Actually, you can. That's not portable behaviour though.
> 

Well, look what I discovered:

# mount |grep read-only
/usr/ports on /mnt/ar0s2d/usr/ports5 (nullfs, local, read-only)
# sh -c '[ -w /mnt/ar0s2d/usr/ports5 ] && echo writeable'
# bash -c '[ -w /mnt/ar0s2d/usr/ports5 ] && echo writeable'
writeable
#

One should really not rely on this.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 155 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20050802/bee3a901/attachment.bin


More information about the freebsd-hackers mailing list