[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Source code

On Tue, Jan 4, 2011 at 8:45 PM, brian m. carlson
<sandals@crustytoothpaste.net> wrote:
> Because lots of programs expect something like
>  fd = open("/tmp/foo", O_WRONLY|O_CREAT|O_EXCL);
>  unlink("/tmp/foo");
>  write(fd, "data", 4);
> to succeed.  This is how Unix filesystem semantics work and pretty much
> always have.  POSIX allows unlink(2) to return EBUSY, but that's not at
> all Unixy.  The only case I can see for EBUSY is what NetBSD and OpenBSD
> do: restrict unlinking a mount point.  (This is also the only case for
> EBUSY on Solaris, Ultrix, and HP-UX.)

unlink will probably return an error, but since that's not checked,
that snippet will succeed.
WRONLY seems weird, what's the purpose of a snippet like this?


Reply to: