Might help with debugging. No size impact.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
struct stat s;
if (stat(dev, &s)) {
- ERROR("Failed to stat %s\n", dev);
+ ERROR("Failed to stat %s: %m\n", dev);
return;
}
patch_stdio("/dev/null");
execvp(kmod[0], kmod);
- ERROR("Failed to start kmodloader\n");
+ ERROR("Failed to start kmodloader: %m\n");
exit(-1);
}
if (pid <= 0) {
- ERROR("Failed to start kmodloader instance\n");
+ ERROR("Failed to start kmodloader instance: %m\n");
} else {
int i;
if (!fp)
return;
if (fscanf(fp, "%d", &lvl) == EOF)
- ERROR("failed to read debug level\n");
+ ERROR("failed to read debug level: %m\n");
fclose(fp);
unlink("/tmp/debug_level");
plugd_proc.pid = fork();
if (!plugd_proc.pid) {
execvp(plug[0], plug);
- ERROR("Failed to start plugd\n");
+ ERROR("Failed to start plugd: %m\n");
exit(-1);
}
if (plugd_proc.pid <= 0) {
- ERROR("Failed to start new plugd instance\n");
+ ERROR("Failed to start new plugd instance: %m\n");
return;
}
uloop_process_add(&plugd_proc);
fd = creat("/tmp/.preinit", 0600);
if (fd < 0)
- ERROR("Failed to create sentinel file\n");
+ ERROR("Failed to create sentinel file: %m\n");
else
close(fd);
preinit_proc.pid = fork();
if (!preinit_proc.pid) {
execvp(init[0], init);
- ERROR("Failed to start preinit\n");
+ ERROR("Failed to start preinit: %m\n");
exit(-1);
}
if (preinit_proc.pid <= 0) {
- ERROR("Failed to start new preinit instance\n");
+ ERROR("Failed to start new preinit instance: %m\n");
return;
}
uloop_process_add(&preinit_proc);
sprintf(path, module, ver.release);
modprobe[1] = path;
execvp(modprobe[0], modprobe);
- ERROR("Can't exec %s\n", modprobe[0]);
+ ERROR("Can't exec %s: %m\n", modprobe[0]);
exit(-1);
}
if (pid <= 0) {
- ERROR("Can't exec %s\n", modprobe[0]);
+ ERROR("Can't exec %s: %m\n", modprobe[0]);
return -1;
} else {
waitpid(pid, NULL, 0);
pid = fork();
if (!pid) {
execvp(mkfs[0], mkfs);
- ERROR("Can't exec %s\n", mkfs[0]);
+ ERROR("Can't exec %s: %m\n", mkfs[0]);
exit(-1);
} else if (pid <= 0) {
- ERROR("Can't exec %s\n", mkfs[0]);
+ ERROR("Can't exec %s: %m\n", mkfs[0]);
return -1;
} else {
waitpid(pid, NULL, 0);
tcsetpgrp(STDIN_FILENO, p);
execvp(a->argv[0], a->argv);
- ERROR("Failed to execute %s\n", a->argv[0]);
+ ERROR("Failed to execute %s: %m\n", a->argv[0]);
exit(-1);
}
char *line;
if (!fp) {
- ERROR("Failed to open %s\n", tab);
+ ERROR("Failed to open %s: %m\n", tab);
return;
}
map = mmap(NULL, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (map == MAP_FAILED) {
- ERROR("failed to mmap %s\n", path);
+ ERROR("failed to mmap %s: %m\n", path);
ret = -1;
goto out;
}
udevtrigger.pid = fork();
if (!udevtrigger.pid) {
execvp(argv[0], argv);
- ERROR("Failed to start coldplug\n");
+ ERROR("Failed to start coldplug: %m\n");
exit(-1);
}
if (udevtrigger.pid <= 0) {
- ERROR("Failed to start new coldplug instance\n");
+ ERROR("Failed to start new coldplug instance: %m\n");
return;
}
sprintf(path, "%s/%s", dir, file);
if (stat(path, &s)) {
- ERROR("Could not find firmware %s\n", path);
+ ERROR("Could not find firmware %s: %m\n", path);
src = -1;
s.st_size = 0;
goto send_to_kernel;
src = open(path, O_RDONLY);
if (src < 0) {
- ERROR("Failed to open %s\n", path);
+ ERROR("Failed to open %s: %m\n", path);
s.st_size = 0;
goto send_to_kernel;
}
snprintf(loadpath, sizeof(loadpath), "/sys/%s/loading", dev);
load = open(loadpath, O_WRONLY);
if (!load) {
- ERROR("Failed to open %s\n", loadpath);
+ ERROR("Failed to open %s: %m\n", loadpath);
exit(-1);
}
if (write(load, "1", 1) == -1) {
- ERROR("Failed to write to %s\n", loadpath);
+ ERROR("Failed to write to %s: %m\n", loadpath);
exit(-1);
}
close(load);
snprintf(syspath, sizeof(syspath), "/sys/%s/data", dev);
fw = open(syspath, O_WRONLY);
if (fw < 0) {
- ERROR("Failed to open %s\n", syspath);
+ ERROR("Failed to open %s: %m\n", syspath);
exit(-1);
}
break;
if (write(fw, buf, len) == -1) {
- ERROR("failed to write firmware file %s/%s to %s\n", dir, file, dev);
+ ERROR("failed to write firmware file %s/%s to %s: %m\n", dir, file, dev);
break;
}
}
load = open(loadpath, O_WRONLY);
if (write(load, "0", 1) == -1)
- ERROR("failed to write to %s\n", loadpath);
+ ERROR("failed to write to %s: %m\n", loadpath);
close(load);
DEBUG(2, "Done loading %s\n", path);
DEBUG(2, "start %s %s \n", s->file, s->param);
if (pipe(pipefd) == -1) {
- ERROR("Failed to create pipe\n");
+ ERROR("Failed to create pipe: %m\n");
return;
}
if (!in->pidfile)
return 0;
if (unlink(in->pidfile)) {
- ERROR("Failed to removed pidfile: %s: %m\n",
- in->pidfile);
+ ERROR("Failed to removed pidfile: %s: %m\n", in->pidfile);
return 1;
}
return 0;
}
_pidfile = fopen(in->pidfile, "w");
if (_pidfile == NULL) {
- ERROR("failed to open pidfile for writing: %s: %m",
- in->pidfile);
+ ERROR("failed to open pidfile for writing: %s: %m", in->pidfile);
return 1;
}
if (fprintf(_pidfile, "%d\n", in->proc.pid) < 0) {
- ERROR("failed to write pidfile: %s: %m",
- in->pidfile);
+ ERROR("failed to write pidfile: %s: %m", in->pidfile);
fclose(_pidfile);
return 2;
}
if (fclose(_pidfile)) {
- ERROR("failed to close pidfile: %s: %m",
- in->pidfile);
+ ERROR("failed to close pidfile: %s: %m", in->pidfile);
return 3;
}
!freopen(tty, "w", stdout) ||
!freopen(tty, "w", stderr) ||
chdir("/"))
- ERROR("failed to set stdio\n");
+ ERROR("failed to set stdio: %m\n");
else
fcntl(STDERR_FILENO, F_SETFL, fcntl(STDERR_FILENO, F_GETFL) | O_NONBLOCK);
}
}
if (chdir("/dev")) {
- ERROR("failed to change dir to /dev\n");
+ ERROR("failed to change dir to /dev: %m\n");
return;
}
while (tty!=NULL) {
i++;
}
if (chdir("/"))
- ERROR("failed to change dir to /\n");
+ ERROR("failed to change dir to /: %m\n");
if (tty != NULL)
set_stdio(tty);