Made all necessary changes to build the DiskDeviceManager as part of the kernel.

Removed KFileDiskDevice functionality for now (since it would have required more changes).
Also disabled actual partition publishing/unpublishing, because this will
be done differently.
This change will temporarily break the DiskDeviceManagerTest build.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7914 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-06-11 21:03:31 +00:00
parent 960371b741
commit 499b29e3ea
20 changed files with 66 additions and 36 deletions
+3 -14
View File
@@ -7,14 +7,11 @@ SEARCH_SOURCE += [ FDirName $(OBOS_TOP) src kits storage ] ;
UsePrivateHeaders [ FDirName kernel boot platform $(OBOS_BOOT_PLATFORM) ] ; UsePrivateHeaders [ FDirName kernel boot platform $(OBOS_BOOT_PLATFORM) ] ;
UsePrivateHeaders [ FDirName kernel disk_device_manager ] ; UsePrivateHeaders [ FDirName kernel disk_device_manager ] ;
UsePrivateHeaders [ FDirName kernel util ] ; UsePrivateHeaders [ FDirName kernel util ] ;
UsePrivateHeaders [ FDirName kernel ] ;
UsePrivateHeaders shared ; UsePrivateHeaders shared ;
UsePrivateHeaders storage ; UsePrivateHeaders storage ;
# As long as we compile for R5 userland, we define the following macros. KernelStaticLibrary libdisk_device_manager :
SubDirCcFlags [ FDefines USER R5_MEMORY_LAYOUT ] ;
SubDirC++Flags [ FDefines USER R5_MEMORY_LAYOUT ] ;
SharedLibrary disk_device_manager :
ddm_operation_validation.cpp ddm_operation_validation.cpp
ddm_userland_interface.cpp ddm_userland_interface.cpp
disk_device_manager.cpp disk_device_manager.cpp
@@ -24,7 +21,7 @@ SharedLibrary disk_device_manager :
KDiskDeviceJobGenerator.cpp KDiskDeviceJobGenerator.cpp
KDiskDeviceJobQueue.cpp KDiskDeviceJobQueue.cpp
KDiskDeviceManager.cpp KDiskDeviceManager.cpp
KFileDiskDevice.cpp # KFileDiskDevice.cpp
KDiskSystem.cpp KDiskSystem.cpp
KFileSystem.cpp KFileSystem.cpp
KPartition.cpp KPartition.cpp
@@ -55,14 +52,6 @@ SharedLibrary disk_device_manager :
DiskDeviceTypes.cpp DiskDeviceTypes.cpp
; ;
LinkSharedOSLibs libdisk_device_manager.so
: <boot!home!config!lib>libkernelland_emu.so ;
# Hack to enable ddm_userland_interface.cpp to include vm.h but not make
# kernel/stdio.h shadow the real stdio.h
ObjectHdrs [ FGristFiles ddm_userland_interface$(SUFOBJ) ]
: [ PrivateHeaders kernel [ FDirName kernel arch $(OBOS_ARCH) ] ] ;
# KFileDiskDevice.cpp needs the virtualdrive.h Header. Add it here to not # KFileDiskDevice.cpp needs the virtualdrive.h Header. Add it here to not
# contaminate the include paths for the other files. # contaminate the include paths for the other files.
ObjectHdrs [ FGristFiles KFileDiskDevice$(SUFOBJ) ] ObjectHdrs [ FGristFiles KFileDiskDevice$(SUFOBJ) ]
@@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <KernelExport.h>
#include <Drivers.h> #include <Drivers.h>
#include "ddm_userland_interface.h" #include "ddm_userland_interface.h"
@@ -16,7 +17,7 @@
// debugging // debugging
//#define DBG(x) //#define DBG(x)
#define DBG(x) x #define DBG(x) x
#define OUT printf #define OUT dprintf
// constructor // constructor
KDiskDevice::KDiskDevice(partition_id id) KDiskDevice::KDiskDevice(partition_id id)
@@ -4,13 +4,14 @@
#include "ddm_userland_interface.h" #include "ddm_userland_interface.h"
#include <util/kernel_cpp.h>
#include <KDiskDeviceJob.h> #include <KDiskDeviceJob.h>
#include <KDiskDeviceUtils.h> #include <KDiskDeviceUtils.h>
// debugging // debugging
//#define DBG(x) //#define DBG(x)
#define DBG(x) x #define DBG(x) x
#define OUT printf #define OUT dprintf
// constructor // constructor
KDiskDeviceJob::KDiskDeviceJob(uint32 type, partition_id partitionID, KDiskDeviceJob::KDiskDeviceJob(uint32 type, partition_id partitionID,
@@ -1,6 +1,6 @@
// KDiskDeviceJobFactory.cpp // KDiskDeviceJobFactory.cpp
#include <new> #include <util/kernel_cpp.h>
#include "KDiskDeviceJob.h" #include "KDiskDeviceJob.h"
#include "KDiskDeviceJobFactory.h" #include "KDiskDeviceJobFactory.h"
@@ -453,7 +453,9 @@ KDiskDeviceJobGenerator::_GenerateRemainingJobs(KShadowPartition *parent,
} }
// recurse // recurse
for (int32 i = 0; KPartition *_child = partition->ChildAt(i); i++) { for (int32 i = 0; KPartition *_child = partition->ChildAt(i); i++) {
KShadowPartition *child = dynamic_cast<KShadowPartition *>(_child); // ToDo: was:
// KShadowPartition *child = dynamic_cast<KShadowPartition *>(_child);
KShadowPartition *child = static_cast<KShadowPartition *>(_child);
if (!child) if (!child)
return B_BAD_VALUE; return B_BAD_VALUE;
status_t error = _GenerateRemainingJobs(partition, child); status_t error = _GenerateRemainingJobs(partition, child);
@@ -1,12 +1,12 @@
// KDiskDeviceJobQueue.cpp // KDiskDeviceJobQueue.cpp
#include <new>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <Vector.h> #include <Vector.h>
#include <KernelExport.h> #include <KernelExport.h>
#include <util/kernel_cpp.h>
#include "KDiskDevice.h" #include "KDiskDevice.h"
#include "KDiskDeviceJob.h" #include "KDiskDeviceJob.h"
@@ -17,7 +17,7 @@
// debugging // debugging
//#define DBG(x) //#define DBG(x)
#define DBG(x) x #define DBG(x) x
#define OUT printf #define OUT dprintf
using namespace std; using namespace std;
@@ -1,5 +1,8 @@
// KDiskDeviceManager.cpp // KDiskDeviceManager.cpp
#include <KernelExport.h>
#include <util/kernel_cpp.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <module.h> #include <module.h>
@@ -28,7 +31,7 @@
// debugging // debugging
//#define DBG(x) //#define DBG(x)
#define DBG(x) x #define DBG(x) x
#define OUT printf #define OUT dprintf
// directories for partitioning and file system modules // directories for partitioning and file system modules
static const char *kPartitioningSystemPrefix = "partitioning_systems"; static const char *kPartitioningSystemPrefix = "partitioning_systems";
@@ -305,6 +308,8 @@ KDiskDeviceManager::FindPartition(partition_id id, bool noShadow)
KFileDiskDevice * KFileDiskDevice *
KDiskDeviceManager::FindFileDevice(const char *filePath) KDiskDeviceManager::FindFileDevice(const char *filePath)
{ {
// ToDo: this solution makes use of dynamic_cast!
#if 0
for (int32 cookie = 0; KDiskDevice *device = NextDevice(&cookie); ) { for (int32 cookie = 0; KDiskDevice *device = NextDevice(&cookie); ) {
KFileDiskDevice *fileDevice = dynamic_cast<KFileDiskDevice*>(device); KFileDiskDevice *fileDevice = dynamic_cast<KFileDiskDevice*>(device);
if (fileDevice && fileDevice->FilePath() if (fileDevice && fileDevice->FilePath()
@@ -312,6 +317,7 @@ KDiskDeviceManager::FindFileDevice(const char *filePath)
return fileDevice; return fileDevice;
} }
} }
#endif
return NULL; return NULL;
} }
@@ -487,6 +493,9 @@ KDiskDeviceManager::WriteLockPartition(partition_id id)
partition_id partition_id
KDiskDeviceManager::CreateFileDevice(const char *filePath) KDiskDeviceManager::CreateFileDevice(const char *filePath)
{ {
// ToDo!
return B_ERROR;
#if 0
if (!filePath) if (!filePath)
return B_BAD_VALUE; return B_BAD_VALUE;
status_t error = B_ERROR; status_t error = B_ERROR;
@@ -517,12 +526,14 @@ KDiskDeviceManager::CreateFileDevice(const char *filePath)
delete device; delete device;
} }
return error; return error;
#endif
} }
// DeleteFileDevice // DeleteFileDevice
status_t status_t
KDiskDeviceManager::DeleteFileDevice(const char *filePath) KDiskDeviceManager::DeleteFileDevice(const char *filePath)
{ {
#if 0
if (KFileDiskDevice *device = RegisterFileDevice(filePath)) { if (KFileDiskDevice *device = RegisterFileDevice(filePath)) {
PartitionRegistrar _(device, true); PartitionRegistrar _(device, true);
if (DeviceWriteLocker locker = device) { if (DeviceWriteLocker locker = device) {
@@ -530,6 +541,7 @@ KDiskDeviceManager::DeleteFileDevice(const char *filePath)
return B_OK; return B_OK;
} }
} }
#endif
return B_ERROR; return B_ERROR;
} }
@@ -537,6 +549,8 @@ KDiskDeviceManager::DeleteFileDevice(const char *filePath)
status_t status_t
KDiskDeviceManager::DeleteFileDevice(partition_id id) KDiskDeviceManager::DeleteFileDevice(partition_id id)
{ {
// ToDo: there is no dynamic_cast in the kernel!
#if 0
if (KDiskDevice *device = RegisterDevice(id)) { if (KDiskDevice *device = RegisterDevice(id)) {
PartitionRegistrar _(device, true); PartitionRegistrar _(device, true);
if (!dynamic_cast<KFileDiskDevice*>(device) || id != device->ID()) if (!dynamic_cast<KFileDiskDevice*>(device) || id != device->ID())
@@ -546,6 +560,7 @@ KDiskDeviceManager::DeleteFileDevice(partition_id id)
return B_OK; return B_OK;
} }
} }
#endif
return B_ERROR; return B_ERROR;
} }
@@ -3,6 +3,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <util/kernel_cpp.h>
#include "ddm_userland_interface.h" #include "ddm_userland_interface.h"
#include "KDiskDeviceManager.h" #include "KDiskDeviceManager.h"
#include "KDiskDeviceUtils.h" #include "KDiskDeviceUtils.h"
@@ -11,7 +13,7 @@
// debugging // debugging
//#define DBG(x) //#define DBG(x)
#define DBG(x) x #define DBG(x) x
#define OUT printf #define OUT dprintf
// constructor // constructor
KDiskSystem::KDiskSystem(const char *name) KDiskSystem::KDiskSystem(const char *name)
@@ -5,6 +5,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <KernelExport.h>
#include <Drivers.h> #include <Drivers.h>
#include <KDiskDeviceUtils.h> #include <KDiskDeviceUtils.h>
@@ -15,7 +16,7 @@
// debugging // debugging
//#define DBG(x) //#define DBG(x)
#define DBG(x) x #define DBG(x) x
#define OUT printf #define OUT dprintf
static const char *kFileDevicesDir = "/dev/disk/virtual/files"; static const char *kFileDevicesDir = "/dev/disk/virtual/files";
@@ -2,13 +2,14 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <new>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <KernelExport.h>
#include <Drivers.h> #include <Drivers.h>
#include <Errors.h> #include <Errors.h>
#include <util/kernel_cpp.h>
#include <ddm_userland_interface.h> #include <ddm_userland_interface.h>
#include <KDiskDevice.h> #include <KDiskDevice.h>
@@ -27,7 +28,7 @@ using namespace std;
// debugging // debugging
//#define DBG(x) //#define DBG(x)
#define DBG(x) x #define DBG(x) x
#define OUT printf #define OUT dprintf
// ListenerSet // ListenerSet
struct KPartition::ListenerSet : VectorSet<KPartitionListener*> {}; struct KPartition::ListenerSet : VectorSet<KPartitionListener*> {};
@@ -163,6 +164,8 @@ status_t
KPartition::PublishDevice() KPartition::PublishDevice()
{ {
// prepare a partition_info // prepare a partition_info
// ToDo!
#if 0
partition_info info; partition_info info;
info.offset = Offset(); info.offset = Offset();
info.size = Size(); info.size = Size();
@@ -187,12 +190,16 @@ KPartition::PublishDevice()
error = errno; error = errno;
close(fd); close(fd);
return error; return error;
#endif
return B_ERROR;
} }
// UnpublishDevice // UnpublishDevice
status_t status_t
KPartition::UnpublishDevice() KPartition::UnpublishDevice()
{ {
return B_OK;
#if 0
// get the entry path // get the entry path
char path[B_PATH_NAME_LENGTH]; char path[B_PATH_NAME_LENGTH];
status_t error = GetPath(path); status_t error = GetPath(path);
@@ -202,6 +209,7 @@ KPartition::UnpublishDevice()
if (remove(path) < 0) if (remove(path) < 0)
return errno; return errno;
return B_OK; return B_OK;
#endif
} }
// SetBusy // SetBusy
@@ -1,6 +1,8 @@
// KPartitionListener.cpp // KPartitionListener.cpp
#include <KPartitionListener.h> #include <KPartitionListener.h>
#include <util/kernel_cpp.h>
// constructor // constructor
KPartitionListener::KPartitionListener() KPartitionListener::KPartitionListener()
@@ -1,6 +1,7 @@
// KPartitionVisitor.cpp // KPartitionVisitor.cpp
#include "KPartitionVisitor.h" #include "KPartitionVisitor.h"
#include <util/kernel_cpp.h>
// constructor // constructor
KPartitionVisitor::KPartitionVisitor() KPartitionVisitor::KPartitionVisitor()
@@ -2,13 +2,13 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <new>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <Drivers.h> #include <Drivers.h>
#include <Errors.h> #include <Errors.h>
#include <util/kernel_cpp.h>
#include "KDiskDevice.h" #include "KDiskDevice.h"
#include "KDiskDeviceManager.h" #include "KDiskDeviceManager.h"
@@ -21,7 +21,7 @@ using namespace std;
// debugging // debugging
//#define DBG(x) //#define DBG(x)
#define DBG(x) x #define DBG(x) x
#define OUT printf #define OUT dprintf
// constructor // constructor
KPhysicalPartition::KPhysicalPartition(partition_id id) KPhysicalPartition::KPhysicalPartition(partition_id id)
@@ -70,6 +70,9 @@ KPhysicalPartition::Open(int flags, int *fd)
status_t status_t
KPhysicalPartition::PublishDevice() KPhysicalPartition::PublishDevice()
{ {
// ToDo!
return B_ERROR;
#if 0
// prepare a partition_info // prepare a partition_info
partition_info info; partition_info info;
info.offset = Offset(); info.offset = Offset();
@@ -95,12 +98,14 @@ KPhysicalPartition::PublishDevice()
error = errno; error = errno;
close(fd); close(fd);
return error; return error;
#endif
} }
// UnpublishDevice // UnpublishDevice
status_t status_t
KPhysicalPartition::UnpublishDevice() KPhysicalPartition::UnpublishDevice()
{ {
#if 0
// get the entry path // get the entry path
char path[B_PATH_NAME_LENGTH]; char path[B_PATH_NAME_LENGTH];
status_t error = GetPath(path); status_t error = GetPath(path);
@@ -109,6 +114,7 @@ KPhysicalPartition::UnpublishDevice()
// remove the entry // remove the entry
if (remove(path) < 0) if (remove(path) < 0)
return errno; return errno;
#endif
return B_OK; return B_OK;
} }
@@ -2,13 +2,13 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <new>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <Drivers.h> #include <Drivers.h>
#include <Errors.h> #include <Errors.h>
#include <util/kernel_cpp.h>
#include "ddm_userland_interface.h" #include "ddm_userland_interface.h"
#include "KDiskDevice.h" #include "KDiskDevice.h"
@@ -21,7 +21,7 @@ using namespace std;
// debugging // debugging
//#define DBG(x) //#define DBG(x)
#define DBG(x) x #define DBG(x) x
#define OUT printf #define OUT dprintf
// constructor // constructor
KShadowPartition::KShadowPartition(KPhysicalPartition *partition) KShadowPartition::KShadowPartition(KPhysicalPartition *partition)
@@ -1,6 +1,6 @@
// RWLocker.cpp // RWLocker.cpp
#include <new> #include <util/kernel_cpp.h>
#include "RWLocker.h" #include "RWLocker.h"
@@ -1,7 +1,6 @@
// UserDataWriter.cpp // UserDataWriter.cpp
#include <new> #include <util/kernel_cpp.h>
#include <ddm_userland_interface.h> #include <ddm_userland_interface.h>
#include <Vector.h> #include <Vector.h>
@@ -1,5 +1,6 @@
// disk_device_manager.cpp // disk_device_manager.cpp
#include <KernelExport.h>
#include <stdio.h> #include <stdio.h>
#include "disk_device_manager.h" #include "disk_device_manager.h"
@@ -14,7 +15,7 @@
// debugging // debugging
//#define DBG(x) //#define DBG(x)
#define DBG(x) x #define DBG(x) x
#define OUT printf #define OUT dprintf
// write_lock_disk_device // write_lock_disk_device
disk_device_data * disk_device_data *
@@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <KernelExport.h>
#include <DiskDeviceDefs.h> #include <DiskDeviceDefs.h>
#include <KDiskDevice.h> #include <KDiskDevice.h>
#include <KDiskDeviceManager.h> #include <KDiskDeviceManager.h>
@@ -16,7 +17,7 @@
// debugging // debugging
//#define DBG(x) //#define DBG(x)
#define DBG(x) x #define DBG(x) x
#define OUT printf #define OUT dprintf
// constructor // constructor
KResizeJob::KResizeJob(partition_id parentID, partition_id partitionID, KResizeJob::KResizeJob(partition_id parentID, partition_id partitionID,
@@ -13,7 +13,7 @@
// debugging // debugging
#define DBG(x) #define DBG(x)
//#define DBG(x) x //#define DBG(x) x
#define OUT printf #define OUT dprintf
// constructor // constructor
KScanPartitionJob::KScanPartitionJob(partition_id partitionID) KScanPartitionJob::KScanPartitionJob(partition_id partitionID)
@@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <KernelExport.h>
#include <DiskDeviceDefs.h> #include <DiskDeviceDefs.h>
#include <KDiskDevice.h> #include <KDiskDevice.h>
#include <KDiskDeviceManager.h> #include <KDiskDeviceManager.h>
@@ -14,7 +15,7 @@
// debugging // debugging
//#define DBG(x) //#define DBG(x)
#define DBG(x) x #define DBG(x) x
#define OUT printf #define OUT dprintf
// constructor // constructor
KUninitializeJob::KUninitializeJob(partition_id partitionID) KUninitializeJob::KUninitializeJob(partition_id partitionID)