9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: cinap_lenrek@gmx.de
To: 9fans@9fans.net
Subject: [9fans] test -w on directory
Date: Fri, 25 May 2012 06:07:04 +0200	[thread overview]
Message-ID: <8363bf9b7069565c35a5d9c65953e079@rei2.9hal> (raw)

yesterday. anth_x discovered that test -w on directory always
returns false even tho the directory is writable.

test works by calling access(AWRITE) on the file which tries
a open(OWRITE) on the directory. this always fails because
you can't open directory for writing.

some rc scripts seem to assume that test -w should work on
directories. examples are /rc/bin/lp which tests for /tmp
being writable. another is /rc/bin/juke that tests on
/mnt/juke.

i dont know if there are other programs that use access()
to test on directory writability. (i guess not)

its hard for access() to figure out effective directory
writability except by trying to create a file in the
dir (very bad idea). (is access() allowed to return
false positives but no false negatives?)

its not clear to me from the manpage that access() is
expected to work on directories.

access bug? is test at fault here? did it work once?
are these rc scripts that use test -w on directories bogus?

suggestions? :)

--
cinap



             reply	other threads:[~2012-05-25  4:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-25  4:07 cinap_lenrek [this message]
2012-05-25  4:41 ` erik quanstrom
2012-05-25  8:48   ` Charles Forsyth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8363bf9b7069565c35a5d9c65953e079@rei2.9hal \
    --to=cinap_lenrek@gmx.de \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).