btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / servers / package / Root.h
blob26b19532ea028319f12a14de8e2c6a3ea7a0a0c0
1 /*
2 * Copyright 2013, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Ingo Weinhold <ingo_weinhold@gmx.de>
7 */
8 #ifndef ROOT_H
9 #define ROOT_H
12 #include <Locker.h>
13 #include <Node.h>
14 #include <ObjectList.h>
15 #include <OS.h>
16 #include <package/PackageDefs.h>
17 #include <String.h>
19 #include <Referenceable.h>
21 #include <package/packagefs.h>
23 #include "JobQueue.h"
24 #include "Volume.h"
27 class Root : public BReferenceable, private Volume::Listener {
28 public:
29 Root();
30 virtual ~Root();
32 status_t Init(const node_ref& nodeRef,
33 bool isSystemRoot);
35 const node_ref& NodeRef() const { return fNodeRef; }
36 dev_t DeviceID() const { return fNodeRef.device; }
37 ino_t NodeID() const { return fNodeRef.node; }
38 const BString& Path() const { return fPath; }
40 bool IsSystemRoot() const
41 { return fIsSystemRoot; }
43 status_t RegisterVolume(Volume* volume);
44 void UnregisterVolume(Volume* volume);
45 // deletes the volume (eventually)
47 Volume* FindVolume(dev_t deviceID) const;
48 Volume* GetVolume(
49 BPackageInstallationLocation location);
51 void HandleRequest(BMessage* message);
53 private:
54 // Volume::Listener
55 virtual void VolumeNodeMonitorEventOccurred(Volume* volume);
57 protected:
58 virtual void LastReferenceReleased();
60 private:
61 struct AbstractVolumeJob;
62 struct VolumeJob;
63 struct ProcessNodeMonitorEventsJob;
64 struct CommitTransactionJob;
65 struct VolumeJobFilter;
67 friend struct CommitTransactionJob;
69 private:
70 Volume** _GetVolume(PackageFSMountType mountType);
71 Volume* _NextVolumeFor(Volume* volume);
73 void _InitPackages(Volume* volume);
74 void _DeleteVolume(Volume* volume);
75 void _ProcessNodeMonitorEvents(Volume* volume);
76 void _CommitTransaction(Volume* volume,
77 BMessage* message);
79 status_t _QueueJob(Job* job);
81 static status_t _JobRunnerEntry(void* data);
82 status_t _JobRunner();
84 static void _ShowError(const char* errorMessage);
86 private:
87 mutable BLocker fLock;
88 node_ref fNodeRef;
89 bool fIsSystemRoot;
90 BString fPath;
91 Volume* fSystemVolume;
92 Volume* fHomeVolume;
93 JobQueue fJobQueue;
94 thread_id fJobRunner;
98 #endif // ROOT_H