int Monitor(mddev_dev_t devlist,
char *mailaddr, char *alert_cmd,
int period, int daemonise, int scan, int oneshot,
- char *config, int test)
+ char *config, int test, char* pidfile)
{
/*
* Every few seconds, scan every md device looking for changes
if (daemonise) {
int pid = fork();
if (pid > 0) {
- printf("%d\n", pid);
+ if (!pidfile)
+ printf("%d\n", pid);
+ else {
+ FILE *pid_file;
+ pid_file=fopen(pidfile, "w");
+ if (!pid_file)
+ perror("cannot create pid file");
+ else {
+ fprintf(pid_file,"%d\n", pid);
+ fclose(pid_file);
+ }
+ }
return 0;
}
if (pid < 0) {
} else {
mddev_dev_t dv;
for (dv=devlist ; dv; dv=dv->next) {
+ mddev_ident_t mdlist = conf_get_ident(config, dv->devname);
struct state *st = malloc(sizeof *st);
if (st == NULL)
continue;
st->percent = -2;
st->expected_spares = -1;
st->spare_group = NULL;
+ if (mdlist) {
+ st->expected_spares = mdlist->spare_disks;
+ if (mdlist->spare_group)
+ st->spare_group = strdup(mdlist->spare_group);
+ }
statelist = st;
}
}
close(fd);
continue;
}
- if (array.level != 1 && array.level != 5 && array.level != -4) {
+ if (array.level != 1 && array.level != 5 && array.level != -4 &&
+ array.level != 6 && array.level != 10) {
if (!st->err)
alert("DeviceDisappeared", dev, "Wrong-Level",
mailaddr, alert_cmd);
struct stat stb;
if (fstat(fd, &stb) == 0 &&
(S_IFMT&stb.st_mode)==S_IFBLK) {
- if (MAJOR(stb.st_rdev) == MD_MAJOR)
- st->devnum = MINOR(stb.st_rdev);
+ if (major(stb.st_rdev) == MD_MAJOR)
+ st->devnum = minor(stb.st_rdev);
else
- st->devnum = -1- (MINOR(stb.st_rdev)>>6);
+ st->devnum = -1- (minor(stb.st_rdev)>>6);
}
}
alert("Fail", dev, dv, mailaddr, alert_cmd);
else if (i >= (unsigned)array.raid_disks &&
(disc.major || disc.minor) &&
- st->devid[i] == MKDEV(disc.major, disc.minor) &&
+ st->devid[i] == makedev(disc.major, disc.minor) &&
((newstate&change)&(1<<MD_DISK_FAULTY))
)
alert("FailSpare", dev, dv, mailaddr, alert_cmd);
alert("SpareActive", dev, dv, mailaddr, alert_cmd);
}
st->devstate[i] = disc.state;
- st->devid[i] = MKDEV(disc.major, disc.minor);
+ st->devid[i] = makedev(disc.major, disc.minor);
}
close(fd);
st->active = array.active_disks;
}
test = 0;
}
+ if (pidfile)
+ unlink(pidfile);
return 0;
}