List of commits:
Subject Hash Author Date (UTC)
waitid WALL and build script convolution removal 3287d331754e4b9b974e3e400a7b907c5b5dc7a2 Sylvain BERTRAND 2023-03-10 13:04:07
fix excessive c99 7c7afb00373813e61be259bae2c097642e717dee Sylvain BERTRAND 2021-05-27 15:04:11
tidy and cosmetics 3475d1fb9c9aaf7cd059b00c1bf791616a6c4118 Sylvain BERTRAND 2021-05-26 23:34:50
/sbin to /bin 5031de4134243797ac2ab9f85262040098ca1bfe Sylvain BERTRAND 2015-02-14 23:29:30
use a real life sysstart 28421b744d0937334e1e0254dff39f45e7d4480d Sylvain BERTRAND 2015-01-20 17:44:51
remove some bash-ism 688ff57cfe8077c235a5ec485ba6b72b0d066dc4 Sylvain BERTRAND 2015-01-07 00:39:53
add some examples 4c3c939272dde88eee1242955d1a7832612d4bbb Sylvain BERTRAND 2014-12-08 17:29:16
Initial commit c72c14065b547486a05ade1b5975e3a1deaf9d18 Sylvain BERTRAND 2014-12-08 15:27:00
Commit 3287d331754e4b9b974e3e400a7b907c5b5dc7a2 - waitid WALL and build script convolution removal
WALL on waitid is supported sinc linux 4.7. Replaced convoluted
build shell script.
Author: Sylvain BERTRAND
Author date (UTC): 2023-03-10 13:04
Committer name: Sylvain BERTRAND
Committer date (UTC): 2023-03-10 13:04
Parent(s): 7c7afb00373813e61be259bae2c097642e717dee
Signing key:
Tree: 1a0ecc143548f1b3dcbe90b5c15dcf83d692bcc3
File Lines added Lines deleted
README 1 3
init.c 3 3
make 0 205
make_x86_64.sh 24 0
ulinux_namespace.h 1 0
File README changed (mode: 100644) (index 6658040..12c193c)
... ... and wait for its completion.
6 6 No libc dependency (Oh... Yeaah!). Only a super thin wrapper layer, ulinux (more No libc dependency (Oh... Yeaah!). Only a super thin wrapper layer, ulinux (more
7 7 recent and "cleaner" ulinux-es are available in other projects). recent and "cleaner" ulinux-es are available in other projects).
8 8
9
10 See ./make --help (you should have all required options for cross compiling
11 friendlyness)
9 See make_x86_64.sh for an example on how to build it.
12 10
13 11 Please use a build directory different than the source directory. Please use a build directory different than the source directory.
File init.c changed (mode: 100644) (index 1c397a0..7ca926a)
... ... static void sysstart(void)
110 110 l r; l r;
111 111
112 112 pid = sysstart_clone(); pid = sysstart_clone();
113 r = waitid(P_PID, pid, 0, WEXITED);
113 r = waitid(P_PID, pid, 0, WEXITED|WALL);
114 114 if (ISERR(r)) { if (ISERR(r)) {
115 115 OUT("ERROR(%ld):unable to wait for /bin/sysstart to exit\n", r); OUT("ERROR(%ld):unable to wait for /bin/sysstart to exit\n", r);
116 116 exit_group(-1); exit_group(-1);
 
... ... static void main_loop(void)
124 124 loop { loop {
125 125 l r; l r;
126 126
127 r = waitid(P_ALL, 0, 0, WEXITED);
127 r = waitid(P_ALL, 0, 0, WEXITED|WALL);
128 128 if (ISERR(r)) { if (ISERR(r)) {
129 129 OUT("ERROR(%ld):unable to wait on orphan process terminations\n", r); OUT("ERROR(%ld):unable to wait on orphan process terminations\n", r);
130 130 } }
 
... ... static void main_loop(void)
144 144 struct siginfo siginfo; struct siginfo siginfo;
145 145 l r; l r;
146 146
147 r = waitid(P_ALL, 0, &siginfo, WEXITED);
147 r = waitid(P_ALL, 0, &siginfo, WEXITED|WALL);
148 148 if(ISERR(r)) { if(ISERR(r)) {
149 149 OUT("ERROR(%ld):unable to wait on /bin/agetty clone and orphan process terminations\n", r); OUT("ERROR(%ld):unable to wait on /bin/agetty clone and orphan process terminations\n", r);
150 150 exit_group(-1); exit_group(-1);
File make deleted (index 293e6df..0000000)
1 #!/bin/sh
2
3 # this script is brutal and verbose, has no tricks and is quite linear, then
4 # quite easy to deal with
5 # for the moment, it's hardcoded for a gcc toolchain... BAD! Since now
6 # gcc is c++ diareha
7
8 # stolen from ffmpeg configure
9 set -e
10
11 # prevent locale nonsense from breaking basic text processing
12 LC_ALL=C
13 export LC_ALL
14
15 init_file_name=init
16
17 #-------------------------------------------------------------------------------
18 # default source files in the binary
19 init_ulinux_src_files="\
20 ulinux/utils/mem.c \
21 ulinux/utils/ascii/string/vsprintf.c"
22 init_src_files=init.c
23 #-------------------------------------------------------------------------------
24 sep_start()
25 {
26 printf "\
27 ################################################################################\
28 \n"
29 }
30
31 sep_end()
32 {
33 printf "\
34 ################################################################################\
35 \n\n"
36 }
37
38 subsep_start()
39 {
40 printf "\
41 ********************************************************************************\
42 \n"
43 }
44
45 subsep_end()
46 {
47 printf "\
48 ********************************************************************************\
49 \n"
50 }
51
52 ################################################################################
53
54 is_in()
55 {
56 value=$1
57 shift
58 for var in $*; do
59 [ $var = $value ] && return 0
60 done
61 return 1
62 }
63
64 set_default()
65 {
66 for opt; do
67 eval : \${$opt:=\$${opt}_default} #1 level of indirection
68 done
69 }
70
71 CMDLINE_SET='
72 init_cpp
73 init_cc
74 init_ld
75 init_ulinux_arch
76 '
77
78 ################################################################################
79
80 # command line set defaults
81 #-------------------------------------------------------------------------------
82 init_cpp_default='gcc -E -Wall -Wextra'
83 init_cc_default='gcc -nostdinc -Wall -Wextra -std=gnu99 -O0 -c'
84 init_ld_default='ld -nostdlib -O10 -s'
85 #-------------------------------------------------------------------------------
86 init_ulinux_arch_default=$(uname -m | sed -e s/i.86/i386/ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh.*/sh/)
87
88 set_default $CMDLINE_SET
89
90 ################################################################################
91
92 show_help()
93 {
94 cat <<EOF
95 Usage: make [options]
96
97 Help options:
98 --help print this message
99
100 Standard options:
101 --quiet init will be silenced (output code compiled out)
102 --no-tty init won't respawn login processes on ttys
103
104 Advanced options:
105 --init-cpp=CPP use CPP compiler command line CPP for target init process [$init_cpp]
106 --init-cc=CC use C compiler command line CC for target init process objects [$init_cc]
107 --init-ld=LD use linker command line LD for target init process [$init_ld]
108 --init-ulinux-arch=ARCH use ulinux ARCH for target init process [$init_ulinux_arch]
109 EOF
110 exit 0
111 }
112
113 ################################################################################
114
115 sep_start;printf 'paths:\n'
116 src_path=$(readlink -f $(dirname "$0"))
117 build_path=$(readlink -f .)
118 printf "source path is $src_path\n"
119 printf "build path is $build_path\n"
120 sep_end
121
122 ################################################################################
123
124
125 show_help_do=
126 for opt do
127 optval="${opt#*=}"
128 case "$opt" in
129 --help|-h)
130 show_help_do=yes #defer until we have all our options
131 ;;
132 --quiet)
133 CPPFLAGS="$CPPFLAGS -DQUIET"
134 init_ulinux_src_files=
135 ;;
136 --no-tty)
137 CPPFLAGS="$CPPFLAGS -DNO_TTY"
138 ;;
139 *)
140 optname=${opt%%=*}
141 optname=${optname#--}
142 optname=$(printf "$optname" | sed 's/-/_/g')
143 if is_in $optname $CMDLINE_SET; then
144 eval $optname='$optval' # 1 level indirection
145 else
146 printf "unknown option \"$opt\"\n"
147 printf "see $0 --help for available options\n"
148 exit 1
149 fi
150 ;;
151 esac
152 done
153 if test $show_help_do; then
154 show_help
155 fi
156
157 ################################################################################
158
159 sep_start;printf 'configure ulinux src tree for target arch:\n'
160 rm -f $build_path/ulinux/arch
161 mkdir -p $build_path/ulinux
162 ln -sTf $src_path/ulinux/archs/$init_ulinux_arch $build_path/ulinux/arch
163 printf "init ulinux arch is $init_ulinux_arch\n"
164 sep_end
165
166 ################################################################################
167
168 #from here we merge all source files
169 all_init_src_files="$init_src_files $init_ulinux_src_files"
170
171 ################################################################################
172
173 sep_start;printf 'C preprocess init src files:\n'
174 for init_src_file in $all_init_src_files
175 do
176 init_pp_c_file=${init_src_file%.c}.pp.c
177 printf "INIT_CPP $src_path/$init_src_file->$build_path/$init_pp_c_file\n"
178 mkdir -p $(dirname $init_pp_c_file)
179 $init_cpp $CPPFLAGS -I$build_path -I$src_path \
180 -o $build_path/$init_pp_c_file $src_path/$init_src_file
181 init_pp_c_files="$init_pp_c_file $init_pp_c_files"
182 done
183 sep_end
184
185 ################################################################################
186
187 sep_start;printf 'compile init preprocessed src files:\n'
188 for init_pp_c_file in $init_pp_c_files
189 do
190 init_obj_file=${init_pp_c_file%.pp.c}.o
191 printf "INIT_CC $build_path/$init_pp_c_file-->$build_path/$init_obj_file\n"
192 $init_cc $CFLAGS -o $build_path/$init_obj_file \
193 $build_path/$init_pp_c_file
194 init_obj_files="$init_obj_file $init_obj_files"
195 done
196 sep_end
197
198 ################################################################################
199
200 sep_start;printf 'link the init objects to produce the init binary:\n'
201 printf "INIT_LD $init_file_name\n"
202 printf "$init_ld -o $build_path/$init_file_name $build_path/$init_obj_files\n"
203 $init_ld -o $build_path/$init_file_name $build_path/$init_obj_files
204 sep_end
205 # vim: set ts=8 sw=0 noexpandtab:
File make_x86_64.sh added (mode: 100755) (index 0000000..8802703)
1 #!/bin/sh
2 build_dir=$(readlink -f .)
3 printf "BUILD_DIR=$build_dir\n"
4 src_dir=$(dirname $(readlink -f $0))
5 printf "SRC_DIR=$src_dir\n"
6
7 cpp=/opt/toolchains/x64/elf/binutils-gcc/current/bin/cpp
8 cc=/opt/toolchains/x64/elf/binutils-gcc/current/bin/gcc
9 ld=/opt/toolchains/x64/elf/binutils-gcc/current/bin/ld
10
11 rm -Rf $build_dir/ulinux
12 mkdir -p $build_dir/ulinux
13 ln -sTf $src_dir/ulinux/archs/x86_64 $build_dir/ulinux/arch
14
15 # Those are the ulinux files to build for a non-quiet/talkative init:
16 # - ulinux/utils/mem.c
17 # - utils/ascii/string/vsprintf.c
18 printf 'CPP init.c->init.cpp.c\n'
19 $cpp -DQUIET -DNO_TTY -I$build_dir -I$src_dir -o $build_dir/init.cpp.c $src_dir/init.c
20 printf 'CC init.cpp.c->init.cpp.c.o\n'
21 $cc -O0 -c -o $build_dir/init.cpp.c.o $build_dir/init.cpp.c
22 printf 'LD init.cpp.c.o->init\n'
23 $ld -nostdlib -s -o $build_dir/init $build_dir/init.cpp.c.o
24
File ulinux_namespace.h changed (mode: 100644) (index b3bf288..73b0a58)
14 14 #define siginfo ulinux_siginfo #define siginfo ulinux_siginfo
15 15 #define P_ALL ULINUX_P_ALL #define P_ALL ULINUX_P_ALL
16 16 #define WEXITED ULINUX_WEXITED #define WEXITED ULINUX_WEXITED
17 #define WALL ULINUX_WALL
17 18 #define u8 ulinux_u8 #define u8 ulinux_u8
18 19 #define i int #define i int
19 20 #define l long #define l long
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/sylware/muinit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/sylware/muinit

Clone this repository using git:
git clone git://git.rocketgit.com/user/sylware/muinit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main