First draft of the userland disk system add-on interface. A good deal of
functionality of the kernel add-ons will be moved into userland, which will simplify the kernel-side significantly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22481 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0b7582a306
commit
98b97f9603
121
headers/private/storage/DiskSystemAddOn.h
Normal file
121
headers/private/storage/DiskSystemAddOn.h
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright 2007, Ingo Weinhold, bonefish@users.sf.net.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _DISK_SYSTEM_ADD_ON_H
|
||||
#define _DISK_SYSTEM_ADD_ON_H
|
||||
|
||||
#include <String.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
class BList;
|
||||
class BMutablePartition;
|
||||
class BPartitionHandle;
|
||||
class BPartitioningInfo;
|
||||
|
||||
|
||||
class BDiskSystemAddOn {
|
||||
public:
|
||||
BDiskSystemAddOn(const char* name,
|
||||
uint32 flags);
|
||||
virtual ~BDiskSystemAddOn();
|
||||
|
||||
const char* Name() const;
|
||||
uint32 Flags() const;
|
||||
|
||||
virtual status_t CreatePartitionHandle(
|
||||
BMutablePartition* partition,
|
||||
BPartitionHandle** handle) = 0;
|
||||
|
||||
virtual bool CanInitialize(BMutablePartition* partition);
|
||||
virtual bool ValidateInitialize(BMutablePartition* partition,
|
||||
BString* name, const char* parameters);
|
||||
virtual status_t Initialize(BMutablePartition* partition,
|
||||
const char* name, const char* parameters,
|
||||
BPartitionHandle** handle);
|
||||
|
||||
private:
|
||||
BString fName;
|
||||
uint32 fFlags;
|
||||
};
|
||||
|
||||
|
||||
class BPartitionHandle {
|
||||
public:
|
||||
BPartitionHandle(BMutablePartition* partition);
|
||||
virtual ~BPartitionHandle();
|
||||
|
||||
BMutablePartition* Partition() const;
|
||||
|
||||
virtual uint32 SupportedOperations(uint32 mask);
|
||||
virtual uint32 SupportedChildOperations(
|
||||
BMutablePartition* child, uint32 mask);
|
||||
|
||||
virtual bool SupportsInitializingChild(
|
||||
BMutablePartition* child,
|
||||
const char* diskSystem);
|
||||
virtual bool IsSubSystemFor(BMutablePartition* child);
|
||||
|
||||
virtual status_t GetNextSupportedType(BMutablePartition* child,
|
||||
int32* cookie, BString* type);
|
||||
// child can be NULL
|
||||
virtual status_t GetTypeForContentType(const char* contentType,
|
||||
BString* type);
|
||||
|
||||
virtual status_t GetPartitioningInfo(BPartitioningInfo* info);
|
||||
|
||||
|
||||
virtual status_t Repair(bool checkOnly);
|
||||
// TODO: How is this supposed to work?
|
||||
|
||||
virtual bool ValidateResize(off_t* size);
|
||||
virtual bool ValidateResizeChild(BMutablePartition* child,
|
||||
off_t* size);
|
||||
virtual status_t Resize(off_t size);
|
||||
virtual status_t ResizeChild(BMutablePartition* child,
|
||||
off_t size);
|
||||
|
||||
virtual bool ValidateMove(off_t* offset);
|
||||
virtual bool ValidateMoveChild(BMutablePartition* child,
|
||||
off_t* offset);
|
||||
virtual status_t Move(off_t offset);
|
||||
virtual status_t MoveChild(BMutablePartition* child,
|
||||
off_t offset);
|
||||
|
||||
virtual bool ValidateSetContentName(BString* name);
|
||||
virtual bool ValidateSetName(BMutablePartition* child,
|
||||
BString* name);
|
||||
virtual status_t SetContentName(const char* name);
|
||||
virtual status_t SetName(BMutablePartition* child,
|
||||
const char* name);
|
||||
|
||||
virtual bool ValidateSetType(BMutablePartition* child,
|
||||
const char* type);
|
||||
virtual status_t SetType(BMutablePartition* child,
|
||||
const char* type);
|
||||
|
||||
virtual bool ValidateSetContentParameters(
|
||||
const char* parameters);
|
||||
virtual bool ValidateSetParameters(BMutablePartition* child,
|
||||
const char* parameters);
|
||||
virtual status_t SetContentParameters(const char* parameters);
|
||||
virtual status_t SetParameters(BMutablePartition* child,
|
||||
const char* parameters);
|
||||
|
||||
virtual bool ValidateCreateChild(off_t* offset,
|
||||
off_t* size, const char* type,
|
||||
const char* parameters);
|
||||
virtual status_t CreateChild(BMutablePartition* child);
|
||||
|
||||
virtual status_t DeleteChild(BMutablePartition* child);
|
||||
|
||||
private:
|
||||
BMutablePartition* fPartition;
|
||||
};
|
||||
|
||||
|
||||
extern "C" status_t get_disk_system_add_ons(BList* addOns);
|
||||
// Implemented in the add-on
|
||||
|
||||
#endif // _DISK_SYSTEM_ADD_ON_H
|
333
src/kits/storage/DiskSystemAddOn.cpp
Normal file
333
src/kits/storage/DiskSystemAddOn.cpp
Normal file
@ -0,0 +1,333 @@
|
||||
/*
|
||||
* Copyright 2007, Ingo Weinhold, bonefish@users.sf.net.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <DiskSystemAddOn.h>
|
||||
|
||||
#include <Errors.h>
|
||||
|
||||
|
||||
// #pragma mark - BDiskSystemAddOn
|
||||
|
||||
|
||||
// constructor
|
||||
BDiskSystemAddOn::BDiskSystemAddOn(const char* name, uint32 flags)
|
||||
: fName(name),
|
||||
fFlags(flags)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// destructor
|
||||
BDiskSystemAddOn::~BDiskSystemAddOn()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Name
|
||||
const char*
|
||||
BDiskSystemAddOn::Name() const
|
||||
{
|
||||
return fName.String();
|
||||
}
|
||||
|
||||
|
||||
// Flags
|
||||
uint32
|
||||
BDiskSystemAddOn::Flags() const
|
||||
{
|
||||
return fFlags;
|
||||
}
|
||||
|
||||
|
||||
// CanInitialize
|
||||
bool
|
||||
BDiskSystemAddOn::CanInitialize(BMutablePartition* partition)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ValidateInitialize
|
||||
bool
|
||||
BDiskSystemAddOn::ValidateInitialize(BMutablePartition* partition,
|
||||
BString* name, const char* parameters)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Initialize
|
||||
status_t
|
||||
BDiskSystemAddOn::Initialize(BMutablePartition* partition, const char* name,
|
||||
const char* parameters, BPartitionHandle** handle)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BPartitionHandle
|
||||
|
||||
|
||||
// constructor
|
||||
BPartitionHandle::BPartitionHandle(BMutablePartition* partition)
|
||||
: fPartition(partition)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// destructor
|
||||
BPartitionHandle::~BPartitionHandle()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Partition
|
||||
BMutablePartition*
|
||||
BPartitionHandle::Partition() const
|
||||
{
|
||||
return fPartition;
|
||||
}
|
||||
|
||||
|
||||
// SupportedOperations
|
||||
uint32
|
||||
BPartitionHandle::SupportedOperations(uint32 mask)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// SupportedChildOperations
|
||||
uint32
|
||||
BPartitionHandle::SupportedChildOperations(BMutablePartition* child,
|
||||
uint32 mask)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// SupportsInitializingChild
|
||||
bool
|
||||
BPartitionHandle::SupportsInitializingChild(BMutablePartition* child,
|
||||
const char* diskSystem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// IsSubSystemFor
|
||||
bool
|
||||
BPartitionHandle::IsSubSystemFor(BMutablePartition* child)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// GetNextSupportedType
|
||||
status_t
|
||||
BPartitionHandle::GetNextSupportedType(BMutablePartition* child, int32* cookie,
|
||||
BString* type)
|
||||
{
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
// GetTypeForContentType
|
||||
status_t
|
||||
BPartitionHandle::GetTypeForContentType(const char* contentType, BString* type)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// GetPartitioningInfo
|
||||
status_t
|
||||
BPartitionHandle::GetPartitioningInfo(BPartitioningInfo* info)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// Repair
|
||||
status_t
|
||||
BPartitionHandle::Repair(bool checkOnly)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// ValidateResize
|
||||
bool
|
||||
BPartitionHandle::ValidateResize(off_t* size)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ValidateResizeChild
|
||||
bool
|
||||
BPartitionHandle::ValidateResizeChild(BMutablePartition* child, off_t* size)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Resize
|
||||
status_t
|
||||
BPartitionHandle::Resize(off_t size)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// ResizeChild
|
||||
status_t
|
||||
BPartitionHandle::ResizeChild(BMutablePartition* child, off_t size)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// ValidateMove
|
||||
bool
|
||||
BPartitionHandle::ValidateMove(off_t* offset)
|
||||
{
|
||||
// Usually moving a disk system is a no-op for the content disk system,
|
||||
// so we default to true here.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ValidateMoveChild
|
||||
bool
|
||||
BPartitionHandle::ValidateMoveChild(BMutablePartition* child, off_t* offset)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Move
|
||||
status_t
|
||||
BPartitionHandle::Move(off_t offset)
|
||||
{
|
||||
// Usually moving a disk system is a no-op for the content disk system,
|
||||
// so we default to OK here.
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// MoveChild
|
||||
status_t
|
||||
BPartitionHandle::MoveChild(BMutablePartition* child, off_t offset)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// ValidateSetContentName
|
||||
bool
|
||||
BPartitionHandle::ValidateSetContentName(BString* name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ValidateSetName
|
||||
bool
|
||||
BPartitionHandle::ValidateSetName(BMutablePartition* child, BString* name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// SetContentName
|
||||
status_t
|
||||
BPartitionHandle::SetContentName(const char* name)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// SetName
|
||||
status_t
|
||||
BPartitionHandle::SetName(BMutablePartition* child, const char* name)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// ValidateSetType
|
||||
bool
|
||||
BPartitionHandle::ValidateSetType(BMutablePartition* child, const char* type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// SetType
|
||||
status_t
|
||||
BPartitionHandle::SetType(BMutablePartition* child, const char* type)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// ValidateSetContentParameters
|
||||
bool
|
||||
BPartitionHandle::ValidateSetContentParameters(const char* parameters)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ValidateSetParameters
|
||||
bool
|
||||
BPartitionHandle::ValidateSetParameters(BMutablePartition* child,
|
||||
const char* parameters)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// SetContentParameters
|
||||
status_t
|
||||
BPartitionHandle::SetContentParameters(const char* parameters)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// SetParameters
|
||||
status_t
|
||||
BPartitionHandle::SetParameters(BMutablePartition* child,
|
||||
const char* parameters)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// ValidateCreateChild
|
||||
bool
|
||||
BPartitionHandle::ValidateCreateChild(off_t* offset, off_t* size,
|
||||
const char* type, const char* parameters)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// CreateChild
|
||||
status_t
|
||||
BPartitionHandle::CreateChild(BMutablePartition* child)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
// DeleteChild
|
||||
status_t
|
||||
BPartitionHandle::DeleteChild(BMutablePartition* child)
|
||||
{
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
@ -78,6 +78,7 @@ MergeObject <libbe>storage_kit.o :
|
||||
DiskDeviceTypes.cpp
|
||||
DiskDeviceVisitor.cpp
|
||||
DiskSystem.cpp
|
||||
DiskSystemAddOn.cpp
|
||||
Partition.cpp
|
||||
PartitioningInfo.cpp
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user