From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu From: "Douglas A. Gwyn" Message-ID: <3E46ACD7.50802@null.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit References: <200302091005.h19A5d2A018648@localhost.localdomain> Subject: Re: [9fans] what a mess the Unix world has become Date: Mon, 10 Feb 2003 10:04:16 +0000 Topicbox-Message-UUID: 5474cb10-eacb-11e9-9e20-41e7f4b1d025 Aharon Robbins wrote: >>I think that one really should be able to do "test -r foo && cat foo" >>without cat failing because of permissions. Yes, that was the intention. But the question comes into even sharper focus if you try to test for writability. What OS facility is there for determining whether a file would be writable without actually modifying the file? The answer: access(2). Not a mere examination of the mode bits; not a trial write to the file. When something like NFS is bolted onto Unix, access(2) is one of the things that needs to be made to work right; if NFS has complicated access rules then that is what access() needs to tap into. (Better in the filesystem support than in user-mode utilities.) VAX/VMS had a "probe" call that, as I recall, checked whether an operation would succeed but didn't do the operation. Of course, all such facilities are somewhat limited in that the condition of the file might change between a probe and actually doing the operation. There are transaction-oriented filesystems (MUMPS comes to mind) that cluster requests until a "commit" and implement a well-defined rollback scheme when the commit is unsuccessful.