summaryrefslogtreecommitdiffstats
path: root/sys/boot/zfs
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2010-09-24 19:49:12 +0000
committerpjd <pjd@FreeBSD.org>2010-09-24 19:49:12 +0000
commit891c7fcf8c7cafacd74e5b0eb6462a111cc62f1b (patch)
treea29246e5237a4044bc235bbad59ee0d0c6a5fff1 /sys/boot/zfs
parent39f36627d95bb74f59e469420305bfd0d61c8626 (diff)
downloadFreeBSD-src-891c7fcf8c7cafacd74e5b0eb6462a111cc62f1b.zip
FreeBSD-src-891c7fcf8c7cafacd74e5b0eb6462a111cc62f1b.tar.gz
- Split code shared by almost any boot loader into separate files and
clean up most layering violations: sys/boot/i386/common/rbx.h: RBX_* defines OPT_SET() OPT_CHECK() sys/boot/common/util.[ch]: memcpy() memset() memcmp() bcpy() bzero() bcmp() strcmp() strncmp() [new] strcpy() strcat() strchr() strlen() printf() sys/boot/i386/common/cons.[ch]: ioctrl putc() xputc() putchar() getc() xgetc() keyhit() [now takes number of seconds as an argument] getstr() sys/boot/i386/common/drv.[ch]: struct dsk drvread() drvwrite() [new] drvsize() [new] sys/boot/common/crc32.[ch] [new] sys/boot/common/gpt.[ch] [new] - Teach gptboot and gptzfsboot about new files. I haven't touched the rest, but there is still a lot of code duplication to be removed. - Implement full GPT support. Currently we just read primary header and partition table and don't care about checksums, etc. After this change we verify checksums of primary header and primary partition table and if there is a problem we fall back to backup header and backup partition table. - Clean up most messages to use prefix of boot program, so in case of an error we know where the error comes from, eg.: gptboot: unable to read primary GPT header - If we can't boot, print boot prompt only once and not every five seconds. - Honour newly added GPT attributes: bootme - this is bootable partition bootonce - try to boot from this partition only once bootfailed - we failed to boot from this partition - Change boot order of gptboot to the following: 1. Try to boot from all the partitions that have both 'bootme' and 'bootonce' attributes one by one. 2. Try to boot from all the partitions that have only 'bootme' attribute one by one. 3. If there are no partitions with 'bootme' attribute, boot from the first UFS partition. - The 'bootonce' functionality is implemented in the following way: 1. Walk through all the partitions and when 'bootonce' attribute is found without 'bootme' attribute, remove 'bootonce' attribute and set 'bootfailed' attribute. 'bootonce' attribute alone means that we tried to boot from this partition, but boot failed after leaving gptboot and machine was restarted. 2. Find partition with both 'bootme' and 'bootonce' attributes. 3. Remove 'bootme' attribute. 4. Try to execute /boot/loader or /boot/kernel/kernel from that partition. If succeeded we stop here. 5. If execution failed, remove 'bootonce' and set 'bootfailed'. 6. Go to 2. If whole boot succeeded there is new /etc/rc.d/gptboot script coming that will log all partitions that we failed to boot from (the ones with 'bootfailed' attribute) and will remove this attribute. It will also find partition with 'bootonce' attribute - this is the partition we booted from successfully. The script will log success and remove the attribute. All the GPT updates we do here goes to both primary and backup GPT if they are valid. We don't touch headers or partition tables when checksum doesn't match. Reviewed by: arch (Message-ID: <20100917234542.GE1902@garage.freebsd.pl>) Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com MFC after: 2 weeks
Diffstat (limited to 'sys/boot/zfs')
-rw-r--r--sys/boot/zfs/Makefile1
-rw-r--r--sys/boot/zfs/zfsimpl.c11
2 files changed, 4 insertions, 8 deletions
diff --git a/sys/boot/zfs/Makefile b/sys/boot/zfs/Makefile
index beba733..91525d7 100644
--- a/sys/boot/zfs/Makefile
+++ b/sys/boot/zfs/Makefile
@@ -5,6 +5,7 @@ INTERNALLIB=
SRCS+= zfs.c
+CFLAGS+= -DBOOTPROG=\"zfsloader\"
CFLAGS+= -I${.CURDIR}/../common -I${.CURDIR}/../.. -I.
CFLAGS+= -I${.CURDIR}/../../../lib/libstand
CFLAGS+= -I${.CURDIR}/../../cddl/boot/zfs
diff --git a/sys/boot/zfs/zfsimpl.c b/sys/boot/zfs/zfsimpl.c
index f5eff62..cb09120 100644
--- a/sys/boot/zfs/zfsimpl.c
+++ b/sys/boot/zfs/zfsimpl.c
@@ -496,12 +496,7 @@ vdev_init_from_nvlist(const unsigned char *nvlist, vdev_t **vdevp, int is_newer)
vdev->v_nparity = 0;
if (nvlist_find(nvlist, ZPOOL_CONFIG_PATH,
DATA_TYPE_STRING, 0, &path) == 0) {
- if (strlen(path) > 5
- && path[0] == '/'
- && path[1] == 'd'
- && path[2] == 'e'
- && path[3] == 'v'
- && path[4] == '/')
+ if (strncmp(path, "/dev/", 5) == 0)
path += 5;
vdev->v_name = strdup(path);
} else {
@@ -682,7 +677,7 @@ pager_printf(const char *fmt, ...)
#endif
-#define STATUS_FORMAT " %-16s %-10s\n"
+#define STATUS_FORMAT " %s %s\n"
static void
print_state(int indent, const char *name, vdev_state_t state)
@@ -1393,7 +1388,7 @@ fzap_list(spa_t *spa, const dnode_phys_t *dnode)
*/
value = fzap_leaf_value(&zl, zc);
- printf("%-32s 0x%llx\n", name, value);
+ printf("%s 0x%llx\n", name, value);
}
}
OpenPOWER on IntegriCloud