On 12/02/2010 06:23 AM, Jean-Baptiste Rouault wrote: > This patch adds a virFileWriteStrEx() function with a > third parameter to set the created file permissions. I'm not a fan of Microsoft's naming conventions (Ex conveys no meaning, and it doesn't scale well to future extensions[1]). Can we come up with a better name, such as virFileWriteStrCreate? [1] http://blogs.msdn.com/b/michkap/archive/2006/01/31/520694.aspx Alternatively, I only counted 16 existing users of virFileWriteStr; and this is an internal API. We could easily rewrite all clients to always pass a third parameter, and change the signature of virFileWriteStr to require a mode_t argument. Hmm; some of those clients are writing to kernel files that should always exist (/proc/sys/net/ipv4/ip_forward, for example), where it's tough to justify what we would pass as a mode_t argument. So maybe pass mode==0 as a sentinel to require a pre-existing file (that is, even though open(,O_CREAT,0) is a valid syscall, it seldom makes sense, since the resulting created file cannot be re-read once closed): int virFileWriteStr(const char *path, const char *str, mode_t mode) { int fd; if (mode == 0) fd = open(path, O_WRONLY|O_TRUNC); else fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, mode); if (fd == -1) ... -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list