added chdir/chroot commands to init for mount switching/pivoting

This commit is contained in:
Jay Freeman (saurik) 2008-11-17 06:41:10 +00:00 committed by Jean-Baptiste Queru
parent 9f28bde9eb
commit e7cb137f32
4 changed files with 24 additions and 0 deletions

View File

@ -131,6 +131,18 @@ static void service_start_if_not_disabled(struct service *svc)
}
}
int do_chdir(int nargs, char **args)
{
chdir(args[1]);
return 0;
}
int do_chroot(int nargs, char **args)
{
chroot(args[1]);
return 0;
}
int do_class_start(int nargs, char **args)
{
/* Starting a class does not start services

View File

@ -1,5 +1,7 @@
#ifndef KEYWORD
int do_chroot(int nargs, char **args);
int do_chdir(int nargs, char **args);
int do_class_start(int nargs, char **args);
int do_class_stop(int nargs, char **args);
int do_domainname(int nargs, char **args);
@ -31,6 +33,8 @@ enum {
K_UNKNOWN,
#endif
KEYWORD(capability, OPTION, 0, 0)
KEYWORD(chdir, COMMAND, 1, do_chdir)
KEYWORD(chroot, COMMAND, 1, do_chroot)
KEYWORD(class, OPTION, 0, 0)
KEYWORD(class_start, COMMAND, 1, do_class_start)
KEYWORD(class_stop, COMMAND, 1, do_class_stop)

View File

@ -128,6 +128,8 @@ int lookup_keyword(const char *s)
switch (*s++) {
case 'c':
if (!strcmp(s, "apability")) return K_capability;
if (!strcmp(s, "hdir")) return K_chdir;
if (!strcmp(s, "hroot")) return K_chroot;
if (!strcmp(s, "lass")) return K_class;
if (!strcmp(s, "lass_start")) return K_class_start;
if (!strcmp(s, "lass_stop")) return K_class_stop;

View File

@ -145,12 +145,18 @@ import <filename>
hostname <name>
Set the host name.
chdir <directory>
Change working directory.
chmod <octal-mode> <path>
Change file access permissions.
chown <owner> <group> <path>
Change file owner and group.
chroot <directory>
Change process root directory.
class_start <serviceclass>
Start all services of the specified class if they are
not already running.