file: drop file_makebad()

The only caller, soo_close() can only be called from a context where
no file references remain, so no further file API calls can be made.

Remove it.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
file: don't initialize with memset()

If we're going to have a vtable in there, the memset() will kill it.

Instead, add initializers for those members not already initialized by
make_file().

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
file: move initialization from falloc_noinstall() to finit()

They are called at the same time, so make falloc_noinstall() responsible
purely for allocation.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
file: fix falloc_noinstall() error case

'new file' doesn't return nullptr, it throws (well except in osv where new
always succeeds).

Replace with new (nothrow) to get the expected behaviour.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
file: fold falloc_noinstall() into make_file()

Simpler.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
file: convert finit() to file's constructor

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
file: allow make_file() to create files with a type derived from 'file'

This paves the way for moving f_ops into the vtable.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
file: generalize make_file() to be able to create derived types

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
file: add virtual functions corresponding to f_ops

The default is to dispatch directly to the corresponding member of f_ops,
but that can be overridden.

The fo_*() functions are redirected to dispatch via the virtual functions.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
file: close() outside destructor

Once file::~file() is called, virtual functions no longer dispatch to the
derived type (which has since been destroyed) but to the base type, which
is uninteresting.

Move the call to close() from the destructor to fdrop().

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
file: make fo_init() optional

Derived file objects will be initialized by the class constructor, no need
for fo_init().

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
file: make 'opaque' optional

Not everyone wants it.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
console: make it a derived class of file

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
initialize: add a way to initialize an array, similar to C99 designated initializers

Useful for C -> C++ conversions.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
sys_socket.c: convert to C++

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
linux_ioctl_socket.c: convert to C++

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
net: use a file derived class for sockets (socket_file)

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
pipe: make it a derived class of 'file'

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
af_local: convert to a derive class of file

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
epoll: convert to a derived class of file

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>