Mail Archives: djgpp/1996/12/05/13:28:01
> >If I call open("filename",mode) with two args to create a new file and write
> >to it, even if I use mode O_RDWR, the file is created with its DOS readonly
> >attribute set so it can't be altered or deleted afterwards (unless I state
> >the permission required, as open("filename",mode,S_IWUSR)). This is
> >unexpected and annoying, and did not happen in v1. Why is this?
>
>
> I thought that ANSI behaviour specifies that whenever you create a file, the
> third parameter to open (the permission) is _mandatory_, not optional. So
> not giving the third parameter while creating the file might be a mistake in
> the first place. (Correct me if I'm wrong guys, I haven't looked at any ref
> manual for a loong time.)
Well, ANSI doesn't specify *anything* for open: it's not part of the
standard. But looking at the man page on a Solaris (POSIX) sytem, it
shows the prototype as:
int open(const char *path, int oflag, /* mode_t mode */ ...);
It also only mentions the use of the mode field if O_CREAT is set in the
oflag field. So it seems that this is perfectly valid usage.
--
The words I live by:
"That which does not kill us makes us stronger."
"There is no knowledge that is not power." Knowledge and power at:
"Without struggle, there is no progress." http://www.cs.pdx.edu/~idr
- Raw text -