Changeset 9646d5be in rtems


Ignore:
Timestamp:
Feb 17, 1998, 6:46:38 PM (22 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
ac61209b
Parents:
e81ef51
Message:

Patch from Eric Norum <eric@…>:

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 ("/TFTPbootfiles/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......

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/libcsupport/src/libio.c

    re81ef51 r9646d5be  
    156156rtems_assoc_t errno_assoc[] = {
    157157    { "OK",                 RTEMS_SUCCESSFUL,                0 },
    158     { "TIMEOUT",            RTEMS_TIMEOUT,                   ETIME },
     158    { "BUSY",               RTEMS_RESOURCE_IN_USE,           EBUSY },
     159    { "INVALID NAME",       RTEMS_INVALID_NAME,              EINVAL },
     160    { "NOT IMPLEMENTED",    RTEMS_NOT_IMPLEMENTED,           ENOSYS },
     161    { "TIMEOUT",            RTEMS_TIMEOUT,                   ETIMEDOUT },
    159162    { "NO MEMORY",          RTEMS_NO_MEMORY,                 ENOMEM },
    160     { "NO DEVICE",          RTEMS_UNSATISFIED,               ENOSYS },
     163    { "NO DEVICE",          RTEMS_UNSATISFIED,               ENODEV },
    161164    { "INVALID NUMBER",     RTEMS_INVALID_NUMBER,            EBADF},
    162165    { "NOT RESOURCE OWNER", RTEMS_NOT_OWNER_OF_RESOURCE,     EPERM},
  • c/src/lib/libc/libio.c

    re81ef51 r9646d5be  
    156156rtems_assoc_t errno_assoc[] = {
    157157    { "OK",                 RTEMS_SUCCESSFUL,                0 },
    158     { "TIMEOUT",            RTEMS_TIMEOUT,                   ETIME },
     158    { "BUSY",               RTEMS_RESOURCE_IN_USE,           EBUSY },
     159    { "INVALID NAME",       RTEMS_INVALID_NAME,              EINVAL },
     160    { "NOT IMPLEMENTED",    RTEMS_NOT_IMPLEMENTED,           ENOSYS },
     161    { "TIMEOUT",            RTEMS_TIMEOUT,                   ETIMEDOUT },
    159162    { "NO MEMORY",          RTEMS_NO_MEMORY,                 ENOMEM },
    160     { "NO DEVICE",          RTEMS_UNSATISFIED,               ENOSYS },
     163    { "NO DEVICE",          RTEMS_UNSATISFIED,               ENODEV },
    161164    { "INVALID NUMBER",     RTEMS_INVALID_NUMBER,            EBADF},
    162165    { "NOT RESOURCE OWNER", RTEMS_NOT_OWNER_OF_RESOURCE,     EPERM},
  • c/src/lib/libc/syscalls.c

    re81ef51 r9646d5be  
    5454  } else {
    5555    switch (rtems_file_descriptor_type (_fd)) {
     56    case RTEMS_FILE_DESCRIPTOR_TYPE_FILE:
     57      _sbuf->st_mode = S_IFREG;
     58      break;
     59
    5660    case RTEMS_FILE_DESCRIPTOR_TYPE_SOCKET:
    5761      _sbuf->st_mode = S_IFSOCK;
     
    5963
    6064    default:
    61       puts( "__rtems_fstat -- unknown socket type" );
     65      puts( "__rtems_fstat -- unknown file descriptor type" );
    6266      assert( 0 );
    6367    }
  • cpukit/libcsupport/src/libio.c

    re81ef51 r9646d5be  
    156156rtems_assoc_t errno_assoc[] = {
    157157    { "OK",                 RTEMS_SUCCESSFUL,                0 },
    158     { "TIMEOUT",            RTEMS_TIMEOUT,                   ETIME },
     158    { "BUSY",               RTEMS_RESOURCE_IN_USE,           EBUSY },
     159    { "INVALID NAME",       RTEMS_INVALID_NAME,              EINVAL },
     160    { "NOT IMPLEMENTED",    RTEMS_NOT_IMPLEMENTED,           ENOSYS },
     161    { "TIMEOUT",            RTEMS_TIMEOUT,                   ETIMEDOUT },
    159162    { "NO MEMORY",          RTEMS_NO_MEMORY,                 ENOMEM },
    160     { "NO DEVICE",          RTEMS_UNSATISFIED,               ENOSYS },
     163    { "NO DEVICE",          RTEMS_UNSATISFIED,               ENODEV },
    161164    { "INVALID NUMBER",     RTEMS_INVALID_NUMBER,            EBADF},
    162165    { "NOT RESOURCE OWNER", RTEMS_NOT_OWNER_OF_RESOURCE,     EPERM},
Note: See TracChangeset for help on using the changeset viewer.