summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2010-05-17 08:54:31 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2010-05-17 08:54:31 -0700
commite95aad61d841e7a472b4141808bbca0c7135b0f5 (patch)
tree9ed76e19ddbcb4d45dda3e70184b51fb475623d5 /init
parent538e5778be15382669b0058de5bafa9f4961247e (diff)
parent93ac1559b8c7ad3125ddcd896082b030faadbbd4 (diff)
downloadsystem_core-e95aad61d841e7a472b4141808bbca0c7135b0f5.zip
system_core-e95aad61d841e7a472b4141808bbca0c7135b0f5.tar.gz
system_core-e95aad61d841e7a472b4141808bbca0c7135b0f5.tar.bz2
merge from open-source master
Change-Id: I414c9479f4f913c777ef18b7ff27e410f49d35b9
Diffstat (limited to 'init')
-rw-r--r--init/builtins.c1
-rw-r--r--init/devices.c26
2 files changed, 25 insertions, 2 deletions
diff --git a/init/builtins.c b/init/builtins.c
index b4af700..44faf17 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -255,6 +255,7 @@ static struct {
const char *name;
unsigned flag;
} mount_flags[] = {
+ { "move", MS_MOVE },
{ "noatime", MS_NOATIME },
{ "nosuid", MS_NOSUID },
{ "nodev", MS_NODEV },
diff --git a/init/devices.c b/init/devices.c
index bde906b..8789b89 100644
--- a/init/devices.c
+++ b/init/devices.c
@@ -157,6 +157,7 @@ static struct perms_ devperms[] = {
{ "/dev/ts0710mux", 0640, AID_RADIO, AID_RADIO, 1 },
{ "/dev/ppp", 0660, AID_RADIO, AID_VPN, 0 },
{ "/dev/tun", 0640, AID_VPN, AID_VPN, 0 },
+ { "/dev/bus/usb/", 0660, AID_ROOT, AID_USB, 1 },
{ NULL, 0, 0, 0, 0 },
};
@@ -380,6 +381,7 @@ static void parse_event(const char *msg, struct uevent *uevent)
static void handle_device_event(struct uevent *uevent)
{
char devpath[96];
+ int devpath_ready = 0;
char *base, *name;
int block;
@@ -405,7 +407,26 @@ static void handle_device_event(struct uevent *uevent)
} else {
block = 0;
/* this should probably be configurable somehow */
- if(!strncmp(uevent->subsystem, "graphics", 8)) {
+ if (!strncmp(uevent->subsystem, "usb", 3)) {
+ if (!strcmp(uevent->subsystem, "usb")) {
+ /* This imitates the file system that would be created
+ * if we were using devfs instead.
+ * Minors are broken up into groups of 128, starting at "001"
+ */
+ int bus_id = uevent->minor / 128 + 1;
+ int device_id = uevent->minor % 128 + 1;
+ /* build directories */
+ mkdir("/dev/bus", 0755);
+ mkdir("/dev/bus/usb", 0755);
+ snprintf(devpath, sizeof(devpath), "/dev/bus/usb/%03d", bus_id);
+ mkdir(devpath, 0755);
+ snprintf(devpath, sizeof(devpath), "/dev/bus/usb/%03d/%03d", bus_id, device_id);
+ devpath_ready = 1;
+ } else {
+ /* ignore other USB events */
+ return;
+ }
+ } else if (!strncmp(uevent->subsystem, "graphics", 8)) {
base = "/dev/graphics/";
mkdir(base, 0755);
} else if (!strncmp(uevent->subsystem, "oncrpc", 6)) {
@@ -435,7 +456,8 @@ static void handle_device_event(struct uevent *uevent)
base = "/dev/";
}
- snprintf(devpath, sizeof(devpath), "%s%s", base, name);
+ if (!devpath_ready)
+ snprintf(devpath, sizeof(devpath), "%s%s", base, name);
if(!strcmp(uevent->action, "add")) {
make_device(devpath, block, uevent->major, uevent->minor);