info.mailfrom = mailfrom;
info.dosyslog = dosyslog;
- if (daemonise)
- if (make_daemon(pidfile))
- return 1;
+ if (daemonise) {
+ int rv = make_daemon(pidfile);
+ if (rv >= 0)
+ return rv;
+ }
if (share)
if (check_one_sharer(scan))
static int make_daemon(char *pidfile)
{
+ /* Return:
+ * -1 in the forked daemon
+ * 0 in the parent
+ * 1 on error
+ * so a none-negative becomes the exit code.
+ */
int pid = fork();
if (pid > 0) {
if (!pidfile)
dup2(0,1);
dup2(0,2);
setsid();
- return 0;
+ return -1;
}
static int check_one_sharer(int scan)
sprintf(devname, "%d:%d", major(devid), minor(devid));
devlist.disposition = 'r';
- if (Manage_subdevs(from->devname, fd2, &devlist, -1, 0) == 0) {
+ if (Manage_subdevs(from->devname, fd2, &devlist, -1, 0, NULL) == 0) {
devlist.disposition = 'a';
- if (Manage_subdevs(to->devname, fd1, &devlist, -1, 0) == 0) {
+ if (Manage_subdevs(to->devname, fd1, &devlist, -1, 0, NULL) == 0) {
alert("MoveSpare", to->devname, from->devname, info);
/* make sure we will see newly added spare before next
* time through loop
close(fd2);
return 1;
}
- else Manage_subdevs(from->devname, fd2, &devlist, -1, 0);
+ else Manage_subdevs(from->devname, fd2, &devlist, -1, 0, NULL);
}
close(fd1);
close(fd2);
return 0;
}
-static int check_donor(struct state *from, struct state *to,
- struct domainlist *domlist)
+static int check_donor(struct state *from, struct state *to)
{
struct state *sub;
return 0;
if (from->spare <= 0)
return 0;
- if (domlist == NULL)
- return 0;
return 1;
}
to->metadata->ss->name);
if (to->spare_group)
domain_add(&domlist, to->spare_group);
-
+ /*
+ * No spare migration if the destination
+ * has no domain. Skip this array.
+ */
+ if (!domlist)
+ continue;
for (from=statelist ; from ; from=from->next) {
dev_t devid;
- if (!check_donor(from, to, domlist))
+ if (!check_donor(from, to))
continue;
if (from->metadata->ss->external)
devid = container_choose_spare(