summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2001-07-06 21:48:16 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2001-07-06 21:48:16 +0000
commitb8c8cab3fcfce28ea68fff8ec97fb3dfc9138cab (patch)
treebe6962e136bd84985e1b83cc39d8b08f1d574b49 /cpukit
parentcaeb33b22de9493023993090d54e8f4f6156e4cf (diff)
downloadrtems-b8c8cab3fcfce28ea68fff8ec97fb3dfc9138cab.tar.bz2
2001-07-06 Thomas Doerfler <Thomas.Doerfler@imd-systems.de>
* src/imfs/deviceio.c: Make sure errno gets set to reflect the status from the driver.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/libfs/ChangeLog5
-rw-r--r--cpukit/libfs/src/imfs/deviceio.c49
2 files changed, 47 insertions, 7 deletions
diff --git a/cpukit/libfs/ChangeLog b/cpukit/libfs/ChangeLog
index eec53b4ddf..f8ede36d3b 100644
--- a/cpukit/libfs/ChangeLog
+++ b/cpukit/libfs/ChangeLog
@@ -1,3 +1,8 @@
+2001-07-06 Thomas Doerfler <Thomas.Doerfler@imd-systems.de>
+
+ * src/imfs/deviceio.c: Make sure errno gets set to reflect
+ the status from the driver.
+
2001-05-25 Joel Sherrill <joel@OARcorp.com>
* src/imfs/imfs_initsupp.c: Create the root node with the
diff --git a/cpukit/libfs/src/imfs/deviceio.c b/cpukit/libfs/src/imfs/deviceio.c
index 1fce0ea47f..eafc48ec4e 100644
--- a/cpukit/libfs/src/imfs/deviceio.c
+++ b/cpukit/libfs/src/imfs/deviceio.c
@@ -20,11 +20,43 @@
#include <rtems.h>
#include <rtems/libio.h>
-#include <rtems/libio_.h>
+#include <rtems/assoc.h> /* assoc.h not included by rtems.h */
+#include <errno.h>
#include "imfs.h"
/*
+ * Convert RTEMS status to a UNIX errno
+ */
+
+rtems_assoc_t errno_assoc[] = {
+ { "OK", RTEMS_SUCCESSFUL, 0 },
+ { "BUSY", RTEMS_RESOURCE_IN_USE, EBUSY },
+ { "INVALID NAME", RTEMS_INVALID_NAME, EINVAL },
+ { "NOT IMPLEMENTED", RTEMS_NOT_IMPLEMENTED, ENOSYS },
+ { "TIMEOUT", RTEMS_TIMEOUT, ETIMEDOUT },
+ { "NO MEMORY", RTEMS_NO_MEMORY, ENOMEM },
+ { "NO DEVICE", RTEMS_UNSATISFIED, ENODEV },
+ { "INVALID NUMBER", RTEMS_INVALID_NUMBER, EBADF},
+ { "NOT RESOURCE OWNER", RTEMS_NOT_OWNER_OF_RESOURCE, EPERM},
+ { "IO ERROR", RTEMS_IO_ERROR, EIO},
+ { 0, 0, 0 },
+};
+
+static unsigned32
+rtems_deviceio_errno(rtems_status_code code)
+{
+ int rc;
+
+ if ((rc = rtems_assoc_remote_by_local(errno_assoc, (unsigned32) code)))
+ {
+ errno = rc;
+ return -1;
+ }
+ return -1;
+}
+
+/*
* device_open
*
* This handler maps an open() operation onto rtems_io_open().
@@ -52,8 +84,10 @@ int device_open(
the_jnode->info.device.minor,
(void *) &args
);
- if ( status )
+ if ( status ) {
+ rtems_deviceio_errno(status);
return RTEMS_UNSATISFIED;
+ }
return 0;
}
@@ -83,9 +117,10 @@ int device_close(
the_jnode->info.device.minor,
(void *) &args
);
- if ( status )
+ if ( status ) {
+ rtems_deviceio_errno(status);
return RTEMS_UNSATISFIED;
-
+ }
return 0;
}
@@ -121,7 +156,7 @@ int device_read(
);
if ( status )
- return -1;
+ return rtems_deviceio_errno(status);
return args.bytes_moved;
}
@@ -158,7 +193,7 @@ int device_write(
);
if ( status )
- return -1;
+ return rtems_deviceio_errno(status);
return args.bytes_moved;
}
@@ -192,7 +227,7 @@ int device_ioctl(
);
if ( status )
- return -1;
+ return rtems_deviceio_errno(status);
return args.ioctl_return;
}