Support reference counting for file descriptors

Close #3132.
This commit is contained in:
Sebastian Huber
2017-09-15 12:46:57 +02:00
parent 666a56883a
commit 894c965d95
5 changed files with 45 additions and 26 deletions

View File

@@ -47,8 +47,13 @@ rtems_bsd_get_file(int fd)
struct file *fp;
if ((uint32_t) fd < rtems_libio_number_iops) {
unsigned int flags;
fp = rtems_bsd_fd_to_fp(fd);
if ((fp->f_io.flags & LIBIO_FLAGS_OPEN) != LIBIO_FLAGS_OPEN) {
flags = rtems_libio_iop_hold(&fp->f_io);
if ((flags & LIBIO_FLAGS_OPEN) == 0) {
rtems_libio_iop_drop(&fp->f_io);
fp = NULL;
}
} else {