Small changes in the header, and implemented everything needed for scanning.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3480 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1bf21e6a40
commit
ac63679417
@ -9,6 +9,10 @@
|
||||
|
||||
#include <Drivers.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// TODO: These don't belong here. partition_id and disk_job_id are
|
||||
// public (exposed by the userland API), while disk_system_id is at least
|
||||
// known to the userland API, but probably exposed as well, as type of a
|
||||
@ -53,10 +57,10 @@ typedef struct partitionable_space_data {
|
||||
} partitionable_space_data;
|
||||
|
||||
// disk device locking
|
||||
disk_device_data *write_lock_disk_device(partition_id partition);
|
||||
void write_unlock_disk_device(partition_id partition);
|
||||
disk_device_data *read_lock_disk_device(partition_id partition);
|
||||
void read_unlock_disk_device(partition_id partition);
|
||||
disk_device_data *write_lock_disk_device(partition_id partitionID);
|
||||
void write_unlock_disk_device(partition_id partitionID);
|
||||
disk_device_data *read_lock_disk_device(partition_id partitionID);
|
||||
void read_unlock_disk_device(partition_id partitionID);
|
||||
// parameter is the ID of any partition on the device
|
||||
|
||||
// getting disk devices/partitions by path
|
||||
@ -66,19 +70,19 @@ int32 find_partition(const char *path);
|
||||
|
||||
// disk device/partition read access
|
||||
// (read lock required)
|
||||
disk_device_data *get_disk_device(partition_id partition);
|
||||
partition_data *get_partition(partition_id partition);
|
||||
partition_data *get_parent_partition(partition_id partition);
|
||||
partition_data *get_child_partition(partition_id partition, int32 index);
|
||||
disk_device_data *get_disk_device(partition_id partitionID);
|
||||
partition_data *get_partition(partition_id partitionID);
|
||||
partition_data *get_parent_partition(partition_id partitionID);
|
||||
partition_data *get_child_partition(partition_id partitionID, int32 index);
|
||||
|
||||
// partition write access
|
||||
// (write lock required)
|
||||
partition_data *create_child_partition(partition_id partition, int32 index,
|
||||
partition_data *create_child_partition(partition_id partitionID, int32 index,
|
||||
partition_id *childID);
|
||||
// childID is used for the return value, but is also an optional input
|
||||
// parameter -- -1 to be ignored
|
||||
bool delete_partition(partition_id partition);
|
||||
void partition_modified(partition_id partition);
|
||||
bool delete_partition(partition_id partitionID);
|
||||
void partition_modified(partition_id partitionID);
|
||||
// tells the disk device manager, that the parition has been modified
|
||||
|
||||
// jobs
|
||||
@ -88,4 +92,8 @@ uint32 get_disk_device_job_status(disk_job_id job);
|
||||
bool update_disk_device_job_progress(disk_job_id job, float progress);
|
||||
bool update_disk_device_job_extra_progress(disk_job_id job, const char *info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _DISK_DEVICE_MANAGER_H
|
||||
|
@ -1,3 +1,153 @@
|
||||
// disk_device_manager.cpp
|
||||
|
||||
#include "disk_device_manager.h"
|
||||
#include "KDiskDevice.h"
|
||||
#include "KDiskDeviceManager.h"
|
||||
#include "KPartition.h"
|
||||
|
||||
// write_lock_disk_device
|
||||
disk_device_data *
|
||||
write_lock_disk_device(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KDiskDevice *device = manager->RegisterDevice(partitionID);
|
||||
if (device && device->WriteLock()) {
|
||||
device->Unregister();
|
||||
return device->DeviceData();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// write_unlock_disk_device
|
||||
void
|
||||
write_unlock_disk_device(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KDiskDevice *device = manager->RegisterDevice(partitionID);
|
||||
if (device) {
|
||||
device->WriteUnlock();
|
||||
device->Unregister();
|
||||
}
|
||||
}
|
||||
|
||||
// read_lock_disk_device
|
||||
disk_device_data *
|
||||
read_lock_disk_device(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KDiskDevice *device = manager->RegisterDevice(partitionID);
|
||||
if (device && device->ReadLock()) {
|
||||
device->Unregister();
|
||||
return device->DeviceData();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// read_unlock_disk_device
|
||||
void
|
||||
read_unlock_disk_device(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KDiskDevice *device = manager->RegisterDevice(partitionID);
|
||||
if (device) {
|
||||
device->ReadUnlock();
|
||||
device->Unregister();
|
||||
}
|
||||
}
|
||||
|
||||
// find_disk_device
|
||||
int32
|
||||
find_disk_device(const char *path)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
partition_id id = -1;
|
||||
if (KDiskDevice *device = manager->RegisterDevice(path)) {
|
||||
device->ID();
|
||||
device->Unregister();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
// find_partition
|
||||
int32
|
||||
find_partition(const char *path)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
partition_id id = -1;
|
||||
if (KPartition *partition = manager->RegisterPartition(path)) {
|
||||
partition->ID();
|
||||
partition->Unregister();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
// get_disk_device
|
||||
disk_device_data *
|
||||
get_disk_device(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KDiskDevice *device = manager->FindDevice(partitionID);
|
||||
return (device ? device->DeviceData() : NULL);
|
||||
}
|
||||
|
||||
// get_partition
|
||||
partition_data *
|
||||
get_partition(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *partition = manager->FindPartition(partitionID);
|
||||
return (partition ? partition->PartitionData() : NULL);
|
||||
}
|
||||
|
||||
// get_parent_partition
|
||||
partition_data *
|
||||
get_parent_partition(partition_id partitionID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
KPartition *partition = manager->FindPartition(partitionID);
|
||||
if (partition && partition->Parent())
|
||||
return partition->Parent()->PartitionData();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// get_child_partition
|
||||
partition_data *
|
||||
get_child_partition(partition_id partitionID, int32 index)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
if (KPartition *partition = manager->FindPartition(partitionID)) {
|
||||
if (KPartition *child = partition->ChildAt(index))
|
||||
return child->PartitionData();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// create_child_partition
|
||||
partition_data *
|
||||
create_child_partition(partition_id partitionID, int32 index,
|
||||
partition_id *childID)
|
||||
{
|
||||
KDiskDeviceManager *manager = KDiskDeviceManager::Default();
|
||||
if (KPartition *partition = manager->FindPartition(partitionID)) {
|
||||
KPartition *child = NULL;
|
||||
if (partition->CreateChild(*childID, index, &child) == B_OK)
|
||||
return child->PartitionData();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// delete_partition
|
||||
bool
|
||||
delete_partition(partition_id partitionID)
|
||||
{
|
||||
// not implemented
|
||||
return false;
|
||||
}
|
||||
|
||||
// partition_modified
|
||||
void
|
||||
partition_modified(partition_id partitionID)
|
||||
{
|
||||
// not implemented
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user