summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1998-02-17 18:46:38 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1998-02-17 18:46:38 +0000
commit9646d5bea1ff0f71143d9ca9be23980fda48f5a9 (patch)
tree9f024a3c46621ccc5bf1810ecdec79f48cafa7f8
parentPatch from Ralf Corsepius <corsepiu@faw.uni-ulm.de>: (diff)
downloadrtems-9646d5bea1ff0f71143d9ca9be23980fda48f5a9.tar.bz2
Patch from Eric Norum <eric@skatter.usask.ca>:
I've gone through and cleaned up the TFTP driver so that it fits into the libio system. Here's the comment from the new driver: /* * Usage: * * To open `/bootfiles/image' on `hostname' for reading: * fd = open ("/TFTP/hostname/bootfiles/image", O_RDONLY); * * The `hostname' can be a symbolic name or four * dot-separated decimal values. * * To open a file on the host which supplied the BOOTP * information just leave the `hostname' part empty: * fd = open ("/TFTP//bootfiles/image", O_RDONLY); * */ You can `fopen' TFTP files the same way: fp = fopen (fullname, "r"); nread = fread (cbuf, sizeof cbuf[0], sizeof cbuf, fp); The diff's are included below. I've also modified the TFTP demo program and the bootstrap PROM example. They should be on my ftp site `soon'. The one thing I don't like is the way I had to do an end-run on the libio routines to get errno passed back from my driver to the application (since there are some errno codes that don't map to RTEMS status codes). My approach was to set errno in the driver and have the driver routine return an RTEMS status code that I `know' isn't in the errno_assoc[] in libio.c. Perhaps there should be an RTEMS_TRANPARENT_ERRNO status code (or something similar) which driver routines could return to indicate that the driver routine has set errno and that the libio routines shouldn't attempt to map the returned status code to errno. Actually, I think the entire I/O system needs looking at -- as you've already mentioned. The hacks I've dropped in to syscalls.c to make fstat work, for example, are *not* shining examples of good code......
-rw-r--r--c/src/exec/libcsupport/src/libio.c7
-rw-r--r--c/src/lib/libc/libio.c7
-rw-r--r--c/src/lib/libc/syscalls.c6
-rw-r--r--cpukit/libcsupport/src/libio.c7
4 files changed, 20 insertions, 7 deletions
diff --git a/c/src/exec/libcsupport/src/libio.c b/c/src/exec/libcsupport/src/libio.c
index 83253a7903..4ac3666a1e 100644
--- a/c/src/exec/libcsupport/src/libio.c
+++ b/c/src/exec/libcsupport/src/libio.c
@@ -155,9 +155,12 @@ rtems_libio_init(void)
rtems_assoc_t errno_assoc[] = {
{ "OK", RTEMS_SUCCESSFUL, 0 },
- { "TIMEOUT", RTEMS_TIMEOUT, ETIME },
+ { "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, ENOSYS },
+ { "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},
diff --git a/c/src/lib/libc/libio.c b/c/src/lib/libc/libio.c
index 83253a7903..4ac3666a1e 100644
--- a/c/src/lib/libc/libio.c
+++ b/c/src/lib/libc/libio.c
@@ -155,9 +155,12 @@ rtems_libio_init(void)
rtems_assoc_t errno_assoc[] = {
{ "OK", RTEMS_SUCCESSFUL, 0 },
- { "TIMEOUT", RTEMS_TIMEOUT, ETIME },
+ { "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, ENOSYS },
+ { "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},
diff --git a/c/src/lib/libc/syscalls.c b/c/src/lib/libc/syscalls.c
index 1c17bfa184..5f4d552db1 100644
--- a/c/src/lib/libc/syscalls.c
+++ b/c/src/lib/libc/syscalls.c
@@ -53,12 +53,16 @@ int __rtems_fstat(int _fd, struct stat* _sbuf)
_sbuf->st_mode = S_IFCHR;
} else {
switch (rtems_file_descriptor_type (_fd)) {
+ case RTEMS_FILE_DESCRIPTOR_TYPE_FILE:
+ _sbuf->st_mode = S_IFREG;
+ break;
+
case RTEMS_FILE_DESCRIPTOR_TYPE_SOCKET:
_sbuf->st_mode = S_IFSOCK;
break;
default:
- puts( "__rtems_fstat -- unknown socket type" );
+ puts( "__rtems_fstat -- unknown file descriptor type" );
assert( 0 );
}
}
diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c
index 83253a7903..4ac3666a1e 100644
--- a/cpukit/libcsupport/src/libio.c
+++ b/cpukit/libcsupport/src/libio.c
@@ -155,9 +155,12 @@ rtems_libio_init(void)
rtems_assoc_t errno_assoc[] = {
{ "OK", RTEMS_SUCCESSFUL, 0 },
- { "TIMEOUT", RTEMS_TIMEOUT, ETIME },
+ { "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, ENOSYS },
+ { "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},