From 9007acaee355e498c1a42626c28d4617ffc1139a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 22 Jun 2003 23:04:56 +0000 Subject: [PATCH] Added Dump(). Small fixes. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3605 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/disk_device_manager/KPartition.h | 2 + .../core/disk_device_manager/KPartition.cpp | 44 +++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/headers/private/kernel/disk_device_manager/KPartition.h b/headers/private/kernel/disk_device_manager/KPartition.h index 9e70012f50..4a3e265551 100644 --- a/headers/private/kernel/disk_device_manager/KPartition.h +++ b/headers/private/kernel/disk_device_manager/KPartition.h @@ -149,6 +149,8 @@ public: void SetContentCookie(void *cookie); void *ContentCookie() const; + virtual void Dump(bool deep, int32 level); + private: void _UpdateChildIndices(int32 index); static int32 _NextID(); diff --git a/src/kernel/core/disk_device_manager/KPartition.cpp b/src/kernel/core/disk_device_manager/KPartition.cpp index 0ed3ed1f79..d61c66cdb6 100644 --- a/src/kernel/core/disk_device_manager/KPartition.cpp +++ b/src/kernel/core/disk_device_manager/KPartition.cpp @@ -10,8 +10,10 @@ #include #include -//#include - // TODO: Move the definitions needed in the kernel to a separate header. +// debugging +//#define DBG(x) +#define DBG(x) x +#define OUT printf #include "KDiskDevice.h" #include "KDiskDeviceManager.h" @@ -435,7 +437,7 @@ KPartition::SetVolumeID(dev_t volumeID) dev_t KPartition::VolumeID() const { - return fPartitionData.id; + return fPartitionData.volume; } // Mount @@ -643,7 +645,7 @@ KPartition::SetDiskSystem(KDiskSystem *diskSystem) // set and load new one fDiskSystem = diskSystem; if (fDiskSystem) - fDiskSystem->Load(); + fDiskSystem->Load(); // can't fail, since it's already loaded } // DiskSystem @@ -703,6 +705,40 @@ KPartition::ContentCookie() const return fPartitionData.content_cookie; } +// Dump +void +KPartition::Dump(bool deep, int32 level) +{ + if (level < 0 || level > 255) + return; + char prefix[256]; + sprintf(prefix, "%*s%*s", (int)level, "", (int)level, ""); + char path[B_PATH_NAME_LENGTH]; + GetPath(path); + if (level > 0) + OUT("%spartition %ld: %s\n", prefix, ID(), path); + OUT("%s offset: %lld\n", prefix, Offset()); + OUT("%s size: %lld\n", prefix, Size()); + OUT("%s block size: %lu\n", prefix, BlockSize()); + OUT("%s child count: %ld\n", prefix, CountChildren()); + OUT("%s index: %ld\n", prefix, Index()); + OUT("%s status: %lu\n", prefix, Status()); + OUT("%s flags: %lx\n", prefix, Flags()); + OUT("%s volume: %ld\n", prefix, VolumeID()); + OUT("%s disk system: %s\n", prefix, + (DiskSystem() ? DiskSystem()->Name() : NULL)); + OUT("%s name: %s\n", prefix, Name()); + OUT("%s content name: %s\n", prefix, ContentName()); + OUT("%s type: %s\n", prefix, Type()); + OUT("%s content type: %s\n", prefix, ContentType()); + OUT("%s params: %s\n", prefix, Parameters()); + OUT("%s content params: %s\n", prefix, ContentParameters()); + if (deep) { + for (int32 i = 0; KPartition *child = ChildAt(i); i++) + child->Dump(true, level + 1); + } +} + // _UpdateChildIndices void KPartition::_UpdateChildIndices(int32 index)