[SLOF] [PATCH 10/16] Implement measurements of the master boot record

Segher Boessenkool segher at kernel.crashing.org
Thu Nov 12 19:09:55 AEDT 2015


On Thu, Nov 12, 2015 at 08:17:37AM +0100, Thomas Huth wrote:
> >>> --- a/slof/fs/packages/disk-label.fs
> >>> +++ b/slof/fs/packages/disk-label.fs
> >>> @@ -545,7 +545,11 @@ B9E5                CONSTANT
> >>> GPT-BASIC-DATA-PARTITION-2
> >>>   \ load from a bootable partition
> >>>   : load-from-boot-partition ( addr -- size )
> >>>      debug-disk-label? IF ." Trying DOS boot " .s cr THEN
> >>> -   dup load-from-dos-boot-partition ?dup 0 <> IF nip EXIT THEN
> >>> +   dup load-from-dos-boot-partition ?dup 0 <> IF
> >>> +      nip
> >>> +      80 block 200 vtpm-add-bcv
> >> what does 80 mean ?
> > 
> > Ah, cannot drop the bcv function...
> 
> ... if you use something like this (untested):
> 
>  s" 80 block 200 vtpm-add-bcv" ['] evaluate CATCH drop
> 
> Yes, Forth is fun! :-)

Eww.  EVALUATE is almost always the wrong tool to use.

A simple solution here would be to provide a simple default definition
for this name, somewhere in generic code (loaded before the TPM thing),
something like

	: vtpm-add-bcv ( x -- )  drop ;

This is a terrible name btw, I have no idea what it does, it is very
specific to some hardware (virtual or not :-) ), and you are using it
in very generic code.

Maybe you want a hook instead?  DEFER is your friend.

Or, actually, aren't you simply checking for another partition table
type?

It would help if the code was factored a bit more.  If you need stack
comments, or even indenting, to read the code -- you need to factor
more.  That also forces you to have names for things, hopefully good
names, and you cannot make good names without factoring into clean
parts.  Win-win-win!


Segher


More information about the SLOF mailing list