Merge libc_vfs plugin into libc

Issue #999
This commit is contained in:
Norman Feske 2014-04-24 12:40:18 +02:00 committed by Christian Helmuth
parent c7f1b85652
commit 60d9c90921
46 changed files with 129 additions and 97 deletions

View File

@ -1,3 +1,3 @@
TARGET = file_terminal
SRC_CC = main.cc
LIBS = libc libc_vfs
LIBS = libc

View File

@ -1,3 +1,3 @@
TARGET = tcp_terminal
SRC_CC = main.cc
LIBS = libc libc_lwip_nic_dhcp libc_vfs libc_lock_pipe
LIBS = libc libc_lwip_nic_dhcp libc_lock_pipe

View File

@ -14,7 +14,9 @@ SRC_CC = atexit.cc dummies.cc rlimit.cc sysctl.cc \
gettimeofday.cc malloc.cc progname.cc fd_alloc.cc file_operations.cc \
plugin.cc plugin_registry.cc select.cc exit.cc environ.cc nanosleep.cc \
libc_mem_alloc.cc pread_pwrite.cc readv_writev.cc poll.cc \
libc_pdbg.cc
libc_pdbg.cc vfs_plugin.cc
INC_DIR += $(REP_DIR)/src/lib/libc
#
# Files from string library that are not included in libc-raw_string because

View File

@ -4,7 +4,7 @@ EXFAT_DIR = $(REP_DIR)/contrib/$(EXFAT)
SRC_C = $(notdir $(EXFAT_DIR)/fuse/main.c)
SRC_CC = init.cc
LIBS = libc libc_vfs libc_fuse libfuse libexfat
LIBS = libc libc_fuse libfuse libexfat
vpath %.c $(EXFAT_DIR)/fuse
vpath %.cc $(REP_DIR)/src/lib/exfat

View File

