]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdstat.c
Make target to install binaries only
[thirdparty/mdadm.git] / mdstat.c
index 20577a35e78b4199ceff85c9c0e8a5f2369104d5..dd96cca7aba1c08a0aef8cf1f82b734a66724cec 100644 (file)
--- a/mdstat.c
+++ b/mdstat.c
@@ -135,7 +135,6 @@ struct mdstat_ent *mdstat_read(int hold, int start)
        if (hold && mdstat_fd != -1) {
                off_t offset = lseek(mdstat_fd, 0L, 0);
                if (offset == (off_t)-1) {
-                       mdstat_close();
                        return NULL;
                }
                fd = dup(mdstat_fd);
@@ -303,7 +302,17 @@ void mdstat_close(void)
        mdstat_fd = -1;
 }
 
-void mdstat_wait(int seconds)
+/*
+ * function: mdstat_wait
+ * Description: Function waits for event on mdstat.
+ * Parameters:
+ *             seconds - timeout for waiting
+ * Returns:
+ *             > 0 - detected event
+ *             0 - timeout
+ *             < 0 - detected error
+ */
+int mdstat_wait(int seconds)
 {
        fd_set fds;
        struct timeval tm;
@@ -312,10 +321,13 @@ void mdstat_wait(int seconds)
        if (mdstat_fd >= 0) {
                FD_SET(mdstat_fd, &fds);
                maxfd = mdstat_fd;
-       }
+       } else
+               return -1;
+
        tm.tv_sec = seconds;
        tm.tv_usec = 0;
-       select(maxfd + 1, NULL, NULL, &fds, &tm);
+
+       return select(maxfd + 1, NULL, NULL, &fds, &tm);
 }
 
 void mdstat_wait_fd(int fd, const sigset_t *sigmask)