POSIX and symbolic links

Sean Fagan seanf at sco.COM
Thu Nov 8 08:55:44 AEST 1990


Submitted-by: seanf at sco.COM (Sean Fagan)

I've been reading the September 1990 draft of 1003.1a (D4), and have a
question about symbolic links.  The draft specifies that an open of a file
"foo" shall fail if opened with O_CREAT and O_EXCL *both* set (which makes
sense).

But what happens if only O_CREAT is set?  To make it interesting, let's
throw in O_TRUNC as well.  That is:

	fd = open ("foo", O_CREAT|O_TRUNC|O_WRONLY, 0666);

Will the system follow the link, truncating whatever foo points to, if it
exists, or creating it otherwise, or will it truncate foo, creating a
regular file called "foo" with mode 0666&~umask?

My initial guess was that it would follow the link.  However, I can think of
cases where you would not want it to do so (someone then prompted, "Well, if
the sticky bit of the symlink is set, then..." 8-)).

Thanks...

-- 
-----------------+
Sean Eric Fagan  | "*Never* knock on Death's door:  ring the bell and 
seanf at sco.COM    |   run away!  Death hates that!"
uunet!sco!seanf  |     -- Dr. Mike Stratford (Matt Frewer, "Doctor, Doctor")
(408) 458-1422   | Any opinions expressed are my own, not my employers'.


Volume-Number: Volume 22, Number 20




More information about the Comp.std.unix mailing list