From ed33625a4a15b00372e3b2155a3ce18f28d8f1ad Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 13 Jan 2009 21:55:35 +0000 Subject: [PATCH 1/2] Added a move flag for init's mount command that maps to MS_MOVE. Change-Id: I7bc1a8ac5f73a34c101247f984cbf9ff29e02e7f --- init/builtins.c | 1 + 1 file changed, 1 insertion(+) diff --git a/init/builtins.c b/init/builtins.c index b4af700bd..44faf1716 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 }, From 93ac1559b8c7ad3125ddcd896082b030faadbbd4 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Thu, 6 May 2010 13:30:09 -0400 Subject: [PATCH 2/2] init: Add support for /dev/bus/usb/ file system and add new unix group AID_USB. init now creates files in /dev/bus/usb/ for user access to USB devices. Files are chmod 660 with group AID_USB. Signed-off-by: Mike Lockwood --- include/private/android_filesystem_config.h | 2 ++ init/devices.c | 26 +++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h index 24b7c819a..535f98c3a 100644 --- a/include/private/android_filesystem_config.h +++ b/include/private/android_filesystem_config.h @@ -51,6 +51,7 @@ #define AID_SDCARD_RW 1015 /* external storage write access */ #define AID_VPN 1016 /* vpn system */ #define AID_KEYSTORE 1017 /* keystore subsystem */ +#define AID_USB 1018 /* USB devices */ #define AID_SHELL 2000 /* adb and debug shell user */ #define AID_CACHE 2001 /* cache access */ @@ -100,6 +101,7 @@ static struct android_id_info android_ids[] = { { "sdcard_rw", AID_SDCARD_RW, }, { "vpn", AID_VPN, }, { "keystore", AID_KEYSTORE, }, + { "usb", AID_USB, }, { "inet", AID_INET, }, { "net_raw", AID_NET_RAW, }, { "net_admin", AID_NET_ADMIN, }, diff --git a/init/devices.c b/init/devices.c index 1dffcd475..401e2544c 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 }, }; @@ -373,6 +374,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; @@ -398,7 +400,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)) { @@ -428,7 +449,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);