diff options
author | tg <tg@FreeBSD.org> | 2001-05-22 11:31:39 +0000 |
---|---|---|
committer | tg <tg@FreeBSD.org> | 2001-05-22 11:31:39 +0000 |
commit | 3f61b37d6ef93cb3ab913074e302df5afa61a23d (patch) | |
tree | 6700c17801da3844803a516f60467be13de8b144 /usr.bin | |
parent | d56823d7f2136e08fe33fd4a3cd2e173db2387bc (diff) | |
download | FreeBSD-src-3f61b37d6ef93cb3ab913074e302df5afa61a23d.zip FreeBSD-src-3f61b37d6ef93cb3ab913074e302df5afa61a23d.tar.gz |
Fix boot order (really try A:, then C:, unless the `boot' option is
specified in .doscmdrc).
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/doscmd/doscmd.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/usr.bin/doscmd/doscmd.c b/usr.bin/doscmd/doscmd.c index 7463af6..9aaf730 100644 --- a/usr.bin/doscmd/doscmd.c +++ b/usr.bin/doscmd/doscmd.c @@ -79,6 +79,7 @@ struct vconnect_area vconnect_area = { /* local prototypes */ static void setup_boot(regcontext_t *REGS); +static int try_boot(int); static void setup_command(int argc, char *argv[], regcontext_t *REGS); static FILE *find_doscmdrc(void); static int do_args(int argc, char *argv[]); @@ -306,21 +307,15 @@ setup_boot(regcontext_t *REGS) booting = read_config(fp); /* where to boot from? */ fclose(fp); if (booting < 0) { /* not specified */ - if ((fd = disk_fd(booting = 0)) < 0) /* try A: */ - fd = disk_fd(booting = 2); /* try C: */ + if ((fd = try_boot(booting = 0)) < 0) /* try A: */ + fd = try_boot(booting = 2); /* try C: */ } else { - fd = disk_fd(booting); /* do like the man says */ - } - - if (fd < 0) { /* can we boot it? */ - errx(1, "Cannot boot from %c", drntol(booting)); - } - - /* read bootblock */ - if (read(fd, (char *)0x7c00, 512) != 512) { - errx(1, "Short read on boot block from %c:", drntol(booting)); + fd = try_boot(booting); /* do like the man says */ } + if (fd < 0) + errx(1, "Failed to boot"); + /* initialise registers for entry to bootblock */ R_EFLAGS = 0x20202; R_CS = 0x0000; @@ -342,6 +337,31 @@ setup_boot(regcontext_t *REGS) } /* +** try_boot +** +** try to read the boot sector from the specified disk +*/ +static int +try_boot(int booting) +{ + int fd; + + fd = disk_fd(booting); + if (fd < 0) { /* can we boot it? */ + debug(D_DISK, "Cannot boot from %c\n", drntol(booting)); + return -1; + } + + /* read bootblock */ + if (read(fd, (char *)0x7c00, 512) != 512) { + debug(D_DISK, "Short read on boot block from %c:\n", drntol(booting)); + return -1; + } + + return fd; +} + +/* ** setup_command ** ** Setup to run a single command and emulate DOS |