[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: what's invalid about this?
You didn't say whether you are opening for read or write...
- todd
In message <199809142235.QAA05102@openbsd.cs.colorado.edu>
so spake Jim Rees (rees):
> Sorry, I've read the man page, and I can't figure this out.
>
> What open flags should I give to create a file if it doesn't exist, or
> truncate it if it does? I used to use (O_CREAT | O_TRUNC), and this worked
> with 2.2, but returns EINVAL with 2.3.
>
> Here's a test program.
>
> #include <fcntl.h>
> #include <sys/errno.h>
>
> main()
> {
> static char name[] = "/tmp/xxxx";
> if (open(name, O_CREAT | O_TRUNC, 0644) < 0)
> perror("creat");
> unlink(name);
> exit(0);
> }