Added F_GETFL support so the fdopen() implementation in newlib 1.8.1

would work.  At the same time, the initial implementation of F_SETFL
was added.  A support routine was added to convert internal libio
flags back to the POSIX style.  Eventually the internal representation
should be eliminated in the interest of simplicity and code reduction.
This problem was reported by Jake Janovetz <janovetz@tempest.ece.uiuc.edu>.
This commit is contained in:
Joel Sherrill
1999-03-06 18:09:15 +00:00
parent eaefca9084
commit 3ef87981eb
12 changed files with 129 additions and 6 deletions

View File

@@ -221,6 +221,10 @@ unsigned32 rtems_libio_fcntl_flags(
unsigned32 fcntl_flags
);
unsigned32 rtems_libio_to_fcntl_flags(
unsigned32 flags
);
void rtems_libio_free(
rtems_libio_t *iop
);

View File

@@ -221,6 +221,10 @@ unsigned32 rtems_libio_fcntl_flags(
unsigned32 fcntl_flags
);
unsigned32 rtems_libio_to_fcntl_flags(
unsigned32 flags
);
void rtems_libio_free(
rtems_libio_t *iop
);

View File

@@ -29,6 +29,7 @@ int fcntl(
rtems_libio_t *iop;
rtems_libio_t *diop;
int fd2;
int flags;
va_start( ap, cmd );
@@ -84,10 +85,24 @@ int fcntl(
return 0;
case F_GETFL: /* more flags (cloexec) */
return -1;
return rtems_libio_to_fcntl_flags( iop->flags );
case F_SETFL:
return -1;
flags = rtems_libio_fcntl_flags( va_arg( ap, int ) );
/*
* XXX Double check this in the POSIX spec. According to the Linux
* XXX man page, only these flags can be added.
*/
flags &= ~(O_APPEND | O_NONBLOCK);
/*
* XXX If we are turning on append, should we seek to the end?
*/
iop->flags |= flags;
return 0;
case F_GETLK:
return -1;

View File

@@ -146,6 +146,24 @@ unsigned32 rtems_libio_fcntl_flags(
return flags;
}
/*
* rtems_libio_to_fcntl_flags
*
* Convert RTEMS internal flags to UNIX fnctl(2) flags
*/
unsigned32 rtems_libio_to_fcntl_flags(
unsigned32 flags
)
{
unsigned32 fcntl_flags = 0;
fcntl_flags = rtems_assoc_remote_by_local( access_modes_assoc, flags );
fcntl_flags |=
rtems_assoc_remote_by_local_bitfield(status_flags_assoc, flags);
return fcntl_flags;
}
/*
* rtems_libio_allocate
*

View File

@@ -221,6 +221,10 @@ unsigned32 rtems_libio_fcntl_flags(
unsigned32 fcntl_flags
);
unsigned32 rtems_libio_to_fcntl_flags(
unsigned32 flags
);
void rtems_libio_free(
rtems_libio_t *iop
);

View File

@@ -29,6 +29,7 @@ int fcntl(
rtems_libio_t *iop;
rtems_libio_t *diop;
int fd2;
int flags;
va_start( ap, cmd );
@@ -84,10 +85,24 @@ int fcntl(
return 0;
case F_GETFL: /* more flags (cloexec) */
return -1;
return rtems_libio_to_fcntl_flags( iop->flags );
case F_SETFL:
return -1;
flags = rtems_libio_fcntl_flags( va_arg( ap, int ) );
/*
* XXX Double check this in the POSIX spec. According to the Linux
* XXX man page, only these flags can be added.
*/
flags &= ~(O_APPEND | O_NONBLOCK);
/*
* XXX If we are turning on append, should we seek to the end?
*/
iop->flags |= flags;
return 0;
case F_GETLK:
return -1;

View File

@@ -146,6 +146,24 @@ unsigned32 rtems_libio_fcntl_flags(
return flags;
}
/*
* rtems_libio_to_fcntl_flags
*
* Convert RTEMS internal flags to UNIX fnctl(2) flags
*/
unsigned32 rtems_libio_to_fcntl_flags(
unsigned32 flags
)
{
unsigned32 fcntl_flags = 0;
fcntl_flags = rtems_assoc_remote_by_local( access_modes_assoc, flags );
fcntl_flags |=
rtems_assoc_remote_by_local_bitfield(status_flags_assoc, flags);
return fcntl_flags;
}
/*
* rtems_libio_allocate
*

View File

@@ -221,6 +221,10 @@ unsigned32 rtems_libio_fcntl_flags(
unsigned32 fcntl_flags
);
unsigned32 rtems_libio_to_fcntl_flags(
unsigned32 flags
);
void rtems_libio_free(
rtems_libio_t *iop
);

View File

@@ -221,6 +221,10 @@ unsigned32 rtems_libio_fcntl_flags(
unsigned32 fcntl_flags
);
unsigned32 rtems_libio_to_fcntl_flags(
unsigned32 flags
);
void rtems_libio_free(
rtems_libio_t *iop
);

View File

@@ -221,6 +221,10 @@ unsigned32 rtems_libio_fcntl_flags(
unsigned32 fcntl_flags
);
unsigned32 rtems_libio_to_fcntl_flags(
unsigned32 flags
);
void rtems_libio_free(
rtems_libio_t *iop
);

View File

@@ -29,6 +29,7 @@ int fcntl(
rtems_libio_t *iop;
rtems_libio_t *diop;
int fd2;
int flags;
va_start( ap, cmd );
@@ -84,10 +85,24 @@ int fcntl(
return 0;
case F_GETFL: /* more flags (cloexec) */
return -1;
return rtems_libio_to_fcntl_flags( iop->flags );
case F_SETFL:
return -1;
flags = rtems_libio_fcntl_flags( va_arg( ap, int ) );
/*
* XXX Double check this in the POSIX spec. According to the Linux
* XXX man page, only these flags can be added.
*/
flags &= ~(O_APPEND | O_NONBLOCK);
/*
* XXX If we are turning on append, should we seek to the end?
*/
iop->flags |= flags;
return 0;
case F_GETLK:
return -1;

View File

@@ -146,6 +146,24 @@ unsigned32 rtems_libio_fcntl_flags(
return flags;
}
/*
* rtems_libio_to_fcntl_flags
*
* Convert RTEMS internal flags to UNIX fnctl(2) flags
*/
unsigned32 rtems_libio_to_fcntl_flags(
unsigned32 flags
)
{
unsigned32 fcntl_flags = 0;
fcntl_flags = rtems_assoc_remote_by_local( access_modes_assoc, flags );
fcntl_flags |=
rtems_assoc_remote_by_local_bitfield(status_flags_assoc, flags);
return fcntl_flags;
}
/*
* rtems_libio_allocate
*