126296b0aSIngo Weinhold /* 226296b0aSIngo Weinhold * Copyright 2013, Haiku, Inc. All Rights Reserved. 326296b0aSIngo Weinhold * Distributed under the terms of the MIT License. 426296b0aSIngo Weinhold * 526296b0aSIngo Weinhold * Authors: 626296b0aSIngo Weinhold * Ingo Weinhold <ingo_weinhold@gmx.de> 726296b0aSIngo Weinhold */ 826296b0aSIngo Weinhold #ifndef VOLUME_H 926296b0aSIngo Weinhold #define VOLUME_H 1026296b0aSIngo Weinhold 1126296b0aSIngo Weinhold 123d53bd47SIngo Weinhold #include <Handler.h> 13*8fb3930aSIngo Weinhold #include <Locker.h> 1426296b0aSIngo Weinhold #include <String.h> 1526296b0aSIngo Weinhold 1626296b0aSIngo Weinhold #include <packagefs.h> 17*8fb3930aSIngo Weinhold #include <util/DoublyLinkedList.h> 1826296b0aSIngo Weinhold 193d53bd47SIngo Weinhold #include "Package.h" 203d53bd47SIngo Weinhold 2126296b0aSIngo Weinhold 2226296b0aSIngo Weinhold class BDirectory; 2326296b0aSIngo Weinhold 2426296b0aSIngo Weinhold class Root; 2526296b0aSIngo Weinhold 2626296b0aSIngo Weinhold 273d53bd47SIngo Weinhold class Volume : public BHandler { 2826296b0aSIngo Weinhold public: 29*8fb3930aSIngo Weinhold Volume(BLooper* looper); 303d53bd47SIngo Weinhold virtual ~Volume(); 3126296b0aSIngo Weinhold 323d53bd47SIngo Weinhold status_t Init(const node_ref& rootDirectoryRef, 333d53bd47SIngo Weinhold node_ref& _packageRootRef); 34*8fb3930aSIngo Weinhold status_t InitPackages(); 35*8fb3930aSIngo Weinhold 36*8fb3930aSIngo Weinhold void Unmounted(); 373d53bd47SIngo Weinhold 383d53bd47SIngo Weinhold virtual void MessageReceived(BMessage* message); 3926296b0aSIngo Weinhold 4026296b0aSIngo Weinhold const BString& Path() const 4126296b0aSIngo Weinhold { return fPath; } 4226296b0aSIngo Weinhold PackageFSMountType MountType() const 4326296b0aSIngo Weinhold { return fMountType; } 443d53bd47SIngo Weinhold 453d53bd47SIngo Weinhold const node_ref& RootDirectoryRef() const 463d53bd47SIngo Weinhold { return fRootDirectoryRef; } 4726296b0aSIngo Weinhold dev_t DeviceID() const 483d53bd47SIngo Weinhold { return fRootDirectoryRef.device; } 4926296b0aSIngo Weinhold ino_t RootDirectoryID() const 503d53bd47SIngo Weinhold { return fRootDirectoryRef.node; } 513d53bd47SIngo Weinhold 523d53bd47SIngo Weinhold const node_ref& PackagesDirectoryRef() const 533d53bd47SIngo Weinhold { return fPackagesDirectoryRef; } 543d53bd47SIngo Weinhold dev_t PackagesDeviceID() const 553d53bd47SIngo Weinhold { return fPackagesDirectoryRef.device; } 563d53bd47SIngo Weinhold ino_t PackagesDirectoryID() const 573d53bd47SIngo Weinhold { return fPackagesDirectoryRef.node; } 5826296b0aSIngo Weinhold 5926296b0aSIngo Weinhold Root* GetRoot() const 6026296b0aSIngo Weinhold { return fRoot; } 6126296b0aSIngo Weinhold void SetRoot(Root* root) 6226296b0aSIngo Weinhold { fRoot = root; } 6326296b0aSIngo Weinhold 643d53bd47SIngo Weinhold int OpenRootDirectory() const; 653d53bd47SIngo Weinhold 66*8fb3930aSIngo Weinhold void ProcessPendingNodeMonitorEvents(); 67*8fb3930aSIngo Weinhold 68*8fb3930aSIngo Weinhold private: 69*8fb3930aSIngo Weinhold struct NodeMonitorEvent; 70*8fb3930aSIngo Weinhold typedef DoublyLinkedList<NodeMonitorEvent> NodeMonitorEventList; 71*8fb3930aSIngo Weinhold 723d53bd47SIngo Weinhold private: 733d53bd47SIngo Weinhold void _HandleEntryCreatedOrRemoved( 743d53bd47SIngo Weinhold const BMessage* message, bool created); 753d53bd47SIngo Weinhold void _HandleEntryMoved(const BMessage* message); 76*8fb3930aSIngo Weinhold void _QueueNodeMonitorEvent(const BString& name, 77*8fb3930aSIngo Weinhold bool wasCreated); 783d53bd47SIngo Weinhold 793d53bd47SIngo Weinhold void _PackagesEntryCreated(const char* name); 803d53bd47SIngo Weinhold void _PackagesEntryRemoved(const char* name); 813d53bd47SIngo Weinhold 823d53bd47SIngo Weinhold status_t _ReadPackagesDirectory(); 833d53bd47SIngo Weinhold status_t _GetActivePackages(int fd); 843d53bd47SIngo Weinhold 8526296b0aSIngo Weinhold private: 8626296b0aSIngo Weinhold BString fPath; 8726296b0aSIngo Weinhold PackageFSMountType fMountType; 883d53bd47SIngo Weinhold node_ref fRootDirectoryRef; 893d53bd47SIngo Weinhold node_ref fPackagesDirectoryRef; 9026296b0aSIngo Weinhold Root* fRoot; 913d53bd47SIngo Weinhold PackageFileNameHashTable fPackagesByFileName; 923d53bd47SIngo Weinhold PackageNodeRefHashTable fPackagesByNodeRef; 93*8fb3930aSIngo Weinhold BLocker fPendingNodeMonitorEventsLock; 94*8fb3930aSIngo Weinhold NodeMonitorEventList fPendingNodeMonitorEvents; 9526296b0aSIngo Weinhold }; 9626296b0aSIngo Weinhold 9726296b0aSIngo Weinhold 9826296b0aSIngo Weinhold #endif // VOLUME_H 99