From: John Wolfe Date: Mon, 22 Feb 2021 17:37:00 +0000 (-0800) Subject: lib/file: Deleting a directory tree should not care about missing files X-Git-Tag: stable-11.3.0~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff99f1169acc775d2e150f9cd4035c3bbd5eaf02;p=thirdparty%2Fopen-vm-tools.git lib/file: Deleting a directory tree should not care about missing files Tolerate a directory entry disappearing while a directory tree is being deleted. --- diff --git a/open-vm-tools/lib/file/file.c b/open-vm-tools/lib/file/file.c index bc6670245..54e850ce8 100644 --- a/open-vm-tools/lib/file/file.c +++ b/open-vm-tools/lib/file/file.c @@ -1923,17 +1923,23 @@ FileDeleteDirectoryTree(const char *pathName, // IN: directory to delete #if !defined(_WIN32) case S_IFLNK: /* Delete symlink, not what it points to */ - if (FileDeletion(curPath, FALSE) != 0) { + err = FileDeletion(curPath, FALSE); + + if ((err != 0) && (err != ENOENT)) { fileError = Err_Errno(); } break; #endif default: - if (FileDeletion(curPath, FALSE) != 0) { + err = FileDeletion(curPath, FALSE); + + if ((err != 0) && (err != ENOENT)) { #if defined(_WIN32) if (File_SetFilePermissions(curPath, S_IWUSR)) { - if (FileDeletion(curPath, FALSE) != 0) { + err = FileDeletion(curPath, FALSE); + + if ((err != 0) && (err != ENOENT)) { fileError = Err_Errno(); } } else { @@ -1946,9 +1952,11 @@ FileDeleteDirectoryTree(const char *pathName, // IN: directory to delete break; } } else { - fileError = Err_Errno(); - Log(LGPFX" %s: Lstat of '%s' failed, errno = %d\n", - __FUNCTION__, curPath, errno); + if (errno != ENOENT) { + fileError = Err_Errno(); + Log(LGPFX" %s: Lstat of '%s' failed, errno = %d\n", + __FUNCTION__, curPath, errno); + } } Posix_Free(curPath);