aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/adaint.c
diff options
context:
space:
mode:
authorFrederic Konrad <konrad@adacore.com>2019-09-18 08:32:09 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-09-18 08:32:09 +0000
commit82fa20a21141a1394d7188b21eb9c486ab16f8ea (patch)
treee4cc10899843041c704b49ef285999ee901245a5 /gcc/ada/adaint.c
parentdcbe49a6c41e586e961664512726799a540757ee (diff)
downloadgcc-82fa20a21141a1394d7188b21eb9c486ab16f8ea.zip
gcc-82fa20a21141a1394d7188b21eb9c486ab16f8ea.tar.gz
gcc-82fa20a21141a1394d7188b21eb9c486ab16f8ea.tar.bz2
[Ada] Fix errno for rename for the VxWorks 6 target
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. 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. From-SVN: r275846
Diffstat (limited to 'gcc/ada/adaint.c')
-rw-r--r--gcc/ada/adaint.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index c76e9ad..595abf8 100644
--- a/gcc/ada/adaint.c
+++ b/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