poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] pickles: Add mbr.pk for MBR partition table


From: Jose E. Marchesi
Subject: Re: [PATCH] pickles: Add mbr.pk for MBR partition table
Date: Tue, 26 Jan 2021 08:05:45 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> A new pickle!
>> Everything is OK (from my PoV) except a weird constraint violation.
>>
>> There's a problem in constraint of `magic` field of `MBR` struct.
>>
>>   struct {
>>     /* ... */
>>     uint16 magic = 0xaa55UH;
>>   };
>>
>> This gives constraint violation!
>> I even tried the following alternatives:
>>   - `uint16 magic : magic == 0xaa55UH;`
>>   - `byte[2] magic = [0x55UB, 0xaaUB];` and
>>   - `byte[2] magic : magic == [0x55UB, 0xaaUB];`
>
> Using uint16 won't work in big-endian.
>
> byte[2] magic = [0x55UB, 0xaaUB] should work well...

I debugged this a bit.

A bug seems to be introduced by the unnamed field.  This works properly:

type MBR = struct
  {
    byte[440#B] bootstrap;
    uint32 signature;
    byte[2] reserved = [0x0UB,0x0UB];
    MBR_PTE[4] pte;
    byte[2] magic = [0x55UB,0xaaUB];
  };

Checking that `reserved' is [0x0,0x0] is necessary anyway in this case,
isnt it?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]