diff --git a/ChangeLog b/ChangeLog index 63aac89f54d..40a24d8f101 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3907,4 +3907,7 @@ that can be used for testing posix_spawn(). * arch/arm/src/stm32: Bring F1 support for general DMA and serial DMA in paricular up to parity with F2/F4 (from Mike Smith). - + * libc/stdio/lib_libfread.c: Correct some error handling when + lib_fread() was passed a bad stream. Needed to move the + releasing of a semaphore inside of some conditional logic + (cosmetic). diff --git a/TODO b/TODO index 9295f6206b9..e257cef79ff 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -NuttX TODO List (Last updated January 10, 2013) +NuttX TODO List (Last updated January 11, 2013) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with @@ -15,7 +15,7 @@ nuttx/ (17) Network (net/, drivers/net) (4) USB (drivers/usbdev, drivers/usbhost) (12) Libraries (libc/, ) - (9) File system/Generic drivers (fs/, drivers/) + (10) File system/Generic drivers (fs/, drivers/) (5) Graphics subystem (graphics/) (1) Pascal add-on (pcode/) (1) Documentation (Documentation/) @@ -863,6 +863,16 @@ o File system / Generic drivers (fs/, drivers/) Status: Open Priority: Medium + Title: dup AND dup2 WILL NOT WORK ON FILES IN A MOUNTED VOLUME + Description: The current implementation of dup() and dup2() will only + work with open device drivers and sockets. It will not + work with open files in a file system. + + A limitation that results from this is that you cannot + redirect I/O to an from and file. + Status: Open + Priority: High + o Graphics subystem (graphics/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/libc/misc/lib_filesem.c b/libc/misc/lib_filesem.c index 5cc4624ec69..f38ff5f238c 100644 --- a/libc/misc/lib_filesem.c +++ b/libc/misc/lib_filesem.c @@ -67,8 +67,8 @@ void lib_sem_initialize(FAR struct file_struct *stream) { - /* Initialize the LIB semaphore to one (to support one-at- - * a-time access to private data sets. + /* Initialize the LIB semaphore to one (to support one-at-a-time access + * to private data sets. */ (void)sem_init(&stream->fs_sem, 0, 1); @@ -98,13 +98,13 @@ void lib_take_semaphore(FAR struct file_struct *stream) /* Take the semaphore (perhaps waiting) */ while (sem_wait(&stream->fs_sem) != 0) - { - /* The only case that an error should occr here is if - * the wait was awakened by a signal. - */ + { + /* The only case that an error should occr here is if the wait + * was awakened by a signal. + */ - ASSERT(get_errno() == EINTR); - } + ASSERT(get_errno() == EINTR); + } /* We have it. Claim the stak and return */ diff --git a/libc/misc/lib_streamsem.c b/libc/misc/lib_streamsem.c index e38298bdbb2..3397f990743 100644 --- a/libc/misc/lib_streamsem.c +++ b/libc/misc/lib_streamsem.c @@ -86,5 +86,3 @@ void stream_semgive(FAR struct streamlist *list) { sem_post(&list->sl_sem); } - - diff --git a/libc/stdio/lib_libfread.c b/libc/stdio/lib_libfread.c index bc6479037d0..3e851bf1776 100644 --- a/libc/stdio/lib_libfread.c +++ b/libc/stdio/lib_libfread.c @@ -301,9 +301,10 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream) { stream->fs_flags |= __FS_FLAG_EOF; } + + lib_give_semaphore(stream); } - lib_give_semaphore(stream); return bytes_read; /* Error exits */