2010/12/3 Eric Blake <eblake@xxxxxxxxxx>: > Making this change will allow the future patches to use > virFileWriteStr to create a file, rather than its current limitation > of only working on pre-existing files. > > * src/util/util.h (virFileWriteStr): Alter signature. > * src/util/util.c (virFileWriteStr): Allow file creation. > * src/network/bridge_driver.c (networkEnableIpForwarding) > (networkDisableIPV6): Adjust clients. > * src/node_device/node_device_driver.c > (nodeDeviceVportCreateDelete): Likewise. > * src/util/cgroup.c (virCgroupSetValueStr): Likewise. > * src/util/pci.c (pciBindDeviceToStub, pciUnBindDeviceFromStub): > Likewise. > Based on a report from Jean-Baptiste Rouault. > --- > >> 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 > > How does this look? ÂAdmittedly, all existing uses were okay with a > mode parameter of 0; and I haven't yet seen your patch that would > use a non-zero mode, but this still makes more sense to me. > > Oh, and VIR_FORCE_CLOSE preserves errno, so I was able to simplify > virFileWriteStr in the process. > > Âsrc/network/bridge_driver.c     Â|  Â8 ++++---- > Âsrc/node_device/node_device_driver.c |  Â2 +- > Âsrc/util/cgroup.c          Â|  Â2 +- > Âsrc/util/pci.c            |  16 ++++++++-------- > Âsrc/util/util.c           Â|  13 ++++++++----- > Âsrc/util/util.h           Â|  Â3 ++- > Â6 files changed, 24 insertions(+), 20 deletions(-) > ACK. Matthias -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list