summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-07-24 20:26:14 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-07-24 20:26:14 +0000
commit85f1b9aa1130d8b4d72885b851594af0b01c6cc1 (patch)
tree8d2bee7a3b24a195ebf2936a6edb884e7ca7000f
parent84b2e65b23be8e338d7e4cfc60fee953d966918d (diff)
2011-07-24 Joel Sherrill <joel.sherrilL@OARcorp.com>
PR 1839/filesystem * libcsupport/include/rtems/libio_.h, libcsupport/src/fchdir.c, libcsupport/src/fdatasync.c, libcsupport/src/fpathconf.c, libcsupport/src/fsync.c, libcsupport/src/read.c, libcsupport/src/readv.c, libcsupport/src/write.c, libcsupport/src/writev.c: Some calls did not return proper status for permission errors or incorrectly permissions at all.
-rw-r--r--cpukit/ChangeLog10
-rw-r--r--cpukit/libcsupport/include/rtems/libio_.h25
-rw-r--r--cpukit/libcsupport/src/fchdir.c8
-rw-r--r--cpukit/libcsupport/src/fdatasync.c4
-rw-r--r--cpukit/libcsupport/src/fpathconf.c3
-rw-r--r--cpukit/libcsupport/src/fsync.c3
-rw-r--r--cpukit/libcsupport/src/read.c4
-rw-r--r--cpukit/libcsupport/src/readv.c4
-rw-r--r--cpukit/libcsupport/src/write.c4
-rw-r--r--cpukit/libcsupport/src/writev.c4
10 files changed, 41 insertions, 28 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 59fa84c304..4196c42dda 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,3 +1,13 @@
+2011-07-24 Joel Sherrill <joel.sherrilL@OARcorp.com>
+
+ PR 1839/filesystem
+ * libcsupport/include/rtems/libio_.h, libcsupport/src/fchdir.c,
+ libcsupport/src/fdatasync.c, libcsupport/src/fpathconf.c,
+ libcsupport/src/fsync.c, libcsupport/src/read.c,
+ libcsupport/src/readv.c, libcsupport/src/write.c,
+ libcsupport/src/writev.c: Some calls did not return proper status for
+ permission errors or incorrectly permissions at all.
+
2011-07-19 Joel Sherrill <joel.sherrilL@OARcorp.com>
PR 1838/filesystem
diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h
index f64fefb2e8..2b6bbf687d 100644
--- a/cpukit/libcsupport/include/rtems/libio_.h
+++ b/cpukit/libcsupport/include/rtems/libio_.h
@@ -124,20 +124,31 @@ extern rtems_libio_t *rtems_libio_iop_freelist;
} while (0)
/*
- * rtems_libio_check_permissions
+ * rtems_libio_check_permissions_with_error
*
* Macro to check if a file descriptor is open for this operation.
+ * On failure, return the user specified error.
*/
-#define rtems_libio_check_permissions(_iop, _flag) \
- do { \
- if (((_iop)->flags & (_flag)) == 0) { \
- rtems_set_errno_and_return_minus_one( EINVAL ); \
- return -1; \
- } \
+#define rtems_libio_check_permissions_with_error(_iop, _flag, _errno) \
+ do { \
+ if (((_iop)->flags & (_flag)) == 0) { \
+ rtems_set_errno_and_return_minus_one( _errno ); \
+ return -1; \
+ } \
} while (0)
/*
+ * rtems_libio_check_permissions
+ *
+ * Macro to check if a file descriptor is open for this operation.
+ * On failure, return EINVAL
+ */
+
+#define rtems_libio_check_permissions(_iop, _flag) \
+ rtems_libio_check_permissions_with_error(_iop, _flag, EINVAL )
+
+/*
* rtems_filesystem_freenode
*
* Macro to free a node.
diff --git a/cpukit/libcsupport/src/fchdir.c b/cpukit/libcsupport/src/fchdir.c
index 603288614d..3069788f95 100644
--- a/cpukit/libcsupport/src/fchdir.c
+++ b/cpukit/libcsupport/src/fchdir.c
@@ -1,7 +1,7 @@
/*
* fchdir() - compatible with SVr4, 4.4BSD and X/OPEN - Change Directory
*
- * COPYRIGHT (c) 1989-2000.
+ * COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -36,12 +36,6 @@ int fchdir(
rtems_libio_check_is_open(iop);
/*
- * Now process the fchmod().
- */
-
- rtems_libio_check_permissions( iop, LIBIO_FLAGS_READ );
-
- /*
* Verify you can change directory into this node.
*/
diff --git a/cpukit/libcsupport/src/fdatasync.c b/cpukit/libcsupport/src/fdatasync.c
index c2b4db43ae..5a7ba4244a 100644
--- a/cpukit/libcsupport/src/fdatasync.c
+++ b/cpukit/libcsupport/src/fdatasync.c
@@ -1,7 +1,7 @@
/*
* fdatasync() - POSIX 1003.1b 6.6.2 - Synchronize the Data of a File
*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -29,7 +29,7 @@ int fdatasync(
rtems_libio_check_fd( fd );
iop = rtems_libio_iop( fd );
rtems_libio_check_is_open(iop);
- rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE );
+ rtems_libio_check_permissions_with_error( iop, LIBIO_FLAGS_WRITE, EBADF );
/*
* Now process the fdatasync().
diff --git a/cpukit/libcsupport/src/fpathconf.c b/cpukit/libcsupport/src/fpathconf.c
index accaae1585..71edaf6ce9 100644
--- a/cpukit/libcsupport/src/fpathconf.c
+++ b/cpukit/libcsupport/src/fpathconf.c
@@ -1,7 +1,7 @@
/*
* fpathconf() - POSIX 1003.1b - 5.7.1 - Configurable Pathname Varables
*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -33,7 +33,6 @@ long fpathconf(
rtems_libio_check_fd(fd);
iop = rtems_libio_iop(fd);
rtems_libio_check_is_open(iop);
- rtems_libio_check_permissions(iop, LIBIO_FLAGS_READ);
/*
* Now process the information request.
diff --git a/cpukit/libcsupport/src/fsync.c b/cpukit/libcsupport/src/fsync.c
index cfd8e8d49b..c7a7745859 100644
--- a/cpukit/libcsupport/src/fsync.c
+++ b/cpukit/libcsupport/src/fsync.c
@@ -1,7 +1,7 @@
/*
* fsync() - POSIX 1003.1b 6.6.1 - Synchronize the State of a File
*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -29,7 +29,6 @@ int fsync(
rtems_libio_check_fd( fd );
iop = rtems_libio_iop( fd );
rtems_libio_check_is_open(iop);
- rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE );
/*
* Now process the fsync().
diff --git a/cpukit/libcsupport/src/read.c b/cpukit/libcsupport/src/read.c
index 286edf3bab..77aa4e5206 100644
--- a/cpukit/libcsupport/src/read.c
+++ b/cpukit/libcsupport/src/read.c
@@ -1,7 +1,7 @@
/*
* read() - POSIX 1003.1b 6.4.1 - Read From a File
*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -32,7 +32,7 @@ ssize_t read(
rtems_libio_check_is_open( iop );
rtems_libio_check_buffer( buffer );
rtems_libio_check_count( count );
- rtems_libio_check_permissions( iop, LIBIO_FLAGS_READ );
+ rtems_libio_check_permissions_with_error( iop, LIBIO_FLAGS_READ, EBADF );
/*
* Now process the read().
diff --git a/cpukit/libcsupport/src/readv.c b/cpukit/libcsupport/src/readv.c
index 7b77c11fe2..c6997a7fe4 100644
--- a/cpukit/libcsupport/src/readv.c
+++ b/cpukit/libcsupport/src/readv.c
@@ -5,7 +5,7 @@
*
* http://www.opengroup.org/onlinepubs/009695399/functions/readv.html
*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -40,7 +40,7 @@ ssize_t readv(
rtems_libio_check_fd( fd );
iop = rtems_libio_iop( fd );
rtems_libio_check_is_open( iop );
- rtems_libio_check_permissions( iop, LIBIO_FLAGS_READ );
+ rtems_libio_check_permissions_with_error( iop, LIBIO_FLAGS_READ, EBADF );
/*
* Argument validation on IO vector
diff --git a/cpukit/libcsupport/src/write.c b/cpukit/libcsupport/src/write.c
index 3bda204015..0850bb69b2 100644
--- a/cpukit/libcsupport/src/write.c
+++ b/cpukit/libcsupport/src/write.c
@@ -1,7 +1,7 @@
/*
* write() - POSIX 1003.1b 6.4.2 - Write to a File
*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -39,7 +39,7 @@ ssize_t write(
rtems_libio_check_is_open( iop );
rtems_libio_check_buffer( buffer );
rtems_libio_check_count( count );
- rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE );
+ rtems_libio_check_permissions_with_error( iop, LIBIO_FLAGS_WRITE, EBADF );
/*
* Now process the write() request.
diff --git a/cpukit/libcsupport/src/writev.c b/cpukit/libcsupport/src/writev.c
index 88d495da56..97f7322065 100644
--- a/cpukit/libcsupport/src/writev.c
+++ b/cpukit/libcsupport/src/writev.c
@@ -5,7 +5,7 @@
*
* http://www.opengroup.org/onlinepubs/009695399/functions/writev.html
*
- * COPYRIGHT (c) 1989-2007.
+ * COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -41,7 +41,7 @@ ssize_t writev(
rtems_libio_check_fd( fd );
iop = rtems_libio_iop( fd );
rtems_libio_check_is_open( iop );
- rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE );
+ rtems_libio_check_permissions_with_error( iop, LIBIO_FLAGS_WRITE, EBADF );
/*
* Argument validation on IO vector