merge from open-source master
diff --git a/init/builtins.c b/init/builtins.c
index cc7c9d1..1e7cb4e 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -131,6 +131,18 @@
}
}
+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
@@ -206,7 +218,7 @@
int do_import(int nargs, char **args)
{
- return -1;
+ return parse_config_file(args[1]);
}
int do_mkdir(int nargs, char **args)
@@ -400,6 +412,8 @@
int do_trigger(int nargs, char **args)
{
+ action_for_each_trigger(args[1], action_add_queue_tail);
+ drain_action_queue();
return 0;
}
diff --git a/init/devices.c b/init/devices.c
index 0347336..79c31dc 100644
--- a/init/devices.c
+++ b/init/devices.c
@@ -307,7 +307,7 @@
chown(path, uid, gid);
}
-#ifdef LOG_UEVENTS
+#if LOG_UEVENTS
static inline suseconds_t get_usecs(void)
{
diff --git a/init/init.c b/init/init.c
old mode 100644
new mode 100755
index 8c2a058..f76eb36
--- a/init/init.c
+++ b/init/init.c
@@ -65,8 +65,6 @@
static int keychords_count = 0;
static int keychords_length = 0;
-static void drain_action_queue(void);
-
static void notify_service_state(const char *name, const char *state)
{
char pname[PROP_NAME_MAX];
@@ -391,12 +389,13 @@
}
}
+ svc->flags |= SVC_RESTARTING;
+
/* Execute all onrestart commands for this service. */
list_for_each(node, &svc->onrestart.commands) {
cmd = node_to_item(node, struct command, clist);
cmd->func(cmd->nargs, cmd->args);
}
- svc->flags |= SVC_RESTARTING;
notify_service_state(svc->name, "restarting");
return 0;
}
@@ -667,7 +666,7 @@
}
}
-static void drain_action_queue(void)
+void drain_action_queue(void)
{
struct listnode *node;
struct command *cmd;
diff --git a/init/init.h b/init/init.h
index f306b7b..60c3055 100644
--- a/init/init.h
+++ b/init/init.h
@@ -165,6 +165,7 @@
void service_start(struct service *svc, const char *dynamic_args);
void property_changed(const char *name, const char *value);
+void drain_action_queue(void);
struct action *action_remove_queue_head(void);
void action_add_queue_tail(struct action *act);
void action_for_each_trigger(const char *trigger,
diff --git a/init/keywords.h b/init/keywords.h
index 641426c..308118e 100644
--- a/init/keywords.h
+++ b/init/keywords.h
@@ -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);
@@ -32,6 +34,8 @@
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)
diff --git a/init/parser.c b/init/parser.c
index affc80c..54622cc 100644
--- a/init/parser.c
+++ b/init/parser.c
@@ -129,6 +129,8 @@
case 'c':
if (!strcmp(s, "opy")) return K_copy;
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;
diff --git a/init/readme.txt b/init/readme.txt
index 665090b..a185790 100644
--- a/init/readme.txt
+++ b/init/readme.txt
@@ -145,12 +145,18 @@
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.
diff --git a/rootdir/etc/init.goldfish.sh b/rootdir/etc/init.goldfish.sh
index f1b801d..5ff0a3a 100755
--- a/rootdir/etc/init.goldfish.sh
+++ b/rootdir/etc/init.goldfish.sh
@@ -3,16 +3,20 @@
ifconfig eth0 10.0.2.15 netmask 255.255.255.0 up
route add default gw 10.0.2.2 dev eth0
-qemud=`getprop.ro.kernel.android.qemud`
-if test -z "$qemud"; then
+qemud=`getprop ro.kernel.android.qemud`
+case "$qemud" in
+ "")
radio_ril=`getprop ro.kernel.android.ril`
- if test -z "$radio_ril"; then
+ case "$radio_ril" in
+ "")
# no need for the radio interface daemon
# telephony is entirely emulated in Java
setprop ro.radio.noril yes
stop ril-daemon
- fi
-fi
+ ;;
+ esac
+ ;;
+esac
num_dns=`getprop ro.kernel.android.ndns`
case "$num_dns" in
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 297afa1..d63d34d 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -39,7 +39,7 @@
# Create cgroup mount points for process groups
mkdir /dev/cpuctl
mount cgroup none /dev/cpuctl cpu
- chown sytem system /dev/cpuctl
+ chown system system /dev/cpuctl
chown system system /dev/cpuctl/tasks
chmod 0777 /dev/cpuctl/tasks
write /dev/cpuctl/cpu.shares 1024
diff --git a/vold/mmc.c b/vold/mmc.c
index 22894a1..d90845d 100644
--- a/vold/mmc.c
+++ b/vold/mmc.c
@@ -158,6 +158,10 @@
sprintf(filename, "/sys%s/name", devpath);
p = read_file(filename, &sz);
+ if (!p) {
+ LOGE("Unable to read MMC name: %s", filename);
+ return -errno;
+ }
p[strlen(p) - 1] = '\0';
sprintf(tmp, "MMC_NAME=%s", p);
free(p);