struct state {
char *devname;
char devnm[32]; /* to sync with mdstat info */
- long utime;
+ unsigned int utime;
int err;
char *spare_group;
int active, working, failed, spare, raid;
if (mdstat)
free_mdstat(mdstat);
mdstat = mdstat_read(oneshot?0:1, 0);
+ if (!mdstat)
+ mdstat_close();
for (st=statelist; st; st=st->next)
if (check_array(st, mdstat, c->test, &info,
} else
alert("RebuildFinished", dev, NULL, ainfo);
if (sra)
- free(sra);
+ sysfs_free(sra);
}
st->percent = mse->percent;
{
struct mdstat_ent *mse;
int new_found = 0;
+ char *name;
for (mse=mdstat; mse; mse=mse->next)
if (mse->devnm[0] &&
struct state *st = xcalloc(1, sizeof *st);
mdu_array_info_t array;
int fd;
- st->devname = xstrdup(get_md_name(mse->devnm));
+
+ name = get_md_name(mse->devnm);
+ if (!name) {
+ free(st);
+ continue;
+ }
+
+ st->devname = xstrdup(name);
if ((fd = open(st->devname, O_RDONLY)) < 0 ||
ioctl(fd, GET_ARRAY_INFO, &array)< 0) {
/* no such array */
{
struct stat stb;
char devnm[32];
+ char *tmp;
int rv = 1;
+ int frozen_remaining = 3;
if (stat(dev, &stb) != 0) {
pr_err("Cannot find %s: %s\n", dev,
strerror(errno));
return 2;
}
- strcpy(devnm, stat2devnm(&stb));
+ tmp = stat2devnm(&stb);
+ if (!tmp) {
+ pr_err("%s is not a block device.\n", dev);
+ return 2;
+ }
+ strcpy(devnm, tmp);
while(1) {
struct mdstat_ent *ms = mdstat_read(1, 0);
if (strcmp(e->devnm, devnm) == 0)
break;
- if (e->percent == RESYNC_NONE) {
+ if (e && e->percent == RESYNC_NONE) {
/* We could be in the brief pause before something
* starts. /proc/mdstat doesn't show that, but
* sync_action does.
sysfs_init(&mdi, -1, devnm);
if (sysfs_get_str(&mdi, NULL, "sync_action",
buf, 20) > 0 &&
- strcmp(buf,"idle\n") != 0)
+ strcmp(buf,"idle\n") != 0) {
e->percent = RESYNC_UNKNOWN;
+ if (strcmp(buf, "frozen\n") == 0) {
+ if (frozen_remaining == 0)
+ e->percent = RESYNC_NONE;
+ else
+ frozen_remaining -= 1;
+ }
+ }
}
if (!e || e->percent == RESYNC_NONE) {
if (e && e->metadata_version &&