summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c/src/exec/include/rtems/libio_.h4
-rw-r--r--c/src/exec/libcsupport/include/rtems/libio_.h4
-rw-r--r--c/src/exec/libcsupport/src/fcntl.c19
-rw-r--r--c/src/exec/libcsupport/src/libio.c18
-rw-r--r--c/src/lib/include/rtems/libio_.h4
-rw-r--r--c/src/lib/libc/fcntl.c19
-rw-r--r--c/src/lib/libc/libio.c18
-rw-r--r--c/src/lib/libc/libio_.h4
-rw-r--r--cpukit/include/rtems/libio_.h4
-rw-r--r--cpukit/libcsupport/include/rtems/libio_.h4
-rw-r--r--cpukit/libcsupport/src/fcntl.c19
-rw-r--r--cpukit/libcsupport/src/libio.c18
12 files changed, 129 insertions, 6 deletions
diff --git a/c/src/exec/include/rtems/libio_.h b/c/src/exec/include/rtems/libio_.h
index 16dc708f53..e14f63c287 100644
--- a/c/src/exec/include/rtems/libio_.h
+++ b/c/src/exec/include/rtems/libio_.h
@@ -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
);
diff --git a/c/src/exec/libcsupport/include/rtems/libio_.h b/c/src/exec/libcsupport/include/rtems/libio_.h
index 16dc708f53..e14f63c287 100644
--- a/c/src/exec/libcsupport/include/rtems/libio_.h
+++ b/c/src/exec/libcsupport/include/rtems/libio_.h
@@ -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
);
diff --git a/c/src/exec/libcsupport/src/fcntl.c b/c/src/exec/libcsupport/src/fcntl.c
index 7673049a58..9359575e51 100644
--- a/c/src/exec/libcsupport/src/fcntl.c
+++ b/c/src/exec/libcsupport/src/fcntl.c
@@ -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;
diff --git a/c/src/exec/libcsupport/src/libio.c b/c/src/exec/libcsupport/src/libio.c
index 59b7086a03..bedd4a920e 100644
--- a/c/src/exec/libcsupport/src/libio.c
+++ b/c/src/exec/libcsupport/src/libio.c
@@ -147,6 +147,24 @@ unsigned32 rtems_libio_fcntl_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
*
* This routine searches the IOP Table for an unused entry. If it
diff --git a/c/src/lib/include/rtems/libio_.h b/c/src/lib/include/rtems/libio_.h
index 16dc708f53..e14f63c287 100644
--- a/c/src/lib/include/rtems/libio_.h
+++ b/c/src/lib/include/rtems/libio_.h
@@ -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
);
diff --git a/c/src/lib/libc/fcntl.c b/c/src/lib/libc/fcntl.c
index 7673049a58..9359575e51 100644
--- a/c/src/lib/libc/fcntl.c
+++ b/c/src/lib/libc/fcntl.c
@@ -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;
diff --git a/c/src/lib/libc/libio.c b/c/src/lib/libc/libio.c
index 59b7086a03..bedd4a920e 100644
--- a/c/src/lib/libc/libio.c
+++ b/c/src/lib/libc/libio.c
@@ -147,6 +147,24 @@ unsigned32 rtems_libio_fcntl_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
*
* This routine searches the IOP Table for an unused entry. If it
diff --git a/c/src/lib/libc/libio_.h b/c/src/lib/libc/libio_.h
index 16dc708f53..e14f63c287 100644
--- a/c/src/lib/libc/libio_.h
+++ b/c/src/lib/libc/libio_.h
@@ -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
);
diff --git a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h
index 16dc708f53..e14f63c287 100644
--- a/cpukit/include/rtems/libio_.h
+++ b/cpukit/include/rtems/libio_.h
@@ -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
);
diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h
index 16dc708f53..e14f63c287 100644
--- a/cpukit/libcsupport/include/rtems/libio_.h
+++ b/cpukit/libcsupport/include/rtems/libio_.h
@@ -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
);
diff --git a/cpukit/libcsupport/src/fcntl.c b/cpukit/libcsupport/src/fcntl.c
index 7673049a58..9359575e51 100644
--- a/cpukit/libcsupport/src/fcntl.c
+++ b/cpukit/libcsupport/src/fcntl.c
@@ -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;
diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c
index 59b7086a03..bedd4a920e 100644
--- a/cpukit/libcsupport/src/libio.c
+++ b/cpukit/libcsupport/src/libio.c
@@ -147,6 +147,24 @@ unsigned32 rtems_libio_fcntl_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
*
* This routine searches the IOP Table for an unused entry. If it