package daemon: Let Root know whether it is the system root
This commit is contained in:
parent
99f9333a2a
commit
383ac67cfa
@ -59,11 +59,6 @@ PackageDaemon::Init()
|
||||
_RegisterVolume(device);
|
||||
}
|
||||
|
||||
// find the system root
|
||||
struct stat st;
|
||||
if (stat("/boot", &st) == 0)
|
||||
fSystemRoot = _FindRoot(node_ref(st.st_dev, st.st_ino));
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -175,7 +170,14 @@ PackageDaemon::_GetOrCreateRoot(const node_ref& nodeRef, Root*& _root)
|
||||
RETURN_ERROR(B_NO_MEMORY);
|
||||
ObjectDeleter<Root> rootDeleter(root);
|
||||
|
||||
status_t error = root->Init(nodeRef);
|
||||
bool isSystemRoot = false;
|
||||
if (fSystemRoot == NULL) {
|
||||
struct stat st;
|
||||
isSystemRoot = stat("/boot", &st) == 0
|
||||
&& node_ref(st.st_dev, st.st_ino) == nodeRef;
|
||||
}
|
||||
|
||||
status_t error = root->Init(nodeRef, isSystemRoot);
|
||||
if (error != B_OK)
|
||||
RETURN_ERROR(error);
|
||||
|
||||
@ -184,6 +186,9 @@ PackageDaemon::_GetOrCreateRoot(const node_ref& nodeRef, Root*& _root)
|
||||
|
||||
rootDeleter.Detach();
|
||||
|
||||
if (isSystemRoot)
|
||||
fSystemRoot = root;
|
||||
|
||||
INFORM("root at \"%s\" (device: %" B_PRIdDEV ", node: %" B_PRIdINO ") "
|
||||
"registered\n", root->Path().String(), nodeRef.device,
|
||||
nodeRef.node);
|
||||
|
@ -76,6 +76,7 @@ Root::Root()
|
||||
:
|
||||
fLock("packagefs root"),
|
||||
fNodeRef(),
|
||||
fIsSystemRoot(false),
|
||||
fPath(),
|
||||
fSystemVolume(NULL),
|
||||
fCommonVolume(NULL),
|
||||
@ -96,9 +97,10 @@ Root::~Root()
|
||||
|
||||
|
||||
status_t
|
||||
Root::Init(const node_ref& nodeRef)
|
||||
Root::Init(const node_ref& nodeRef, bool isSystemRoot)
|
||||
{
|
||||
fNodeRef = nodeRef;
|
||||
fIsSystemRoot = isSystemRoot;
|
||||
|
||||
// init members and spawn job runner thread
|
||||
status_t error = fJobQueue.Init();
|
||||
|
@ -29,7 +29,8 @@ public:
|
||||
Root();
|
||||
virtual ~Root();
|
||||
|
||||
status_t Init(const node_ref& nodeRef);
|
||||
status_t Init(const node_ref& nodeRef,
|
||||
bool isSystemRoot);
|
||||
|
||||
const node_ref& NodeRef() const { return fNodeRef; }
|
||||
dev_t DeviceID() const { return fNodeRef.device; }
|
||||
@ -76,6 +77,7 @@ private:
|
||||
private:
|
||||
mutable BLocker fLock;
|
||||
node_ref fNodeRef;
|
||||
bool fIsSystemRoot;
|
||||
BString fPath;
|
||||
Volume* fSystemVolume;
|
||||
Volume* fCommonVolume;
|
||||
|
Loading…
x
Reference in New Issue
Block a user