On 07/10/2012 05:33 AM, Osier Yang wrote:
Instead of changing the existed virFileMakePath to accept mode
argument and modifying a pile of its uses, this patch introduces
virFileMakePathWithMode, and use it instead of mkdir() to create
the readline history dir.
---
src/libvirt_private.syms | 1 +
src/util/util.c | 15 +++++++++++----
src/util/util.h | 2 ++
tools/virsh.c | 3 ++-
4 files changed, 16 insertions(+), 5 deletions(-)
Does this always do the right thing? Remember, 'mkdir -p a/b/c' has the
ability to create parent directories 'a' and 'a/b' with a different mode
than the final directory 'a/b/c'; it is often the case that you want the
parent directories to have more permissions than the final child.
+++ b/tools/virsh.c
@@ -20627,7 +20627,8 @@ static void
vshReadlineDeinit (vshControl *ctl)
{
if (ctl->historyfile != NULL) {
- if (mkdir(ctl->historydir, 0755) < 0 && errno != EEXIST) {
+ if (virFileMakePathWithMode(ctl->historydir, 0755) < 0 &&
But if we are happy with all intermediate directories being created mode
0755 instead of the default of 0777 from the original virFileMakePath,
then this patch makes sense.
ACK.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org