kernel: ~Stack can grow now (upto 4MB)
[meinos.git] / apps / rc / boot.c
blob3982d8d51759a850e151c6db6734c7a610cf8cb5
1 /*
2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <stdio.h>
20 #include <dirent.h>
22 #include "helper.h"
24 static const char *grub_module_template =
25 "#!/bin/sh"
26 "# Copyright (c) 2009 Janosch Graef"
27 "#"
28 "### BEGIN INIT INFO"
29 "# Provides: %s"
30 "# Required-Start:"
31 "# Required-Stop:"
32 "# Should-Start:"
33 "# Should-Stop:"
34 "# Default-Start: 1 2 3 5"
35 "# Default-Stop:"
36 "# Short-Description: Pseudo RC script for grub module '%s'"
37 "# Description: Pseudo RC script for grub module '%s'"
38 "### END INIT INFO"
40 "case \"$1\" in"
41 " start)"
42 " echo \"This is a GRUB module. It should already run.\""
43 " ;;"
44 " stop)"
45 " echo \"Cannot stop GRUB modules.\" > 2"
46 " ;;"
47 " status)"
48 " echo \"running\""
49 " ;;"
50 " *)"
51 " echo \"Usage: $0 {start|stop|status}\" > 2"
52 " ;;"
53 "esac";
55 static int make_grub_module_script(const char *name) {
56 char *script;
57 char *path;
58 int ret = -1;
60 asprintf(&path,"/etc/init.d/%s",name);
61 asprintf(&script,grub_module_template,name,name,name);
63 FILE *fd = fopen(path,"w");
64 if (fd!=NULL) {
65 fputs(script,fd);
66 fclose(fd);
67 ret = 0;
70 free(path);
71 free(script);
73 make_rc_symlink(name,1,1,'S');
74 make_rc_symlink(name,2,1,'S');
75 make_rc_symlink(name,3,1,'S');
76 make_rc_symlink(name,5,1,'S');
77 make_rc_symlink(name,1,1,'K');
78 make_rc_symlink(name,2,1,'K');
79 make_rc_symlink(name,3,1,'K');
80 make_rc_symlink(name,5,1,'K');
82 return ret;
85 int main(int argc,char *argv[]) {
86 /// @todo get GRUB modules and create module scripts
87 make_grub_module_script("vfs");
88 return 0;