Implemented KDiskSystem. Should be almost complete.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3461 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2003-06-10 22:36:31 +00:00
parent 29a37d780d
commit f254d01839
2 changed files with 407 additions and 7 deletions

View File

@ -12,22 +12,23 @@ class KDiskDeviceJob;
class KPartition; class KPartition;
class KDiskSystem { class KDiskSystem {
public:
KDiskSystem(const char *name); KDiskSystem(const char *name);
virtual ~KDiskSystem(); virtual ~KDiskSystem();
void SetID(disk_system_id id); void SetID(disk_system_id id);
disk_system_id ID() const; disk_system_id ID() const;
const char *Name() const; const char *Name() const;
// We might want to introduce another name -- a more user friendly one. virtual const char *PrettyName();
// This one is the name of the partition module/FS add-on, e.g. // TODO: Add an Init(), make PrettyName() non-virtual and add a
// "intel/extended", "bfs". // protected setter.
virtual bool IsFileSystem() const; virtual bool IsFileSystem() const;
bool IsPartitioningSystem() const; bool IsPartitioningSystem() const;
virtual status_t Load(); // load/unload -- can be nested status_t Load(); // load/unload -- can be nested
virtual status_t Unload(); // void Unload(); //
virtual bool IsLoaded() const; bool IsLoaded() const;
// Scanning // Scanning
// Device must be write locked. // Device must be write locked.
@ -89,7 +90,6 @@ class KDiskSystem {
KDiskDeviceJob *job, KDiskDeviceJob *job,
KPartition **child = NULL, KPartition **child = NULL,
partition_id childID = -1); partition_id childID = -1);
// optional childID parameter or allow setting the ID later?
virtual status_t DeleteChild(KPartition *child, KDiskDeviceJob *job); virtual status_t DeleteChild(KPartition *child, KDiskDeviceJob *job);
virtual status_t Initialize(KPartition *partition, const char *parameters, virtual status_t Initialize(KPartition *partition, const char *parameters,
KDiskDeviceJob *job); KDiskDeviceJob *job);
@ -103,6 +103,15 @@ class KDiskSystem {
// since the device will not be locked, when they are called. The KPartition // since the device will not be locked, when they are called. The KPartition
// is registered though, so that it is at least guaranteed that the object // is registered though, so that it is at least guaranteed that the object
// won't go away. // won't go away.
protected:
virtual status_t LoadModule();
virtual void UnloadModule();
private:
disk_system_id fID;
char *fName;
int32 fLoadCounter;
}; };
} // namespace DiskDevice } // namespace DiskDevice

View File

