From: VMware, Inc <> Date: Tue, 29 Mar 2011 19:58:14 +0000 (-0700) Subject: Translate EEXIST into ENOTEMPTY for Posix guests. X-Git-Tag: 2011.03.28-387002~64 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4ced9c4bc1aba88dae0d772de28b0b8d9c9e8a1a;p=thirdparty%2Fopen-vm-tools.git Translate EEXIST into ENOTEMPTY for Posix guests. 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 --- diff --git a/open-vm-tools/services/plugins/vix/vixTools.c b/open-vm-tools/services/plugins/vix/vixTools.c index c5d568916..6ea798dc9 100644 --- a/open-vm-tools/services/plugins/vix/vixTools.c +++ b/open-vm-tools/services/plugins/vix/vixTools.c @@ -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; }