boot loader: Almost removed use of kernel_cpp.h.

* For some reason that is beyond me, fat/CachedBlock.cpp needs this header,
  or else building the boot loader fails.
This commit is contained in:
Axel Dörfler
2013-05-11 19:34:22 +02:00
parent c3e68d8d92
commit 4b723e3fb8
24 changed files with 110 additions and 126 deletions
+10 -11
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2006, Axel Dörfler, [email protected]. All rights reserved.
* Copyright 2003-2013, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
@@ -7,7 +7,6 @@
#include "RootFileSystem.h"
#include <OS.h>
#include <util/kernel_cpp.h>
#include <string.h>
#include <fcntl.h>
@@ -29,7 +28,7 @@ RootFileSystem::~RootFileSystem()
}
status_t
status_t
RootFileSystem::Open(void **_cookie, int mode)
{
EntryIterator *iterator = new (std::nothrow) EntryIterator(&fList);
@@ -42,7 +41,7 @@ RootFileSystem::Open(void **_cookie, int mode)
}
status_t
status_t
RootFileSystem::Close(void *cookie)
{
delete (EntryIterator *)cookie;
@@ -84,7 +83,7 @@ RootFileSystem::Lookup(const char *name, bool /*traverseLinks*/)
}
status_t
status_t
RootFileSystem::GetNextEntry(void *_cookie, char *name, size_t size)
{
EntryIterator *iterator = (EntryIterator *)_cookie;
@@ -98,7 +97,7 @@ RootFileSystem::GetNextEntry(void *_cookie, char *name, size_t size)
}
status_t
status_t
RootFileSystem::GetNextNode(void *_cookie, Node **_node)
{
EntryIterator *iterator = (EntryIterator *)_cookie;
@@ -113,24 +112,24 @@ RootFileSystem::GetNextNode(void *_cookie, Node **_node)
}
status_t
status_t
RootFileSystem::Rewind(void *_cookie)
{
EntryIterator *iterator = (EntryIterator *)_cookie;
iterator->Rewind();
return B_OK;
return B_OK;
}
bool
bool
RootFileSystem::IsEmpty()
{
return fList.IsEmpty();
}
status_t
status_t
RootFileSystem::AddVolume(Directory *volume, Partition *partition)
{
struct entry *entry = new (std::nothrow) RootFileSystem::entry();
@@ -165,7 +164,7 @@ RootFileSystem::AddLink(const char *name, Directory *target)
}
status_t
status_t
RootFileSystem::GetPartitionFor(Directory *volume, Partition **_partition)
{
EntryIterator iterator = fList.GetIterator();
@@ -1,7 +1,7 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2003-2013, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "Directory.h"
@@ -9,7 +9,6 @@
#include "File.h"
#include <StorageDefs.h>
#include <util/kernel_cpp.h>
#include <string.h>
#include <unistd.h>
@@ -18,6 +17,7 @@
namespace FFS {
Directory::Directory(Volume &volume, int32 block)
:
fVolume(volume)
@@ -45,14 +45,14 @@ Directory::~Directory()
}
status_t
status_t
Directory::InitCheck()
{
return fNode.ValidateCheckSum();
}
status_t
status_t
Directory::Open(void **_cookie, int mode)
{
_inherited::Open(_cookie, mode);
@@ -71,7 +71,7 @@ Directory::Open(void **_cookie, int mode)
}
status_t
status_t
Directory::Close(void *cookie)
{
_inherited::Close(cookie);
@@ -113,7 +113,7 @@ Directory::Lookup(const char *name, bool traverseLinks)
}
status_t
status_t
Directory::GetNextEntry(void *cookie, char *name, size_t size)
{
HashIterator *iterator = (HashIterator *)cookie;
@@ -127,7 +127,7 @@ Directory::GetNextEntry(void *cookie, char *name, size_t size)
}
status_t
status_t
Directory::GetNextNode(void *cookie, Node **_node)
{
return B_ERROR;
@@ -165,4 +165,5 @@ Directory::Inode() const
return fNode.HeaderKey();
}
} // namespace FFS
@@ -1,7 +1,7 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2003-2013, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "File.h"
@@ -10,11 +10,10 @@
#include <sys/stat.h>
#include <unistd.h>
#include <util/kernel_cpp.h>
namespace FFS {
class Stream {
public:
Stream(int device, FileBlock &node);
@@ -255,4 +254,5 @@ File::Inode() const
return fNode.HeaderKey();
}
} // namespace FFS
@@ -1,7 +1,7 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2003-2013, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "Volume.h"
@@ -9,7 +9,6 @@
#include <boot/partitions.h>
#include <boot/platform.h>
#include <util/kernel_cpp.h>
#include <string.h>
#include <unistd.h>
@@ -87,7 +86,7 @@ Volume::~Volume()
}
status_t
status_t
Volume::InitCheck()
{
if (fRoot != NULL)
@@ -1,14 +1,13 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2003-2013, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "amiga_ffs.h"
#include <boot/partitions.h>
#include <boot/platform.h>
#include <util/kernel_cpp.h>
#include <string.h>
#include <unistd.h>
@@ -31,7 +30,7 @@ class BCPLString {
};
int32
int32
BCPLString::CopyTo(char *name, size_t size)
{
int32 length = size - 1 > Length() ? Length() : size - 1;
@@ -56,7 +55,7 @@ BaseBlock::GetNameBackOffset(int32 offset, char *name, size_t size) const
}
status_t
status_t
BaseBlock::ValidateCheckSum() const
{
if (fData == NULL)
@@ -74,7 +73,7 @@ BaseBlock::ValidateCheckSum() const
// #pragma mark -
char
char
DirectoryBlock::ToUpperChar(int32 type, char c) const
{
// Taken from Ralph Babel's "The Amiga Guru Book" (1993), section 15.3.4.3
@@ -87,11 +86,11 @@ DirectoryBlock::ToUpperChar(int32 type, char c) const
}
int32
int32
DirectoryBlock::HashIndexFor(int32 type, const char *name) const
{
int32 hash = strlen(name);
while (name[0]) {
hash = (hash * 13 + ToUpperChar(type, name[0])) & 0x7ff;
name++;
@@ -101,7 +100,7 @@ DirectoryBlock::HashIndexFor(int32 type, const char *name) const
}
int32
int32
DirectoryBlock::HashValueAt(int32 index) const
{
return index >= HashSize() ? -1 : (int32)B_BENDIAN_TO_HOST_INT32(HashTable()[index]);
@@ -116,11 +115,11 @@ DirectoryBlock::FirstHashValue(int32 &index) const
}
int32
int32
DirectoryBlock::NextHashValue(int32 &index) const
{
index++;
int32 value;
while ((value = HashValueAt(index)) == 0) {
if (++index >= HashSize())
@@ -152,14 +151,14 @@ HashIterator::~HashIterator()
}
status_t
status_t
HashIterator::InitCheck()
{
return fData != NULL ? B_OK : B_NO_MEMORY;
}
void
void
HashIterator::Goto(int32 index)
{
fCurrent = index;
@@ -197,7 +196,7 @@ HashIterator::GetNext(int32 &block)
}
void
void
HashIterator::Rewind()
{
fCurrent = 0;
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2010, Axel Dörfler, [email protected].
* Copyright 2003-2013, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
@@ -10,7 +10,6 @@
#include <StorageDefs.h>
#include <KernelExport.h>
#include <util/kernel_cpp.h>
#include <string.h>
#include <unistd.h>
@@ -52,14 +51,14 @@ Directory::~Directory()
}
status_t
status_t
Directory::InitCheck()
{
return fStream.InitCheck();
}
status_t
status_t
Directory::Open(void **_cookie, int mode)
{
_inherited::Open(_cookie, mode);
@@ -72,7 +71,7 @@ Directory::Open(void **_cookie, int mode)
}
status_t
status_t
Directory::Close(void *cookie)
{
_inherited::Close(cookie);
@@ -118,7 +117,7 @@ Directory::Lookup(const char *name, bool traverseLinks)
}
status_t
status_t
Directory::GetNextEntry(void *cookie, char *name, size_t size)
{
TreeIterator *iterator = (TreeIterator *)cookie;
@@ -129,7 +128,7 @@ Directory::GetNextEntry(void *cookie, char *name, size_t size)
}
status_t
status_t
Directory::GetNextNode(void *cookie, Node **_node)
{
TreeIterator *iterator = (TreeIterator *)cookie;
@@ -149,7 +148,7 @@ Directory::GetNextNode(void *cookie, Node **_node)
}
status_t
status_t
Directory::Rewind(void *cookie)
{
TreeIterator *iterator = (TreeIterator *)cookie;
@@ -158,7 +157,7 @@ Directory::Rewind(void *cookie)
}
bool
bool
Directory::IsEmpty()
{
TreeIterator iterator(&fTree);
@@ -1,16 +1,15 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2003-2013, Axel Dörfler, [email protected].
* This file may be used under the terms of the MIT License.
*/
#include "File.h"
#include <util/kernel_cpp.h>
namespace BFS {
File::File(Volume &volume, block_run run)
:
fStream(volume, run)
@@ -37,14 +36,14 @@ File::~File()
}
status_t
status_t
File::InitCheck()
{
return fStream.InitCheck();
}
ssize_t
ssize_t
File::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize)
{
status_t status = fStream.ReadAt(pos, (uint8 *)buffer, &bufferSize);
@@ -55,7 +54,7 @@ File::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize)
}
ssize_t
ssize_t
File::WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize)
{
return EROFS;
@@ -89,4 +88,5 @@ File::Inode() const
return fStream.ID();
}
} // namespace BFS
@@ -1,16 +1,15 @@
/*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2004-2013, Axel Dörfler, [email protected].
* This file may be used under the terms of the MIT License.
*/
#include "Link.h"
#include <util/kernel_cpp.h>
namespace BFS {
Link::Link(Volume &volume, block_run run)
: File(volume, run)
{
@@ -63,4 +62,5 @@ Link::Type() const
return S_IFLNK;
}
} // namespace BFS
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2010, Axel Dörfler, [email protected].
* Copyright 2003-2013, Axel Dörfler, [email protected].
* This file may be used under the terms of the MIT License.
*/
@@ -12,8 +12,6 @@
#include "File.h"
#include "Link.h"
#include <util/kernel_cpp.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2009, Axel Dörfler, [email protected].
* Copyright 2003-2013, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
@@ -12,7 +12,6 @@
#include <boot/partitions.h>
#include <boot/platform.h>
#include <boot/vfs.h>
#include <util/kernel_cpp.h>
#include "Volume.h"
#include "Directory.h"
@@ -9,16 +9,12 @@
#define CACHED_BLOCK_H
#include <SupportDefs.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
#include "Volume.h"
namespace FATFS {
class CachedBlock {
public:
enum {
@@ -1,7 +1,8 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2003-2013, Axel Dörfler, [email protected].
* Copyright 2008, François Revol <[email protected]>
* Distributed under the terms of the MIT License.
*/
#include "Directory.h"
@@ -14,7 +15,6 @@
#include <new>
#include <StorageDefs.h>
#include <util/kernel_cpp.h>
#include "CachedBlock.h"
#include "File.h"
@@ -24,8 +24,10 @@
//#define TRACE(x) dprintf x
#define TRACE(x) do {} while (0)
namespace FATFS {
struct dir_entry {
void *Buffer() const { return (void *)fName; };
const char *BaseName() const { return fName; };
@@ -328,7 +330,7 @@ Directory::Open(void **_cookie, int mode)
TRACE(("FASFS::Directory::%s(, %d)\n", __FUNCTION__, mode));
_inherited::Open(_cookie, mode);
struct dir_cookie *c = new struct dir_cookie;
dir_cookie *c = new(nothrow) dir_cookie;
if (c == NULL)
return B_NO_MEMORY;
@@ -1,7 +1,8 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2003-2013, Axel Dörfler, [email protected].
* Copyright 2008, François Revol <[email protected]>
* Distributed under the terms of the MIT License.
*/
#include "File.h"
@@ -9,8 +10,6 @@
#include <sys/stat.h>
#include <unistd.h>
#include <util/kernel_cpp.h>
#include "Directory.h"
@@ -137,4 +136,5 @@ File::Inode() const
return fStream.FirstCluster() << 16;
}
} // namespace FATFS
@@ -17,12 +17,12 @@
#include <algorithm>
#include <boot/FileMapDisk.h>
#include <util/kernel_cpp.h>
#include "CachedBlock.h"
#include "Directory.h"
#include "File.h"
//#define TRACE(x) dprintf x
#define TRACE(x) do {} while (0)
@@ -1,7 +1,8 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2003-2013, Axel Dörfler, [email protected].
* Copyright 2008, François Revol <[email protected]>
* Distributed under the terms of the MIT License.
*/
#include "Volume.h"
@@ -10,7 +11,6 @@
#include <boot/partitions.h>
#include <boot/platform.h>
#include <util/kernel_cpp.h>
#include <string.h>
#include <unistd.h>
@@ -18,9 +18,11 @@
#include <stdio.h>
#include <stdlib.h>
//#define TRACE(x) dprintf x
#define TRACE(x) do {} while (0)
using namespace FATFS;
@@ -33,7 +35,7 @@ Volume::Volume(boot::Partition *partition)
if ((fDevice = open_node(partition, O_RDONLY)) < B_OK)
return;
fCachedBlock = new CachedBlock(*this);
fCachedBlock = new(nothrow) CachedBlock(*this);
if (fCachedBlock == NULL)
return;
@@ -135,13 +137,13 @@ Volume::Volume(boot::Partition *partition)
fFatBits = 16;
goto err1;
}
TRACE(("%s: block size %d, sector size %d, sectors/cluster %d\n", __FUNCTION__,
fBlockSize, fBytesPerSector, fSectorsPerCluster));
TRACE(("%s: block shift %d, sector shift %d, cluster shift %d\n", __FUNCTION__,
fBlockShift, fSectorShift, fClusterShift));
TRACE(("%s: reserved %d, max root entries %d, media %02x, sectors/fat %d\n", __FUNCTION__,
fReservedSectors, fMaxRootEntries, fMediaDesc, fSectorsPerFat));
TRACE(("%s: block size %d, sector size %d, sectors/cluster %d\n",
__FUNCTION__, fBlockSize, fBytesPerSector, fSectorsPerCluster));
TRACE(("%s: block shift %d, sector shift %d, cluster shift %d\n",
__FUNCTION__, fBlockShift, fSectorShift, fClusterShift));
TRACE(("%s: reserved %d, max root entries %d, media %02x, sectors/fat %d\n",
__FUNCTION__, fReservedSectors, fMaxRootEntries, fMediaDesc,
fSectorsPerFat));
//if (fTotalSectors > partition->sectors_per_track * partition->cylinder_count * partition->head_count)
if ((off_t)fTotalSectors * fBytesPerSector > partition->size)
@@ -150,7 +152,7 @@ Volume::Volume(boot::Partition *partition)
TRACE(("%s: found fat%d filesystem, root dir at cluster %d\n", __FUNCTION__,
fFatBits, fRootDirCluster));
fRoot = new Directory(*this, 0, fRootDirCluster, "/");
fRoot = new(nothrow) Directory(*this, 0, fRootDirCluster, "/");
return;
err1:
@@ -413,7 +415,7 @@ static status_t
dosfs_get_file_system(boot::Partition *partition, ::Directory **_root)
{
TRACE(("%s()\n", __FUNCTION__));
Volume *volume = new Volume(partition);
Volume *volume = new(nothrow) Volume(partition);
if (volume == NULL)
return B_NO_MEMORY;
@@ -1,14 +1,13 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
* Copyright 2008, François Revol <[email protected]>
* Distributed under the terms of the MIT License.
*/
#include "fatfs.h"
#include <boot/partitions.h>
#include <boot/platform.h>
#include <util/kernel_cpp.h>
#include <string.h>
#include <unistd.h>
@@ -1,5 +1,5 @@
/*
* Copyright 2005, Axel Dörfler, [email protected]. All rights reserved.
* Copyright 2005-2013, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
@@ -8,7 +8,6 @@
#include <boot/partitions.h>
#include <boot/platform.h>
#include <util/kernel_cpp.h>
#include <string.h>
#include <unistd.h>
@@ -1,6 +1,6 @@
/*
* Copyright 2005-2007, Ingo Weinhold, [email protected].
* Copyright 2005-2009, Axel Dörfler, [email protected].
* Copyright 2005-2013, Axel Dörfler, [email protected].
*
* Distributed under the terms of the MIT License.
*/
@@ -21,7 +21,6 @@
#include <boot/partitions.h>
#include <boot/platform.h>
#include <util/kernel_cpp.h>
#include <util/DoublyLinkedList.h>
@@ -39,6 +38,7 @@ static const size_t kTarRegionSize = 8 * 1024 * 1024; // 8 MB
namespace TarFS {
struct RegionDelete {
inline void operator()(void* memory)
{
@@ -813,7 +813,6 @@ TarFS::Volume::_Inflate(boot::Partition* partition, void* cookie, off_t offset,
}
// #pragma mark -
+1 -2
View File
@@ -1,12 +1,11 @@
/*
* Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
#include <boot/heap.h>
#include <boot/platform.h>
#include <util/kernel_cpp.h>
#ifdef HEAP_TEST
# include <stdio.h>
+1 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
@@ -14,8 +14,6 @@
#include <boot/heap.h>
#include <boot/stdio.h>
#include <util/kernel_cpp.h>
//#define TRACE_MAIN
#ifdef TRACE_MAIN
+1 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2010, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2011, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
@@ -21,7 +21,6 @@
#include <boot/platform/generic/text_console.h>
#include <boot/stdio.h>
#include <safemode.h>
#include <util/kernel_cpp.h>
#include <util/ring_buffer.h>
#include "kernel_debug_config.h"
+3 -4
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2008, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
@@ -16,7 +16,6 @@
#include <boot/stdio.h>
#include <boot/vfs.h>
#include <ddm_modules.h>
#include <util/kernel_cpp.h>
#include "RootFileSystem.h"
@@ -212,7 +211,7 @@ Partition::Type() const
Partition *
Partition::AddChild()
{
Partition *child = new Partition(fFD);
Partition *child = new(nothrow) Partition(fFD);
TRACE(("%p Partition::AddChild %p\n", this, child));
if (child == NULL)
return NULL;
@@ -426,7 +425,7 @@ add_partitions_for(int fd, bool mountFileSystems, bool isBootDevice)
TRACE(("add_partitions_for(fd = %d, mountFS = %s)\n", fd,
mountFileSystems ? "yes" : "no"));
Partition *partition = new Partition(fd);
Partition *partition = new(nothrow) Partition(fd);
// set some magic/default values
partition->block_size = 512;
+1 -2
View File
@@ -1,12 +1,11 @@
/*
* Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
#include <boot/vfs.h>
#include <boot/stdio.h>
#include <util/kernel_cpp.h>
#include <errno.h>
#include <stdarg.h>
+1 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2008, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
@@ -18,7 +18,6 @@
#include <boot/partitions.h>
#include <boot/stdio.h>
#include <boot/stage2.h>
#include <util/kernel_cpp.h>
#include <syscall_utils.h>
#include "RootFileSystem.h"