From a9ed9230c63b917bf01daaaff17d731be2604416 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Sun, 31 Jul 2011 14:12:29 +0000 Subject: 2011-07-31 Joel Sherrill 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/ftruncate.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. --- cpukit/ChangeLog | 11 +++++++++++ cpukit/libcsupport/include/rtems/libio_.h | 17 ++++++++++++++--- cpukit/libcsupport/src/fchdir.c | 8 +------- cpukit/libcsupport/src/fdatasync.c | 4 ++-- cpukit/libcsupport/src/fpathconf.c | 3 +-- cpukit/libcsupport/src/fsync.c | 3 +-- cpukit/libcsupport/src/ftruncate.c | 1 + cpukit/libcsupport/src/read.c | 2 +- cpukit/libcsupport/src/readv.c | 4 ++-- cpukit/libcsupport/src/write.c | 2 +- cpukit/libcsupport/src/writev.c | 4 ++-- 11 files changed, 37 insertions(+), 22 deletions(-) (limited to 'cpukit') diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index e11a32862f..6258481572 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,14 @@ +2011-07-31 Joel Sherrill + + 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/ftruncate.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 PR 1838/filesystem diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h index a0bc0aa47b..6e1776e413 100644 --- a/cpukit/libcsupport/include/rtems/libio_.h +++ b/cpukit/libcsupport/include/rtems/libio_.h @@ -124,19 +124,30 @@ 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) \ +#define rtems_libio_check_permissions_with_error(_iop, _flag, _errno) \ do { \ if (((_iop)->flags & (_flag)) == 0) { \ - rtems_set_errno_and_return_minus_one( EINVAL ); \ + 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 * diff --git a/cpukit/libcsupport/src/fchdir.c b/cpukit/libcsupport/src/fchdir.c index 0f3cf9ebb3..8ecb44ff59 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 @@ -35,12 +35,6 @@ int fchdir( iop = rtems_libio_iop( fd ); 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/ftruncate.c b/cpukit/libcsupport/src/ftruncate.c index 6619ca5f74..42026ef123 100644 --- a/cpukit/libcsupport/src/ftruncate.c +++ b/cpukit/libcsupport/src/ftruncate.c @@ -32,6 +32,7 @@ int ftruncate( 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 ftruncate() request. diff --git a/cpukit/libcsupport/src/read.c b/cpukit/libcsupport/src/read.c index 4e44eec4ff..80a5e49435 100644 --- a/cpukit/libcsupport/src/read.c +++ b/cpukit/libcsupport/src/read.c @@ -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 cb64797d8d..33e9df3782 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..468dffb036 100644 --- a/cpukit/libcsupport/src/write.c +++ b/cpukit/libcsupport/src/write.c @@ -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 a453209d87..d00c0a071b 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 -- cgit v1.2.3