@ -1,3 +1,394 @@
// KDiskSystem.cpp // KDiskSystem.cpp
#include <stdlib.h>
#include "KDiskDeviceUtils.h"
#include "KDiskSystem.h" #include "KDiskSystem.h"
// constructor
KDiskSystem::KDiskSystem(const char *name)
: fID(-1),
fName(NULL),
fLoadCounter(0)
{
}
// destructor
KDiskSystem::~KDiskSystem()
{
free(fName);
}
// SetID
void
KDiskSystem::SetID(disk_system_id id)
{
fID = id;
}
// ID
disk_system_id
KDiskSystem::ID() const
{
return fID;
}
// Name
const char *
KDiskSystem::Name() const
{
return fName;
}
// PrettyName
const char *
KDiskSystem::PrettyName()
{
// to be implemented by derived classes
return NULL;
}
// IsFileSystem
bool
KDiskSystem::IsFileSystem() const
{
// to be implemented by derived classes
return false;
}
// IsPartitioningSystem
bool
KDiskSystem::IsPartitioningSystem() const
{
return !IsFileSystem();
}
// Load
status_t
KDiskSystem::Load()
{
status_t error = B_OK;
if (fLoadCounter == 0)
error = LoadModule();
if (error == B_OK)
fLoadCounter++;
return error;
}
// Unload
void
KDiskSystem::Unload()
{
if (fLoadCounter > 0 && --fLoadCounter == 0)
UnloadModule();
}
// IsLoaded
bool
KDiskSystem::IsLoaded() const
{
return (fLoadCounter > 0);
}
// Identify
float
KDiskSystem::Identify(KPartition *partition, void **cookie)
{
// to be implemented by derived classes
return -1;
}
// Scan
status_t
KDiskSystem::Scan(KPartition *partition, void *cookie)
{
// to be implemented by derived classes
return B_ERROR;
}
// FreeIdentifyCookie
void
KDiskSystem::FreeIdentifyCookie(KPartition *partition, void *cookie)
{
// to be implemented by derived classes
}
// FreeCookie
void
KDiskSystem::FreeCookie(KPartition *partition)
{
// to be implemented by derived classes
}
// FreeContentCookie
void
KDiskSystem::FreeContentCookie(KPartition *partition)
{
// to be implemented by derived classes
}
// SupportsDefragmenting
bool
KDiskSystem::SupportsDefragmenting(KPartition *partition, bool *whileMounted)
{
// to be implemented by derived classes
if (whileMounted)
*whileMounted = false;
return false;
}
// SupportsRepairing
bool
KDiskSystem::SupportsRepairing(KPartition *partition, bool checkOnly,
bool *whileMounted)
{
// to be implemented by derived classes
if (whileMounted)
*whileMounted = false;
return false;
}
// SupportsResizing
bool
KDiskSystem::SupportsResizing(KPartition *partition, bool *whileMounted)
{
// to be implemented by derived classes
if (whileMounted)
*whileMounted = false;
return false;
}
// SupportsResizingChild
bool
KDiskSystem::SupportsResizingChild(KPartition *child)
{
// to be implemented by derived classes
return false;
}
// SupportsMoving
bool
KDiskSystem::SupportsMoving(KPartition *partition, bool *whileMounted)
{
// to be implemented by derived classes
return false;
}
// SupportsMovingChild
bool
KDiskSystem::SupportsMovingChild(KPartition *child)
{
// to be implemented by derived classes
return false;
}
// SupportsParentSystem
bool
KDiskSystem::SupportsParentSystem(KDiskSystem *system)
{
// to be implemented by derived classes
return false;
}
// SupportsChildSystem
bool
KDiskSystem::SupportsChildSystem(KDiskSystem *system)
{
// to be implemented by derived classes
return false;
}
// ValidateResize
bool
KDiskSystem::ValidateResize(KPartition *partition, off_t *size)
{
// to be implemented by derived classes
return false;
}
// ValidateMove
bool
KDiskSystem::ValidateMove(KPartition *partition, off_t *start)
{
// to be implemented by derived classes
return false;
}
// ValidateResizeChild
bool
KDiskSystem::ValidateResizeChild(KPartition *partition, off_t *size)
{
// to be implemented by derived classes
return false;
}
// ValidateMoveChild
bool
KDiskSystem::ValidateMoveChild(KPartition *partition, off_t *start)
{
// to be implemented by derived classes
return false;
}
// ValidateCreateChild
bool
KDiskSystem::ValidateCreateChild(KPartition *partition, off_t *start,
off_t *size, const char *parameters)
{
// to be implemented by derived classes
return false;
}
// ValidateInitialize
bool
KDiskSystem::ValidateInitialize(KPartition *partition, const char *parameters)
{
// to be implemented by derived classes
return false;
}
// ValidateSetParameters
bool
KDiskSystem::ValidateSetParameters(KPartition *partition,
const char *parameters)
{
// to be implemented by derived classes
return false;
}
// ValidateSetContentParameters
bool
KDiskSystem::ValidateSetContentParameters(KPartition *child,
const char *parameters)
{
// to be implemented by derived classes
return false;
}
// CountPartitionableSpaces
int32
KDiskSystem::CountPartitionableSpaces(KPartition *partition)
{
// to be implemented by derived classes
return 0;
}
// GetPartitionableSpaces
bool
KDiskSystem::GetPartitionableSpaces(KPartition *partition,
partitionable_space_data *spaces,
int32 count, int32 *actualCount)
{
// to be implemented by derived classes
return false;
}
// Defragment
status_t
KDiskSystem::Defragment(KPartition *partition, KDiskDeviceJob *job)
{
// to be implemented by derived classes
return B_ERROR;
}
// Repair
status_t
KDiskSystem::Repair(KPartition *partition, bool checkOnly,
KDiskDeviceJob *job)
{
// to be implemented by derived classes
return B_ERROR;
}
// Resize
status_t
KDiskSystem::Resize(KPartition *partition, off_t size, KDiskDeviceJob *job)
{
// to be implemented by derived classes
return B_ERROR;
}
// ResizeChild
status_t
KDiskSystem::ResizeChild(KPartition *child, off_t size, KDiskDeviceJob *job)
{
// to be implemented by derived classes
return B_ERROR;
}
// Move
status_t
KDiskSystem::Move(KPartition *partition, off_t offset, KDiskDeviceJob *job)
{
// to be implemented by derived classes
return B_ERROR;
}
// MoveChild
status_t
KDiskSystem::MoveChild(KPartition *child, off_t offset, KDiskDeviceJob *job)
{
// to be implemented by derived classes
return B_ERROR;
}
// CreateChild
status_t
KDiskSystem::CreateChild(KPartition *partition, off_t offset, off_t size,
const char *parameters, KDiskDeviceJob *job,
KPartition **child, partition_id childID)
{
// to be implemented by derived classes
return B_ERROR;
}
// DeleteChild
status_t
KDiskSystem::DeleteChild(KPartition *child, KDiskDeviceJob *job)
{
// to be implemented by derived classes
return B_ERROR;
}
// Initialize
status_t
KDiskSystem::Initialize(KPartition *partition, const char *parameters,
KDiskDeviceJob *job)
{
// to be implemented by derived classes
return B_ERROR;
}
// SetParameters
status_t
KDiskSystem::SetParameters(KPartition *partition, const char *parameters,
KDiskDeviceJob *job)
{
// to be implemented by derived classes
return B_ERROR;
}
// SetContentParameters
status_t
KDiskSystem::SetContentParameters(KPartition *partition,
const char *parameters, KDiskDeviceJob *job)
{
// to be implemented by derived classes
return B_ERROR;
}
// LoadModule
status_t
KDiskSystem::LoadModule()
{
// to be implemented by derived classes
return B_ERROR;
}
// UnloadModule
void
KDiskSystem::UnloadModule()
{
// to be implemented by derived classes
}