This is my first message to this mailinglist, so Hello, world! ;-)
I'm new to Genode and trying to learn the basics. Our goal is to develop a setup that demonstrates the application of Genode to create a powerful separation between critical and non-critical code. Genode looks really promising for this!
To get a better understanding of the build environment and Noux in particular, I'm trying to run a simple "Hello, world" application on Noux. However, I don't know how to achieve this yet. The Porting Guide [1] doesn't help me much, as I don't think the example is really applicable to my use case. It raises the following questions:
* Is it necessary to create a "port file" for any application I want to run on Noux (even if it's just a simple application consisting of one source file that is already part of the build directory)? * How can I add files generated by the Genode build system to the Noux environment, so that I can call my "hello" binary from bash in Noux?
Any help or a working example would be much appreciated. It would help me much if someone could explain me how to extend the "run/noux_bash" [2] example to include my hello-world application, if this is right way to continue.
[1] https://genode.org/documentation/developer-resources/porting_noux_packages [2] https://github.com/genodelabs/genode/blob/master/repos/ports/run/noux_bash.r...
Kind regards,
Wouter van Oijen Lead Designer
T +31(0)182594000 | E wouter.van.oijen@technolution.nl A Burgemeester Jamessingel 1, P.O. Box 2013, 2800 BD Gouda, The Netherlands | W technolution.com
This e-mail is intended exclusively for the addressee(s), and may not be passed on to, or made available for use by any person other than the addressee(s). Technolution B.V. rules out any and every liability resulting from any electronic transmission.
You are absolutely correct about Genode being able to isolate critical code from non-critical code – that's one of its main purposes.
Port files are only necessary to download external code.
I'm not sure about your second question. In particular, noux was intended exclusively for ported software. At this point, its main purpose is to emulate the fork() system call. For software that doesn't require that, I'd recommend just using libc instead. Noux also isn't designed for code isolation within a single noux instance, so that might be an issue as well.
There are plenty of code isolation examples available, and we can help you more if you tell us more about what you're trying to do. Then we can give you much better advice on what libraries and RPC interfaces to use. For example, if you want to separate a login screen's GUI from the password verification and login code, I'd recommend using the Report interface and/or the File_system interface.
On Tue, Nov 13, 2018, 2:57 AM Wouter van Oijen < wouter.van.oijen@technolution.nl wrote:
This is my first message to this mailinglist, so Hello, world! ;-)
I'm new to Genode and trying to learn the basics. Our goal is to develop a setup that demonstrates the application of Genode to create a powerful separation between critical and non-critical code. Genode looks really promising for this!
To get a better understanding of the build environment and Noux in particular, I'm trying to run a simple "Hello, world" application on Noux. However, I don't know how to achieve this yet. The Porting Guide [1] doesn't help me much, as I don't think the example is really applicable to my use case. It raises the following questions:
- Is it necessary to create a "port file" for any application I want
to run on Noux (even if it's just a simple application consisting of one source file that is already part of the build directory)?
- How can I add files generated by the Genode build system to the Noux
environment, so that I can call my "hello" binary from bash in Noux?
Any help or a working example would be much appreciated. It would help me much if someone could explain me how to extend the "run/noux_bash" [2] example to include my hello-world application, if this is right way to continue.
[1] https://genode.org/documentation/developer-resources/porting_noux_packages [2] https://github.com/genodelabs/genode/blob/master/repos/ports/run/noux_bash.r...
Kind regards,
Wouter van Oijen Lead Designer
T +31(0)182594000 | E wouter.van.oijen@technolution.nl A Burgemeester Jamessingel 1, P.O. Box 2013, 2800 BD Gouda, The Netherlands | W technolution.com
This e-mail is intended exclusively for the addressee(s), and may not be passed on to, or made available for use by any person other than the addressee(s). Technolution B.V. rules out any and every liability resulting from any electronic transmission.
Genode users mailing list users@lists.genode.org https://lists.genode.org/listinfo/users
Hi "Nobody III" ;-)
Thanks for your reaction! I have some follow-up questions though:
Port files are only necessary to download external code.
Okay, thanks for clearing that up :-)
I'm not sure about your second question. In particular, noux was intended exclusively for ported software. At this point, its main purpose is to emulate the fork() system call. For software that doesn't require that, I'd recommend just using libc instead. Noux also isn't designed for code isolation within a single noux instance, so that might be an issue as well.
Hmm, now I'm a bit confused. I was under the impression that Noux was necessary for a lot more than just fork(), like things as file access and networking as well. For example, at https://genode.org/documentation/release-notes/11.02 it is mentioned that "without the right environment that presents the program the needed UNIX functionality, those [unmodified, recompiled] programs won't do much. This leads us to the Noux execution environment." And also "Currently the Noux execution environment implements the following system calls: getcwd, write, stat, fstat, fcntl, open, close, dirent, fchdir, read, and execve."
Are these functions now implemented in libc and can they work without Noux? In general, could I then recompile any Unix application that doesn't use fork(), and run it as a Genode component?
If not, what would I need to do compile a simple standard-C application that writes some data to a file and then reads from that file?
I do understand that the code isolation is limited to isolation between different Noux instances and not within the application itself. This is fine for our demo, but thanks for pointing it out.
There are plenty of code isolation examples available, and we can help you more if you tell us more about what you're trying to do. Then we can give you much better advice on what libraries and RPC interfaces to use. For example, if you want to separate a login screen's GUI from the password verification and login code, I'd recommend using the Report interface and/or the File_system interface.
I'm currently trying to get existing software (specifically: a Mosquitto broker) to build and run in Genode, so I'm not using the Genode interfaces. However, since the Genode build flow is still a big mystery for me, I was first trying to build and run some basic examples... Hence the above questions.
Kind regards, Wouter
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.
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.
On Mon, Nov 19, 2018 at 8:42 AM Wouter van Oijen < wouter.van.oijen@technolution.nl> wrote:
Hi "Nobody III" ;-)
Thanks for your reaction! I have some follow-up questions though:
Port files are only necessary to download external code.
Okay, thanks for clearing that up :-)
I'm not sure about your second question. In particular, noux was
intended exclusively for ported software. At this point, its main purpose is to emulate the fork() system call. For software that doesn't require that, I'd recommend just using libc instead. Noux also isn't designed for code isolation within a single noux instance, so that might be an issue as well.
Hmm, now I'm a bit confused. I was under the impression that Noux was necessary for a lot more than just fork(), like things as file access and networking as well. For example, at https://genode.org/documentation/release-notes/11.02 it is mentioned that "without the right environment that presents the program the needed UNIX functionality, those [unmodified, recompiled] programs won't do much. This leads us to the Noux execution environment." And also "Currently the Noux execution environment implements the following system calls: getcwd, write, stat, fstat, fcntl, open, close, dirent, fchdir, read, and execve."
Are these functions now implemented in libc and can they work without Noux? In general, could I then recompile any Unix application that doesn't use fork(), and run it as a Genode component?
If not, what would I need to do compile a simple standard-C application that writes some data to a file and then reads from that file?
I do understand that the code isolation is limited to isolation between different Noux instances and not within the application itself. This is fine for our demo, but thanks for pointing it out.
There are plenty of code isolation examples available, and we can help
you more if you tell us more about what you're trying to do. Then we can give you much better advice on what libraries and RPC interfaces to use. For example, if you want to separate a login screen's GUI from the password verification and login code, I'd recommend using the Report interface and/or the File_system interface.
I'm currently trying to get existing software (specifically: a Mosquitto broker) to build and run in Genode, so I'm not using the Genode interfaces. However, since the Genode build flow is still a big mystery for me, I was first trying to build and run some basic examples... Hence the above questions.
Kind regards, Wouter
Genode users mailing list users@lists.genode.org https://lists.genode.org/listinfo/users
Op ma 19 nov. 2018 om 17:53 schreef Nobody III hungryninja101@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