diff --git a/src/add-ons/kernel/file_systems/bfs/CachedBlock.h b/src/add-ons/kernel/file_systems/bfs/CachedBlock.h index 77d3cb2ce7..adff9ec4e2 100644 --- a/src/add-ons/kernel/file_systems/bfs/CachedBlock.h +++ b/src/add-ons/kernel/file_systems/bfs/CachedBlock.h @@ -1,11 +1,12 @@ -/* CachedBlock - interface for the block cache - * - * Copyright 2001-2004, Axel Dörfler, axeld@pinc-software.de. +/* + * Copyright 2001-2007, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ #ifndef CACHED_BLOCK_H #define CACHED_BLOCK_H +//! interface for the block cache + #include "system_dependencies.h" @@ -35,9 +36,12 @@ class CachedBlock { inline const uint8 *SetTo(off_t block, off_t base, size_t length); inline const uint8 *SetTo(off_t block); inline const uint8 *SetTo(block_run run); - inline uint8 *SetToWritable(Transaction &transaction, off_t block, off_t base, size_t length, bool empty = false); - inline uint8 *SetToWritable(Transaction &transaction, off_t block, bool empty = false); - inline uint8 *SetToWritable(Transaction &transaction, block_run run, bool empty = false); + inline uint8 *SetToWritable(Transaction &transaction, off_t block, + off_t base, size_t length, bool empty = false); + inline uint8 *SetToWritable(Transaction &transaction, off_t block, + bool empty = false); + inline uint8 *SetToWritable(Transaction &transaction, block_run run, + bool empty = false); inline status_t MakeWritable(Transaction &transaction); const uint8 *Block() const { return fBlock; } @@ -57,7 +61,6 @@ class CachedBlock { }; -//-------------------------------------- // inlines @@ -121,8 +124,10 @@ CachedBlock::Keep() inline void CachedBlock::Unset() { - if (fBlock != NULL) + if (fBlock != NULL) { block_cache_put(fVolume->BlockCache(), fBlockNumber); + fBlock = NULL; + } } @@ -131,7 +136,8 @@ CachedBlock::SetTo(off_t block, off_t base, size_t length) { Unset(); fBlockNumber = block; - return fBlock = (uint8 *)block_cache_get_etc(fVolume->BlockCache(), block, base, length); + return fBlock = (uint8 *)block_cache_get_etc(fVolume->BlockCache(), + block, base, length); } @@ -150,16 +156,21 @@ CachedBlock::SetTo(block_run run) inline uint8 * -CachedBlock::SetToWritable(Transaction &transaction, off_t block, off_t base, size_t length, bool empty) +CachedBlock::SetToWritable(Transaction &transaction, off_t block, off_t base, + size_t length, bool empty) { Unset(); fBlockNumber = block; - if (empty) - return fBlock = (uint8 *)block_cache_get_empty(fVolume->BlockCache(), block, transaction.ID()); + if (empty) { + fBlock = (uint8 *)block_cache_get_empty(fVolume->BlockCache(), + block, transaction.ID()); + } else { + fBlock = (uint8 *)block_cache_get_writable_etc(fVolume->BlockCache(), + block, base, length, transaction.ID()); + } - return fBlock = (uint8 *)block_cache_get_writable_etc(fVolume->BlockCache(), - block, base, length, transaction.ID()); + return fBlock; } @@ -183,7 +194,8 @@ CachedBlock::MakeWritable(Transaction &transaction) if (fBlock == NULL) return B_NO_INIT; - return block_cache_make_writable(fVolume->BlockCache(), fBlockNumber, transaction.ID()); + return block_cache_make_writable(fVolume->BlockCache(), fBlockNumber, + transaction.ID()); } diff --git a/src/add-ons/kernel/file_systems/bfs/Lock.h b/src/add-ons/kernel/file_systems/bfs/Lock.h index eec8830683..ec5180c188 100644 --- a/src/add-ons/kernel/file_systems/bfs/Lock.h +++ b/src/add-ons/kernel/file_systems/bfs/Lock.h @@ -1,5 +1,4 @@ /* - * * Copyright 2001-2007, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ diff --git a/src/add-ons/kernel/file_systems/bfs/system_dependencies.h b/src/add-ons/kernel/file_systems/bfs/system_dependencies.h index 393993dc39..32863421ea 100644 --- a/src/add-ons/kernel/file_systems/bfs/system_dependencies.h +++ b/src/add-ons/kernel/file_systems/bfs/system_dependencies.h @@ -2,7 +2,6 @@ * Copyright 2007, Ingo Weinhold, bonefish@cs.tu-berlin.de. * Distributed under the terms of the MIT License. */ - #ifndef _SYSTEM_DEPENDENCIES_H #define _SYSTEM_DEPENDENCIES_H @@ -13,6 +12,28 @@ #else // !BFS_SHELL +#include +#include +#include + +#include + +#ifndef _BOOT_MODE +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +#endif // _BOOT_MODE + #include #include #include @@ -22,28 +43,6 @@ #include #include -#include - -#ifndef _BOOT_MODE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif // _BOOT_MODE - -#include -#include -#include - #endif // !BFS_SHELL