• Home
  • Raw
  • Download

Lines Matching refs:uctrl

71         struct udev_ctrl *uctrl;  member
76 struct udev_ctrl *uctrl; in udev_ctrl_new_from_fd() local
80 uctrl = new0(struct udev_ctrl, 1); in udev_ctrl_new_from_fd()
81 if (uctrl == NULL) in udev_ctrl_new_from_fd()
83 uctrl->refcount = 1; in udev_ctrl_new_from_fd()
84 uctrl->udev = udev; in udev_ctrl_new_from_fd()
87 uctrl->sock = socket(AF_LOCAL, SOCK_SEQPACKET|SOCK_NONBLOCK|SOCK_CLOEXEC, 0); in udev_ctrl_new_from_fd()
88 if (uctrl->sock < 0) { in udev_ctrl_new_from_fd()
90 udev_ctrl_unref(uctrl); in udev_ctrl_new_from_fd()
94 uctrl->bound = true; in udev_ctrl_new_from_fd()
95 uctrl->sock = fd; in udev_ctrl_new_from_fd()
97 r = setsockopt(uctrl->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)); in udev_ctrl_new_from_fd()
101 uctrl->saddr.un.sun_family = AF_LOCAL; in udev_ctrl_new_from_fd()
102 …strscpy(uctrl->saddr.un.sun_path, sizeof(uctrl->saddr.un.sun_path), UDEV_ROOT_RUN "/udev/control"); in udev_ctrl_new_from_fd()
103 uctrl->addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(uctrl->saddr.un.sun_path); in udev_ctrl_new_from_fd()
104 return uctrl; in udev_ctrl_new_from_fd()
111 int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl) { in udev_ctrl_enable_receiving() argument
114 if (!uctrl->bound) { in udev_ctrl_enable_receiving()
115 err = bind(uctrl->sock, &uctrl->saddr.sa, uctrl->addrlen); in udev_ctrl_enable_receiving()
117 unlink(uctrl->saddr.un.sun_path); in udev_ctrl_enable_receiving()
118 err = bind(uctrl->sock, &uctrl->saddr.sa, uctrl->addrlen); in udev_ctrl_enable_receiving()
127 err = listen(uctrl->sock, 0); in udev_ctrl_enable_receiving()
134 uctrl->bound = true; in udev_ctrl_enable_receiving()
135 uctrl->cleanup_socket = true; in udev_ctrl_enable_receiving()
140 struct udev *udev_ctrl_get_udev(struct udev_ctrl *uctrl) { in udev_ctrl_get_udev() argument
141 return uctrl->udev; in udev_ctrl_get_udev()
144 static struct udev_ctrl *udev_ctrl_ref(struct udev_ctrl *uctrl) { in udev_ctrl_ref() argument
145 if (uctrl) in udev_ctrl_ref()
146 uctrl->refcount++; in udev_ctrl_ref()
148 return uctrl; in udev_ctrl_ref()
151 struct udev_ctrl *udev_ctrl_unref(struct udev_ctrl *uctrl) { in udev_ctrl_unref() argument
152 if (uctrl && -- uctrl->refcount == 0) { in udev_ctrl_unref()
153 if (uctrl->sock >= 0) in udev_ctrl_unref()
154 close(uctrl->sock); in udev_ctrl_unref()
155 free(uctrl); in udev_ctrl_unref()
161 int udev_ctrl_cleanup(struct udev_ctrl *uctrl) { in udev_ctrl_cleanup() argument
162 if (uctrl == NULL) in udev_ctrl_cleanup()
164 if (uctrl->cleanup_socket) in udev_ctrl_cleanup()
165 unlink(uctrl->saddr.un.sun_path); in udev_ctrl_cleanup()
169 int udev_ctrl_get_fd(struct udev_ctrl *uctrl) { in udev_ctrl_get_fd() argument
170 if (uctrl == NULL) in udev_ctrl_get_fd()
172 return uctrl->sock; in udev_ctrl_get_fd()
187 struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) { in udev_ctrl_get_connection() argument
197 conn->uctrl = uctrl; in udev_ctrl_get_connection()
200 conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK); in udev_ctrl_get_connection()
204 conn->sock = accept4_fallback(uctrl->sock); in udev_ctrl_get_connection()
206 conn->sock = accept4_fallback(uctrl->sock); in udev_ctrl_get_connection()
231 udev_ctrl_ref(uctrl); in udev_ctrl_get_connection()
252 udev_ctrl_unref(conn->uctrl); in udev_ctrl_connection_unref()
260 static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int intval, const char … in ctrl_send() argument
274 if (!uctrl->connected) { in ctrl_send()
275 if (connect(uctrl->sock, &uctrl->saddr.sa, uctrl->addrlen) < 0) { in ctrl_send()
279 uctrl->connected = true; in ctrl_send()
281 if (send(uctrl->sock, &ctrl_msg_wire, sizeof(ctrl_msg_wire), 0) < 0) { in ctrl_send()
291 pfd[0].fd = uctrl->sock; in ctrl_send()
314 int udev_ctrl_send_set_log_level(struct udev_ctrl *uctrl, int priority, int timeout) { in udev_ctrl_send_set_log_level() argument
315 return ctrl_send(uctrl, UDEV_CTRL_SET_LOG_LEVEL, priority, NULL, timeout); in udev_ctrl_send_set_log_level()
318 int udev_ctrl_send_stop_exec_queue(struct udev_ctrl *uctrl, int timeout) { in udev_ctrl_send_stop_exec_queue() argument
319 return ctrl_send(uctrl, UDEV_CTRL_STOP_EXEC_QUEUE, 0, NULL, timeout); in udev_ctrl_send_stop_exec_queue()
322 int udev_ctrl_send_start_exec_queue(struct udev_ctrl *uctrl, int timeout) { in udev_ctrl_send_start_exec_queue() argument
323 return ctrl_send(uctrl, UDEV_CTRL_START_EXEC_QUEUE, 0, NULL, timeout); in udev_ctrl_send_start_exec_queue()
326 int udev_ctrl_send_reload(struct udev_ctrl *uctrl, int timeout) { in udev_ctrl_send_reload() argument
327 return ctrl_send(uctrl, UDEV_CTRL_RELOAD, 0, NULL, timeout); in udev_ctrl_send_reload()
330 int udev_ctrl_send_set_env(struct udev_ctrl *uctrl, const char *key, int timeout) { in udev_ctrl_send_set_env() argument
331 return ctrl_send(uctrl, UDEV_CTRL_SET_ENV, 0, key, timeout); in udev_ctrl_send_set_env()
334 int udev_ctrl_send_set_children_max(struct udev_ctrl *uctrl, int count, int timeout) { in udev_ctrl_send_set_children_max() argument
335 return ctrl_send(uctrl, UDEV_CTRL_SET_CHILDREN_MAX, count, NULL, timeout); in udev_ctrl_send_set_children_max()
338 int udev_ctrl_send_ping(struct udev_ctrl *uctrl, int timeout) { in udev_ctrl_send_ping() argument
339 return ctrl_send(uctrl, UDEV_CTRL_PING, 0, NULL, timeout); in udev_ctrl_send_ping()
342 int udev_ctrl_send_exit(struct udev_ctrl *uctrl, int timeout) { in udev_ctrl_send_exit() argument
343 return ctrl_send(uctrl, UDEV_CTRL_EXIT, 0, NULL, timeout); in udev_ctrl_send_exit()