From 78f4d6d72ef51e9bdd33e2ed258fb6af5701153e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 8 Jun 2010 08:30:04 +0000 Subject: 2010-06-08 Sebastian Huber * libfs/src/devfs/devclose.c, libfs/src/devfs/devopen.c, libfs/src/imfs/deviceerrno.c, libfs/src/imfs/deviceio.c, libfs/src/rfs/rtems-rfs-rtems-dev.c: Changed rtems_deviceio_errno() to cope with a status code of RTEMS_SUCCESSFUL. Removed dependency on association framework. --- cpukit/ChangeLog | 8 ++++ cpukit/libfs/src/devfs/devclose.c | 6 +-- cpukit/libfs/src/devfs/devopen.c | 4 +- cpukit/libfs/src/imfs/deviceerrno.c | 67 ++++++++++++++++++------------ cpukit/libfs/src/imfs/deviceio.c | 18 ++------ cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c | 8 +--- 6 files changed, 57 insertions(+), 54 deletions(-) diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 123d93ffad..54b7c57594 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,11 @@ +2010-06-08 Sebastian Huber + + * libfs/src/devfs/devclose.c, libfs/src/devfs/devopen.c, + libfs/src/imfs/deviceerrno.c, libfs/src/imfs/deviceio.c, + libfs/src/rfs/rtems-rfs-rtems-dev.c: Changed rtems_deviceio_errno() to + cope with a status code of RTEMS_SUCCESSFUL. Removed dependency on + association framework. + 2010-06-07 Ralf Corsépius * aclocal/version.m4: Bump RTEMS_API to 4.11. diff --git a/cpukit/libfs/src/devfs/devclose.c b/cpukit/libfs/src/devfs/devclose.c index 66a89b98e7..eaaf164c84 100644 --- a/cpukit/libfs/src/devfs/devclose.c +++ b/cpukit/libfs/src/devfs/devclose.c @@ -34,10 +34,8 @@ int devFS_close( np->minor, (void *) &args ); - if ( status ) { - return rtems_deviceio_errno(status); - } - return 0; + + return rtems_deviceio_errno(status); } diff --git a/cpukit/libfs/src/devfs/devopen.c b/cpukit/libfs/src/devfs/devopen.c index e1dcf64957..f06aa8939b 100644 --- a/cpukit/libfs/src/devfs/devopen.c +++ b/cpukit/libfs/src/devfs/devopen.c @@ -37,8 +37,6 @@ int devFS_open( np->minor, (void *) &args ); - if ( status ) - return rtems_deviceio_errno(status); - return 0; + return rtems_deviceio_errno(status); } diff --git a/cpukit/libfs/src/imfs/deviceerrno.c b/cpukit/libfs/src/imfs/deviceerrno.c index 9a3251f7c5..b0daf4d8f8 100644 --- a/cpukit/libfs/src/imfs/deviceerrno.c +++ b/cpukit/libfs/src/imfs/deviceerrno.c @@ -18,40 +18,53 @@ #include "config.h" #endif -#include -#include -#include /* assoc.h not included by rtems.h */ #include -/* - * Convert RTEMS status to a UNIX errno - */ +#include +#include -const 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 const int status_code_to_errno [RTEMS_STATUS_CODES_LAST + 1] = { + [RTEMS_SUCCESSFUL] = 0, + [RTEMS_TASK_EXITTED] = EIO, + [RTEMS_MP_NOT_CONFIGURED] = EIO, + [RTEMS_INVALID_NAME] = EINVAL, + [RTEMS_INVALID_ID] = EIO, + [RTEMS_TOO_MANY] = EIO, + [RTEMS_TIMEOUT] = ETIMEDOUT, + [RTEMS_OBJECT_WAS_DELETED] = EIO, + [RTEMS_INVALID_SIZE] = EIO, + [RTEMS_INVALID_ADDRESS] = EIO, + [RTEMS_INVALID_NUMBER] = EBADF, + [RTEMS_NOT_DEFINED] = EIO, + [RTEMS_RESOURCE_IN_USE] = EBUSY, + [RTEMS_UNSATISFIED] = ENODEV, + [RTEMS_INCORRECT_STATE] = EIO, + [RTEMS_ALREADY_SUSPENDED] = EIO, + [RTEMS_ILLEGAL_ON_SELF] = EIO, + [RTEMS_ILLEGAL_ON_REMOTE_OBJECT] = EIO, + [RTEMS_CALLED_FROM_ISR] = EIO, + [RTEMS_INVALID_PRIORITY] = EIO, + [RTEMS_NOT_OWNER_OF_RESOURCE] = EPERM, + [RTEMS_NOT_IMPLEMENTED] = ENOSYS, + [RTEMS_INTERNAL_ERROR] = EIO, + [RTEMS_NO_MEMORY] = ENOMEM, + [RTEMS_IO_ERROR] = EIO, + [RTEMS_PROXY_BLOCKING] = EIO }; -int -rtems_deviceio_errno(rtems_status_code code) +int rtems_deviceio_errno(rtems_status_code sc) { - int rc; + if (sc == RTEMS_SUCCESSFUL) { + return 0; + } else { + int eno = EINVAL; - if ((rc = rtems_assoc_remote_by_local(errno_assoc, (uint32_t ) code))) - { - errno = rc; - return -1; + if ((unsigned) sc <= RTEMS_STATUS_CODES_LAST) { + eno = status_code_to_errno [sc]; } - return -1; -} + errno = eno; + return -1; + } +} diff --git a/cpukit/libfs/src/imfs/deviceio.c b/cpukit/libfs/src/imfs/deviceio.c index 70cb936425..61d138ae59 100644 --- a/cpukit/libfs/src/imfs/deviceio.c +++ b/cpukit/libfs/src/imfs/deviceio.c @@ -20,16 +20,10 @@ #include #include -#include /* assoc.h not included by rtems.h */ -#include +#include #include "imfs.h" -/* - * Convert RTEMS status to a UNIX errno - */ -extern int rtems_deviceio_errno(rtems_status_code code); - /* * device_open * @@ -58,10 +52,8 @@ int device_open( the_jnode->info.device.minor, (void *) &args ); - if ( status ) - return rtems_deviceio_errno(status); - return 0; + return rtems_deviceio_errno( status ); } /* @@ -89,10 +81,8 @@ int device_close( the_jnode->info.device.minor, (void *) &args ); - if ( status ) { - return rtems_deviceio_errno(status); - } - return 0; + + return rtems_deviceio_errno( status ); } /* diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c index 862e442a3b..7e4ee60a7f 100644 --- a/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c +++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c @@ -83,10 +83,8 @@ rtems_rfs_rtems_device_open ( rtems_libio_t *iop, args.mode = mode; status = rtems_io_open (major, minor, (void *) &args); - if (status) - return rtems_deviceio_errno(status); - return 0; + return rtems_deviceio_errno (status); } /** @@ -112,10 +110,8 @@ rtems_rfs_rtems_device_close (rtems_libio_t* iop) args.mode = 0; status = rtems_io_close (major, minor, (void *) &args); - if (status) - return rtems_deviceio_errno (status); - return 0; + return rtems_deviceio_errno (status); } /** -- cgit v1.2.3