[PATCH] libio: Remove special-case reference count

Gedare Bloom gedare at rtems.org
Mon Sep 11 18:34:18 UTC 2017


On Fri, Sep 8, 2017 at 1:04 AM, Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
> On 08/09/17 00:08, Gedare Bloom wrote:
>
>> I understand the motivation. I need to look carefully at whether this
>> breaks the special case, and how to otherwise fix it.
>
>
> The change didn't introduce test suite failures.
>
Yeah, I neglected to create a test case for this. When I can, I will.
The language at issue here from the standard is:
"The mmap() function shall add an extra reference to the file
associated with the file descriptor fildes which is not removed by a
subsequent close() on that file descriptor. This reference shall be
removed when there are no more mappings to the file."

The sequence of operations that would be used to test it would be
something like:
fd = open()
addr = mmap(fd)
close(fd)
munmap(addr)

Between close() and munmap() the fd should not be reused.

> The mmap() implementation has some other problems. It contains too many
> conditionals. It doesn't follow the object oriented design of the file
> system layer. The mmap() is basically a factory. The mmap_h handler should
> construct a mapping object. A destructor is currently missing. Maybe the
> mmap_h handler should use a flag to deal with construction and destruction.
>
Yeah. It evolved in a way that doesn't fit. The mmap_h was an
afterthought really, since my original intention was to support shared
memory objects, but file mapping was perceived useful for some
applications. Maybe open a new ticket. I don't know when I can work on
this more.

> --
> Sebastian Huber, embedded brains GmbH
>
> Address : Dornierstr. 4, D-82178 Puchheim, Germany
> Phone   : +49 89 189 47 41-16
> Fax     : +49 89 189 47 41-09
> E-Mail  : sebastian.huber at embedded-brains.de
> PGP     : Public key available on request.
>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>


More information about the devel mailing list