diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2018-01-14 22:55:09 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2018-01-14 22:55:09 +0000 |
commit | a9d10d4ce41395923f52114f722dd02d9c732c81 (patch) | |
tree | 6ee7590561fd57c2d51854f7a2e52a2f5fec4546 | |
parent | 4984158b95c5a0c3922cd34940c393652d080f99 (diff) | |
download | mdevd-a9d10d4ce41395923f52114f722dd02d9c732c81.tar.xz |
netlink isn't fd 0 anymore
-rw-r--r-- | src/mdevd/mdevd.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mdevd/mdevd.c b/src/mdevd/mdevd.c index ca1e070..1715f27 100644 --- a/src/mdevd/mdevd.c +++ b/src/mdevd/mdevd.c @@ -210,7 +210,7 @@ static inline int netlink_init (unsigned int kbufsz) return fd ; } -static inline size_t netlink_read (char *s) +static inline size_t netlink_read (int fd, char *s) { struct sockaddr_nl nl; struct iovec v = { .iov_base = s, .iov_len = UEVENT_MAX_SIZE } ; @@ -224,7 +224,7 @@ static inline size_t netlink_read (char *s) .msg_controllen = 0, .msg_flags = 0 } ; - ssize_t r = sanitize_read(fd_recvmsg(0, &msg)) ; + ssize_t r = sanitize_read(fd_recvmsg(fd, &msg)) ; if (r < 0) { if (errno == EPIPE) @@ -261,10 +261,10 @@ static inline size_t netlink_read (char *s) return r ; } -static inline int uevent_read (struct uevent_s *event) +static inline int uevent_read (int fd, struct uevent_s *event) { unsigned short len = 0 ; - event->len = netlink_read(event->buf) ; + event->len = netlink_read(fd, event->buf) ; if (!event->len) return 0 ; event->varn = 0 ; while (len < event->len) @@ -974,10 +974,10 @@ static inline void handle_signals (void) } } -static inline void handle_event (scriptelem const *script, unsigned short scriptlen, char const *storage, struct envmatch_s const *envmatch) +static inline void handle_event (int fd, scriptelem const *script, unsigned short scriptlen, char const *storage, struct envmatch_s const *envmatch) { struct uevent_s event = UEVENT_ZERO ; - if (uevent_read(&event) && event.varn > 1) + if (uevent_read(fd, &event) && event.varn > 1) on_event(&event, script, scriptlen, storage, envmatch) ; } @@ -1084,7 +1084,7 @@ int main (int argc, char const *const *argv) if (x[0].revents & IOPAUSE_READ) handle_signals() ; if (!pid && cont == 2 && x[1].revents & IOPAUSE_READ) - handle_event(script, scriptlen, storage, envmatch) ; + handle_event(x[1].fd, script, scriptlen, storage, envmatch) ; } script_free(script, scriptlen, envmatch, envmatchlen) ; |