diff --git a/src/servers/registrar/DiskDeviceManager.h b/src/servers/registrar/DiskDeviceManager.h deleted file mode 100644 index 5a248e4d37..0000000000 --- a/src/servers/registrar/DiskDeviceManager.h +++ /dev/null @@ -1,58 +0,0 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- - -#ifndef DISK_DEVICE_MANAGER_H -#define DISK_DEVICE_MANAGER_H - -#include -#include -#include - -#include "PriorityMessageQueue.h" -#include "RDiskDeviceList.h" -#include "RVolumeList.h" -#include "WatchingService.h" - -class EventQueue; -class MessageEvent; - -class DiskDeviceManager : public BLooper { -public: - DiskDeviceManager(EventQueue *eventQueue); - virtual ~DiskDeviceManager(); - - virtual void MessageReceived(BMessage *message); - -private: - // requests - void _NextDiskDeviceRequest(BMessage *request); - void _GetDiskDeviceRequest(BMessage *request); - void _UpdateDiskDeviceRequest(BMessage *request); - void _StartWatchingRequest(BMessage *request); - void _StopWatchingRequest(BMessage *request); - - bool _PushMessage(BMessage *message, int32 priority); - BMessage *_PopMessage(); - - static int32 _WorkerEntry(void *parameters); - int32 _Worker(); - -private: - class RescanEvent; - -private: - EventQueue *fEventQueue; - MessageEvent *fRescanEvent; - BLocker fDeviceListLock; - WatchingService fWatchingService; - RVolumeList fVolumeList; - RDiskDeviceList fDeviceList; - PriorityMessageQueue fMessageQueue; - thread_id fWorker; - sem_id fMessageCounter; - bool fTerminating; -}; - -#endif // DISK_DEVICE_MANAGER_H diff --git a/src/servers/registrar/RChangeCounter.h b/src/servers/registrar/RChangeCounter.h deleted file mode 100644 index 63830a8822..0000000000 --- a/src/servers/registrar/RChangeCounter.h +++ /dev/null @@ -1,43 +0,0 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- - -#ifndef CHANGE_COUNTER_H -#define CHANGE_COUNTER_H - -#include - -class RChangeCounter { -public: - RChangeCounter() : fCount(0), fLocked(0), fChanged(false) {} - ~RChangeCounter() {} - - int32 Count() const { return fCount; } - - bool Lock() { fLocked++; return true; } - void Unlock() { if (fLocked > 0 && --fLocked == 0) fChanged = false; } - bool IsLocked() const { return (fLocked > 0); } - - bool Increment() - { - bool changed = false; - if (IsLocked() && !fChanged) { - fCount++; - changed = fChanged = true; - } - return changed; - } - - void Reset() { fCount = 0; fLocked = 0; fChanged = false; } - -public: - typedef BPrivate::BObjectLocker Locker; - -private: - int32 fCount; - int32 fLocked; - bool fChanged; -}; - -#endif // CHANGE_COUNTER_H diff --git a/src/servers/registrar/RDiskDevice.h b/src/servers/registrar/RDiskDevice.h deleted file mode 100644 index 4f2602e882..0000000000 --- a/src/servers/registrar/RDiskDevice.h +++ /dev/null @@ -1,90 +0,0 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- - -#ifndef DISK_DEVICE_H -#define DISK_DEVICE_H - -#include -#include -#include - -#include "RChangeCounter.h" - -struct session_info; - -class RDiskDeviceList; -class RPartition; -class RSession; - -#include "Debug.h" -class RDiskDevice { -public: - RDiskDevice(); - ~RDiskDevice(); - - status_t SetTo(const char *path, int fd, const device_geometry *geometry, - status_t mediaStatus); - void Unset(); - - void SetDeviceList(RDiskDeviceList *deviceList) - { fDeviceList = deviceList ;} - RDiskDeviceList *DeviceList() const { return fDeviceList; } - - status_t MediaChanged(); - status_t SessionLayoutChanged(); - - int32 ID() const { return fID; } - int32 ChangeCounter() const { return fChangeCounter.Count(); } - void Changed() { fChangeCounter.Increment(); } - - void SetTouched(bool touched) { fTouched = touched; } - bool Touched() const { return fTouched; } - - int FD() const { return fFD; } - off_t Size() const; - int32 BlockSize() const { return fGeometry.bytes_per_sector; } - bool IsReadOnly() { return fGeometry.read_only; } - - const char *Path() const { return fPath.String(); } - - status_t AddSession(const session_info *sessionInfo, - uint32 cause/* = B_DEVICE_CAUSE_UNKNOWN*/); - bool AddSession(RSession *session, - uint32 cause/* = B_DEVICE_CAUSE_UNKNOWN*/); - bool RemoveSession(int32 index, - uint32 cause/* = B_DEVICE_CAUSE_UNKNOWN*/); - bool RemoveSession(RSession *session, - uint32 cause/* = B_DEVICE_CAUSE_UNKNOWN*/); - int32 CountSessions() const { return fSessions.CountItems(); } - RSession *SessionAt(int32 index) const { return fSessions.ItemAt(index); } - int32 IndexOfSession(const RSession *session) const - { return fSessions.IndexOf(session); } - - status_t Update(); - - status_t Archive(BMessage *archive) const; - - void Dump() const; - -private: - status_t _RescanSessions(uint32 cause); - - static int32 _NextID(); - -private: - BObjectList fSessions; - RDiskDeviceList *fDeviceList; - int32 fID; - RChangeCounter fChangeCounter; - bool fTouched; - BString fPath; - int fFD; - device_geometry fGeometry; - status_t fMediaStatus; - - static vint32 fNextID; -}; - -#endif // DISK_DEVICE_H diff --git a/src/servers/registrar/RDiskDeviceList.h b/src/servers/registrar/RDiskDeviceList.h deleted file mode 100644 index adae1c24c1..0000000000 --- a/src/servers/registrar/RDiskDeviceList.h +++ /dev/null @@ -1,112 +0,0 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- - -#ifndef DISK_DEVICE_LIST_H -#define DISK_DEVICE_LIST_H - -#include -#include -#include - -#include "MessageHandler.h" -#include "RVolumeList.h" - -class BDirectory; -class BEntry; -class BLocker; - -class RDiskDevice; -class RPartition; -class RSession; -class WatchingService; - -class RDiskDeviceList : public MessageHandler, public RVolumeListListener { -public: - RDiskDeviceList(BMessenger target, BLocker &lock, RVolumeList &volumeList, - WatchingService *watchingService); - ~RDiskDeviceList(); - - virtual void HandleMessage(BMessage *message); - - // external event hooks - virtual void VolumeMounted(const RVolume *volume); - virtual void VolumeUnmounted(const RVolume *volume); - virtual void MountPointMoved(const RVolume *volume, - const entry_ref *oldRoot, - const entry_ref *newRoot); - virtual void DeviceAppeared(const char *devicePath); - virtual void DeviceDisappeared(const char *devicePath); - - bool AddDevice(RDiskDevice *device); - bool RemoveDevice(int32 index); - bool RemoveDevice(RDiskDevice *device); - int32 CountDevices() const { return fDevices.CountItems(); } - RDiskDevice *DeviceAt(int32 index) const { return fDevices.ItemAt(index); } - - int32 CountSessions() const { return fSessions.CountItems(); } - RSession *SessionAt(int32 index) const { return fSessions.ItemAt(index); } - - int32 CountPartitions() const { return fPartitions.CountItems(); } - RPartition *PartitionAt(int32 index) const - { return fPartitions.ItemAt(index); } - - RDiskDevice *DeviceWithID(int32 id, bool exact = true) const; - RSession *SessionWithID(int32 id) const; - RPartition *PartitionWithID(int32 id) const; - - RDiskDevice *DeviceWithPath(const char *path) const; - RPartition *PartitionWithPath(const char *path) const; - - status_t Rescan(); - - bool Lock(); - void Unlock(); - - // internal event hooks - void DeviceAdded(RDiskDevice *device, - uint32 cause = B_DEVICE_CAUSE_UNKNOWN); - void DeviceRemoved(RDiskDevice *device, - uint32 cause = B_DEVICE_CAUSE_UNKNOWN); - void MediaChanged(RDiskDevice *device, - uint32 cause = B_DEVICE_CAUSE_UNKNOWN); - void SessionAdded(RSession *session, - uint32 cause = B_DEVICE_CAUSE_UNKNOWN); - void SessionRemoved(RSession *session, - uint32 cause = B_DEVICE_CAUSE_UNKNOWN); - void PartitionAdded(RPartition *partition, - uint32 cause = B_DEVICE_CAUSE_UNKNOWN); - void PartitionRemoved(RPartition *partition, - uint32 cause = B_DEVICE_CAUSE_UNKNOWN); - void PartitionChanged(RPartition *partition, - uint32 cause = B_DEVICE_CAUSE_UNKNOWN); - - - void Dump() const; - -private: - status_t _Scan(BDirectory &dir); - status_t _ScanDevice(const char *path); - - status_t _InitNotificationMessage(BMessage *message, uint32 event, - uint32 cause); - status_t _InitNotificationMessage(BMessage *message, uint32 event, - uint32 cause, const RDiskDevice *device); - status_t _InitNotificationMessage(BMessage *message, uint32 event, - uint32 cause, const RSession *session); - status_t _InitNotificationMessage(BMessage *message, uint32 event, - uint32 cause, - const RPartition *partition); - -private: - mutable BLocker &fLock; - BMessenger fTarget; - RVolumeList &fVolumeList; - WatchingService *fWatchingService; - BObjectList fDevices; // sorted by ID - BObjectList fSessions; // - BObjectList fPartitions; // -}; - -#endif // DISK_DEVICE_LIST_H diff --git a/src/servers/registrar/RPartition.h b/src/servers/registrar/RPartition.h deleted file mode 100644 index fc72d5540f..0000000000 --- a/src/servers/registrar/RPartition.h +++ /dev/null @@ -1,69 +0,0 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- - -#ifndef PARTITION_H -#define PARTITION_H - -#include -#include - -#include "RChangeCounter.h" - -class BMessage; - -class RDiskDevice; -class RDiskDeviceList; -class RSession; -class RVolume; - -class RPartition { -public: - RPartition(); - ~RPartition(); - - status_t SetTo(int fd, const extended_partition_info *partitionInfo); - void Unset(); - - void SetSession(RSession *session) { fSession = session; } - RDiskDeviceList *DeviceList() const; - RDiskDevice *Device() const; - RSession *Session() const { return fSession; } - - status_t PartitionChanged(); - - int32 ID() const { return fID; } - int32 ChangeCounter() const { return fChangeCounter.Count(); } - void Changed(); - - int32 Index() const; - - const extended_partition_info *Info() const { return &fInfo; } - void GetPath(char *path) const; - off_t Offset() const { return fInfo.info.offset; } - off_t Size() const { return fInfo.info.size; } - - void SetVolume(const RVolume *volume) { fVolume = volume; } - const RVolume *Volume() const { return fVolume; } - - status_t Archive(BMessage *archive) const; - - status_t Update(const extended_partition_info *partitionInfo); - - void Dump() const; - -private: - static int32 _NextID(); - -private: - RSession *fSession; - int32 fID; - RChangeCounter fChangeCounter; - extended_partition_info fInfo; - const RVolume *fVolume; - - static vint32 fNextID; -}; - -#endif // PARTITION_H diff --git a/src/servers/registrar/RSession.h b/src/servers/registrar/RSession.h deleted file mode 100644 index a42a6ff091..0000000000 --- a/src/servers/registrar/RSession.h +++ /dev/null @@ -1,75 +0,0 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- - -#ifndef SESSION_H -#define SESSION_H - -#include -#include - -#include "RChangeCounter.h" - -class RDiskDevice; -class RDiskDeviceList; -class RPartition; - -class RSession { -public: - RSession(); - ~RSession(); - - status_t SetTo(int fd, const session_info *sessionInfo); - void Unset(); - - void SetDevice(RDiskDevice *device) { fDevice = device; } - RDiskDeviceList *DeviceList() const; - RDiskDevice *Device() const { return fDevice; } - - status_t PartitionLayoutChanged(); - - int32 ID() const { return fID; } - int32 ChangeCounter() const { return fChangeCounter.Count(); } - void Changed(); - - int32 Index() const; - - status_t AddPartition(int fd, const extended_partition_info *partitionInfo, - uint32 cause); - bool AddPartition(RPartition *partition, uint32 cause); - bool RemovePartition(int32 index, uint32 cause); - bool RemovePartition(RPartition *partition, uint32 cause); - int32 CountPartitions() const { return fPartitions.CountItems(); } - RPartition *PartitionAt(int32 index) const - { return fPartitions.ItemAt(index); } - int32 IndexOfPartition(const RPartition *partition) const - { return fPartitions.IndexOf(partition); } - - const session_info *Info() const { return &fInfo; } - off_t Offset() const { return fInfo.offset; } - off_t Size() const { return fInfo.size; } - - status_t Update(const session_info *sessionInfo); - - status_t Archive(BMessage *archive) const; - - void Dump() const; - -private: - - status_t _RescanPartitions(int fd, uint32 cause); - static int32 _NextID(); - -private: - BObjectList fPartitions; - RDiskDevice *fDevice; - int32 fID; - RChangeCounter fChangeCounter; - session_info fInfo; - char fPartitioningSystem[B_FILE_NAME_LENGTH]; - - static vint32 fNextID; -}; - -#endif // SESSION_H diff --git a/src/servers/registrar/RVolumeList.h b/src/servers/registrar/RVolumeList.h deleted file mode 100644 index 00a8bf570f..0000000000 --- a/src/servers/registrar/RVolumeList.h +++ /dev/null @@ -1,94 +0,0 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- - -#ifndef VOLUME_LIST_H -#define VOLUME_LIST_H - -#include -#include -#include -#include -#include - -#include "MessageHandler.h" - -class BLocker; - -// RVolume -class RVolume { -public: - RVolume(); - ~RVolume() {} - - status_t SetTo(dev_t id); - void Unset(); - - dev_t ID() const { return fID; } - ino_t RootNode() const { return fRootNode; } - void GetRootDirNode(node_ref *ref) const - { ref->device = fID; ref->node = fRootNode; } - void GetRootDirEntry(entry_ref *ref) const { *ref = fRootEntry; } - const char *DevicePath() const { return fDevicePath; } - - void SetRootDirEntry(const entry_ref *ref) { fRootEntry = *ref; } - - status_t StartWatching(BMessenger target) const; - status_t StopWatching(BMessenger target) const; - -private: - dev_t fID; - ino_t fRootNode; - entry_ref fRootEntry; - char fDevicePath[B_FILE_NAME_LENGTH]; -}; - -// RVolumeListListener -class RVolumeListListener { -public: - RVolumeListListener(); - virtual ~RVolumeListListener(); - - virtual void VolumeMounted(const RVolume *volume); - virtual void VolumeUnmounted(const RVolume *volume); - virtual void MountPointMoved(const RVolume *volume, - const entry_ref *oldRoot, - const entry_ref *newRoot); -}; - -// RVolumeList -class RVolumeList : public MessageHandler { -public: - RVolumeList(BMessenger target, BLocker &lock); - virtual ~RVolumeList(); - - virtual void HandleMessage(BMessage *message); - - status_t Rescan(); - - const RVolume *VolumeForDevicePath(const char *devicePath) const; - - bool Lock(); - void Unlock(); - - void SetListener(RVolumeListListener *listener); - - void Dump() const; - -private: - RVolume *_AddVolume(dev_t id); - bool _RemoveVolumeAt(int32 index); - void _DeviceMounted(BMessage *message); - void _DeviceUnmounted(BMessage *message); - void _MountPointMoved(BMessage *message); - -private: - mutable BLocker &fLock; - BMessenger fTarget; - BObjectList fVolumes; - BVolumeRoster fRoster; - RVolumeListListener *fListener; -}; - -#endif // VOLUME_LIST_H