2 * Copyright (c) 1998 Robert Nordier
5 * Redistribution and use in source and binary forms are freely
6 * permitted provided that the above copyright notice and this
7 * paragraph and the following disclaimer are duplicated in all
10 * This software is provided "AS IS" and without any express or
11 * implied warranties, including, without limitation, the implied
12 * warranties of merchantability and fitness for a particular
16 #include <sys/cdefs.h>
17 __FBSDID("$FreeBSD$");
19 #include <sys/param.h>
20 #include <sys/errno.h>
21 #include <sys/diskmbr.h>
25 #include <sys/reboot.h>
26 #include <sys/queue.h>
28 #include <machine/bootinfo.h>
29 #include <machine/elf.h>
30 #include <machine/pc/bios.h>
53 #define BIOS_NUMDRIVES 0x475
59 #define TYPE_MAXHARD TYPE_DA
62 #define DEV_GELIBOOT_BSIZE 4096
67 static const uuid_t freebsd_zfs_uuid = GPT_ENT_TYPE_FREEBSD_ZFS;
69 static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */
70 static const unsigned char flags[NOPT] = {
88 static const unsigned char dev_maj[NDEV] = {30, 4, 2};
91 static char cmddup[512];
92 static char kname[1024];
93 static char rootname[256];
94 static int comspeed = SIOSPD;
95 static struct bootinfo bootinfo;
96 static uint32_t bootdev;
97 static struct zfs_boot_args zfsargs;
98 static struct zfsmount zfsmount;
100 vm_offset_t high_heap_base;
101 uint32_t bios_basemem, bios_extmem, high_heap_size;
103 static struct bios_smap smap;
106 * The minimum amount of memory to reserve in bios_extmem for the heap.
108 #define HEAP_MIN (3 * 1024 * 1024)
110 static char *heap_next;
111 static char *heap_end;
113 /* Buffers that must not span a 64k boundary. */
114 #define READ_BUF_SIZE 8192
116 char rdbuf[READ_BUF_SIZE]; /* for reading large things */
117 char secbuf[READ_BUF_SIZE]; /* for MBR/disklabel */
119 static struct dmadat *dmadat;
123 static void load(void);
124 static int parse(void);
125 static void bios_getmem(void);
126 void *malloc(size_t n);
127 void free(void *ptr);
133 if (p + n > heap_end) {
134 printf("malloc failure\n");
152 strdup(const char *s)
154 char *p = malloc(strlen(s) + 1);
159 #ifdef LOADER_GELI_SUPPORT
160 #include "geliboot.c"
161 static char gelipw[GELI_PW_MAXLEN];
167 * Read from a dnode (which must be from a ZPL filesystem).
170 zfs_read(spa_t *spa, const dnode_phys_t *dnode, off_t *offp, void *start, size_t size)
172 const znode_phys_t *zp = (const znode_phys_t *) dnode->dn_bonus;
177 if (*offp + n > zp->zp_size)
178 n = zp->zp_size - *offp;
180 rc = dnode_read(spa, dnode, *offp, start, n);
192 static spa_t *primary_spa;
193 static vdev_t *primary_vdev;
196 * A wrapper for dskread that doesn't have to worry about whether the
197 * buffer pointer crosses a 64k boundary.
200 vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes)
203 daddr_t lba, alignlba;
205 unsigned int nb, alignnb;
206 struct dsk *dsk = (struct dsk *) priv;
208 if ((off & (DEV_BSIZE - 1)) || (bytes & (DEV_BSIZE - 1)))
212 lba = off / DEV_BSIZE;
215 * Align reads to 4k else 4k sector GELIs will not decrypt.
216 * Round LBA down to nearest multiple of DEV_GELIBOOT_BSIZE bytes.
218 alignlba = rounddown2(off, DEV_GELIBOOT_BSIZE) / DEV_BSIZE;
220 * The read must be aligned to DEV_GELIBOOT_BSIZE bytes relative to the
221 * start of the GELI partition, not the start of the actual disk.
223 alignlba += dsk->start;
224 diff = (lba - alignlba) * DEV_BSIZE;
227 nb = bytes / DEV_BSIZE;
229 * Ensure that the read size plus the leading offset does not
230 * exceed the size of the read buffer.
232 if (nb > (READ_BUF_SIZE - diff) / DEV_BSIZE)
233 nb = (READ_BUF_SIZE - diff) / DEV_BSIZE;
235 * Round the number of blocks to read up to the nearest multiple
236 * of DEV_GELIBOOT_BSIZE.
238 alignnb = roundup2(nb * DEV_BSIZE + diff, DEV_GELIBOOT_BSIZE)
241 if (drvread(dsk, dmadat->rdbuf, alignlba, alignnb))
243 #ifdef LOADER_GELI_SUPPORT
245 if (is_geli(dsk) == 0) {
246 if (geli_read(dsk, ((alignlba - dsk->start) *
247 DEV_BSIZE), dmadat->rdbuf, alignnb * DEV_BSIZE))
251 memcpy(p, dmadat->rdbuf + diff, nb * DEV_BSIZE);
255 bytes -= nb * DEV_BSIZE;
256 /* Don't need the leading offset after the first block. */
264 vdev_write(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes)
269 struct dsk *dsk = (struct dsk *) priv;
271 if ((off & (DEV_BSIZE - 1)) || (bytes & (DEV_BSIZE - 1)))
275 lba = off / DEV_BSIZE;
278 nb = bytes / DEV_BSIZE;
279 if (nb > READ_BUF_SIZE / DEV_BSIZE)
280 nb = READ_BUF_SIZE / DEV_BSIZE;
281 memcpy(dmadat->rdbuf, p, nb * DEV_BSIZE);
282 if (drvwrite(dsk, dmadat->rdbuf, lba, nb))
286 bytes -= nb * DEV_BSIZE;
293 xfsread(const dnode_phys_t *dnode, off_t *offp, void *buf, size_t nbyte)
295 if ((size_t)zfs_read(spa, dnode, offp, buf, nbyte) != nbyte) {
296 printf("Invalid format\n");
303 * Read Pad2 (formerly "Boot Block Header") area of the first
304 * vdev label of the given vdev.
307 vdev_read_pad2(vdev_t *vdev, char *buf, size_t size)
310 char *tmp = zap_scratch;
311 off_t off = offsetof(vdev_label_t, vl_pad2);
313 if (size > VDEV_PAD_SIZE)
314 size = VDEV_PAD_SIZE;
317 BP_SET_LSIZE(&bp, VDEV_PAD_SIZE);
318 BP_SET_PSIZE(&bp, VDEV_PAD_SIZE);
319 BP_SET_CHECKSUM(&bp, ZIO_CHECKSUM_LABEL);
320 BP_SET_COMPRESS(&bp, ZIO_COMPRESS_OFF);
321 DVA_SET_OFFSET(BP_IDENTITY(&bp), off);
322 if (vdev_read_phys(vdev, &bp, tmp, off, 0))
324 memcpy(buf, tmp, size);
329 vdev_clear_pad2(vdev_t *vdev)
331 char *zeroes = zap_scratch;
333 off_t off = offsetof(vdev_label_t, vl_pad2);
335 memset(zeroes, 0, VDEV_PAD_SIZE);
336 end = (uint64_t *)(zeroes + VDEV_PAD_SIZE);
337 /* ZIO_CHECKSUM_LABEL magic and pre-calcualted checksum for all zeros */
338 end[-5] = 0x0210da7ab10c7a11;
339 end[-4] = 0x97f48f807f6e2a3f;
340 end[-3] = 0xaf909f1658aacefc;
341 end[-2] = 0xcbd1ea57ff6db48b;
342 end[-1] = 0x6ec692db0d465fab;
343 if (vdev_write(vdev, vdev->v_read_priv, off, zeroes, VDEV_PAD_SIZE))
353 /* Parse system memory map */
357 v86.addr = 0x15; /* int 0x15 function 0xe820*/
359 v86.ecx = sizeof(struct bios_smap);
361 v86.es = VTOPSEG(&smap);
362 v86.edi = VTOPOFF(&smap);
364 if (V86_CY(v86.efl) || (v86.eax != SMAP_SIG))
366 /* look for a low-memory segment that's large enough */
367 if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0) &&
368 (smap.length >= (512 * 1024)))
369 bios_basemem = smap.length;
370 /* look for the first segment in 'extended' memory */
371 if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0x100000)) {
372 bios_extmem = smap.length;
376 * Look for the largest segment in 'extended' memory beyond
379 if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base > 0x100000) &&
380 (smap.base < 0x100000000ull)) {
384 * If this segment crosses the 4GB boundary, truncate it.
386 if (smap.base + size > 0x100000000ull)
387 size = 0x100000000ull - smap.base;
389 if (size > high_heap_size) {
390 high_heap_size = size;
391 high_heap_base = smap.base;
394 } while (v86.ebx != 0);
396 /* Fall back to the old compatibility function for base memory */
397 if (bios_basemem == 0) {
399 v86.addr = 0x12; /* int 0x12 */
402 bios_basemem = (v86.eax & 0xffff) * 1024;
405 /* Fall back through several compatibility functions for extended memory */
406 if (bios_extmem == 0) {
408 v86.addr = 0x15; /* int 0x15 function 0xe801*/
411 if (!V86_CY(v86.efl)) {
412 bios_extmem = ((v86.ecx & 0xffff) + ((v86.edx & 0xffff) * 64)) * 1024;
415 if (bios_extmem == 0) {
417 v86.addr = 0x15; /* int 0x15 function 0x88*/
420 bios_extmem = (v86.eax & 0xffff) * 1024;
424 * If we have extended memory and did not find a suitable heap
425 * region in the SMAP, use the last 3MB of 'extended' memory as a
426 * high heap candidate.
428 if (bios_extmem >= HEAP_MIN && high_heap_size < HEAP_MIN) {
429 high_heap_size = HEAP_MIN;
430 high_heap_base = bios_extmem + 0x100000 - HEAP_MIN;
435 * Try to detect a device supported by the legacy int13 BIOS
438 int13probe(int drive)
446 if (!V86_CY(v86.efl) && /* carry clear */
447 ((v86.edx & 0xff) != (drive & DRV_MASK))) { /* unit # OK */
448 if ((v86.ecx & 0x3f) == 0) { /* absurd sector size */
449 return(0); /* skip device */
457 * We call this when we find a ZFS vdev - ZFS consumes the dsk
458 * structure so we must make a new one.
461 copy_dsk(struct dsk *dsk)
465 newdsk = malloc(sizeof(struct dsk));
471 probe_drive(struct dsk *dsk)
476 unsigned part, entries_per_sec;
479 #if defined(GPT) || defined(LOADER_GELI_SUPPORT)
483 struct dos_partition *dp;
488 * If we find a vdev on the whole disk, stop here.
490 if (vdev_probe(vdev_read, dsk, NULL) == 0)
493 #ifdef LOADER_GELI_SUPPORT
495 * Taste the disk, if it is GELI encrypted, decrypt it and check to see if
496 * it is a usable vdev then. Otherwise dig
497 * out the partition table and probe each slice/partition
498 * in turn for a vdev or GELI encrypted vdev.
504 if (geli_taste(vdev_read, dsk, elba) == 0) {
505 if (geli_passphrase(&gelipw, dsk->unit, ':', 0, dsk) == 0) {
506 if (vdev_probe(vdev_read, dsk, NULL) == 0) {
511 #endif /* LOADER_GELI_SUPPORT */
513 sec = dmadat->secbuf;
518 * First check for GPT.
520 if (drvread(dsk, sec, 1, 1)) {
523 memcpy(&hdr, sec, sizeof(hdr));
524 if (memcmp(hdr.hdr_sig, GPT_HDR_SIG, sizeof(hdr.hdr_sig)) != 0 ||
525 hdr.hdr_lba_self != 1 || hdr.hdr_revision < 0x00010000 ||
526 hdr.hdr_entsz < sizeof(*ent) || DEV_BSIZE % hdr.hdr_entsz != 0) {
531 * Probe all GPT partitions for the presence of ZFS pools. We
532 * return the spa_t for the first we find (if requested). This
533 * will have the effect of booting from the first pool on the
536 * If no vdev is found, GELI decrypting the device and try again
538 entries_per_sec = DEV_BSIZE / hdr.hdr_entsz;
539 slba = hdr.hdr_lba_table;
540 elba = slba + hdr.hdr_entries / entries_per_sec;
541 while (slba < elba) {
543 if (drvread(dsk, sec, slba, 1))
545 for (part = 0; part < entries_per_sec; part++) {
546 ent = (struct gpt_ent *)(sec + part * hdr.hdr_entsz);
547 if (memcmp(&ent->ent_type, &freebsd_zfs_uuid,
548 sizeof(uuid_t)) == 0) {
549 dsk->start = ent->ent_lba_start;
550 dsk->slice = part + 1;
552 if (vdev_probe(vdev_read, dsk, NULL) == 0) {
554 * This slice had a vdev. We need a new dsk
555 * structure now since the vdev now owns this one.
559 #ifdef LOADER_GELI_SUPPORT
560 else if (geli_taste(vdev_read, dsk, ent->ent_lba_end -
561 ent->ent_lba_start) == 0) {
562 if (geli_passphrase(&gelipw, dsk->unit, 'p', dsk->slice, dsk) == 0) {
564 * This slice has GELI, check it for ZFS.
566 if (vdev_probe(vdev_read, dsk, NULL) == 0) {
568 * This slice had a vdev. We need a new dsk
569 * structure now since the vdev now owns this one.
576 #endif /* LOADER_GELI_SUPPORT */
585 if (drvread(dsk, sec, DOSBBSECTOR, 1))
587 dp = (void *)(sec + DOSPARTOFF);
589 for (i = 0; i < NDOSPART; i++) {
592 dsk->start = dp[i].dp_start;
594 if (vdev_probe(vdev_read, dsk, NULL) == 0) {
597 #ifdef LOADER_GELI_SUPPORT
598 else if (geli_taste(vdev_read, dsk, dp[i].dp_size -
599 dp[i].dp_start) == 0) {
600 if (geli_passphrase(&gelipw, dsk->unit, 's', i, dsk) == 0) {
602 * This slice has GELI, check it for ZFS.
604 if (vdev_probe(vdev_read, dsk, NULL) == 0) {
606 * This slice had a vdev. We need a new dsk
607 * structure now since the vdev now owns this one.
614 #endif /* LOADER_GELI_SUPPORT */
628 dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
632 if (high_heap_size > 0) {
633 heap_end = PTOV(high_heap_base + high_heap_size);
634 heap_next = PTOV(high_heap_base);
636 heap_next = (char *)dmadat + sizeof(*dmadat);
637 heap_end = (char *)PTOV(bios_basemem);
640 dsk = malloc(sizeof(struct dsk));
641 dsk->drive = *(uint8_t *)PTOV(ARGS);
642 dsk->type = dsk->drive & DRV_HARD ? TYPE_AD : TYPE_FD;
643 dsk->unit = dsk->drive & DRV_MASK;
644 dsk->slice = *(uint8_t *)PTOV(ARGS + 1) + 1;
649 bootinfo.bi_version = BOOTINFO_VERSION;
650 bootinfo.bi_size = sizeof(bootinfo);
651 bootinfo.bi_basemem = bios_basemem / 1024;
652 bootinfo.bi_extmem = bios_extmem / 1024;
653 bootinfo.bi_memsizes_valid++;
654 bootinfo.bi_bios_dev = dsk->drive;
656 bootdev = MAKEBOOTDEV(dev_maj[dsk->type],
657 dsk->slice, dsk->unit, dsk->part);
659 /* Process configuration file */
663 #ifdef LOADER_GELI_SUPPORT
669 * Probe the boot drive first - we will try to boot from whatever
670 * pool we find on that drive.
675 * Probe the rest of the drives that the bios knows about. This
676 * will find any other available pools and it may fill in missing
677 * vdevs for the boot pool.
680 for (i = 0; i < *(unsigned char *)PTOV(BIOS_NUMDRIVES); i++)
682 for (i = 0; i < MAXBDDEV; i++)
685 if ((i | DRV_HARD) == *(uint8_t *)PTOV(ARGS))
688 if (!int13probe(i | DRV_HARD))
691 dsk = malloc(sizeof(struct dsk));
692 dsk->drive = i | DRV_HARD;
693 dsk->type = dsk->drive & TYPE_AD;
703 * The first discovered pool, if any, is the pool.
705 spa = spa_get_primary();
707 printf("%s: No ZFS pools located, can't boot\n", BOOTPROG);
713 primary_vdev = spa_get_primary_vdev(spa);
716 rc = vdev_read_pad2(primary_vdev, cmd, sizeof(cmd));
717 if (vdev_clear_pad2(primary_vdev))
718 printf("failed to clear pad2 area of primary vdev\n");
722 * We could find an old-style ZFS Boot Block header here.
725 if (*(uint64_t *)cmd != 0x2f5b007b10c) {
727 * Note that parse() is destructive to cmd[] and we also want
728 * to honor RBX_QUIET option that could be present in cmd[].
731 memcpy(cmddup, cmd, sizeof(cmd));
733 printf("failed to parse pad2 area of primary vdev\n");
736 if (!OPT_CHECK(RBX_QUIET))
737 printf("zfs nextboot: %s\n", cmddup);
739 /* Do not process this command twice */
743 printf("failed to read pad2 area of primary vdev\n");
745 /* Mount ZFS only if it's not already mounted via nextboot parsing. */
746 if (zfsmount.spa == NULL &&
747 (zfs_spa_init(spa) != 0 || zfs_mount(spa, 0, &zfsmount) != 0)) {
748 printf("%s: failed to mount default pool %s\n",
749 BOOTPROG, spa->spa_name);
751 } else if (zfs_lookup(&zfsmount, PATH_CONFIG, &dn) == 0 ||
752 zfs_lookup(&zfsmount, PATH_DOTCONFIG, &dn) == 0) {
754 zfs_read(spa, &dn, &off, cmd, sizeof(cmd));
759 * Note that parse() is destructive to cmd[] and we also want
760 * to honor RBX_QUIET option that could be present in cmd[].
762 memcpy(cmddup, cmd, sizeof(cmd));
765 if (!OPT_CHECK(RBX_QUIET))
766 printf("%s: %s\n", PATH_CONFIG, cmddup);
767 /* Do not process this command twice */
771 /* Do not risk waiting at the prompt forever. */
772 if (nextboot && !autoboot)
776 * Try to exec /boot/loader. If interrupted by a keypress,
777 * or in case of failure, try to load a kernel directly instead.
780 if (autoboot && !*kname) {
781 memcpy(kname, PATH_LOADER_ZFS, sizeof(PATH_LOADER_ZFS));
784 memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
788 /* Present the user with the boot2 prompt. */
791 if (!autoboot || !OPT_CHECK(RBX_QUIET)) {
792 printf("\nFreeBSD/x86 boot\n");
793 if (zfs_rlookup(spa, zfsmount.rootobj, rootname) != 0)
794 printf("Default: %s/<0x%llx>:%s\n"
796 spa->spa_name, zfsmount.rootobj, kname);
797 else if (rootname[0] != '\0')
798 printf("Default: %s/%s:%s\n"
800 spa->spa_name, rootname, kname);
802 printf("Default: %s:%s\n"
804 spa->spa_name, kname);
806 if (ioctrl & IO_SERIAL)
808 if (!autoboot || keyhit(5))
809 getstr(cmd, sizeof(cmd));
810 else if (!autoboot || !OPT_CHECK(RBX_QUIET))
820 /* XXX - Needed for btxld to link the boot2 binary; do not remove. */
840 static Elf32_Phdr ep[2];
841 static Elf32_Shdr es[2];
848 if (zfs_lookup(&zfsmount, kname, &dn)) {
849 printf("\nCan't find %s\n", kname);
853 if (xfsread(&dn, &off, &hdr, sizeof(hdr)))
855 if (N_GETMAGIC(hdr.ex) == ZMAGIC)
857 else if (IS_ELF(hdr.eh))
860 printf("Invalid %s\n", "format");
864 addr = hdr.ex.a_entry & 0xffffff;
867 if (xfsread(&dn, &off, p, hdr.ex.a_text))
869 p += roundup2(hdr.ex.a_text, PAGE_SIZE);
870 if (xfsread(&dn, &off, p, hdr.ex.a_data))
872 p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE);
873 bootinfo.bi_symtab = VTOP(p);
874 memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms));
875 p += sizeof(hdr.ex.a_syms);
877 if (xfsread(&dn, &off, p, hdr.ex.a_syms))
880 if (xfsread(&dn, &off, p, sizeof(int)))
885 if (xfsread(&dn, &off, p, x))
890 off = hdr.eh.e_phoff;
891 for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) {
892 if (xfsread(&dn, &off, ep + j, sizeof(ep[0])))
894 if (ep[j].p_type == PT_LOAD)
897 for (i = 0; i < 2; i++) {
898 p = PTOV(ep[i].p_paddr & 0xffffff);
899 off = ep[i].p_offset;
900 if (xfsread(&dn, &off, p, ep[i].p_filesz))
903 p += roundup2(ep[1].p_memsz, PAGE_SIZE);
904 bootinfo.bi_symtab = VTOP(p);
905 if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) {
906 off = hdr.eh.e_shoff + sizeof(es[0]) *
907 (hdr.eh.e_shstrndx + 1);
908 if (xfsread(&dn, &off, &es, sizeof(es)))
910 for (i = 0; i < 2; i++) {
911 memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size));
912 p += sizeof(es[i].sh_size);
913 off = es[i].sh_offset;
914 if (xfsread(&dn, &off, p, es[i].sh_size))
919 addr = hdr.eh.e_entry & 0xffffff;
921 bootinfo.bi_esymtab = VTOP(p);
922 bootinfo.bi_kernelname = VTOP(kname);
923 zfsargs.size = sizeof(zfsargs);
924 zfsargs.pool = zfsmount.spa->spa_guid;
925 zfsargs.root = zfsmount.rootobj;
926 zfsargs.primary_pool = primary_spa->spa_guid;
927 #ifdef LOADER_GELI_SUPPORT
928 bcopy(gelipw, zfsargs.gelipw, sizeof(zfsargs.gelipw));
929 bzero(gelipw, sizeof(gelipw));
931 zfsargs.gelipw[0] = '\0';
933 if (primary_vdev != NULL)
934 zfsargs.primary_vdev = primary_vdev->v_guid;
936 printf("failed to detect primary vdev\n");
937 __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
939 KARGS_FLAGS_ZFS | KARGS_FLAGS_EXTARG,
940 (uint32_t) spa->spa_guid,
941 (uint32_t) (spa->spa_guid >> 32),
947 zfs_mount_ds(char *dsname)
953 q = strchr(dsname, '/');
956 newspa = spa_find_by_name(dsname);
957 if (newspa == NULL) {
958 printf("\nCan't find ZFS pool %s\n", dsname);
962 if (zfs_spa_init(newspa))
967 if (zfs_lookup_dataset(newspa, q, &newroot)) {
968 printf("\nCan't find dataset %s in ZFS pool %s\n",
969 q, newspa->spa_name);
973 if (zfs_mount(newspa, newroot, &zfsmount)) {
974 printf("\nCan't mount ZFS dataset\n");
989 while ((c = *arg++)) {
990 if (c == ' ' || c == '\t' || c == '\n')
992 for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++);
997 while ((c = *arg++)) {
999 if (*(uint8_t *)PTOV(0x496) & 0x10) {
1002 opts |= OPT_SET(RBX_DUAL) | OPT_SET(RBX_SERIAL);
1005 printf("Keyboard: %s\n", cp);
1007 } else if (c == 'S') {
1009 while ((unsigned int)(i = *arg++ - '0') <= 9)
1011 if (j > 0 && i == -'0') {
1015 /* Fall through to error below ('S' not in optstr[]). */
1017 for (i = 0; c != optstr[i]; i++)
1020 opts ^= OPT_SET(flags[i]);
1022 ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) :
1023 OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD;
1024 if (ioctrl & IO_SERIAL) {
1025 if (sio_init(115200 / comspeed) != 0)
1026 ioctrl &= ~IO_SERIAL;
1031 if (zfs_lookup(&zfsmount, arg, &dn) == 0) {
1039 * Report pool status if the comment is 'status'. Lets
1040 * hope no-one wants to load /status as a kernel.
1042 if (!strcmp(arg, "status")) {
1048 * If there is "zfs:" prefix simply ignore it.
1050 if (strncmp(arg, "zfs:", 4) == 0)
1054 * If there is a colon, switch pools.
1056 q = strchr(arg, ':');
1059 if (zfs_mount_ds(arg) != 0)
1063 if ((i = ep - arg)) {
1064 if ((size_t)i >= sizeof(kname))
1066 memcpy(kname, arg, i + 1);