Hello, world!
Wouter van Oijen
wouter.van.oijen at technolution.nl
Tue Nov 20 17:24:07 CET 2018
Op ma 19 nov. 2018 om 17:53 schreef Nobody III <hungryninja101 at gmail.com>:
>
> You're welcome. Glad I could help.
>
> From the list, most of those functions are implemented in libc, but overridden in Noux. Please note that Noux provides a system call interface, while libc doesn't normally use or require that, but instead uses Genode's library function calls more directly. The execve function isn't implemented except in Noux AFAIK, but could possibly be implemented without a special environment.
Then what is the difference between the libc-implementations and the
overridden implementations in Noux? I understand that the
execute/fork-type calls could only be implemented in Noux, but what
about the other functions? Or are they mainly 'stubbed' in libc so
that the programs at least compile and partially run? For example,
when I call getuid() in my application it logs "Warning: getuid:
getuid not implemented" and the function returns 0. Likewise, if I try
to create a file /tmp/hello.txt, the application logs "Error:
plugin()->open("/tmp/hello.txt") failed" and open() fails with erro
"invalid argument". However, reading an existing file (created in the
init script) works fine with libc.
I wonder why creating/writing files fails. It could have something to
do with write permissions (I found several ways to create a Virtual
File System, but all resulted in different errors so far). Or is this
where Noux starts to play a role? What is necessary for an application
to be able to create and write to files?
>
> First, if you haven't already, you should follow the instructions for creating a build directory, then build and run one of the many scenarios, e.g. run/demo.
>
> For compiling a simple C application, you first need to have/pick a repos subdirectory. To start out, you could use one of the ones provided, e.g. repos/gems. You then need to create a subdirectory for your application somewhere inside repos/[your repo]/src, e.g. repos/gems/app/simple_c_app. After that, you need to write your C code and place it in a file in that directory. Then write a makefile named target.mk in the same directory with the C code. The makefile should look something like the following:
>
> TARGET = simple_c_app
> SRC_C = main.c
> LIBS = base libc posix
>
> When you have your source file(s) and makefile written, and your repo directory added to etc/build.conf in your build directory, you should be able to compile it using "make app/simple_c_app".
>
> If you want to run your app, you need to write a run script. Creating a good run script for testing your app might be difficult, but you can start with something simple. You can start by copying repos/gems/run/pipe.run and modifying that.
>
> For most of this, I'd recommend looking at the pipe example by Emery Hemingway, as found in repos/gems/src/app/pipe, and the aforementioned run script. Please note that the pipe example uses C-style C++. If you want to use pure C, be sure to use the variable SRC_C in the makefile rather than SRC_CC.
>
> I hope this helps.
Thanks again for your time to write this steps down. The basic steps
are clear to me (I did create build directories, execute a number of
scenarios, write simple test applications and build and run them on
Genode). However, I did consider the learning curve quite steep and
still don't quite understand all internals and available options. So
when trying slightly more advanced examples, I quickly get lost... I'm
now in the process of porting the Mosquitto server to Genode and will
probably get back to the list with some questions about that ;-)
Kind regards,
Wouter
More information about the users
mailing list