Date: Sun, 17 Oct 2010 20:10:00 +0000 (UTC) From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: cvs-src-old@freebsd.org Subject: cvs commit: src/etc/rc.d Makefile gptboot src/sbin/geom/class/part gpart.8 src/sys/boot/common crc32.c crc32.h gpt.c gpt.h util.c util.h src/sys/boot/i386/common cons.c cons.h drv.c drv.h rbx.h src/sys/boot/i386/gptboot Makefile gptboot.c ... Message-ID: <201010172011.o9HKBnhc022644@repoman.freebsd.org>
index | next in thread | raw e-mail
pjd 2010-10-17 20:10:00 UTC
FreeBSD src repository
Modified files: (Branch: RELENG_8)
etc/rc.d Makefile
sbin/geom/class/part gpart.8
sys/boot/i386/gptboot Makefile gptboot.c
sys/boot/i386/gptzfsboot Makefile
sys/boot/i386/zfsboot Makefile zfsboot.c
sys/boot/zfs Makefile zfsimpl.c
sys/geom/part g_part_gpt.c
sys/sys gpt.h
Added files: (Branch: RELENG_8)
etc/rc.d gptboot
sys/boot/common crc32.c crc32.h gpt.c gpt.h util.c util.h
sys/boot/i386/common cons.c cons.h drv.c drv.h rbx.h
Log:
SVN rev 213994 on 2010-10-17 20:10:00Z by pjd
MFC r213133,r213135,r213136,r213137,r213245:
r213133:
Add three GPT attributes:
GPT_ENT_ATTR_BOOTME - this is bootable partition
GPT_ENT_ATTR_BOOTONCE - try to boot only once from this partition
GPT_ENT_ATTR_BOOTFAILED - set this flag if we cannot boot from partition
containing GPT_ENT_ATTR_BOOTONCE flag; note that if we cannot
boot from partition that contains only GPT_ENT_ATTR_BOOTME flag,
the GPT_ENT_ATTR_BOOTFAILED flag won't be set
According to wikipedia Microsoft TechNet says that attributes are divided into
two halves: the lower 4 bytes representing partition independent attributes,
and the upper 4 bytes are partition type dependent. Microsoft is already using
bits 60 (read-only), 62 (hidden) and 63 (do not automount) and I'd like to not
collide with those, so we are using bit 59 (bootme), 58 (bootonce) and 57
(bootfailed).
Reviewed by: arch (Message-ID: <20100917234542.GE1902@garage.freebsd.pl>)
r213135:
Allow to configure GPT attributes. It shouldn't be allowed to set bootfailed
attribute (it should be allowed only to unset it), but for test purposes it
might be useful, so the current code allows it.
Reviewed by: arch@ (Message-ID: <20100917234542.GE1902@garage.freebsd.pl>)
r213136:
- 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
r213137:
Add gptboot script that is responsible for:
- looking for partition with 'bootonce' attribute alone (without 'bootme'
attribute), removing it and logging that we successfully booted from this
partition.
- looking for partitions with 'bootfailed' attribute, removing it and
logging that we failed to boot from this partition.
Reviewed by: arch (Message-ID: <20100917234542.GE1902@garage.freebsd.pl>)
Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com
r213245:
Document recently added GPT attributes (bootme, bootonce, bootfailed) and
list other schemes attributes.
Reviewed by: simon, rpaulo
Revision Changes Path
1.99.2.7 +1 -1 src/etc/rc.d/Makefile
1.1.2.2 +76 -0 src/etc/rc.d/gptboot (new)
1.7.2.9 +104 -1 src/sbin/geom/class/part/gpart.8
1.1.2.2 +108 -0 src/sys/boot/common/crc32.c (new)
1.1.2.2 +13 -0 src/sys/boot/common/crc32.h (new)
1.1.2.2 +381 -0 src/sys/boot/common/gpt.c (new)
1.1.2.2 +39 -0 src/sys/boot/common/gpt.h (new)
1.1.2.2 +176 -0 src/sys/boot/common/util.c (new)
1.1.2.2 +53 -0 src/sys/boot/common/util.h (new)
1.1.2.2 +152 -0 src/sys/boot/i386/common/cons.c (new)
1.1.2.2 +34 -0 src/sys/boot/i386/common/cons.h (new)
1.1.2.2 +131 -0 src/sys/boot/i386/common/drv.c (new)
1.1.2.2 +48 -0 src/sys/boot/i386/common/drv.h (new)
1.1.2.2 +61 -0 src/sys/boot/i386/common/rbx.h (new)
1.62.6.2 +8 -5 src/sys/boot/i386/gptboot/Makefile
1.88.2.5 +142 -434 src/sys/boot/i386/gptboot/gptboot.c
1.3.4.2 +7 -3 src/sys/boot/i386/gptzfsboot/Makefile
1.2.4.2 +10 -7 src/sys/boot/i386/zfsboot/Makefile
1.3.4.10 +14 -405 src/sys/boot/i386/zfsboot/zfsboot.c
1.3.4.2 +1 -0 src/sys/boot/zfs/Makefile
1.5.4.8 +3 -8 src/sys/boot/zfs/zfsimpl.c
1.16.2.12 +85 -0 src/sys/geom/part/g_part_gpt.c
1.13.2.3 +3 -0 src/sys/sys/gpt.h
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010172011.o9HKBnhc022644>
