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

Re: Source code



On Tue, Jan 04, 2011 at 08:55:41PM +0100, Olaf van der Spek wrote:
> 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?

It was an example, so I omitted error checking.  And, yes, it probably
should have been O_RDWR.  AFAIK, the only way Windows has anything
resembling Unix filesystem semantics (or Unix semantics in general) is
Services for Unix, since the Win32 API on which mingw32 and cygwin are
based just does not support them.  And even that does not allow
setuid/setgid programs by default.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187

Attachment: signature.asc
Description: Digital signature


Reply to: