From eee57d3d2ec36903a4c8c68ec58aeef8d121ca6f Mon Sep 17 00:00:00 2001 From: Andreas-Joachim Peters Date: Mon, 30 Sep 2024 15:40:16 +0200 Subject: [PATCH] XrdS3: fix makePath implementation --- src/XrdS3/XrdS3Utils.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/XrdS3/XrdS3Utils.cc b/src/XrdS3/XrdS3Utils.cc index 77cfbf8c83e..a95dce13ad6 100644 --- a/src/XrdS3/XrdS3Utils.cc +++ b/src/XrdS3/XrdS3Utils.cc @@ -340,8 +340,14 @@ int S3Utils::makePath(char *path, mode_t mode) { // while ((next_path = index(next_path, int('/')))) { *next_path = '\0'; - if (XrdPosix_Mkdir(path, mode)) - if (errno != EEXIST) return errno; + if (!XrdPosix_Stat(path, &buf)) { + if (!S_ISDIR(buf.st_mode)) { + return ENOTDIR; + } + } else { + if (XrdPosix_Mkdir(path, mode)) + if (errno != EEXIST) return errno; + } *next_path = '/'; next_path = next_path + 1; }