From 3f687b627a643a4f3f78013a4ae8dd8688c7b12b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 8 Mar 2005 12:29:09 +0000 Subject: [PATCH] mkbfs now also writes a standard boot block to disk (works for images only). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11617 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/bfs/mkbfs/mkbfs.cpp | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/tests/add-ons/kernel/file_systems/bfs/mkbfs/mkbfs.cpp b/src/tests/add-ons/kernel/file_systems/bfs/mkbfs/mkbfs.cpp index 280e00277e..5f325393cb 100644 --- a/src/tests/add-ons/kernel/file_systems/bfs/mkbfs/mkbfs.cpp +++ b/src/tests/add-ons/kernel/file_systems/bfs/mkbfs/mkbfs.cpp @@ -1,11 +1,12 @@ -/* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ +/* + * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ #include "Volume.h" +#include "boot_block.h" #include "compat.h" #include "kprotos.h" @@ -34,10 +35,10 @@ struct nspace { fsystem *fs; vnlist vnodes; void *data; - vnode * root; - vnode * mount; - nspace * prev; - nspace * next; + vnode *root; + vnode *mount; + nspace *prev; + nspace *next; char shutdown; }; @@ -156,6 +157,27 @@ main(int argc, char **argv) } shutdown_block_cache(); + + // make the disk image bootable + + int device = open(deviceName, O_RDWR); + if (device < 0) { + fprintf(stderr, "%s: Could not make image bootable: %s\n", programName, strerror(errno)); + return -1; + } + + // change BIOS drive and partition offset + // ToDo: for now, this will only work for images only + + sBootBlockData1[kBIOSDriveOffset] = 0x80; + // for now, this should be replaced by the real thing + uint32 *offset = (uint32 *)&sBootBlockData1[kPartitionDataOffset]; + *offset = 0; + + write_pos(device, 0, sBootBlockData1, kBootBlockData1Size); + write_pos(device, kBootBlockData2Offset, sBootBlockData2, kBootBlockData2Size); + + close(device); sync(); return 0;