run hooks, namely /sbin/init-{top,premount,bottom}, if exist

This commit is contained in:
Sergey Bolshakov 2009-07-06 17:19:52 +04:00
parent e8a5fe8036
commit e01b4d2209
2 changed files with 23 additions and 1 deletions

19
init.c
View File

@ -58,6 +58,10 @@ char *udevd[] = {"/sbin/udevd", "udevd", NULL};
char *udevtrigger[] = {"/sbin/udevadm", "udevadm", "trigger", NULL};
char *udevsettle[] = {"/sbin/udevadm", "udevadm", "settle", NULL};
char *init_top[] = {"/sbin/init-top", "init-top", NULL};
char *init_premount[] = {"/sbin/init-premount", "init-premount", NULL};
char *init_bottom[] = {"/sbin/init-bottom", "init-bottom", NULL};
extern void stage1();
void fatal(const char *) __attribute__((noreturn));
@ -133,6 +137,15 @@ pid_t spawn(char *av[])
}
}
void spawn_hook(char *av[])
{
struct stat st;
int status;
if (stat(av[0], &st) || !S_ISREG(st.st_mode) || !(st.st_mode & S_IXUSR)) return;
if (waitpid(spawn(av), &status, 0) < 0 || !(WIFEXITED(status))) fatal(av[0]);
}
void take_env(int fd)
{
static char buf[PIPE_BUF];
@ -390,6 +403,8 @@ int main(int argc, char **argv)
klogpid = doklog();
spawn_hook(init_top);
if (mkdir("/dev/.udev", 0755) < 0 ||
mkdir("/dev/.udev/db", 0755) < 0)
fatal("/dev/.udev/db");
@ -411,6 +426,8 @@ int main(int argc, char **argv)
printf("done\n");
spawn_hook(init_premount);
/* Go into normal init mode - keep going, and then do a orderly shutdown
when:
@ -481,6 +498,8 @@ int main(int argc, char **argv)
} else fatal("creat()");
}
spawn_hook(init_bottom);
kill(klogpid, 9);
waitpid(klogpid, &wait_status, 0);

View File

@ -3,7 +3,7 @@
Name: propagator
Version: 20090301
Release: alt3
Release: alt4
Summary: 'Early userspace' set of binaries
License: GPL
@ -39,6 +39,9 @@ make %{?_with_shell:WITH_SHELL=t} %{?_with_splash:WITH_SPLASH=t} libdir=%_libdir
%_libdir/%name
%changelog
* Mon Jul 6 2009 Sergey Bolshakov <sbolshakov@altlinux.ru> 20090301-alt4
- run hooks, namely /sbin/init-{top,premount,bottom}, if exist
* Thu Jun 25 2009 Sergey Bolshakov <sbolshakov@altlinux.ru> 20090301-alt3
- add /lib/firmware/<kernel version> to fw search paths (#20583)