diff options
| author | Thomas Gellekum <tg@FreeBSD.org> | 2001-05-22 11:31:39 +0000 |
|---|---|---|
| committer | Thomas Gellekum <tg@FreeBSD.org> | 2001-05-22 11:31:39 +0000 |
| commit | 02cefb1b5c055b937c8eba2c773600489b44a413 (patch) | |
| tree | 39e43c6812603d7e492b5aa04d7f6af03ea91e0c /usr.bin/doscmd/doscmd.c | |
| parent | 8784582c8a1db381b809fde48c5650d6ac66b86f (diff) | |
Notes
Diffstat (limited to 'usr.bin/doscmd/doscmd.c')
| -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 7463af6add23..9aaf73015394 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 |
