By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,373 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

the difeirent bettwen the function open() with two an three parameters

P: n/a
hi all, i dont dont whats the difference, and the different bettwen flags
and mode
Sep 28 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"freegnu" <fr*****@163.comwrites:
hi all, i dont dont whats the difference, and the different bettwen flags
and mode
Please include your question in the body of your article. Not everyone
can easily see the subject header.

The question was: "the difeirent bettwen the function open() with two
an three parameters".

The open() function is not part of standard C. You're probably
referring to the POSIX function by that name. If so,
comp.unix.programmer would be an appropriate newsgroup for your
question. (That's assuming that reading your system's documentation
("man open" or "man 2 open") doesn't answer it for you.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Sep 28 '06 #2

P: n/a

freegnu wrote:
hi all, i dont dont whats the difference, and the different bettwen flags
and mode
The third parameter in open is to give mode while we create a file
using open system call, where flag 'll be O_CREAT and we can specify
the user access permissions using mode.
ex: open(char filename, O_CREAT, S_IRUSER);

If the file is already there, no need of third parameter.

flag is to give type of access of file and mode to specify who can
access the files.

Sep 28 '06 #3

P: n/a
deepak wrote:
freegnu wrote:
>hi all, i dont dont whats the difference, and the different bettwen flags
and mode

The third parameter in open is to give mode while we create a file
using open system call, where flag 'll be O_CREAT and we can specify
the user access permissions using mode.
ex: open(char filename, O_CREAT, S_IRUSER);

If the file is already there, no need of third parameter.
Just to be clear, it is needed when you use the O_CREAT
flag, wether the file already exists or not :-)
Sep 28 '06 #4

P: n/a
=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?= <NO*@Utel.nowrote:
deepak wrote:
freegnu wrote:
hi all, i dont dont whats the difference, and the different bettwen flags
and mode
The third parameter in open is to give mode while we create a file
using open system call, where flag 'll be O_CREAT and we can specify
the user access permissions using mode.
ex: open(char filename, O_CREAT, S_IRUSER);

If the file is already there, no need of third parameter.

Just to be clear, it is needed when you use the O_CREAT
flag, wether the file already exists or not :-)
Just to be clearer, it may or may not be needed for any existing open()
function; ISO C does not define it, so in conforming mode, a compiler
must accept my declaration of a function open(struct list *head).

Just to be even clearer, if the function accepts both 2 or 3 arguments,
but is not a variadic function, it isn't C at all; not ISO C, not POSIX,
not any kind of C.

Richard
Oct 3 '06 #5

P: n/a
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
[...]
Just to be clearer, it may or may not be needed for any existing open()
function; ISO C does not define it, so in conforming mode, a compiler
must accept my declaration of a function open(struct list *head).

Just to be even clearer, if the function accepts both 2 or 3 arguments,
but is not a variadic function, it isn't C at all; not ISO C, not POSIX,
not any kind of C.
POSIX (or IEEE 1003.1, or whatever) declares it as:

int open(const char *path, int oflag, ... );

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Oct 3 '06 #6

P: n/a
Keith Thompson <ks***@mib.orgwrote:
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
[...]
Just to be clearer, it may or may not be needed for any existing open()
function; ISO C does not define it, so in conforming mode, a compiler
must accept my declaration of a function open(struct list *head).

Just to be even clearer, if the function accepts both 2 or 3 arguments,
but is not a variadic function, it isn't C at all; not ISO C, not POSIX,
not any kind of C.

POSIX (or IEEE 1003.1, or whatever) declares it as:

int open(const char *path, int oflag, ... );
A creative use of variadic functions, that, but I wouldn't recommend it.

Richard
Oct 3 '06 #7

P: n/a
Richard Bos wrote:
A creative use of variadic functions, that, but I wouldn't recommend it.

Richard
Interesting, I didn't know that POSIX open() was variadic. That being said, I
don't think I can remember myself using it in a variadic fashion.
Oct 3 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.