The hello.c
code looks familiar and simple to a developer that uses C, and is fully compatible with POSIX:
hello.c
#include <stdio.h>
#include <stdlib.h>
int main(int argc, const char *argv[])
{
fprintf(stderr,"Hello world!\n");
return EXIT_SUCCESS;
}
Compile this code using aarch64-kos-gcc
, which is included in the development tools of KasperskyOS Community Edition:
aarch64-kos-gcc -o hello hello.c
The program name (and, consequently, the name of the executable file) must begin with an uppercase letter.
EDL description of the Hello process class
A static description of the Hello
program consists of a single file named Hello.edl
that must indicate the name of the process class:
Hello.edl
/* The process class name follows the reserved word "entity". */
entity Hello
The process class name must begin with an uppercase letter. The name of an EDL file must match the name of the class that it describes.
Creating the Einit initializing program
When KasperskyOS is loaded, the kernel starts a program named Einit
. The Einit
program starts all other programs included in the solution, which means that it serves as the initializing program.
The KasperskyOS Community Edition toolkit includes the einit tool, which lets you generate the code of the initializing program (einit.c
) based on the init description. In the example provided below, the file containing the init description is named init.yaml
, but it can have any name.
For more details, refer to "Starting processes".
If you want the Hello
application to start after the operating system is loaded, all you need to do is specify its name in the init.yaml
file and build an Einit
application from it.
init.yaml
entities:
# Start the "Hello" application.
- name: Hello
Building the security module
The hello example contains a basic solution security policy (security.psl
) that allows all interactions.
The security module (ksm.module
) is built based on security.psl
.
Example files
The code of the example and build scripts are available at the following path:
/opt/KasperskyOS-Community-Edition-<version>/examples/hello
Building and running example
See Building and running examples section.
The general build scheme for the hello example looks as follows:
Page top