On Tuesday, July 7, 2020 at 2:00:46 AM UTC-4 Nadav Har'El wrote:
> On Tue, Jul 7, 2020 at 5:56 AM Commit Bot <[email protected]> > wrote: > >> From: Waldemar Kozaczuk <[email protected]> >> Committer: Waldemar Kozaczuk <[email protected]> >> Branch: master >> >> scripts: use common binary partition header file to build disk images >> >> The scripts/build accepts the '--create-disk' option to allow >> creating disk images (disk.img) intended to be used when booting >> OSv in direct kernel mode (-k option to run.py). Currently >> the build script uses `build/last/boot.bin` as a partition table disk >> header. >> Even though the end result is working, boot.bin contains unnecessary code >> from arch/x64/boot16.S and more importantly is not present in aarch64 >> build. >> >> So this patch adds tiny 512-bytes partition table template file (510 >> zeros followed by 0xaa, 0x55) >> > which is then used as a disk image header when creating a ROFS or ZFS disk. >> > > How did you determine this magic file needs to be exactly those bytes? > Your actual file has 0x55 first and then 0xaa, and not the other way > around as you said it.... Does that matter? > Yeah, I made a mistake when writing a comment. And yes the order matters. I simply discovered that by looking at arch/x64/boot16.S and more importantly the code in fs/devfs/device.cc (read_partition_table) - https://github.com/cloudius-systems/osv/blob/771b61dc6813aa4807f020ad96edb9929259deab/fs/devfs/device.cc#L104-L148. Yeah, in theory, we could have added this logic to scripts/imgedit.py which manipulates the partition table of a disk. > > By the way, you could have the script (or Makefile) create it with a > command instead of having it pre-exist, for example: > python -c 'import sys; sys.stdout.buffer.write(b"\0"*510+b"\x55\xaa")' > To make it easier for somebody to later change these bytes - but I don't > know if that would ever be needed. > > >> Signed-off-by: Waldemar Kozaczuk <[email protected]> >> >> --- >> diff --git a/scripts/build b/scripts/build >> --- a/scripts/build >> +++ b/scripts/build >> @@ -266,7 +266,7 @@ fi >> >> if [[ ${vars[create_disk]} == "true" ]]; then >> partition_offset=512 >> - bare=boot.bin >> + bare="$SRC"/scripts/disk.bin >> raw_disk=disk >> qcow2_disk=disk >> upload_kernel_mode="-k" >> diff --git a/scripts/disk.bin b/scripts/disk.bin >> --- a/scripts/disk.bin >> +++ b/scripts/disk.bin >> null >> >> -- >> You received this message because you are subscribed to the Google Groups >> "OSv Development" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/osv-dev/000000000000a1ab8005a9d1242a%40google.com >> . >> > -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/500f3e49-7535-4f1c-9d46-2a5465e9c407n%40googlegroups.com.
