From: Ian D Romanick Message-Id: <199612051809.KAA12682@xavier.cs.pdx.edu> Subject: Re: v2 funnies To: tehmul%NIITPUN AT iris DOT ernet DOT in Date: Thu, 5 Dec 1996 10:09:10 -0800 (PST) Cc: djgpp AT delorie DOT com In-Reply-To: <9E6C083001E72A00@iris.ernet.in> from "tehmul%NIITPUN@iris.ernet.in" at Dec 5, 96 09:34:00 pm MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > >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