Author: tsoome Date: Wed Aug 22 10:04:42 2018 New Revision: 338188 URL: https://svnweb.freebsd.org/changeset/base/338188
Log: loader: bios loader should allow to chain load a file The current chain command does accept only device, allow also a file to be used, such as /boot/pmbr or /boot/mbr (or stored third party MBR/VBR block). Also fix file descriptor leak. Modified: head/stand/i386/loader/chain.c Modified: head/stand/i386/loader/chain.c ============================================================================== --- head/stand/i386/loader/chain.c Wed Aug 22 09:49:38 2018 (r338187) +++ head/stand/i386/loader/chain.c Wed Aug 22 10:04:42 2018 (r338188) @@ -92,24 +92,26 @@ command_chain(int argc, char *argv[]) i386_getdev((void **)(&rootdev), argv[1], NULL); if (rootdev == NULL) { command_errmsg = "can't determine root device"; + close(fd); return (CMD_ERROR); } - if (archsw.arch_readin(fd, mem, SECTOR_SIZE) != SECTOR_SIZE) { + if (archsw.arch_readin(fd, mem, size) != size) { command_errmsg = "failed to read disk"; close(fd); return (CMD_ERROR); } close(fd); - if (*((uint16_t *)PTOV(mem + DOSMAGICOFFSET)) != DOSMAGIC) { + if (argv[1][len-1] == ':' && + *((uint16_t *)PTOV(mem + DOSMAGICOFFSET)) != DOSMAGIC) { command_errmsg = "wrong magic"; return (CMD_ERROR); } relocater_data[0].src = mem; relocater_data[0].dest = 0x7C00; - relocater_data[0].size = SECTOR_SIZE; + relocater_data[0].size = size; relocator_edx = bd_unit2bios(rootdev->dd.d_unit); relocator_esi = relocater_size; _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"