public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix errno for rename for the VxWorks 6 target
@ 2019-09-18  8:39 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2019-09-18  8:39 UTC (permalink / raw)
  To: gcc-patches; +Cc: Frederic Konrad

[-- Attachment #1: Type: text/plain, Size: 454 bytes --]

This fixes the wrong errno for rename when the file is not existing on a
dosFs. In the end it makes Ada.Directories.Rename raising the right
exception in the case we are trying to move a file in a non existing
directory.

Tested on x86_64-pc-linux-gnu, committed on trunk

2019-09-18  Frederic Konrad  <konrad@adacore.com>

gcc/ada/

	* adaint.c: Include dosFsLib.h and vwModNum.h for VxWorks 6.
	(__gnat_rename): Map S_dosFsLib_FILE_NOT_FOUND to ENOENT.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1051 bytes --]

--- gcc/ada/adaint.c
+++ gcc/ada/adaint.c
@@ -74,6 +74,12 @@
    (such as chmod) are only available on VxWorks 6.  */
 #include "version.h"
 
+/* vwModNum.h and dosFsLib.h are needed for the VxWorks 6 rename workaround.
+   See below.  */
+#if (_WRS_VXWORKS_MAJOR == 6)
+#include <vwModNum.h>
+#include <dosFsLib.h>
+#endif /* 6.x */
 #endif /* VxWorks */
 
 #if defined (__APPLE__)
@@ -754,6 +760,20 @@ __gnat_rename (char *from, char *to)
     S2WSC (wto, to, GNAT_MAX_PATH_LEN);
     return _trename (wfrom, wto);
   }
+#elif defined (__vxworks) && (_WRS_VXWORKS_MAJOR == 6)
+  {
+    /* When used on a dos filesystem under VxWorks 6.9 rename will trigger a
+       S_dosFsLib_FILE_NOT_FOUND errno when the file is not found.  Let's map
+       that to ENOENT so Ada.Directory.Rename can detect that and raise the
+       Name_Error exception.  */
+    int ret = rename (from, to);
+
+    if (ret && (errno == S_dosFsLib_FILE_NOT_FOUND))
+      {
+        errno = ENOENT;
+      }
+    return ret;
+  }
 #else
   return rename (from, to);
 #endif


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-18  8:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18  8:39 [Ada] Fix errno for rename for the VxWorks 6 target Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).