diff options
author | Dima Zavin <dima@android.com> | 2011-08-31 18:07:36 -0700 |
---|---|---|
committer | Dima Zavin <dima@android.com> | 2011-09-02 12:11:17 -0700 |
commit | 2d55e02d0f3c27f0c99ab889ab7b73126280a21c (patch) | |
tree | 160bd0d7677ca899527ec9ab4a6a619c3698c2a8 /init | |
parent | 09e32886e64258c0600e2696e26a2aca559310e2 (diff) | |
download | system_core-2d55e02d0f3c27f0c99ab889ab7b73126280a21c.zip system_core-2d55e02d0f3c27f0c99ab889ab7b73126280a21c.tar.gz system_core-2d55e02d0f3c27f0c99ab889ab7b73126280a21c.tar.bz2 |
libcutils/init: move uevent socket opening code to libcutils
Change-Id: I90adf78c0eb6185505f2bf7b62e96e25ab918345
Signed-off-by: Dima Zavin <dima@android.com>
Diffstat (limited to 'init')
-rw-r--r-- | init/devices.c | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/init/devices.c b/init/devices.c index 60659ce..43d0ca3 100644 --- a/init/devices.c +++ b/init/devices.c @@ -58,33 +58,6 @@ struct uevent { int minor; }; -static int open_uevent_socket(void) -{ - struct sockaddr_nl addr; - int sz = 64*1024; // XXX larger? udev uses 16MB! - int on = 1; - int s; - - memset(&addr, 0, sizeof(addr)); - addr.nl_family = AF_NETLINK; - addr.nl_pid = getpid(); - addr.nl_groups = 0xffffffff; - - s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT); - if(s < 0) - return -1; - - setsockopt(s, SOL_SOCKET, SO_RCVBUFFORCE, &sz, sizeof(sz)); - setsockopt(s, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)); - - if(bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { - close(s); - return -1; - } - - return s; -} - struct perms_ { char *name; char *attr; @@ -847,7 +820,8 @@ void device_init(void) struct stat info; int fd; - device_fd = open_uevent_socket(); + /* is 64K enough? udev uses 16MB! */ + device_fd = uevent_open_socket(64*1024, true); if(device_fd < 0) return; |