From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <8363bf9b7069565c35a5d9c65953e079@rei2.9hal> Date: Fri, 25 May 2012 06:07:04 +0200 From: cinap_lenrek@gmx.de To: 9fans@9fans.net MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] test -w on directory Topicbox-Message-UUID: 953d1416-ead7-11e9-9d60-3106f5b1d025 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