Lines Matching defs:uctrl

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