2 * Copyright 2003-2007, Ingo Weinhold, bonefish@cs.tu-berlin.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 #ifndef _K_DISK_DEVICE_H
6 #define _K_DISK_DEVICE_H
13 #include "KPartition.h"
17 namespace DiskDevice
{
23 class KDiskDevice
: public KPartition
{
25 KDiskDevice(partition_id id
= -1);
26 virtual ~KDiskDevice();
28 status_t
SetTo(const char *path
);
30 virtual status_t
InitCheck() const;
31 // TODO: probably superfluous
33 // A read lock owner can be sure that the device (incl. all of its
34 // partitions won't be changed).
35 // A write lock owner is moreover allowed to make changes.
36 // The hierarchy is additionally protected by the disk device manager's
37 // lock -- only a device write lock owner is allowed to change it, but
38 // manager lock owners can be sure, that it won't change.
44 virtual void SetID(partition_id id
);
46 virtual status_t
PublishDevice();
47 virtual status_t
UnpublishDevice();
48 virtual status_t
RepublishDevice();
50 void SetDeviceFlags(uint32 flags
); // comprises the ones below
51 uint32
DeviceFlags() const;
52 bool IsReadOnlyMedia() const;
53 bool IsWriteOnce() const;
54 bool IsRemovable() const;
55 bool HasMedia() const;
56 bool MediaChanged() const;
58 void UpdateMediaStatusIfNeeded();
59 void UninitializeMedia();
61 void UpdateGeometry();
63 status_t
SetPath(const char *path
);
64 // TODO: Remove this method or make it private. Once initialized the
65 // path must not be changed.
66 const char *Path() const;
67 virtual status_t
GetFileName(char* buffer
, size_t size
) const;
68 virtual status_t
GetPath(KPath
*path
) const;
70 // File descriptor: Set only from a kernel thread, valid only for
75 // access to C style device data
76 disk_device_data
*DeviceData();
77 const disk_device_data
*DeviceData() const;
79 virtual void WriteUserData(UserDataWriter
&writer
,
80 user_partition_data
*data
);
81 void WriteUserData(UserDataWriter
&writer
);
83 virtual void Dump(bool deep
= true, int32 level
= 0);
86 virtual status_t
GetMediaStatus(status_t
*mediaStatus
);
87 virtual status_t
GetGeometry(device_geometry
*geometry
);
90 void _ResetGeometry();
91 void _InitPartitionData();
92 void _UpdateDeviceFlags();
94 disk_device_data fDeviceData
;
97 status_t fMediaStatus
;
101 } // namespace DiskDevice
102 } // namespace BPrivate
104 using BPrivate::DiskDevice::KDiskDevice
;
106 #endif // _K_DISK_DEVICE_H