]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Translate EEXIST into ENOTEMPTY for Posix guests.
authorVMware, Inc <>
Tue, 29 Mar 2011 19:58:14 +0000 (12:58 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 29 Mar 2011 19:58:14 +0000 (12:58 -0700)
When the user executes DeleteDirectoryInGuest api with recursiveflag set to
FALSE, vix code calls File_DeleteEmptDirectory() and it internally calls
rmdir() function. If the specified directory is not empty, rmdir fails and
errno is set to different values on linux and solaris. To maintain
consistency, modified the code to translate EEXIST into ENOTEMPTY error
for Posix guests.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/services/plugins/vix/vixTools.c

index c5d568916a421852447f2238670c0ce56cca7532..6ea798dc974a8d0f1233ba1012d95c19ef4d8239 100644 (file)
@@ -2886,6 +2886,20 @@ VixToolsDeleteObject(VixCommandRequestHeader *requestMsg)  // IN
       }
       success = File_DeleteEmptyDirectory(pathName);
       if (!success) {
+#if !defined(_WIN32)
+         /*
+          * If the specified directory is not empty then
+          * File_DeleteEmptyDirectory() fails and
+          * 1. errno is set to either EEXIST or ENOTEMPTY on linux platforms.
+          * 2. errno is set EEXIST on Solaris platforms.
+          *
+          * To maintain consistency across different Posix platforms, lets
+          * re-write the error before returning.
+          */
+         if (EEXIST == errno) {
+            errno = ENOTEMPTY;
+         }
+#endif
          err = FoundryToolsDaemon_TranslateSystemErr();
          goto abort;
       }
@@ -2986,6 +3000,22 @@ VixToolsDeleteDirectory(VixCommandRequestHeader *requestMsg)  // IN
    }
 
    if (!success) {
+      if (!recursive) {
+#if !defined(_WIN32)
+         /*
+          * If the specified directory is not empty then
+          * File_DeleteEmptyDirectory() fails and
+          * 1. errno is set to either EEXIST or ENOTEMPTY on linux platforms.
+          * 2. errno is set EEXIST on Solaris platforms.
+          *
+          * To maintain consistency across different Posix platforms, lets
+          * re-write the error before returning.
+          */
+         if (EEXIST == errno) {
+            errno = ENOTEMPTY;
+         }
+#endif
+      }
       err = FoundryToolsDaemon_TranslateSystemErr();
       goto abort;
    }