*/
flock(inst->lock, LOCK_UN);
close(inst->lock);
+
+ inst->lock = -1;
}
}
struct fsck_instance *inst, *p;
pid_t pid;
- inst = xmalloc(sizeof(struct fsck_instance));
- memset(inst, 0, sizeof(struct fsck_instance));
+ inst = xcalloc(1, sizeof(*inst));
sprintf(prog, "fsck.%s", type);
argv[0] = xstrdup(prog);
if (noexecute)
pid = -1;
else if ((pid = fork()) < 0) {
- perror("fork");
+ warn(_("fork failed"));
free(inst);
return errno;
} else if (pid == 0) {
if (!interactive)
close(0);
- (void) execv(s, argv);
- perror(argv[0]);
- free(inst);
- exit(FSCK_EX_ERROR);
+ execv(s, argv);
+ err(FSCK_EX_ERROR, _("%s: execute failed"), s);
}
for (i=0; i < argc; i++)
warnx(_("wait: no more child process?!?"));
return NULL;
}
- perror("wait");
+ warn(_("waidpid failed"));
continue;
}
for (prev = 0, inst = instance_list;
}
}
- cmp->list = xmalloc(num * sizeof(char *));
- cmp->type = xmalloc(num * sizeof(int));
- memset(cmp->list, 0, num * sizeof(char *));
- memset(cmp->type, 0, num * sizeof(int));
+ cmp->list = xcalloc(num, sizeof(char *));
+ cmp->type = xcalloc(num, sizeof(int));
cmp->negate = 0;
if (!fs_type)
"with 'no' or '!'."));
}
}
-#if 0
- printf("Adding %s to list (type %d).\n", s, cmp->type[num]);
-#endif
+
cmp->list[num++] = xstrdup(s);
s = strtok(NULL, ",");
}
if (stat(device, &st) == -1)
return 0;
-
if (!S_ISBLK(st.st_mode))
return 0;
-
return 1;
}
count++;
}
+
closedir(dir);
return count;
}
if (!idisk || disk == idisk)
return 1;
}
+
return 0;
}