Rename FILE_ORIGIN_SET to FILE_ORIGIN_BEGINNING
Add all useful Linux file open flags to the file API

Set O_NOCTTY by default.

Only deal with file permissions if FILE_FLAG_CREATE is given
Turn inventory into an object to avoid global state

Before, the current iteration indices of the inventory were global. This
doesn't work well with more than one client iterating the inventory at
the same time.

Now, the current iteration index is part of the inventory object state.
Multiple client can use their own inventory objects to iterate the objects
without interfering with each other.