提交 262b3c05 编写于 作者: C Cole Robinson

storage: fs: Don't attempt directory creation if it already exists

The current code attempts to handle this, but it only catches mkdir
failing with EEXIST. However if say trying to build /tmp for an
unprivileged qemu:///session, mkdir will fail with EPERM.

Rather than catch any errors, just don't attempt mkdir if the directory
already exists.
上级 d6f8b35d
......@@ -2289,12 +2289,13 @@ virDirCreateNoFork(const char *path,
int ret = 0;
struct stat st;
if ((mkdir(path, mode) < 0)
&& !((errno == EEXIST) && (flags & VIR_DIR_CREATE_ALLOW_EXIST))) {
ret = -errno;
virReportSystemError(errno, _("failed to create directory '%s'"),
path);
goto error;
if (!((flags & VIR_DIR_CREATE_ALLOW_EXIST) && !virFileExists(path))) {
if (mkdir(path, mode) < 0) {
ret = -errno;
virReportSystemError(errno, _("failed to create directory '%s'"),
path);
goto error;
}
}
if (stat(path, &st) == -1) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册