diff --git a/headers/os/drivers/disk_device_manager.h b/headers/os/drivers/disk_device_manager.h index b86641bf8c..930ad5c025 100644 --- a/headers/os/drivers/disk_device_manager.h +++ b/headers/os/drivers/disk_device_manager.h @@ -102,22 +102,25 @@ partition_data *get_child_partition(partition_id partitionID, int32 index); // partition write access // (write lock required) partition_data *create_child_partition(partition_id partitionID, int32 index, - partition_id childID); + partition_id childID); // childID is an optional input parameter -- -1 to be ignored bool delete_partition(partition_id partitionID); void partition_modified(partition_id partitionID); // tells the disk device manager, that the parition has been modified +status_t scan_partition(partition_id partitionID); + // Service method for disks systems: Synchronously scans the partition. + // Device must not be locked. + // disk systems disk_system_id find_disk_system(const char *name); // jobs bool update_disk_device_job_progress(disk_job_id jobID, float progress); -bool update_disk_device_job_extra_progress(disk_job_id jobID, - const char *info); +bool update_disk_device_job_extra_progress(disk_job_id jobID, const char *info); bool set_disk_device_job_error_message(disk_job_id jobID, const char *message); uint32 update_disk_device_job_interrupt_properties(disk_job_id jobID, - uint32 interruptProperties); + uint32 interruptProperties); // returns one of B_DISK_DEVICE_JOB_{CONTINUE,CANCEL,REVERSE} #ifdef __cplusplus diff --git a/headers/private/fs_shell/fssh_api_wrapper.h b/headers/private/fs_shell/fssh_api_wrapper.h index c9939db7cd..867ffdae63 100644 --- a/headers/private/fs_shell/fssh_api_wrapper.h +++ b/headers/private/fs_shell/fssh_api_wrapper.h @@ -343,6 +343,8 @@ #define delete_partition fssh_delete_partition #define partition_modified fssh_partition_modified +#define scan_partition fssh_scan_partition + // disk systems #define find_disk_system fssh_find_disk_system diff --git a/headers/private/fs_shell/fssh_disk_device_manager.h b/headers/private/fs_shell/fssh_disk_device_manager.h index 9fb1a1cb73..084d716972 100644 --- a/headers/private/fs_shell/fssh_disk_device_manager.h +++ b/headers/private/fs_shell/fssh_disk_device_manager.h @@ -113,6 +113,10 @@ bool fssh_delete_partition(fssh_partition_id partitionID); void fssh_partition_modified(fssh_partition_id partitionID); // tells the disk device manager, that the parition has been modified +fssh_status_t fssh_scan_partition(fssh_partition_id partitionID); + // Service method for disks systems: Synchronously scans the partition. + // Device must not be locked. + // disk systems fssh_disk_system_id fssh_find_disk_system(const char *name); diff --git a/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h b/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h index 12cf7e4bc5..8dd83b2176 100644 --- a/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h +++ b/headers/private/kernel/disk_device_manager/KDiskDeviceManager.h @@ -66,6 +66,8 @@ public: // Both the device and the partition is also registered and must be // unregistered by the caller. + status_t ScanPartition(KPartition* partition, bool async); + partition_id CreateFileDevice(const char *filePath, bool *newlyCreated = NULL, bool async = true); status_t DeleteFileDevice(const char *filePath); diff --git a/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp b/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp index 2924aa0a15..76218d5afe 100644 --- a/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp +++ b/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp @@ -488,9 +488,28 @@ KDiskDeviceManager::WriteLockPartition(partition_id id) return NULL; } + +// ScanPartition +status_t +KDiskDeviceManager::ScanPartition(KPartition* partition, bool async) +{ +// TODO: This won't do. Locking the DDM while scanning the partition is not a +// good idea. Even locking the device doesn't feels right. Marking the partition +// busy and passing the disk system a temporary clone of the partition_data +// should work as well. + if (DeviceWriteLocker deviceLocker = partition->Device()) { + if (ManagerLocker locker = this) + return _ScanPartition(partition, async); + } + + return B_ERROR; +} + + // CreateFileDevice partition_id -KDiskDeviceManager::CreateFileDevice(const char *filePath, bool *newlyCreated, bool async) +KDiskDeviceManager::CreateFileDevice(const char *filePath, bool *newlyCreated, + bool async) { if (!filePath) return B_BAD_VALUE; @@ -716,7 +735,8 @@ KDiskDeviceManager::RemoveJobQueue(KDiskDeviceJobQueue *jobQueue) return jobQueue->InitCheck(); if (jobQueue->IsExecuting()) return B_BAD_VALUE; - return (_RemoveJobQueue(jobQueue) ? B_OK : B_ENTRY_NOT_FOUND); + return (_RemoveJobQueue(jobQueue) + ? (status_t)B_OK : (status_t)B_ENTRY_NOT_FOUND); } // DeleteJobQueue diff --git a/src/system/kernel/disk_device_manager/disk_device_manager.cpp b/src/system/kernel/disk_device_manager/disk_device_manager.cpp index 1f8dc57d51..aae976323a 100644 --- a/src/system/kernel/disk_device_manager/disk_device_manager.cpp +++ b/src/system/kernel/disk_device_manager/disk_device_manager.cpp @@ -178,9 +178,26 @@ delete_partition(partition_id partitionID) void partition_modified(partition_id partitionID) { - // not implemented + // TODO: implemented } + +// scan_partition +status_t +scan_partition(partition_id partitionID) +{ + // get the partition + KDiskDeviceManager* manager = KDiskDeviceManager::Default(); + KPartition* partition = manager->RegisterPartition(partitionID); + if (partition == NULL) + return B_ENTRY_NOT_FOUND; + PartitionRegistrar _(partition, true); + + // scan it + return manager->ScanPartition(partition, false); +} + + // find_disk_system disk_system_id find_disk_system(const char *name) diff --git a/src/tools/fs_shell/Jamfile b/src/tools/fs_shell/Jamfile index 66c8498b3a..fee8e3810e 100644 --- a/src/tools/fs_shell/Jamfile +++ b/src/tools/fs_shell/Jamfile @@ -33,6 +33,7 @@ BuildPlatformStaticLibrary fs_shell.a : atomic.cpp block_cache.cpp command_cp.cpp + disk_device_manager.cpp driver_settings.cpp errno.cpp fcntl.cpp diff --git a/src/tools/fs_shell/disk_device_manager.cpp b/src/tools/fs_shell/disk_device_manager.cpp new file mode 100644 index 0000000000..b9611b6b8f --- /dev/null +++ b/src/tools/fs_shell/disk_device_manager.cpp @@ -0,0 +1,22 @@ +/* + * Copyright 2007, Ingo Weinhold, bonefish@cs.tu-berlin.de. + * Distributed under the terms of the MIT License. + */ + +#include "fssh_disk_device_manager.h" + +#include "fssh_errors.h" + + +fssh_status_t +fssh_scan_partition(fssh_partition_id partitionID) +{ + return FSSH_B_OK; +} + + +bool +fssh_update_disk_device_job_progress(fssh_disk_job_id jobID, float progress) +{ + return true; +}