@ -5,7 +5,7 @@ FILTER_OUT = fuse-ext2.probe.c fuse-ext2.wait.c
SRC_C = $(filter-out $(FILTER_OUT), $(notdir $(wildcard $(FUSE_EXT2_DIR)/*.c)))
SRC_CC = init.cc
LIBS = libc libc_vfs libc_fuse libfuse libext2fs
LIBS = libc libc_fuse libfuse libext2fs
CC_OPT = -DHAVE_CONFIG_H -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64

View File

@ -4,7 +4,7 @@ NTFS_3G_DIR = $(REP_DIR)/contrib/$(NTFS_3G)
SRC_C = ntfs-3g.c ntfs-3g_common.c
SRC_CC = init.cc
LIBS = libc libc_vfs libc_fuse libfuse libntfs-3g
LIBS = libc libc_fuse libfuse libntfs-3g
CC_OPT = -DHAVE_TIMESPEC -DHAVE_CONFIG_H -DRECORD_LOCKING_NOT_IMPLEMENTED

View File

@ -1,5 +0,0 @@
SRC_CC = plugin.cc
LIBS += libc
INC_DIR += $(REP_DIR)/src/lib/libc
vpath plugin.cc $(REP_DIR)/src/lib/libc_vfs

View File

@ -3,7 +3,7 @@ include $(REP_DIR)/lib/import/import-av.inc
TARGET = avplay
SRC_C = avplay.c cmdutils.c libc_dummies.c
LIBS += avfilter avformat avcodec avutil swscale
LIBS += sdl libc libm libc_vfs config_args
LIBS += sdl libc libm config_args
CC_WARN += -Wno-parentheses -Wno-switch -Wno-uninitialized \
-Wno-format-zero-length -Wno-pointer-sign

View File

@ -1,3 +1,3 @@
TARGET = eglgears
SRC_C = eglgears.c
LIBS = libc libc_vfs libm gallium
LIBS = libc libm gallium

View File

@ -2,7 +2,7 @@ MUPDF_DIR = $(REP_DIR)/contrib/mupdf-0.9
TARGET = mupdf
SRC_C = pdfapp.c
SRC_CC = main.cc
LIBS = libc mupdf libc_vfs
LIBS = libc mupdf
INC_DIR += $(MUPDF_DIR)/apps
vpath pdfapp.c $(MUPDF_DIR)/apps

View File

@ -1,6 +1,6 @@
INC_DIR += $(PRG_DIR)
LIBS += libc libc_vfs
LIBS += libc
# set the stack size of the main thread
CC_CXX_OPT += -DQT_MAIN_STACK_SIZE=$(QT_MAIN_STACK_SIZE)

View File

@ -162,63 +162,71 @@ class Libc_file_system_factory : public Vfs::File_system_factory
};
static Genode::Xml_node libc_config()
{
return Genode::config()->xml_node().sub_node("libc");
}
namespace Libc {
static Genode::Xml_node config()
{
return Genode::config()->xml_node().sub_node("libc");
}
static Genode::Xml_node libc_vfs_config()
{
return libc_config().sub_node("vfs");
}
Genode::Xml_node vfs_config() __attribute__((weak));
Genode::Xml_node vfs_config()
{
return Libc::config().sub_node("vfs");
}
class Libc_config_attr
{
private:
class Config_attr
{
private:
char _buf[Vfs::MAX_PATH_LEN];
char _buf[Vfs::MAX_PATH_LEN];
public:
public:
Libc_config_attr(char const *attr_name, char const *default_value)
{
strncpy(_buf, default_value, sizeof(_buf));
try {
libc_config().attribute(attr_name).value(_buf, sizeof(_buf));
} catch (...) { }
}
Config_attr(char const *attr_name, char const *default_value)
{
Genode::strncpy(_buf, default_value, sizeof(_buf));
try {
Libc::config().attribute(attr_name).value(_buf, sizeof(_buf));
} catch (...) { }
}
char const *string() const { return _buf; }
};
char const *string() const { return _buf; }
};
static char const *libc_initial_cwd()
{
static Libc_config_attr initial_cwd("cwd", "/");
return initial_cwd.string();
}
char const *initial_cwd() __attribute__((weak));
char const *initial_cwd()
{
static Config_attr initial_cwd("cwd", "/");
return initial_cwd.string();
}
static char const *libc_config_stdin()
{
static Libc_config_attr stdin("stdin", "");
return stdin.string();
}
char const *config_stdin() __attribute__((weak));
char const *config_stdin()
{
static Config_attr stdin("stdin", "");
return stdin.string();
}
static char const *libc_config_stdout()
{
static Libc_config_attr stdout("stdout", "");
return stdout.string();
}
char const *config_stdout() __attribute__((weak));
char const *config_stdout()
{
static Config_attr stdout("stdout", "");
return stdout.string();
}
static char const *libc_config_stderr()
{
static Libc_config_attr stderr("stderr", "");
return stderr.string();
char const *config_stderr() __attribute__((weak));
char const *config_stderr()
{
static Config_attr stderr("stderr", "");
return stderr.string();
}
}
@ -236,7 +244,7 @@ class Libc::Vfs_plugin : public Libc::Plugin
Genode::Xml_node _vfs_config()
{
try {
return libc_vfs_config();
return vfs_config();
} catch (...) {
PINF("no VFS configured");
return Genode::Xml_node("<vfs/>");
@ -275,11 +283,11 @@ class Libc::Vfs_plugin : public Libc::Plugin
*/
Vfs_plugin() : _root_dir(_vfs_config(), _fs_factory)
{
chdir(libc_initial_cwd());
chdir(initial_cwd());
_open_stdio(0, libc_config_stdin(), O_RDONLY);
_open_stdio(1, libc_config_stdout(), O_WRONLY);
_open_stdio(2, libc_config_stderr(), O_WRONLY);
_open_stdio(0, config_stdin(), O_RDONLY);
_open_stdio(1, config_stdout(), O_WRONLY);
_open_stdio(2, config_stderr(), O_WRONLY);
}
~Vfs_plugin() { }

View File

@ -1,3 +1,3 @@
TARGET = fs_log
SRC_CC = main.cc
LIBS = base libc_vfs libc
LIBS = base libc

View File

@ -7,7 +7,7 @@ SRC_C = $(notdir $(EXFAT_DIR)/fuse/main.c)
SRC_CC = fuse_fs_main.cc \
init.cc
LIBS = base config server libc libc_vfs libfuse libexfat
LIBS = base config server libc libfuse libexfat
INC_DIR += $(PRG_DIR)/..
CC_OPT += -Wno-unused-function

View File

@ -10,7 +10,7 @@ SRC_C = $(filter-out $(FILTER_OUT), $(notdir $(wildcard $(FUSE_EXT2_DIR)/*.c)))
SRC_CC = fuse_fs_main.cc \
init.cc
LIBS = base config server libc libc_vfs libfuse libext2fs
LIBS = base config server libc libfuse libext2fs
CC_OPT += -DHAVE_CONFIG_H -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64

View File

@ -7,7 +7,7 @@ SRC_C = ntfs-3g.c ntfs-3g_common.c
SRC_CC = fuse_fs_main.cc \
init.cc
LIBS = base config server libc libc_vfs libfuse libntfs-3g
LIBS = base config server libc libfuse libntfs-3g
CC_OPT = -DHAVE_TIMESPEC -DHAVE_CONFIG_H -DRECORD_LOCKING_NOT_IMPLEMENTED

View File

@ -1,3 +1,3 @@
TARGET = test-expat
SRC_CC = main.cc
LIBS = expat libc libc_vfs
LIBS = expat libc

View File

@ -1,3 +1,3 @@
TARGET = test-libc
SRC_CC = main.cc
LIBS = libm libc libc_vfs
LIBS = libm libc

View File

@ -1,3 +1,3 @@
TARGET = test-libc_block
LIBS = libc libc_vfs
LIBS = libc
SRC_CC = main.cc

View File

@ -1,3 +1,3 @@
TARGET = test-libc_ffat
LIBS = libc libc_vfs libc_ffat
LIBS = libc libc_ffat
SRC_CC = main.cc

View File

@ -1,3 +1,3 @@
TARGET = test-libc_fs_tar_fs
LIBS = libc libc_vfs
LIBS = libc
SRC_CC = main.cc

View File

@ -1,5 +1,5 @@
TARGET = test-libc_fuse_exfat
LIBS = libc libc_vfs libc_fuse_exfat
LIBS = libc libc_fuse_exfat
SRC_CC = main.cc
vpath %.cc $(PRG_DIR)/../libc_ffat/

View File

@ -1,5 +1,5 @@
TARGET = test-libc_fuse_ext2
LIBS = libc libc_vfs libc_fuse_ext2
LIBS = libc libc_fuse_ext2
SRC_CC = main.cc
vpath %.cc $(PRG_DIR)/../libc_ffat

View File

@ -1,5 +1,5 @@
TARGET = test-libc_fuse_ntfs-3g
LIBS = libc libc_vfs libc_fuse_ntfs-3g
LIBS = libc libc_fuse_ntfs-3g
SRC_CC = main.cc
vpath %.cc $(PRG_DIR)/../libc_ffat

View File

@ -1,5 +1,5 @@
TARGET = test-libc_vfs
LIBS = libc libc_vfs
LIBS = libc
SRC_CC = main.cc
# we re-use the libc_ffat test

View File

@ -1,5 +1,5 @@
TARGET = test-http_clnt
LIBS = lwip libc libc_vfs
LIBS = lwip libc
SRC_CC = main.cc
REQUIRES = foc

View File

@ -1,5 +1,5 @@
TARGET = test-lwip_httpsrv_static
LIBS = lwip libc libc_vfs
LIBS = lwip libc
SRC_CC = main.cc
INC_DIR += $(REP_DIR)/src/lib/lwip/include

View File

@ -1,5 +1,5 @@
TARGET = test-lwip_httpsrv_tracing
LIBS = lwip libc libc_vfs
LIBS = lwip libc
SRC_CC = main.cc
REQUIRES = foc

View File

@ -1,5 +1,5 @@
TARGET = test-lwip_httpsrv_tracing_nob
LIBS = lwip libc libc_vfs
LIBS = lwip libc
SRC_CC = main.cc
REQUIRES = foc

View File

@ -1,3 +1,3 @@
TARGET = test-lwip_loop
LIBS = lwip libc libc_lwip_loopback libc_vfs
LIBS = lwip libc libc_lwip_loopback
SRC_CC = main.cc

View File

@ -1,5 +1,5 @@
TARGET = test-ping_client_libc_lwip
LIBS = base libc lwip libc_lwip_nic_dhcp libc_vfs config_args
LIBS = base libc lwip libc_lwip_nic_dhcp config_args
SRC_CC = main.cc pingpong.cc
vpath main.cc $(PRG_DIR)/..

View File

@ -1,5 +1,5 @@
TARGET = test-ping_client_lwip
LIBS = base libc lwip libc_vfs config_args
LIBS = base libc lwip config_args
SRC_CC = main.cc pingpong.cc
INC_DIR += $(REP_DIR)/src/lib/lwip/include

View File

@ -1,5 +1,5 @@
TARGET = test-ping_server_libc_lwip
LIBS = base libc libc_vfs libc_lwip_nic_dhcp libc_lwip lwip config_args
LIBS = base libc libc_lwip_nic_dhcp libc_lwip lwip config_args
SRC_CC = main.cc pingpong.cc
vpath main.cc $(PRG_DIR)/..

View File

@ -1,5 +1,5 @@
TARGET = test-ping_server_lwip
LIBS = base libc lwip libc_vfs config_args
LIBS = base libc lwip config_args
SRC_CC = main.cc pingpong.cc
CC_OPT += -DLWIP_NATIVE

View File

@ -1,3 +1,3 @@
TARGET = test-moon
LIBS = luacxx libc libm libc_vfs
LIBS = luacxx libc libm
SRC_CC = main.cc

View File

@ -1,3 +1,3 @@
TARGET = test-pthread
SRC_CC = main.cc
LIBS = libc libc_vfs pthread
LIBS = libc pthread

View File

@ -1,4 +1,4 @@
TARGET = test-python
LIBS = python libc libc_vfs libm
LIBS = python libc libm
REQUIRES = x86
SRC_CC = main.cc

View File

@ -25,7 +25,7 @@ SRC_CC += libc/select.cc
SRC_CC += libc_terminal/plugin.cc
# Genode vfs plugin
SRC_CC += libc_vfs/plugin.cc
SRC_CC += libc/vfs_plugin.cc
SRC_CC += libc/pread_pwrite.cc
# Genode lock pipe plugin (needed by VirtualBox "HostSerial" driver)

View File

@ -54,5 +54,5 @@ CC_WARN += -Wno-unused-variable -Wno-unused-function -Wno-switch -Wno-unused-val
-Wno-sign-compare -Wno-narrowing -Wno-missing-braces -Wno-array-bounds \
-Wno-parentheses
LIBS += libc libc_vfs libm libpng sdl sdl_net stdcxx zlib
LIBS += libc libm libpng sdl sdl_net stdcxx zlib
LIBS += libc_lwip_nic_dhcp config_args

View File

@ -10,7 +10,7 @@ INC_DIR += $(GDB_CONTRIB_DIR)/include \
$(PRG_DIR)/gdbserver \
$(PRG_DIR)
LIBS = libc libc_vfs libc_terminal libc_lock_pipe \
LIBS = libc libc_terminal libc_lock_pipe \
gdbserver_platform gdbserver_libc_support
SRC_C = event-loop.c \

View File

@ -2,4 +2,4 @@ TARGET = lighttpd
include $(REP_DIR)/src/app/lighttpd/target.inc
LIBS += libc libm libc_vfs libc_lwip_nic_dhcp
LIBS += libc libm libc_lwip_nic_dhcp

View File

@ -3,7 +3,7 @@ CONTRIB_DIR = $(REP_DIR)/contrib/netperf
LIBS += base libc libm libc-resolv libc-net libc-nameser libc-isc
# plug-in to libc
LIBS += libc_vfs config_args
LIBS += config_args
SRC_C = netserver.c netlib.c netsh.c nettest_bsd.c dscp.c
# omni test

View File

@ -62,6 +62,20 @@ enum { verbose = false };
enum { verbose_signals = false };
/*
* Customize libc VFS
*/
namespace Libc {
/*
* Override the weak function interface of the VFS plugin as Noux programs
* do not obtain a VFS configuration via Genode's config mechansim.
*/
Genode::Xml_node vfs_config() { return Xml_node("<vfs/>"); }
}
class Noux_connection
{
private:
@ -805,12 +819,19 @@ namespace {
class Plugin : public Libc::Plugin
{
private:
/*
* Override the libc's default VFS plugin
*/
enum { PLUGIN_PRIORITY = 1 };
public:
/**
* Constructor
*/
Plugin()
Plugin() : Libc::Plugin(PLUGIN_PRIORITY)
{
/* register inherited open file descriptors */
int fd = 0;
@ -829,6 +850,7 @@ namespace {
bool supports_unlink(char const *) { return true; }
bool supports_readlink(const char *, char *, size_t) { return true; }
bool supports_rename(const char *, const char *) { return true; }
bool supports_rmdir(char const *) { return true; }
bool supports_mkdir(const char *, mode_t) { return true; }
bool supports_socket(int, int, int) { return true; }
bool supports_mmap() { return true; }
@ -849,12 +871,13 @@ namespace {
::off_t lseek(Libc::File_descriptor *, ::off_t offset, int whence);
ssize_t read(Libc::File_descriptor *, void *, ::size_t);
ssize_t readlink(const char *path, char *buf, size_t bufsiz);
int rename(const char *oldpath, const char *newpath);
int rmdir(char const *path);
int stat(char const *, struct stat *);
int symlink(const char *, const char *);
int ioctl(Libc::File_descriptor *, int request, char *argp);
int pipe(Libc::File_descriptor *pipefd[2]);
int unlink(char const *path);
int rename(const char *oldpath, const char *newpath);
int mkdir(const char *path, mode_t mode);
void *mmap(void *addr, ::size_t length, int prot, int flags,
Libc::File_descriptor *, ::off_t offset);
@ -1563,6 +1586,12 @@ namespace {
}
int Plugin::rmdir(char const *path)
{
return Plugin::unlink(path);
}
ssize_t Plugin::readlink(const char *path, char *buf, size_t bufsiz)
{
if (verbose)

View File

@ -1,3 +1,3 @@
TARGET = test-gdb_monitor
SRC_CC = main.cc
LIBS = libc libc_vfs
LIBS = libc

View File

@ -1,3 +1,3 @@
TARGET = vbox-auto-test-helper
SRC_CC = main.cc
LIBS = libc libc_fs
LIBS = libc

View File

@ -12,5 +12,3 @@ vpath % $(QMAKE_PROJECT_PATH)
include $(QT4_REP_DIR)/src/app/tmpl/target_defaults.inc
include $(QT4_REP_DIR)/src/app/tmpl/target_final.inc
LIBS += libc_vfs