* Changed the way the BFS_IOCTL_UPDATE_BOOT_BLOCK ioctl works; it's a bit

more flexible to use now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28053 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-10-13 21:54:40 +00:00
parent 38bbc95758
commit cfa4660b47
2 changed files with 22 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2001-2007, Axel Dörfler, axeld@pinc-software.de
* Copyright 2001-2008, Axel Dörfler, axeld@pinc-software.de
* This file may be used under the terms of the MIT License.
*/
#ifndef BFS_CONTROL_H
@ -8,7 +8,11 @@
//! additional functionality exported via ioctl()
#include "system_dependencies.h"
#ifdef BFS_SHELL
# include "system_dependencies.h"
#else
# include <SupportDefs.h>
#endif
/* ioctl to check the version of BFS used - parameter is a uint32 *
@ -18,6 +22,12 @@
#define BFS_IOCTL_UPDATE_BOOT_BLOCK 14204
struct update_boot_block {
uint32 offset;
const uint8* data;
uint32 length;
};
/* ioctls to use the "chkbfs" feature from the outside
* all calls use a struct check_result as single parameter
*/

View File

@ -624,9 +624,16 @@ bfs_ioctl(fs_volume* _volume, fs_vnode* _node, void* _cookie, ulong cmd,
{
// let's makebootable (or anyone else) update the boot block
// while BFS is mounted
if (user_memcpy(&volume->SuperBlock().pad_to_block,
(uint8*)buffer + offsetof(disk_super_block, pad_to_block),
sizeof(volume->SuperBlock().pad_to_block)) < B_OK)
update_boot_block update;
if (bufferLength != sizeof(update_boot_block))
return B_BAD_VALUE;
if (user_memcpy(&update, buffer, sizeof(update_boot_block)) != B_OK)
return B_BAD_ADDRESS;
if (update.offset < offsetof(disk_super_block, pad_to_block)
|| update.length + update.offset > 512)
return B_BAD_VALUE;
if (user_memcpy((uint8*)&volume->SuperBlock() + update.offset,
update.data, update.length) != B_OK)
return B_BAD_ADDRESS;
return volume->WriteSuperBlock();