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:
parent
242a2cbef2
commit
bdc530c737
@ -25,7 +25,7 @@ public:
|
|||||||
|
|
||||||
status_t SetTo(const char *path);
|
status_t SetTo(const char *path);
|
||||||
void Unset();
|
void Unset();
|
||||||
status_t InitCheck() const;
|
virtual status_t InitCheck() const;
|
||||||
// TODO: probably superfluous
|
// TODO: probably superfluous
|
||||||
|
|
||||||
// A read lock owner can be sure that the device (incl. all of its
|
// A read lock owner can be sure that the device (incl. all of its
|
||||||
@ -69,6 +69,12 @@ public:
|
|||||||
void SetShadowOwner(team_id team);
|
void SetShadowOwner(team_id team);
|
||||||
team_id ShadowOwner() const;
|
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:
|
private:
|
||||||
void _InitPartitionData();
|
void _InitPartitionData();
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <Drivers.h>
|
#include <Drivers.h>
|
||||||
@ -9,6 +10,11 @@
|
|||||||
#include "KDiskDevice.h"
|
#include "KDiskDevice.h"
|
||||||
#include "KDiskDeviceUtils.h"
|
#include "KDiskDeviceUtils.h"
|
||||||
|
|
||||||
|
// debugging
|
||||||
|
//#define DBG(x)
|
||||||
|
#define DBG(x) x
|
||||||
|
#define OUT printf
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
KDiskDevice::KDiskDevice(partition_id id)
|
KDiskDevice::KDiskDevice(partition_id id)
|
||||||
: KPartition(id),
|
: KPartition(id),
|
||||||
@ -48,11 +54,13 @@ KDiskDevice::SetTo(const char *path)
|
|||||||
if (fFD < 0)
|
if (fFD < 0)
|
||||||
return errno;
|
return errno;
|
||||||
// get device geometry and media status
|
// get device geometry and media status
|
||||||
// TODO: files need to be handled differently
|
error = GetMediaStatus(&fMediaStatus);
|
||||||
if (ioctl(fFD, B_GET_MEDIA_STATUS, &fMediaStatus) == 0
|
if (error != B_OK)
|
||||||
&& ioctl(fFD, B_GET_GEOMETRY, &fDeviceData.geometry) == 0) {
|
return error;
|
||||||
_InitPartitionData();
|
error = GetGeometry(&fDeviceData.geometry);
|
||||||
}
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
_InitPartitionData();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,6 +256,35 @@ KDiskDevice::ShadowOwner() const
|
|||||||
return fShadowOwner;
|
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
|
// _InitPartitionData
|
||||||
void
|
void
|
||||||
KDiskDevice::_InitPartitionData()
|
KDiskDevice::_InitPartitionData()
|
||||||
|
Loading…
Reference in New Issue
Block a user