File petitboot.mount-all-needed-blockdevs.patch of Package petitboot
---
lib/petitboot-kexec.c | 10 ++++++++++
lib/petitboot-mount.c | 7 +++++++
lib/petitboot-paths.c | 24 ++++++++++++++++++++++++
lib/petitboot.h | 1 +
4 files changed, 42 insertions(+)
--- a/lib/petitboot-mount.c
+++ b/lib/petitboot-mount.c
@@ -136,6 +136,9 @@ int pb_mount_device(const char *devname)
char *argv[8];
char *dir;
+ if (devname == NULL) {
+ return 1;
+ }
dir = pb_mount_device_path(devname);
argv[0] = MOUNT_BIN;
@@ -154,6 +157,7 @@ int pb_mount_device(const char *devname)
// try to mount as readonly vfat so it doesn't auto mount as msdos
if (pb_fexec(argv[0], argv, MOUNT_TIMEOUT)) {
+ pb_log("mounting as vfat failed, try again without \"-t vfat\"\n");
argv[5] = NULL;
// try to auto mount as readonly
if (pb_fexec(argv[0], argv, MOUNT_TIMEOUT)) {
@@ -198,6 +202,9 @@ char *pb_mount_device_path(const char *d
{
int i;
+ if (devname == NULL) {
+ return NULL;
+ }
if (!strncmp(devname, "/dev/", 5))
devname += 5;
--- a/lib/petitboot-kexec.c
+++ b/lib/petitboot-kexec.c
@@ -168,6 +168,7 @@ int pb_kexec(const char *devname, const
char *kernel_file;
char *initrd_file;
char *kexec_opts[6];
+ char *dev_tmp;
int i, nr_opts = 2;
int ret = 0;
@@ -193,6 +194,15 @@ int pb_kexec(const char *devname, const
if (pb_mount_device(devname))
pb_log("failed to mount %s\n", devname);
+ /*
+ * mount devices that hold kernel and initrd they might differ
+ * from devname supplied to pb_kexec
+ */
+ if (dev_tmp = pb_parse_device_name(kernel))
+ pb_mount_device(dev_tmp);
+ if (dev_tmp = pb_parse_device_name(initrd))
+ pb_mount_device(dev_tmp);
+
if (command_line && *command_line) {
kexec_opts[nr_opts] = malloc(strlen("--command_line=") +
strlen(command_line) + 1);
--- a/lib/petitboot-paths.c
+++ b/lib/petitboot-paths.c
@@ -200,3 +200,27 @@ char *pb_parse_device_path(const char *d
return pb_join_paths("/dev", dev_str);
}
+
+/*
+ * extract the block device part from string
+ * example:
+ * /dev/ps3da1:/boot/vmlinux returns /dev/ps3da1
+ */
+char *pb_parse_device_name(const char *path)
+{
+ char *ret;
+ const char *devpath, *sep;
+
+ if (!path)
+ return NULL;
+
+ sep = strchr(path, ':');
+ if (!sep) {
+ /* no valid path */
+ ret = NULL;
+ } else {
+ devpath = strndup(path, sep - path);
+ ret = devpath;
+ }
+ return ret;
+}
--- a/lib/petitboot.h
+++ b/lib/petitboot.h
@@ -136,6 +136,7 @@ int pb_rmdir_recursive(const char *dir);
char *pb_join_paths(const char *a, const char *b);
char *pb_resolve_path(const char *path, const char *current_device);
char *pb_parse_device_path(const char *dev_str, const char *current_device);
+char *pb_parse_device_name(const char *path);
char *pb_encode_label(const char *label);
#endif //_PETITBOOT_H