Implemented the scanning functionality.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3604 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2003-06-22 23:03:58 +00:00
parent b22221ad17
commit fcf461b32c
2 changed files with 249 additions and 0 deletions
@@ -8,6 +8,8 @@
#include "KDiskSystem.h"
struct fs_module_info;
namespace BPrivate {
namespace DiskDevice {
@@ -16,6 +18,8 @@ public:
KFileSystem(const char *name);
virtual ~KFileSystem();
virtual status_t Init();
virtual bool IsFileSystem() const;
// Scanning
@@ -60,6 +64,9 @@ public:
protected:
virtual status_t LoadModule();
virtual void UnloadModule();
private:
fs_module_info *fModule;
};
} // namespace DiskDevice
@@ -1,3 +1,245 @@
// KFileSystem.cpp
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include "ddm_modules.h"
#include "KDiskDeviceUtils.h"
#include "KFileSystem.h"
#include "KPartition.h"
// constructor
KFileSystem::KFileSystem(const char *name)
: KDiskSystem(name),
fModule(NULL)
{
}
// destructor
KFileSystem::~KFileSystem()
{
}
// Init
status_t
KFileSystem::Init()
{
status_t error = KDiskSystem::Init();
if (error != B_OK)
return error;
error = Load();
if (error != B_OK)
return error;
error = SetPrettyName(fModule->pretty_name);
Unload();
return error;
}
// IsFileSystem
bool
KFileSystem::IsFileSystem() const
{
return true;
}
// Identify
float
KFileSystem::Identify(KPartition *partition, void **cookie)
{
if (!partition || !cookie || !fModule || !fModule->identify_partition)
return -1;
int fd = -1;
if (partition->Open(O_RDONLY, &fd) != B_OK)
return -1;
float result = fModule->identify_partition(fd, partition->PartitionData(),
cookie);
close(fd);
return result;
}
// Scan
status_t
KFileSystem::Scan(KPartition *partition, void *cookie)
{
if (!partition || !fModule || !fModule->scan_partition)
return B_ERROR;
int fd = -1;
status_t result = partition->Open(O_RDONLY, &fd);
if (result != B_OK)
return result;
result = fModule->scan_partition(fd, partition->PartitionData(), cookie);
close(fd);
return result;
}
// FreeIdentifyCookie
void
KFileSystem::FreeIdentifyCookie(KPartition *partition, void *cookie)
{
if (!partition || !fModule || !fModule->free_identify_partition_cookie)
return;
fModule->free_identify_partition_cookie(partition->PartitionData(),
cookie);
}
// FreeContentCookie
void
KFileSystem::FreeContentCookie(KPartition *partition)
{
if (!partition || !fModule || !fModule->free_partition_content_cookie)
return;
fModule->free_partition_content_cookie(partition->PartitionData());
}
// SupportsDefragmenting
bool
KFileSystem::SupportsDefragmenting(KPartition *partition, bool *whileMounted)
{
// to be implemented
if (whileMounted)
*whileMounted = false;
return false;
}
// SupportsRepairing
bool
KFileSystem::SupportsRepairing(KPartition *partition, bool checkOnly,
bool *whileMounted)
{
// to be implemented
if (whileMounted)
*whileMounted = false;
return false;
}
// SupportsResizing
bool
KFileSystem::SupportsResizing(KPartition *partition, bool *whileMounted)
{
// to be implemented
if (whileMounted)
*whileMounted = false;
return false;
}
// SupportsMoving
bool
KFileSystem::SupportsMoving(KPartition *partition, bool *whileMounted)
{
// to be implemented
if (whileMounted)
*whileMounted = false;
return false;
}
// SupportsParentSystem
bool
KFileSystem::SupportsParentSystem(KDiskSystem *system)
{
// to be implemented
return false;
}
// ValidateResize
bool
KFileSystem::ValidateResize(KPartition *partition, off_t *size)
{
// to be implemented
return false;
}
// ValidateMove
bool
KFileSystem::ValidateMove(KPartition *partition, off_t *start)
{
// to be implemented
return false;
}
// ValidateInitialize
bool
KFileSystem::ValidateInitialize(KPartition *partition, const char *parameters)
{
// to be implemented
return false;
}
// ValidateSetContentParameters
bool
KFileSystem::ValidateSetContentParameters(KPartition *child,
const char *parameters)
{
// to be implemented
return false;
}
// Defragment
status_t
KFileSystem::Defragment(KPartition *partition, KDiskDeviceJob *job)
{
// to be implemented
return B_ERROR;
}
// Repair
status_t
KFileSystem::Repair(KPartition *partition, bool checkOnly, KDiskDeviceJob *job)
{
// to be implemented
return B_ERROR;
}
// Resize
status_t
KFileSystem::Resize(KPartition *partition, off_t size, KDiskDeviceJob *job)
{
// to be implemented
return B_ERROR;
}
// Move
status_t
KFileSystem::Move(KPartition *partition, off_t offset, KDiskDeviceJob *job)
{
// to be implemented
return B_ERROR;
}
// Initialize
status_t
KFileSystem::Initialize(KPartition *partition, const char *parameters,
KDiskDeviceJob *job)
{
// to be implemented
return B_ERROR;
}
// SetContentParameters
status_t
KFileSystem::SetContentParameters(KPartition *partition,
const char *parameters, KDiskDeviceJob *job)
{
// to be implemented
return B_ERROR;
}
// LoadModule
status_t
KFileSystem::LoadModule()
{
if (fModule) // shouldn't happen
return B_OK;
return get_module(Name(), (module_info**)&fModule);
}
// UnloadModule
void
KFileSystem::UnloadModule()
{
if (fModule) {
put_module(fModule->module.name);
fModule = NULL;
}
}