1/*
2 * Copyright 2011-2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include "UnpackingNode.h"
8
9#include "DebugSupport.h"
10#include "Node.h"
11#include "PackageNode.h"
12
13
14UnpackingNode::~UnpackingNode()
15{
16}
17
18
19status_t
20UnpackingNode::CloneTransferPackageNodes(ino_t id, UnpackingNode*& _newNode)
21{
22	return B_BAD_VALUE;
23}
24
25
26status_t
27UnpackingNode::NodeInitVFS(dev_t deviceID, ino_t nodeID,
28	PackageNode* packageNode)
29{
30	status_t error = B_OK;
31	if (packageNode != NULL)
32		error = packageNode->VFSInit(deviceID, nodeID);
33
34	return error;
35}
36
37
38void
39UnpackingNode::NodeUninitVFS(PackageNode* packageNode, uint32& nodeFlags)
40{
41	if (packageNode != NULL) {
42		if ((nodeFlags & NODE_FLAG_VFS_INIT_ERROR) == 0)
43			packageNode->VFSUninit();
44		else
45			nodeFlags &= ~(uint32)NODE_FLAG_VFS_INIT_ERROR;
46	}
47}
48
49
50void
51UnpackingNode::NodeReinitVFS(dev_t deviceID, ino_t nodeID,
52	PackageNode* packageNode, PackageNode* previousPackageNode,
53	uint32& nodeFlags)
54{
55	if ((nodeFlags & NODE_FLAG_KNOWN_TO_VFS) == 0)
56		return;
57
58	if (packageNode != previousPackageNode) {
59		bool hadInitError = (nodeFlags & NODE_FLAG_VFS_INIT_ERROR) != 0;
60		nodeFlags &= ~(uint32)NODE_FLAG_VFS_INIT_ERROR;
61
62		if (packageNode != NULL) {
63			status_t error = packageNode->VFSInit(deviceID, nodeID);
64			if (error != B_OK) {
65				ERROR("UnpackingNode::NodeReinitVFS(): VFSInit() failed for "
66					"(%" B_PRIdDEV ", %" B_PRIdINO ")\n", deviceID, nodeID);
67				nodeFlags |= NODE_FLAG_VFS_INIT_ERROR;
68			}
69		}
70
71		if (previousPackageNode != NULL && !hadInitError)
72			previousPackageNode->VFSUninit();
73	}
74}
75