diff options
| -rw-r--r-- | com32/modules/linux.c | 41 | ||||
| -rw-r--r-- | core/fs/btrfs/btrfs.c | 5 | ||||
| -rw-r--r-- | utils/Makefile | 2 |
3 files changed, 39 insertions, 9 deletions
diff --git a/com32/modules/linux.c b/com32/modules/linux.c index a5ce01f2..8784ded1 100644 --- a/com32/modules/linux.c +++ b/com32/modules/linux.c @@ -38,6 +38,7 @@ * Usage: linux.c32 [-dhcpinfo] kernel arguments... */ +#include <errno.h> #include <stdbool.h> #include <stdlib.h> #include <stdio.h> @@ -142,9 +143,12 @@ int main(int argc, char *argv[]) kernel_name = arg; + errno = 0; boot_image = malloc(strlen(kernel_name) + 12); - if (!boot_image) + if (!boot_image) { + fprintf(stderr, "Error allocating BOOT_IMAGE string: "); goto bail; + } strcpy(boot_image, "BOOT_IMAGE="); strcpy(boot_image + 11, kernel_name); /* argp now points to the kernel name, and the command line follows. @@ -157,23 +161,30 @@ int main(int argc, char *argv[]) if (!opt_quiet) printf("Loading %s... ", kernel_name); + errno = 0; if (loadfile(kernel_name, &kernel_data, &kernel_len)) { if (opt_quiet) printf("Loading %s ", kernel_name); - printf("failed!\n"); + printf("failed: "); goto bail; } if (!opt_quiet) printf("ok\n"); + errno = 0; cmdline = make_cmdline(argp); - if (!cmdline) + if (!cmdline) { + fprintf(stderr, "make_cmdline() failed: "); goto bail; + } /* Initialize the initramfs chain */ + errno = 0; initramfs = initramfs_init(); - if (!initramfs) + if (!initramfs) { + fprintf(stderr, "initramfs_init() failed: "); goto bail; + } if ((arg = find_argument(argp, "initrd="))) { do { @@ -183,10 +194,11 @@ int main(int argc, char *argv[]) if (!opt_quiet) printf("Loading %s... ", arg); + errno = 0; if (initramfs_load_archive(initramfs, arg)) { if (opt_quiet) printf("Loading %s ", kernel_name); - printf("failed!\n"); + printf("failed: "); goto bail; } if (!opt_quiet) @@ -200,15 +212,30 @@ int main(int argc, char *argv[]) /* Append the DHCP info */ if (opt_dhcpinfo && !pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) { + errno = 0; if (initramfs_add_file(initramfs, dhcpdata, dhcplen, dhcplen, - "/dhcpinfo.dat", 0, 0755)) + "/dhcpinfo.dat", 0, 0755)) { + fprintf(stderr, "Unable to add DHCP info: "); goto bail; + } } /* This should not return... */ + errno = 0; syslinux_boot_linux(kernel_data, kernel_len, initramfs, cmdline); + fprintf(stderr, "syslinux_boot_linux() failed: "); bail: - fprintf(stderr, "Kernel load failure (insufficient memory?)\n"); + switch(errno) { + case ENOENT: + fprintf(stderr, "File not found\n"); + break; + case ENOMEM: + fprintf(stderr, "Out of memory\n"); + default: + fprintf(stderr, "Error %d\n", errno); + break; + } + fprintf(stderr, "%s: Boot aborted!\n", progname); return 1; } diff --git a/core/fs/btrfs/btrfs.c b/core/fs/btrfs/btrfs.c index 8dedf8ac..16386cc0 100644 --- a/core/fs/btrfs/btrfs.c +++ b/core/fs/btrfs/btrfs.c @@ -602,12 +602,15 @@ static void btrfs_get_fs_tree(struct fs_info *fs) do { do { struct btrfs_root_ref *ref; + int pathlen; if (btrfs_comp_keys_type(&search_key, &path.item.key)) break; ref = (struct btrfs_root_ref *)path.data; - if (!strcmp((char*)(ref + 1), SubvolName)) { + pathlen = path.item.size - sizeof(struct btrfs_root_ref); + + if (!strncmp((char*)(ref + 1), SubvolName, pathlen)) { subvol_ok = true; break; } diff --git a/utils/Makefile b/utils/Makefile index 44cb54fb..be739935 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -51,7 +51,7 @@ isohdpfx.c: $(ISOHDPFX) isohdpfxarray.pl $(PERL) isohdpfxarray.pl $(ISOHDPFX) > $@ isohybrid: isohybrid.o isohdpfx.o - $(CC) $(LDFLAGS) -luuid -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ -luuid gethostip: gethostip.o $(CC) $(LDFLAGS) -o $@ $^ |
