LWN.net Logo

Add new mode letter to fopen()

Add new mode letter to fopen()

Posted Mar 18, 2009 0:17 UTC (Wed) by quotemstr (subscriber, #45331)
In reply to: Add new mode letter to fopen() by ikm
Parent article: Better than POSIX?

FILE * f = fopen( "precious_config", "wf" );
All we need is a "t" flag. :-)

In all seriousness, I think that's the wrong level of abstraction for this functionality. A C FILE* returned by fopen should correspond to only one underlying file, and that file shouldn't magically change its name.

Besides, a flag to open won't work because the kernel would have to spool modifications to that file until commit, and that would not only be very complex, but could open up all kind of denial-of-service attacks.

I wouldn't mind, however, a libc function that encapsulated the very common open-write-close-rename sequence. I wouldn't even mind some function that returned a FILE*. I just don't think that function should be called fopen, and don't think that FILE* shouldn't be closed with fclose -- think of something more like popen.


(Log in to post comments)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds