]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
add sysfs_array_state to struct mdinfo
authorSong Liu <songliubraving@fb.com>
Tue, 15 Dec 2015 01:43:42 +0000 (17:43 -0800)
committerNeilBrown <neilb@suse.com>
Wed, 16 Dec 2015 01:43:45 +0000 (12:43 +1100)
Add sysfs_array_state to struct mdinfo, and add GET_ARRAY_STATE to
options of sysfs_read.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: NeilBrown <neilb@suse.com>
mdadm.h
sysfs.c

diff --git a/mdadm.h b/mdadm.h
index 840a3597ad9f4fd598cea61654d12d96e7bbafaf..21fe7894cbe4ad3f45807742e5d9b307386461a6 100755 (executable)
--- a/mdadm.h
+++ b/mdadm.h
@@ -305,6 +305,9 @@ struct mdinfo {
        #define DS_REMOVE       1024
        #define DS_UNBLOCK      2048
        int prev_state, curr_state, next_state;
+
+       /* info read from sysfs */
+       char            sysfs_array_state[20];
 };
 
 struct createinfo {
@@ -588,6 +591,7 @@ enum sysfs_read_flags {
        GET_SIZE        = (1 << 22),
        GET_STATE       = (1 << 23),
        GET_ERROR       = (1 << 24),
+       GET_ARRAY_STATE = (1 << 25),
 };
 
 /* If fd >= 0, get the array it is open on,
diff --git a/sysfs.c b/sysfs.c
index f1fd610bf5875fb6a669e942c60aaf3690176baf..260034327e3ae852f0683722b052d102b6bb460e 100644 (file)
--- a/sysfs.c
+++ b/sysfs.c
@@ -230,6 +230,13 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
                        goto abort;
        }
 
+       if (options & GET_ARRAY_STATE) {
+               strcpy(base, "array_state");
+               if (load_sys(fname, sra->sysfs_array_state))
+                       goto abort;
+       } else
+               sra->sysfs_array_state[0] = 0;
+
        if (! (options & GET_DEVS))
                return sra;