mirror of
https://github.com/systemd/systemd.git
synced 2024-11-06 08:26:52 +03:00
udevd: rename systemd_fds to listen_fds
This commit is contained in:
parent
8314de1d81
commit
fcff1e7241
@ -1262,38 +1262,43 @@ static int on_post(sd_event_source *s, void *userdata) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int systemd_fds(int *rctrl, int *rnetlink) {
|
static int listen_fds(int *rctrl, int *rnetlink) {
|
||||||
int ctrl = -1, netlink = -1;
|
int ctrl_fd = -1, netlink_fd = -1;
|
||||||
int fd, n;
|
int fd, n;
|
||||||
|
|
||||||
|
assert(rctrl);
|
||||||
|
assert(rnetlink);
|
||||||
|
|
||||||
n = sd_listen_fds(true);
|
n = sd_listen_fds(true);
|
||||||
if (n <= 0)
|
if (n < 0)
|
||||||
return -1;
|
return n;
|
||||||
|
|
||||||
for (fd = SD_LISTEN_FDS_START; fd < n + SD_LISTEN_FDS_START; fd++) {
|
for (fd = SD_LISTEN_FDS_START; fd < n + SD_LISTEN_FDS_START; fd++) {
|
||||||
if (sd_is_socket(fd, AF_LOCAL, SOCK_SEQPACKET, -1)) {
|
if (sd_is_socket(fd, AF_LOCAL, SOCK_SEQPACKET, -1)) {
|
||||||
if (ctrl >= 0)
|
if (ctrl_fd >= 0)
|
||||||
return -1;
|
return -EINVAL;
|
||||||
ctrl = fd;
|
ctrl_fd = fd;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sd_is_socket(fd, AF_NETLINK, SOCK_RAW, -1)) {
|
if (sd_is_socket(fd, AF_NETLINK, SOCK_RAW, -1)) {
|
||||||
if (netlink >= 0)
|
if (netlink_fd >= 0)
|
||||||
return -1;
|
return -EINVAL;
|
||||||
netlink = fd;
|
netlink_fd = fd;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctrl < 0 || netlink < 0)
|
if (ctrl_fd < 0 || netlink_fd < 0)
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
|
log_debug("ctrl=%i netlink=%i", ctrl_fd, netlink_fd);
|
||||||
|
|
||||||
|
*rctrl = ctrl_fd;
|
||||||
|
*rnetlink = netlink_fd;
|
||||||
|
|
||||||
log_debug("ctrl=%i netlink=%i", ctrl, netlink);
|
|
||||||
*rctrl = ctrl;
|
|
||||||
*rnetlink = netlink;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1465,7 +1470,7 @@ static int manager_new(Manager **ret) {
|
|||||||
udev_list_node_init(&manager->events);
|
udev_list_node_init(&manager->events);
|
||||||
udev_list_init(manager->udev, &manager->properties, true);
|
udev_list_init(manager->udev, &manager->properties, true);
|
||||||
|
|
||||||
r = systemd_fds(&fd_ctrl, &fd_uevent);
|
r = listen_fds(&fd_ctrl, &fd_uevent);
|
||||||
if (r >= 0) {
|
if (r >= 0) {
|
||||||
/* get control and netlink socket from systemd */
|
/* get control and netlink socket from systemd */
|
||||||
manager->ctrl = udev_ctrl_new_from_fd(manager->udev, fd_ctrl);
|
manager->ctrl = udev_ctrl_new_from_fd(manager->udev, fd_ctrl);
|
||||||
|
Loading…
Reference in New Issue
Block a user