9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] test -w on directory
@ 2012-05-25  4:07 cinap_lenrek
  2012-05-25  4:41 ` erik quanstrom
  0 siblings, 1 reply; 3+ messages in thread
From: cinap_lenrek @ 2012-05-25  4:07 UTC (permalink / raw)
  To: 9fans

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] test -w on directory
  2012-05-25  4:07 [9fans] test -w on directory cinap_lenrek
@ 2012-05-25  4:41 ` erik quanstrom
  2012-05-25  8:48   ` Charles Forsyth
  0 siblings, 1 reply; 3+ messages in thread
From: erik quanstrom @ 2012-05-25  4:41 UTC (permalink / raw)
  To: 9fans

> 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.

in both cases, the test returning the wrong result won't easily
be noticed.  lp just mounts somthing else on /tmp on failure,
and juke restarts/remounts whatever.

i'm not sure anyone has noticed.

by the way, i notice juke has this gem:

	kb=4096

say what!?  fittingly, it's unused.

- erik



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] test -w on directory
  2012-05-25  4:41 ` erik quanstrom
@ 2012-05-25  8:48   ` Charles Forsyth
  0 siblings, 0 replies; 3+ messages in thread
From: Charles Forsyth @ 2012-05-25  8:48 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 165 bytes --]

>
>
>        kb=4096
>
> say what!?  fittingly, it's unused.
>
>
i'd suppose it was probably going to reduce the buffer size on a
wirelessly-connected ipaq

[-- Attachment #2: Type: text/html, Size: 383 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-05-25  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-25  4:07 [9fans] test -w on directory cinap_lenrek
2012-05-25  4:41 ` erik quanstrom
2012-05-25  8:48   ` Charles Forsyth

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).