Clean ldso from using deprecated APIs

Issue #1987
This commit is contained in:
Norman Feske
2016-10-30 15:17:24 +01:00
committed by Christian Helmuth
parent 20faa8b84e
commit 784e728727
40 changed files with 1535 additions and 1136 deletions

View File

@@ -0,0 +1,21 @@
/*
* \brief Rump initialization
* \author Norman Feske
* \date 2016-11-02
*/
/*
* Copyright (C) 2016 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__RUMP__BOOTSTRAP_H_
#define _INCLUDE__RUMP__BOOTSTRAP_H_
#include <base/env.h>
#include <base/allocator.h>
void rump_bootstrap_init(Genode::Env &env, Genode::Allocator &heap);
#endif /* _INCLUDE__RUMP__BOOTSTRAP_H_ */

View File

@@ -1,4 +1,4 @@
/**
/*
* \brief Definitions for FS front-end
* \author Sebastian Sumpf
* \date 2014-01-22

View File

@@ -17,7 +17,7 @@ extern "C" {
#include <elf.h>
}
#include <base/env.h>
#include <rump/bootstrap.h>
#include <base/log.h>
#include <base/shared_object.h>
#include <util/string.h>
@@ -35,7 +35,46 @@ typedef Elf32_Sym Elf_Sym;
static bool const verbose = false;
static Genode::Shared_object *obj_main;
static Genode::Shared_object *obj_main;
static Genode::Env *env_ptr;
static Genode::Allocator *heap_ptr;
void rump_bootstrap_init(Genode::Env &env, Genode::Allocator &alloc)
{
/* ignore subsequent calls */
if (env_ptr)
return;
env_ptr = &env;
heap_ptr = &alloc;
}
/**
* Exception type
*/
class Missing_call_of_rump_bootstrap_init { };
static Genode::Env &env()
{
if (!env_ptr)
throw Missing_call_of_rump_bootstrap_init();
return *env_ptr;
}
static Genode::Allocator &heap()
{
if (!heap_ptr)
throw Missing_call_of_rump_bootstrap_init();
return *heap_ptr;
}
struct Sym_tab
{
@@ -183,13 +222,17 @@ struct Sym_tab
* Call init functions of libraries
*/
static void _dl_init(Genode::Shared_object::Link_map const *map,
rump_modinit_fn mod_init,
rump_compload_fn comp_init)
rump_modinit_fn mod_init,
rump_compload_fn comp_init)
{
using namespace Genode;
Shared_object *obj;
try { obj = new (Genode::env()->heap()) Shared_object(map->path); }
catch (...) { error("Could not dlopen ", map->path); return; }
Shared_object *obj = nullptr;
try {
obj = new (heap()) Shared_object(::env(), heap(), map->path,
Shared_object::BIND_LAZY,
Shared_object::DONT_KEEP);
}
catch (...) { error("could not dlopen ", map->path); return; }
struct modinfo **mi_start, **mi_end;
struct rump_component **rc_start, **rc_end;
@@ -218,9 +261,14 @@ void rumpuser_dl_bootstrap(rump_modinit_fn domodinit, rump_symload_fn symload,
/* open main program and request link map */
using namespace Genode;
obj_main = new (env()->heap()) Shared_object(nullptr, Shared_object::NOW);
try {
obj_main = new (heap()) Shared_object(::env(), heap(), nullptr,
Shared_object::BIND_NOW,
Shared_object::KEEP);
}
catch (...) { error("could not dlopen the main executable"); return; }
Shared_object::Link_map const *map = obj_main->link_map();
Shared_object::Link_map const *map = &obj_main->link_map();
for (; map->next; map = map->next) ;
Shared_object::Link_map const *curr_map;

View File

@@ -13,11 +13,12 @@
#include "file_system.h"
#include <os/config.h>
#include <rump/bootstrap.h>
#include <rump_fs/fs.h>
#include <util/string.h>
#include <util/hard_context.h>
#include <base/log.h>
#include <base/attached_rom_dataspace.h>
/**
* We define our own fs arg structure to fit all sizes, we assume that 'fspec'
@@ -31,28 +32,24 @@ struct fs_args
fs_args() { Genode::memset(pad, 0, sizeof(pad)); }
};
namespace File_system {
class Sync;
};
namespace File_system { class Sync; };
static char const *fs_types[] = { RUMP_MOUNT_CD9660, RUMP_MOUNT_EXT2FS,
RUMP_MOUNT_FFS, RUMP_MOUNT_MSDOS,
RUMP_MOUNT_NTFS, RUMP_MOUNT_UDF, 0 };
typedef Genode::String<16> Fs_type;
static Fs_type & fs_type()
{
static Fs_type inst = Genode::config()->xml_node().attribute_value("fs", Fs_type());
return inst;
}
static bool _supports_symlinks;
static bool _check_type(char const *type)
static bool _check_type(Fs_type const &type)
{
for (int i = 0; fs_types[i]; i++)
if (!Genode::strcmp(type, fs_types[i]))
if (!Genode::strcmp(type.string(), fs_types[i]))
return true;
return false;
}
@@ -66,35 +63,32 @@ static void _print_types()
}
static bool check_symlinks()
static bool check_symlinks(Fs_type const &fs_type)
{
if (!Genode::strcmp(fs_type().string(), RUMP_MOUNT_EXT2FS))
return true;
if (!Genode::strcmp(fs_type().string(), RUMP_MOUNT_FFS))
return true;
return false;
return (fs_type == RUMP_MOUNT_EXT2FS)
|| (fs_type == RUMP_MOUNT_FFS);
}
static bool check_read_only()
static bool check_read_only(Fs_type const &fs_type)
{
if (!Genode::strcmp(fs_type().string(), RUMP_MOUNT_CD9660))
return true;
return false;
return fs_type == RUMP_MOUNT_CD9660;
}
void File_system::init()
void File_system::init(Genode::Env &env, Genode::Allocator &alloc, Genode::Xml_node config)
{
if (!_check_type(fs_type().string())) {
Fs_type const fs_type = config.attribute_value("fs", Fs_type());
if (!_check_type(fs_type)) {
Genode::error("Invalid or no file system given (use \'<config fs=\"<fs type>\"/>)");
_print_types();
throw Genode::Exception();
}
Genode::log("Using ", fs_type().string(), " as file system");
Genode::log("Using ", fs_type, " as file system");
/* make Genode env and heap known to the rump kernel */
rump_bootstrap_init(env, alloc);
/* start rump kernel */
rump_init();
@@ -104,16 +98,16 @@ void File_system::init()
/* mount into extra-terrestrial-file system */
struct fs_args args;
int opts = check_read_only() ? RUMP_MNT_RDONLY : 0;
int opts = check_read_only(fs_type) ? RUMP_MNT_RDONLY : 0;
args.fspec = (char *)GENODE_DEVICE;
if (rump_sys_mount(fs_type().string(), "/", opts, &args, sizeof(args)) == -1) {
Genode::error("Mounting '", fs_type().string(), "' file system failed (errno ", errno, " )");
if (rump_sys_mount(fs_type.string(), "/", opts, &args, sizeof(args)) == -1) {
Genode::error("Mounting '", fs_type, "' file system failed (errno ", errno, " )");
throw Genode::Exception();
}
/* check support for symlinks */
_supports_symlinks = check_symlinks();
_supports_symlinks = check_symlinks(fs_type);
}

View File

@@ -13,6 +13,11 @@
#ifndef _FILE_SYSTEM_H_
#define _FILE_SYSTEM_H_
/* Genode includes */
#include <util/xml_node.h>
#include <base/env.h>
#include <base/allocator.h>
extern "C" {
#include <sys/cdefs.h>
#include <sys/errno.h>
@@ -26,7 +31,7 @@ extern "C" {
}
namespace File_system {
void init();
void init(Genode::Env &, Genode::Allocator &heap, Genode::Xml_node config);
bool supports_symlinks();
}

View File

@@ -15,6 +15,7 @@
/* Genode includes */
#include <file_system/node_handle_registry.h>
#include <file_system_session/rpc_object.h>
#include <base/attached_rom_dataspace.h>
#include <timer_session/connection.h>
#include <os/session_policy.h>
#include <root/component.h>
@@ -481,16 +482,20 @@ struct File_system::Main
Genode::Signal_handler<Main> sync_handler
{ env.ep(), *this, &Main::sync };
Heap heap { env.ram(), env.rm() };
/*
* Initialize root interface
*/
Sliced_heap sliced_heap = { env.ram(), env.rm() };
Sliced_heap sliced_heap { env.ram(), env.rm() };
Root fs_root = { env, sliced_heap };
Root fs_root { env, sliced_heap };
Attached_rom_dataspace config { env, "config" };
Main(Genode::Env &env) : env(env)
{
File_system::init();
File_system::init(env, heap, config.xml());
/* set all bits but the stickies */
rump_sys_umask(S_ISUID|S_ISGID|S_ISVTX);