X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fdir.c;h=3df6233a5a1580082f6f3b113855b14d3bf9830d;hp=f706466082ea9392714bdd7ff967ba5d8548cda3;hb=f6e36bf361c587e0dbb2f0c71f5d22a7cf7f4f42;hpb=1e4173be10cf762c85f7f64ab27be98f3b57dd7a diff --git a/daemon/dir.c b/daemon/dir.c index f706466..3df6233 100644 --- a/daemon/dir.c +++ b/daemon/dir.c @@ -117,10 +117,21 @@ recursive_mkdir (const char *path) int loop = 0; int r; char *ppath, *p; + struct stat buf; again: r = mkdir (path, 0777); if (r == -1) { + if (errno == EEXIST) { /* Something exists here, might not be a dir. */ + r = lstat (path, &buf); + if (r == -1) return -1; + if (!S_ISDIR (buf.st_mode)) { + errno = ENOTDIR; + return -1; + } + return 0; /* OK - directory exists here already. */ + } + if (!loop && errno == ENOENT) { loop = 1; /* Stops it looping forever. */