SO_RCVBUF Sets or gets the maximum socket receive buffer in bytes. The kernel doubles this value (to allow space for bookkeeping overhead) when it is set using setsockopt(2), and this doubled value is returned by getsockopt(2). The default value is set by the/proc/sys/net/core/rmem_...
//打开uevent的socket。这里的uevent是用到netlink中的内核事件向用户态通知(NETLINK_KOBJECT_UEVENT)功能 //是内核和用户态进行双向数据传输的非常好的方式,除了eventd外,netd和vold也是使用uevent的 device_fd = uevent_open_socket(256*1024, true); if(device_fd < 0) return; fcntl(device_fd, F_SETFD,...
device_init()函数做了两件事: uevent_open_socket(),创建netlink套接字,并赋值给全局变量device_fd,用于后续的uevent事件监听,uevent_open_socket()函数涉及到netlink机制与socket编程,具体分析请参考:uevent_open_socket()浅析 coldboot(),递归扫描/sys目录下的uevent节点,然后写入字符串“add”,强制触发内核ueven...
int socket_fd = -1; char msg[UEVENT_MSG_LEN+2]; int n; socket_fd = open_uevent_socket();---创建socket。 printf("socket_fd = %d\n", socket_fd); do { while((n = recv(socket_fd, msg, UEVENT_MSG_LEN, 0)) > 0) {---接收uevent信息。 struct cooling_device cdev; memset(&cd...
1. uevent初始化:要使用uevent,需要创建一个socket。这个socket是基于netlink协议的,用于接收内核发送的uevent通知。 intsocket_fd=socket(AF_NETLINK,SOCK_DGRAM,NETLINK_KOBJECT_UEVENT); 2. 绑定uevent到socket:通过setsockopt设置过滤器,这样只有特定的uevent通知会被发送到socket。
6. selinux_status_open(true); 7. } 8. 9.//创建socket,该socekt用于监听后续的uevent事件 10. device_fd=uevent_open_socket(256*1024,true); 11.if(device_fd==-1) { 12.return; 13. } 14.//通过fcntl函数,将device_fd置为非阻塞。
函数首先调用uevent_open_socket 来创建PF_NETLINK socket 并绑定到指定地址上: int uevent_open_socket(int buf_sz, bool passcred) { struct sockaddr_nl addr; int on = passcred; int s; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; ...
"Unable to open socket forUEventObserver"); } } hardware/libhardware_legacy/uevent/uevent.c int uevent_init() { struct sockaddr_nl addr; int sz = 64*1024; int s; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; ...
函数: 1 static void uevent_init(void) { 2 uevent_fd = uevent_open_socket(64*1024, true); 3 4...uevent_fd, uevent_event)) 11 KLOG_ERROR(LOG_TAG, 12 "register for uevent events...failed\n"); 13 } 创建并打开一个64k的socket文件描述符uevent_fd,设置文件状态标志为非阻塞模,将uevent事...
openlog(applet_name, LOG_PID, LOG_DAEMON); logmode |= LOGMODE_SYSLOG; } #if ENABLE_FEATURE_MDEV_DAEMON if (opt & MDEV_OPT_DAEMON) { /* Daemon mode listening on uevent netlink socket. Fork away * after initial scan so that caller can be sure everything ...