[PLUG] Trying to learn low level Linux programming for cs201...

Tim tim-pdxlug at sentinelchicken.org
Fri Jan 9 23:14:32 UTC 2009


> I was looking at man 2 open, thought from there that I could O_TRUNC ||
> O_CREAT.  Changing it to O_WRONLY made the copy work.  Strange.

Well, if you want truncation behavior, I think you should leave that flag
there.  It's just that O_TRUNC doesn't imply O_WRONLY or O_RDWR.  After
all, which would it be, reading-and-writing or just writing?  So I would
suggest using flags:

  O_WRONLY|O_CREAT|O_TRUNC

Good luck,
tim



More information about the PLUG mailing list