Subject: Re: funlink() for fun!
To: NetBSD Kernel Technical Discussion List <>
From: None <>
List: tech-kern
Date: 07/12/2003 13:07:26
On Fri, Jul 11, 2003 at 04:20:43PM -0700, Greywolf wrote:
> Where does access(2) win over *stat(2)?  I don't understand that at all.
> Is it because it saves the copyout into the (struct stat *)?  How
> expensive is that in the grand scheme of things?
> faccess(2) would be moot, wouldn't it, given fstat(2)?

Well, for traditional UNIX filesystem both can be implemented by *stat.
For local filesystems without ACLs too. As soon as ACLs are implemented
e.g. in FFS, NTFS, AFS to name a few *stat is _not_ enough to implement
access or faccess. Even implementing proper ACL checks in user space
might not be enough for network filesystems like AFS if you don't check
the actual credentials. So basically an implementation of access or
faccess in user space would is filesystem dependent.

> How about flink(2), for an open fd?  Now, *THAT* could be useful for an
> applicable filesystem object.  I see it most useful for error recovery.
> Obviously it would not work for input streams, but for plain files, it
> could be useful.  Of course, if you have said applicable fd open for reading,
> it's probably just as easy to set up an open/write-while-read routine
> to handle the same thing, essentially, but if you have an fd which is not
> open for reading on a (S_IFREG) object which has somehow been completely
> unlinked and all you have is the fd - provided, too, that you can arrange
> a place to relink! - then you could do flink(fd, path); and be done.

I like the idea of flink(2). With flink you could extend the creat(3)
syntax (or open(2)) to allow creation of anonymous files on a filesystem
given jut one writtable directory and later add a reference somewhere.
E.g. passwd creates an anonymous files, updates it with the content of
/etc/master.passwd and links it there. To cleanup mess with unexpected
reboot etc.

> Just a thought.

Me too.


> 				--*greywolf;
> --
> NetBSD:  Don't login as root, use the su command.