diff options
author | Neil Brown <neilb@suse.de> | 2006-12-14 07:31:22 +0100 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2006-12-14 07:31:22 +0100 |
commit | b90c0e9a12090c435f23da8378b3436c93f77f2f (patch) | |
tree | 221aa0ad769db836533999ef8fd2003e90904066 /Monitor.c | |
parent | Change 'Device Size' to 'Used Dev Size' (diff) | |
download | mdadm-b90c0e9a12090c435f23da8378b3436c93f77f2f.tar.xz mdadm-b90c0e9a12090c435f23da8378b3436c93f77f2f.zip |
--wait or -W will wait for resync activity to finish on the given devices.
Diffstat (limited to 'Monitor.c')
-rw-r--r-- | Monitor.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -553,3 +553,38 @@ static void alert(char *event, char *dev, char *disc, char *mailaddr, char *mail syslog(priority, "%s event detected on md device %s", event, dev); } } + +/* Not really Monitor but ... */ +int Wait(char *dev) +{ + struct stat stb; + int devnum; + int rv = 1; + + if (stat(dev, &stb) != 0) { + fprintf(stderr, Name ": Cannot find %s: %s\n", dev, + strerror(errno)); + return 2; + } + if (major(stb.st_rdev) == MD_MAJOR) + devnum = minor(stb.st_rdev); + else + devnum = -minor(stb.st_rdev)/16; + + while(1) { + struct mdstat_ent *ms = mdstat_read(1, 0); + struct mdstat_ent *e; + + for (e=ms ; e; e=e->next) + if (e->devnum == devnum) + break; + + if (!e || e->percent < 0) { + free_mdstat(ms); + return rv; + } + free(ms); + rv = 0; + mdstat_wait(5); + } +} |