From: Matthew Dillon Date: Tue, 2 Sep 2008 17:21:18 +0000 (+0000) Subject: Adjust the boot code to boot from either a root with a /boot, or directly X-Git-Tag: v2.1.1~515 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/79dc5fc68b82cbd37e951d5ef3f85d92c32e70ae Adjust the boot code to boot from either a root with a /boot, or directly from a /boot partition (which will look like '/' to the loader). These changes allow you to make your 'a' partition a /boot only partition. Your /boot/loader.conf would then have a directive to tell the kernel where the root partition is, e.g.: vfs.root.mountfrom="hammer:${disk}s1d" * Add a chdir() hack and rel_open() that uses the chdir base. * chdir("/boot")... if it exists. * Change all config and most other paths to be relative * boot2 does not have access to the chdir() hack. Adjust boot2 to look for the loader as both "/loader" and "/boot/loader". --- diff --git a/sys/boot/common/Makefile.inc b/sys/boot/common/Makefile.inc index 2a65716fa3..fae6a38dd5 100644 --- a/sys/boot/common/Makefile.inc +++ b/sys/boot/common/Makefile.inc @@ -1,9 +1,9 @@ # $FreeBSD: src/sys/boot/common/Makefile.inc,v 1.16 2003/06/26 03:51:57 peter Exp $ -# $DragonFly: src/sys/boot/common/Makefile.inc,v 1.4 2005/02/20 16:30:39 swildner Exp $ +# $DragonFly: src/sys/boot/common/Makefile.inc,v 1.5 2008/09/02 17:21:12 dillon Exp $ SRCS+= bcache.c boot.c commands.c console.c devopen.c interp.c SRCS+= interp_backslash.c interp_parse.c ls.c misc.c -SRCS+= module.c panic.c +SRCS+= module.c panic.c rel_open.c .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" SRCS+= load_elf32.c load_elf64.c diff --git a/sys/boot/common/bootstrap.h b/sys/boot/common/bootstrap.h index fb76bb3183..fac6efb72b 100644 --- a/sys/boot/common/bootstrap.h +++ b/sys/boot/common/bootstrap.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/boot/common/bootstrap.h,v 1.38 2003/05/01 03:56:29 peter Exp $ - * $DragonFly: src/sys/boot/common/bootstrap.h,v 1.3 2003/11/10 06:08:31 dillon Exp $ + * $DragonFly: src/sys/boot/common/bootstrap.h,v 1.4 2008/09/02 17:21:12 dillon Exp $ */ #include @@ -71,6 +71,8 @@ int bf_run(char *line); int autoboot(int timeout, char *prompt); void autoboot_maybe(void); int getrootmount(char *rootdev); +int rel_open(const char *path, int flags); +int chdir(const char *path); /* misc.c */ char *unargv(int argc, char *argv[]); diff --git a/sys/boot/common/commands.c b/sys/boot/common/commands.c index 68ac31bb6a..60335f7b8e 100644 --- a/sys/boot/common/commands.c +++ b/sys/boot/common/commands.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/boot/common/commands.c,v 1.19 2003/08/25 23:30:41 obrien Exp $ - * $DragonFly: src/sys/boot/common/commands.c,v 1.3 2003/11/10 06:08:31 dillon Exp $ + * $DragonFly: src/sys/boot/common/commands.c,v 1.4 2008/09/02 17:21:12 dillon Exp $ */ #include @@ -131,8 +131,8 @@ command_help(int argc, char *argv[]) char *topic, *subtopic, *t, *s, *d; /* page the help text from our load path */ - sprintf(buf, "%s/boot/loader.help", getenv("loaddev")); - if ((hfd = open(buf, O_RDONLY)) < 0) { + /* sprintf(buf, "%s/boot/loader.help", getenv("loaddev")); */ + if ((hfd = rel_open("loader.help", O_RDONLY)) < 0) { printf("Verbose help not available, use '?' to list commands\n"); return(CMD_OK); } diff --git a/sys/boot/common/interp.c b/sys/boot/common/interp.c index 7d72ae0d63..caa4d43812 100644 --- a/sys/boot/common/interp.c +++ b/sys/boot/common/interp.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/boot/common/interp.c,v 1.29 2003/08/25 23:30:41 obrien Exp $ - * $DragonFly: src/sys/boot/common/interp.c,v 1.3 2003/11/10 06:08:31 dillon Exp $ + * $DragonFly: src/sys/boot/common/interp.c,v 1.4 2008/09/02 17:21:12 dillon Exp $ */ /* @@ -102,11 +102,19 @@ interact(void) bf_init(); #endif + /* + * We may be booting from the boot partition, or we may be booting + * from the root partition with a /boot sub-directory. If the latter + * chdir into /boot. Ignore any error. Only rel_open() uses the chdir + * info. + */ + chdir("/boot"); + /* * Read our default configuration */ - if(include("/boot/loader.rc")!=CMD_OK) - include("/boot/boot.conf"); + if(include("loader.rc")!=CMD_OK) + include("boot.conf"); printf("\n"); /* * Before interacting, we might want to autoboot. @@ -203,7 +211,7 @@ include(const char *filename) int fd, flags, line; #endif - if (((fd = open(filename, O_RDONLY)) == -1)) { + if (((fd = rel_open(filename, O_RDONLY)) == -1)) { sprintf(command_errbuf,"can't open '%s': %s\n", filename, strerror(errno)); return(CMD_ERROR); } diff --git a/sys/boot/common/interp_forth.c b/sys/boot/common/interp_forth.c index fcf29f41af..d0efaaf543 100644 --- a/sys/boot/common/interp_forth.c +++ b/sys/boot/common/interp_forth.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/boot/common/interp_forth.c,v 1.23 2003/08/25 23:30:41 obrien Exp $ - * $DragonFly: src/sys/boot/common/interp_forth.c,v 1.4 2004/01/25 22:50:20 drhodus Exp $ + * $DragonFly: src/sys/boot/common/interp_forth.c,v 1.5 2008/09/02 17:21:12 dillon Exp $ */ #include /* to pick up __DragonFly_version */ @@ -259,7 +259,7 @@ bf_init(void) (bootprog_rev[0] - '0') * 10 + (bootprog_rev[2] - '0')); /* try to load and run init file if present */ - if ((fd = open("/boot/boot.4th", O_RDONLY)) != -1) { + if ((fd = rel_open("boot.4th", O_RDONLY)) != -1) { (void)ficlExecFD(bf_vm, fd); close(fd); } diff --git a/sys/boot/common/load.c b/sys/boot/common/load.c index 9646ef5742..dd4cd66ee7 100644 --- a/sys/boot/common/load.c +++ b/sys/boot/common/load.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/boot/common/load.c,v 1.3 2003/08/25 23:30:41 obrien Exp $ - * $DragonFly: src/sys/boot/common/load.c,v 1.3 2003/11/10 06:08:31 dillon Exp $ + * $DragonFly: src/sys/boot/common/load.c,v 1.4 2008/09/02 17:21:12 dillon Exp $ */ #include @@ -45,7 +45,7 @@ filedup(const char *path, int flags) int fd; size_t size, result; - if ((fd = open(path, F_READ | flags)) == -1) + if ((fd = rel_open(path, F_READ | flags)) == -1) return(NULL); printf("%s open, flags 0x%x\n", path, files[fd].f_flags); @@ -87,7 +87,7 @@ filedup(const char *path, int flags) close(fd); /* reopen the file, realloc the buffer */ - if ((fd = open(path, F_READ | flags)) == -1) + if ((fd = rel_open(path, F_READ | flags)) == -1) return(NULL); buf = alloc(size); result = read(fd, buf, size); diff --git a/sys/boot/common/load_elf.c b/sys/boot/common/load_elf.c index f7dcc35534..5b12262ddf 100644 --- a/sys/boot/common/load_elf.c +++ b/sys/boot/common/load_elf.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/boot/common/load_elf.c,v 1.29 2003/08/25 23:30:41 obrien Exp $ - * $DragonFly: src/sys/boot/common/load_elf.c,v 1.6 2007/11/25 18:10:07 swildner Exp $ + * $DragonFly: src/sys/boot/common/load_elf.c,v 1.7 2008/09/02 17:21:12 dillon Exp $ */ #include @@ -104,7 +104,7 @@ __elfN(loadfile)(char *filename, u_int64_t dest, struct preloaded_file **result) */ if (filename == NULL) /* can't handle nameless */ return(EFTYPE); - if ((ef.fd = open(filename, O_RDONLY)) == -1) + if ((ef.fd = rel_open(filename, O_RDONLY)) == -1) return(errno); ef.firstpage = malloc(PAGE_SIZE); if (ef.firstpage == NULL) { diff --git a/sys/boot/common/ls.c b/sys/boot/common/ls.c index ca0eac3efc..d06b2faaa2 100644 --- a/sys/boot/common/ls.c +++ b/sys/boot/common/ls.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/boot/common/ls.c,v 1.11 2003/08/25 23:30:41 obrien Exp $ - * $DragonFly: src/sys/boot/common/ls.c,v 1.4 2003/11/10 06:08:31 dillon Exp $ + * $DragonFly: src/sys/boot/common/ls.c,v 1.5 2008/09/02 17:21:12 dillon Exp $ */ #include @@ -158,7 +158,7 @@ ls_getdir(char **pathp) if (*cp == 0) strcat(path, "/"); - fd = open(path, O_RDONLY); + fd = rel_open(path, O_RDONLY); if (fd < 0) { sprintf(command_errbuf, "open '%s' failed: %s", path, strerror(errno)); goto out; diff --git a/sys/boot/common/module.c b/sys/boot/common/module.c index 1446408f02..8c7bd2db96 100644 --- a/sys/boot/common/module.c +++ b/sys/boot/common/module.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/boot/common/module.c,v 1.25 2003/08/25 23:30:41 obrien Exp $ - * $DragonFly: src/sys/boot/common/module.c,v 1.5 2008/09/01 19:39:45 dillon Exp $ + * $DragonFly: src/sys/boot/common/module.c,v 1.6 2008/09/02 17:21:12 dillon Exp $ */ /* @@ -327,7 +327,7 @@ file_loadraw(char *type, char *name) } name = cp; - if ((fd = open(name, O_RDONLY)) < 0) { + if ((fd = rel_open(name, O_RDONLY)) < 0) { sprintf(command_errbuf, "can't open '%s': %s", name, strerror(errno)); free(name); return(CMD_ERROR); @@ -865,7 +865,7 @@ moduledir_readhints(struct moduledir *mdp) return; path = moduledir_fullpath(mdp, "linker.hints"); if (stat(path, &st) != 0 || st.st_size < (sizeof(version) + sizeof(int)) || - st.st_size > 100 * 1024 || (fd = open(path, O_RDONLY)) < 0) { + st.st_size > 100 * 1024 || (fd = rel_open(path, O_RDONLY)) < 0) { free(path); mdp->d_flags |= MDIR_NOHINTS; return; diff --git a/sys/boot/common/pnp.c b/sys/boot/common/pnp.c index b69b4adef3..9a2def8b34 100644 --- a/sys/boot/common/pnp.c +++ b/sys/boot/common/pnp.c @@ -2,7 +2,7 @@ * mjs copyright * * $FreeBSD: src/sys/boot/common/pnp.c,v 1.16 2003/08/25 23:30:41 obrien Exp $ - * $DragonFly: src/sys/boot/common/pnp.c,v 1.3 2003/11/10 06:08:31 dillon Exp $ + * $DragonFly: src/sys/boot/common/pnp.c,v 1.4 2008/09/02 17:21:12 dillon Exp $ */ /* @@ -176,7 +176,7 @@ pnp_readconf(char *path) char *cp, *ep, *tp, c; /* try to open the file */ - if ((fd = open(path, O_RDONLY)) >= 0) { + if ((fd = rel_open(path, O_RDONLY)) >= 0) { line = 0; currbus = NULL; diff --git a/sys/boot/common/rel_open.c b/sys/boot/common/rel_open.c new file mode 100644 index 0000000000..91277ac872 --- /dev/null +++ b/sys/boot/common/rel_open.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2008 The DragonFly Project. All rights reserved. + * + * This code is derived from software contributed to The DragonFly Project + * by Matthew Dillon + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of The DragonFly Project nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific, prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $DragonFly: src/sys/boot/common/rel_open.c,v 1.1 2008/09/02 17:21:13 dillon Exp $ + */ + +#include +#include +#include "bootstrap.h" + +const char *DirBase; + +int +chdir(const char *path) +{ + struct stat st; + + if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) + DirBase = path; +} + +int +rel_open(const char *path, int flags) +{ + int fd; + char *ptr; + + if (DirBase && path[0] != '/') { + ptr = malloc(strlen(DirBase) + strlen(path) + 2); + sprintf(ptr, "%s/%s", DirBase, path); + fd = open(ptr, flags); + free(ptr); + } else { + fd = open(path, flags); + } + return(fd); +} + diff --git a/sys/boot/ficl/loader.c b/sys/boot/ficl/loader.c index 0d8fc8e169..bf54e3b597 100644 --- a/sys/boot/ficl/loader.c +++ b/sys/boot/ficl/loader.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/boot/ficl/loader.c,v 1.12 2006/05/12 04:07:42 jhb Exp $ - * $DragonFly: src/sys/boot/ficl/loader.c,v 1.6 2008/03/29 23:31:07 swildner Exp $ + * $DragonFly: src/sys/boot/ficl/loader.c,v 1.7 2008/09/02 17:21:14 dillon Exp $ */ /******************************************************************* @@ -433,7 +433,7 @@ static void pfopen(FICL_VM *pVM) name[count] = 0; /* open the file */ - fd = open(name, mode); + fd = rel_open(name, mode); free(name); stackPushINT(pVM->pStack, fd); return; diff --git a/sys/boot/forth/beastie.4th b/sys/boot/forth/beastie.4th index 44606d7365..5e72222162 100644 --- a/sys/boot/forth/beastie.4th +++ b/sys/boot/forth/beastie.4th @@ -24,12 +24,12 @@ \ SUCH DAMAGE. \ \ $FreeBSD: src/sys/boot/forth/beastie.4th,v 1.7 2003/10/28 17:18:42 scottl Exp $ -\ $DragonFly: src/sys/boot/forth/beastie.4th,v 1.8 2007/08/09 00:28:09 swildner Exp $ +\ $DragonFly: src/sys/boot/forth/beastie.4th,v 1.9 2008/09/02 17:21:15 dillon Exp $ marker task-beastie.4th -include /boot/screen.4th -include /boot/frames.4th +include screen.4th +include frames.4th hide diff --git a/sys/boot/forth/loader-bootp.conf b/sys/boot/forth/loader-bootp.conf index 1473b30a6e..eb6e82db3a 100644 --- a/sys/boot/forth/loader-bootp.conf +++ b/sys/boot/forth/loader-bootp.conf @@ -7,7 +7,7 @@ # All arguments must be in double quotes. # # $FreeBSD: src/sys/boot/forth/loader.conf,v 1.72 2003/07/01 01:03:32 brueffer Exp $ -# $DragonFly: src/sys/boot/forth/loader-bootp.conf,v 1.26 2008/09/01 19:39:46 dillon Exp $ +# $DragonFly: src/sys/boot/forth/loader-bootp.conf,v 1.27 2008/09/02 17:21:15 dillon Exp $ ############################################################## ### Basic configuration options ############################ @@ -23,8 +23,8 @@ userconfig_script_load="NO" userconfig_script_name="/boot/kernel-bootp.conf" userconfig_script_type="userconfig_script" -loader_conf_files="/boot/loader-bootp.conf /boot/loader-bootp.conf.local" -nextboot_conf="/boot/nextboot-bootp.conf" +loader_conf_files="loader-bootp.conf loader-bootp.conf.local" +nextboot_conf="nextboot-bootp.conf" nextboot_enable="NO" verbose_loading="NO" # Set to YES for verbose loader output @@ -51,7 +51,7 @@ bitmap_type="splash_image_data" # and place it on the module_path #loader_color="NO" # Set to YES for a color version of Fred #console="vidconsole" # Set the current console #currdev="disk1s1a" # Set the current device -module_path="/boot;/boot/modules;/;/modules" # Set the module search path +module_path="/;/modules" # Set the module search path #prompt="\\${interpret}" # Set the command prompt #root_disk_unit="0" # Force the root disk unit number #rootdev="disk1s1a" # Set the root filesystem @@ -332,8 +332,7 @@ atspeaker_load="NO" # AT speaker module acpi_dsdt_load="NO" # DSDT Overriding acpi_dsdt_type="acpi_dsdt" # Don't change this -acpi_dsdt_name="/boot/acpi_dsdt.aml" - # Override DSDT in BIOS by this file +acpi_dsdt_name="acpi_dsdt.aml" # Override DSDT in BIOS by this file ############################################################## diff --git a/sys/boot/forth/loader.4th b/sys/boot/forth/loader.4th index 3ebcdea4ed..9f0bdca156 100644 --- a/sys/boot/forth/loader.4th +++ b/sys/boot/forth/loader.4th @@ -23,7 +23,7 @@ \ SUCH DAMAGE. \ \ $FreeBSD: src/sys/boot/forth/loader.4th,v 1.24 2002/05/24 02:28:58 gordon Exp $ -\ $DragonFly: src/sys/boot/forth/loader.4th,v 1.8 2005/02/20 16:31:53 swildner Exp $ +\ $DragonFly: src/sys/boot/forth/loader.4th,v 1.9 2008/09/02 17:21:15 dillon Exp $ s" arch-i386" environment? [if] [if] s" loader_version" environment? [if] @@ -40,7 +40,7 @@ s" arch-i386" environment? [if] [if] 256 dictthreshold ! \ 256 cells minimum free space 2048 dictincrease ! \ 2048 additional cells each time -include /boot/support.4th +include support.4th \ ***** boot-conf \ @@ -122,9 +122,9 @@ only forth definitions also support-functions : start ( -- ) ( throws: abort & user-defined ) s" boot.nfsroot.path" getenv? if - s" /boot/defaults/loader-bootp.conf" initialize + s" defaults/loader-bootp.conf" initialize else - s" /boot/defaults/loader.conf" initialize + s" defaults/loader.conf" initialize then include_conf_files include_nextboot_file @@ -144,9 +144,9 @@ only forth definitions also support-functions : initialize ( -- flag ) s" boot.nfsroot.path" getenv? if - s" /boot/defaults/loader-bootp.conf" initialize + s" defaults/loader-bootp.conf" initialize else - s" /boot/defaults/loader.conf" initialize + s" defaults/loader.conf" initialize then include_conf_files include_nextboot_file diff --git a/sys/boot/forth/loader.conf b/sys/boot/forth/loader.conf index 67e188829f..44d44754a7 100644 --- a/sys/boot/forth/loader.conf +++ b/sys/boot/forth/loader.conf @@ -7,7 +7,7 @@ # All arguments must be in double quotes. # # $FreeBSD: src/sys/boot/forth/loader.conf,v 1.72 2003/07/01 01:03:32 brueffer Exp $ -# $DragonFly: src/sys/boot/forth/loader.conf,v 1.33 2008/09/01 19:39:46 dillon Exp $ +# $DragonFly: src/sys/boot/forth/loader.conf,v 1.34 2008/09/02 17:21:15 dillon Exp $ ############################################################## ### Basic configuration options ############################ @@ -25,8 +25,8 @@ userconfig_script_type="userconfig_script" # Must be accessible if either / or /boot is the boot directory. # -loader_conf_files="/boot/loader.conf /boot/loader.conf.local /loader.conf /loader.conf.local" -nextboot_conf="/boot/nextboot.conf" +loader_conf_files="loader.conf loader.conf.local" +nextboot_conf="nextboot.conf" nextboot_enable="NO" verbose_loading="NO" # Set to YES for verbose loader output diff --git a/sys/boot/forth/loader.rc b/sys/boot/forth/loader.rc index 07212cc4d3..02a1316388 100644 --- a/sys/boot/forth/loader.rc +++ b/sys/boot/forth/loader.rc @@ -1,9 +1,9 @@ \ Loader.rc \ $FreeBSD: src/sys/boot/forth/loader.rc,v 1.2 1999/11/24 17:59:37 dcs Exp $ -\ $DragonFly: src/sys/boot/forth/loader.rc,v 1.3 2003/11/10 06:08:34 dillon Exp $ +\ $DragonFly: src/sys/boot/forth/loader.rc,v 1.4 2008/09/02 17:21:15 dillon Exp $ \ \ Includes additional commands -include /boot/loader.4th +include loader.4th \ Reads and processes loader.rc start diff --git a/sys/boot/pc32/Makefile b/sys/boot/pc32/Makefile index 3a065b3d60..583484d08a 100644 --- a/sys/boot/pc32/Makefile +++ b/sys/boot/pc32/Makefile @@ -1,7 +1,8 @@ # $FreeBSD: src/sys/boot/i386/Makefile,v 1.19 2002/12/31 02:29:03 obrien Exp $ -# $DragonFly: src/sys/boot/pc32/Makefile,v 1.4 2005/09/03 23:52:45 dillon Exp $ +# $DragonFly: src/sys/boot/pc32/Makefile,v 1.5 2008/09/02 17:21:16 dillon Exp $ -SUBDIR= mbr boot0 btx boot2 cdboot kgzldr libi386 loader loader_tftp +SUBDIR= mbr boot0 btx boot2 cdboot kgzldr libi386 loader loader_tftp \ + boot0gpt # special boot programs, 'self-extracting boot2+loader' SUBDIR+= pxeldr pxeldr_tftp diff --git a/sys/boot/pc32/boot2/boot2.c b/sys/boot/pc32/boot2/boot2.c index e283e7fb97..471065e09a 100644 --- a/sys/boot/pc32/boot2/boot2.c +++ b/sys/boot/pc32/boot2/boot2.c @@ -45,7 +45,7 @@ * purpose. * * $FreeBSD: src/sys/boot/i386/boot2/boot2.c,v 1.64 2003/08/25 23:28:31 obrien Exp $ - * $DragonFly: src/sys/boot/pc32/boot2/boot2.c,v 1.16 2007/06/18 05:13:42 dillon Exp $ + * $DragonFly: src/sys/boot/pc32/boot2/boot2.c,v 1.17 2008/09/02 17:21:17 dillon Exp $ */ #include #include @@ -92,7 +92,8 @@ #define RBX_MASK 0x2005ffff #define PATH_CONFIG "/boot.config" -#define PATH_BOOT3 "/boot/loader" +#define PATH_BOOT3 "/boot/loader" /* /boot in root */ +#define PATH_BOOT3_ALT "/loader" /* /boot partition */ #define PATH_KERNEL "/kernel" #define NDEV 3 @@ -297,11 +298,15 @@ main(void) /* * Try to exec stage 3 boot loader. If interrupted by a keypress, * or in case of failure, try to load a kernel directly instead. + * + * We have to try boot /boot/loader and /loader to support booting + * from a /boot partition instead of a root partition. */ - if (autoboot && !*kname) { memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3)); if (!keyhit(3*SECOND)) { + load(); + memcpy(kname, PATH_BOOT3_ALT, sizeof(PATH_BOOT3_ALT)); load(); memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL)); } diff --git a/sys/boot/pc32/loader/loader.rc b/sys/boot/pc32/loader/loader.rc index 6caf685057..8b0d6f8d00 100644 --- a/sys/boot/pc32/loader/loader.rc +++ b/sys/boot/pc32/loader/loader.rc @@ -1,9 +1,9 @@ \ Loader.rc \ $FreeBSD: src/sys/boot/i386/loader/loader.rc,v 1.1 2003/05/31 05:25:18 scottl Exp $ -\ $DragonFly: src/sys/boot/pc32/loader/loader.rc,v 1.1 2003/11/10 06:08:36 dillon Exp $ +\ $DragonFly: src/sys/boot/pc32/loader/loader.rc,v 1.2 2008/09/02 17:21:18 dillon Exp $ \ \ Includes additional commands -include /boot/loader.4th +include loader.4th \ Reads and processes loader.rc start @@ -12,7 +12,7 @@ start check-password \ Load in the boot menu -include /boot/beastie.4th +include beastie.4th \ Do the normal initialization and startup initialize drop