]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/file: Deleting a directory tree should not care about missing files
authorJohn Wolfe <jwolfe@vmware.com>
Mon, 22 Feb 2021 17:37:00 +0000 (09:37 -0800)
committerJohn Wolfe <jwolfe@vmware.com>
Mon, 22 Feb 2021 17:37:00 +0000 (09:37 -0800)
Tolerate a directory entry disappearing while a directory tree is being
deleted.

open-vm-tools/lib/file/file.c

index bc6670245e76e1c116d2ce2b2d389761c456f9d4..54e850ce81f10a1ed23b040c9fad5c6d9e6977d3 100644 (file)
@@ -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);