From bdc530c737fac207c8409e71eb0201a00910b2b1 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 22 Jun 2003 22:57:42 +0000 Subject: [PATCH] Some small adjustments for KFileDiskDevice. Added Dump(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3600 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/disk_device_manager/KDiskDevice.h | 8 +++- .../core/disk_device_manager/KDiskDevice.cpp | 47 +++++++++++++++++-- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/headers/private/kernel/disk_device_manager/KDiskDevice.h b/headers/private/kernel/disk_device_manager/KDiskDevice.h index 6ea59a78f9..80a72f43fe 100644 --- a/headers/private/kernel/disk_device_manager/KDiskDevice.h +++ b/headers/private/kernel/disk_device_manager/KDiskDevice.h @@ -25,7 +25,7 @@ public: status_t SetTo(const char *path); void Unset(); - status_t InitCheck() const; + virtual status_t InitCheck() const; // TODO: probably superfluous // A read lock owner can be sure that the device (incl. all of its @@ -69,6 +69,12 @@ public: void SetShadowOwner(team_id team); team_id ShadowOwner() const; + virtual void Dump(bool deep = true, int32 level = 0); + +protected: + virtual status_t GetMediaStatus(status_t *mediaStatus); + virtual status_t GetGeometry(device_geometry *geometry); + private: void _InitPartitionData(); diff --git a/src/kernel/core/disk_device_manager/KDiskDevice.cpp b/src/kernel/core/disk_device_manager/KDiskDevice.cpp index 37bbe241c5..fe861db725 100644 --- a/src/kernel/core/disk_device_manager/KDiskDevice.cpp +++ b/src/kernel/core/disk_device_manager/KDiskDevice.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -9,6 +10,11 @@ #include "KDiskDevice.h" #include "KDiskDeviceUtils.h" +// debugging +//#define DBG(x) +#define DBG(x) x +#define OUT printf + // constructor KDiskDevice::KDiskDevice(partition_id id) : KPartition(id), @@ -48,11 +54,13 @@ KDiskDevice::SetTo(const char *path) if (fFD < 0) return errno; // get device geometry and media status - // TODO: files need to be handled differently - if (ioctl(fFD, B_GET_MEDIA_STATUS, &fMediaStatus) == 0 - && ioctl(fFD, B_GET_GEOMETRY, &fDeviceData.geometry) == 0) { - _InitPartitionData(); - } + error = GetMediaStatus(&fMediaStatus); + if (error != B_OK) + return error; + error = GetGeometry(&fDeviceData.geometry); + if (error != B_OK) + return error; + _InitPartitionData(); return B_OK; } @@ -248,6 +256,35 @@ KDiskDevice::ShadowOwner() const return fShadowOwner; } +// Dump +void +KDiskDevice::Dump(bool deep, int32 level) +{ + OUT("device %ld: %s\n", ID(), Path()); + OUT(" media status: %s\n", strerror(fMediaStatus)); + OUT(" device flags: %lx\n", DeviceFlags()); + if (fMediaStatus == B_OK) + KPartition::Dump(deep, 0); +} + +// GetMediaStatus +status_t +KDiskDevice::GetMediaStatus(status_t *mediaStatus) +{ + if (ioctl(fFD, B_GET_MEDIA_STATUS, mediaStatus) != 0) + return errno; + return B_OK; +} + +// GetGeometry +status_t +KDiskDevice::GetGeometry(device_geometry *geometry) +{ + if (ioctl(fFD, B_GET_GEOMETRY, geometry) != 0) + return errno; + return B_OK; +} + // _InitPartitionData void KDiskDevice::_InitPartitionData()