Some small adjustments for KFileDiskDevice. Added Dump().

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3600 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2003-06-22 22:57:42 +00:00
parent 242a2cbef2
commit bdc530c737
2 changed files with 49 additions and 6 deletions

View File

@ -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();

View File

@ -2,6 +2,7 @@
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <Drivers.h>
@ -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()