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.
This commit is contained in:
Joel Sherrill
2001-07-06 21:48:16 +00:00
parent caeb33b22d
commit b8c8cab3fc
6 changed files with 141 additions and 21 deletions

View File

@@ -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

View File

@@ -20,10 +20,42 @@
#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
*
@@ -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;
}

View File

@@ -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

View File

@@ -20,10 +20,42 @@
#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
*
@@ -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;
}

View File

@@ -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

View File

@@ -20,10 +20,42 @@
#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
*
@@ -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;
}