return -1;
}
- fgets(uuid, sizeof(uuid), fp);
+ if (!fgets(uuid, sizeof(uuid), fp))
+ ULOG_ERR("extroot: failed to read UUID from %s: %d (%s)\n",
+ tag, errno, strerror(errno));
fclose(fp);
- if (!strcasecmp(uuid, pr->uuid))
+ if (*uuid || !strcasecmp(uuid, pr->uuid))
return 0;
ULOG_ERR("extroot: UUID mismatch (root: %s, %s: %s)\n",
ULOG_ERR("failed to open /proc/swaps\n");
return -1;
}
- fgets(line, sizeof(line), fp);
- while (fgets(line, sizeof(line), fp)) {
- char *end = strchr(line, ' ');
- int err;
+ if (fgets(line, sizeof(line), fp))
+ while (fgets(line, sizeof(line), fp)) {
+ char *end = strchr(line, ' ');
+ int err;
- if (!end)
- continue;
- *end = '\0';
- err = swapoff(line);
- if (err)
- ULOG_ERR("failed to swapoff %s (%d)\n", line, err);
- }
+ if (!end)
+ continue;
+ *end = '\0';
+ err = swapoff(line);
+ if (err)
+ ULOG_ERR("failed to swapoff %s (%d)\n", line, err);
+ }
fclose(fp);
} else {
struct stat s;
char magic[32] = { 0 };
lseek(pr->fd, off, SEEK_SET);
- read(pr->fd, magic, mag->len);
+ if (read(pr->fd, magic, mag->len) < 0)
+ return -1;
DEBUG("magic: %s %s %d\n", mag->magic, magic, mag->len);
if (!memcmp(mag->magic, magic, mag->len))
mode = 0600;
find_devs(true);
- chdir("/");
- return 0;
+ return chdir("/");
}
setenv("LD_LIBRARY_PATH", ldlib_path, 1);
snprintf(kmod_loader, sizeof(kmod_loader),
"/sbin/kmodloader %s/etc/modules-boot.d/", dirname(ldlib_path));
- system(kmod_loader);
+ if (system(kmod_loader))
+ ULOG_ERR("failed to launch kmodloader from internal overlay\n");
}
pid = fork();
return -1;
}
- system("cp -a /tmp/root/* /rom/overlay"); /**/
+ if (system("cp -a /tmp/root/* /rom/overlay")) {
+ ULOG_ERR("failed - cp -a /tmp/root/* /rom/overlay: %s\n", strerror(errno));
+ return -1;
+ }
if (pivot("/rom", "/mnt")) {
ULOG_ERR("failed - pivot /rom /mnt: %s\n", strerror(errno));
snapshot_sync(v);
setenv("SNAPSHOT", "magic", 1);
_ramoverlay("/rom", "/overlay");
- system("/sbin/snapshot unpack");
+ if (system("/sbin/snapshot unpack") == -1) {
+ perror("system");
+ return -1;
+ }
foreachdir("/overlay/", handle_whiteout);
mkdir("/volatile", 0700);
_ramoverlay("/rom", "/volatile");
mount_move("/rom/volatile", "/volatile", "");
mount_move("/rom/rom", "/rom", "");
- system("/sbin/snapshot config_unpack");
+ if (system("/sbin/snapshot config_unpack")) {
+ perror("system");
+ return -1;
+ }
foreachdir("/volatile/", handle_whiteout);
unsetenv("SNAPSHOT");
return -1;