Commit Graph

45 Commits

Author SHA1 Message Date
Norman Feske
b078224753 Replace Genode::strncpy by Genode::copy_cstring
- Since Genode::strncpy is not 100% compatible with the POSIX
  strncpy function, better use a distinct name.

- Remove bogus return value from the function, easing the potential
  enforcement of mandatory return-value checks later.

Fixes #3752
2020-05-27 11:56:45 +02:00
Christian Prochaska
31d7b3eb97 vfs_lwip: guard 'blocked_handles' Fifo
Fixes #3738
2020-04-28 11:37:56 +02:00
Christian Helmuth
504539ad1e vfs/lwip: notify I/O progress on sent packets
Incoming ACK packets for sent data packets may be the only unblocker for
suspended write/send loops. This patch informs VFS users about I/O of
VFS handle on successfully sent packets.
2019-12-19 17:01:42 +01:00
Sebastian Sumpf
9767c4db0e vfs_lwip/lwip: Lwip::lock for concurrent access
This is required in case the send and receive of IP packets is
performed by multiple thread because lwip is not thread safe.

issue #3568
2019-12-19 17:01:42 +01:00
Christian Helmuth
e70c04ef86 lwip: shut down TCP sockets return WRITE_ERR_IO on write 2019-11-19 14:54:13 +01:00
Norman Feske
5ab1505d43 file system: enhanced file status info
This patch extends the 'File_system::Status',
'File_system::Directory_entry', and the related 'Vfs' types with
the following additional information:

- Distinction between continuous and transactional files (Node_type)
  (issue #3507)
- Readable, writeable, and executable attributes (Node_rwx),
  replacing the former 'mode' bits
  (issue #3030)

The types 'Node_rwx', 'Node_type' are defined twice,
once for the VFS (vfs/types.h) and once for the 'File_system'
session (file_system_session/file_system_session.h).
Similarly, there is a direct correspondance between
'Vfs::Directory_service::Dirent' and 'File_system::Directory_entry'.

This duplication of types follows the existing pattern of keeping the
VFS and file-system session independent from each other.
2019-11-19 14:23:56 +01:00
Norman Feske
e0ee56275e vfs_lwip: fix switch fall-through
Pointed out by a compiler warning.
2019-11-19 14:10:55 +01:00
36111a2edf Libc: implement getifaddrs
Implement getifaddrs and freeifaddrs within the libc using socket
control files at the VFS. Add an "address" and "netmask" file to the
lwIP plugin.

Only a single IPv4 address is initially supported, and the broadcast
address returned will never be valid.

Fixes #3439
2019-09-02 16:36:07 +02:00
66f49e6c42 VFS lwIP: support opening a handle on the root directory
The "nameserver" file cannot be opened through a VFS File_system client
if the plugin does not support opening the parent directory of
"/nameserver", which would be "/".

Ref #3269
2019-04-09 12:30:34 +02:00
a635873568 VFS: Replace global response handlers with local handlers
Replace the I/O response handler that is passed to the VFS at
construction with an object that is dynamically attached to handles.
This object shall also accept read-ready notifications, and plugins are
encouraged to keep handles awaiting ready-ready notifications separate
from handles that await I/O progress.

Replace the use of handle lists in plugins with handle queues, this
makes the code easier to understand and the ordering of notifications to
the application more explicit.

These changes replace the use of the Post_signal_hook from all VFS
plugins, applications must assume that read-ready and I/O notifications
occur during I/O signal dispatch and use an Io_progress_handler at its
entrypoints to defer response until after signal dispatching.

Fix #3257
2019-04-09 12:30:34 +02:00
800b4e44b1 Reduce Vfs::Vfs_handle::Context to empty struct type
The "Vfs::Vfs_handle" type should not contain any public members that
can be initialized by the VFS internally and by the application, so
remove inheritance from the "Genode::list::Element" class. The VFS
plugins must instead use lists of "Vfs::Vfs_handle" sub-classes, the
lifetime of which are always managed by the plugin.

Ref #3036
2019-04-01 19:33:47 +02:00
2fa7964a39 VFS lwIP: fix TCP pbuf unchaining
The lwIP VFS plugin uses lwIP pbuf chains to queue recieved TCP data and
must rechain them when the application dequeues data. Remove an
"pbuf_realloc" call which is not needed for updating pbuf metadata when
dequeuing the head of the chain.

Fix #3169
2019-02-26 14:44:31 +01:00
Norman Feske
b3727a9b46 Add missing override annotations
Issue #3159
2019-02-19 11:12:11 +01:00
38ab456c78 Remove pointers from Genode::Fifo interface
Replace methods of Genode::Fifo returning pointers with methods which
call lambdas with references.

Ref #3135
2019-02-19 11:08:17 +01:00
Christian Prochaska
e8ea28d897 socket fs: support non-blocking 'connect()'
Fixes #3113
2019-01-30 13:35:28 +01:00
Norman Feske
81fb10daaa Consistently name block components
This patch replaces abbreviations like "blk", "cli", and "srv" by their
full forms "block", "client", and "server".

Fixes #1258
2019-01-14 12:34:39 +01:00
bd53e5b496 VFS lwIP: send application data immediately
Call 'tcp_output' if application data has been successfully queued. This
sends data immediately that may otherwise remain queued until the next
periodic TCP timer event.

This reverts a change made in 3e31e2ba53.

Fix #3067
2019-01-07 12:25:46 +01:00
3e31e2ba53 VFS LwIP: blocking TCP write
Block and loop until application writes are sent or buffered in their
entirety. Do not call "tcp_output" directly, LwIP calls this procedure
internally and calling it again appears to disrupt the LwIP TCP state
machine.

Fix #3017
2018-10-29 09:36:22 +01:00
98380cebda VFS LwIP: do not free TCP PCBs on error
The VFS LwIP plugin is page-faulting on connect error because the LwIP
library frees a failed TCP protocol control block before calling the
error callback, and then the VFS plugin dereferences the PCB to free it
a second time. This problem was caused by a failure to follow
documentation during a transition from a C callback to a C++ method.

Fix #2972
2018-09-13 15:21:11 +02:00
6f8e8a6ea4 LwIP: clamp reads to a value that can be expressed in 16 bits
There is a bug in the LwIP VFS plugin, the chained buffers used by Lwip
use sizes expressed in sixteen bits, and under conditions such as a read
of 1<<16 the higher bits are lost and the plugin performs a zero length
read, and the application interprets this as a closed connection.

Fix #2947
2018-08-30 09:24:47 +02:00
26611db95b LwIP VFS: remove link status messages
Remove warnings from the plugin that were used to check behavior of
applications waiting for link and IP status changes.

Ref #2335
2018-08-28 17:10:57 +02:00
ffd688642a VFS LwIP: state tracking fixes
Better track the state of TCP connections and PCB pointers. Allow
received data that has queued to be read under any conditions.

Ref #2335
2018-08-28 16:45:27 +02:00
67d88526b9 VFS LwIP: delay accepted connections
Ref #2335
2018-08-28 16:45:27 +02:00
4678f27802 Propagate LwIP connect errors with sync
Ref #2335
Ref #2920
2018-08-08 11:34:21 +02:00
e208fbb1b3 VFS LwIP: notify peek handles on recv
Ref #2335
2018-08-08 10:59:02 +02:00
Emery Hemingway
d9a4773194 LwIP VFS plugin
This patch reintroduces the LwIP stack to libc as a VFS plugin
implementing the socket_fs interface. Rather than use LwIP's socket
emulation layer this plugin interfaces directly to LwIP raw API and is
single threaded.

The internal TCP parameters of the stack are untuned.

Fix #2050
Fix #2335
2018-08-02 14:36:48 +02:00
82a683eccc VFS: construct file-systems using Vfs::Env object
Reduce the size and forward compatibility of VFS file-system
constructors by passing an object holding accessors for 'Genode::Env',
'Genode::Allocator', response handlers, and the root file-system.

Fix #2742
2018-04-19 12:38:27 +02:00
8ba26c612a FatFS watch support
Implement watch support using a watch handle list.

Test at run/fs_rom_update_fat.

Ref #1934
2018-04-10 11:11:51 +02:00
Norman Feske
b0b92e4ee2 vfs: pass root directory to plugins
This patch enables the use of the VFS from VFS plugins by passing a
reference of the root directory to the constructors of file-system
instances. Since it changes the signature of 'Vfs::Dir_file_system',
any code that uses the VFS directly requires an adaptation.

Fixes #2701
2018-04-10 11:09:17 +02:00
90753f3e50 Update Fatfs library to 0.13a, vfs_fatfs recipe
Fix #2673
2018-02-14 20:41:07 +01:00
Norman Feske
366bba0227 Exclude higher-level repos from strict warnings
This is a follow-up commit to "Increase default warning level", which
overrides Genode's new default warning level for targets contained in
higher-level repositories. By explicitly whitelisting all those targets,
we can selectively adjust them to the new strictness over time - by
looking out for 'CC_CXX_WARN_STRICT' in the target description files.

Issue #465
2018-01-17 12:14:36 +01:00
Emery Hemingway
ead59325c7 lib/vfs/fatfs: sync after every write
Ref #2410
2017-08-28 16:49:44 +02:00
Christian Prochaska
b0935ef9b2 VFS: nonblocking interface
The VFS library can be used in single-threaded or multi-threaded
environments and depending on that, signals are handled by the same thread
which uses the VFS library or possibly by a different thread. If a VFS
plugin needs to block to wait for a signal, there is currently no way
which works reliably in both environments.

For this reason, this commit makes the interface of the VFS library
nonblocking, similar to the File_system session interface.

The most important changes are:

- Directories are created and opened with the 'opendir()' function and the
  directory entries are read with the recently introduced 'queue_read()'
  and 'complete_read()' functions.

- Symbolic links are created and opened with the 'openlink()' function and
  the link target is read with the 'queue_read()' and 'complete_read()'
  functions and written with the 'write()' function.

- The 'write()' function does not wait for signals anymore. This can have
  the effect that data written by a VFS library user has not been
  processed by a file system server yet when the library user asks for the
  size of the file or closes it (both done with RPC functions at the file
  system server). For this reason, a user of the VFS library should
  request synchronization before calling 'stat()' or 'close()'. To make
  sure that a file system server has processed all write request packets
  which a client submitted before the synchronization request,
  synchronization is now requested at the file system server with a
  synchronization packet instead of an RPC function. Because of this
  change, the synchronization interface of the VFS library is now split
  into 'queue_sync()' and 'complete_sync()' functions.

Fixes #2399
2017-08-28 16:49:38 +02:00
Emery Hemingway
31caae4765 lib/vfs/fatfs: FAT file-system plugin using FatFS library
See repos/libports/src/lib/vfs/fatfs/README and
/home/user/repo/genode/repos/libports/run/libc_vfs_fat.run for
documentation.

Ref #2410
2017-08-17 11:04:23 +02:00
Norman Feske
29b8d609c9 Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
Sebastian Sumpf
aa602032dd vfs: dynamic configuration support 2017-02-23 14:54:48 +01:00
Josef Söntgen
c407fb80fa jitterentropy: remove deprecated env() usage
This change introduces a Genode specific init function, which sets the
backend allocator used by jent_zalloc/zfree(). As consequence the
library can solely be used by native Genode components, direct libc
usage is not supported.

Fixes #2274.
2017-02-23 14:54:43 +01:00
Christian Helmuth
f9389109bf Support select in libc VFS plugin by read_ready() 2017-02-07 11:12:29 +01:00
Emery Hemingway
ddf3716cff vfs: pass Env and allocator when creating file-systems
Fix #1891
2016-11-08 15:26:31 +01:00
Norman Feske
17c79a9e23 base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.

While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).

To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.

Issue #1987
2016-08-29 17:27:10 +02:00
Stefan Kalkowski
5cf8c49cb8 libports: prevent dummy target warnings
Fix #1681
2015-09-16 13:58:50 +02:00
Christian Helmuth
e8c9125d9f Pseudo target for vfs_jitterentropy
Run script depending on VFS plugins (i.e., shared objects) like
vfs_jitterentropy.lib.so have to state this dependency rather the actual
binaries linked against libc. The latter introduces a library dependency
that is just not there. For example, the dependency on vfs_jitterentropy
is a result from the config node for libc which automatically loads the
plugin.
2015-08-21 11:00:57 +02:00
Norman Feske
e3be65833f vfs: decouple file-system factory from libc
This patch moves the VFS file-system factory to a separate vfs library
that is independent from libc. This enables libc-less Genode programs to
easily use the VFS infrastructure.

Fixes #1561
2015-06-09 11:00:10 +02:00
Alexander Boettcher
8b8c2713ae vfs: use 64bit for file offset and size
Fixes #1246
2014-10-10 13:02:28 +02:00
Josef Söntgen
1a170e9caf libports: add vfs_jitterentropy library
This file system library uses the the jitterentropy library to provide
a rudimentary '/dev/random' device.

Fixes #1239.
2014-08-26 11:00:13 +02:00