Remove kernel_interface.cpp LeafNode dependency
Introduce abstract virtual Node::ReadSymlink() method that is now used in packagefs_read_symlink() instead of casting to LeafNode.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
* Copyright 2009-2011, Ingo Weinhold, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -164,6 +164,13 @@ Directory::Read(io_request* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Directory::ReadSymlink(void* buffer, size_t* bufferSize)
|
||||||
|
{
|
||||||
|
return B_IS_A_DIRECTORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Directory::AddChild(Node* node)
|
Directory::AddChild(Node* node)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
* Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef DIRECTORY_H
|
#ifndef DIRECTORY_H
|
||||||
@@ -48,6 +48,9 @@ public:
|
|||||||
size_t* bufferSize);
|
size_t* bufferSize);
|
||||||
virtual status_t Read(io_request* request);
|
virtual status_t Read(io_request* request);
|
||||||
|
|
||||||
|
virtual status_t ReadSymlink(void* buffer,
|
||||||
|
size_t* bufferSize);
|
||||||
|
|
||||||
void AddChild(Node* node);
|
void AddChild(Node* node);
|
||||||
void RemoveChild(Node* node);
|
void RemoveChild(Node* node);
|
||||||
Node* FindChild(const char* name);
|
Node* FindChild(const char* name);
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
* Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "LeafNode.h"
|
#include "LeafNode.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -168,6 +172,27 @@ LeafNode::Read(io_request* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
LeafNode::ReadSymlink(void* buffer, size_t* bufferSize)
|
||||||
|
{
|
||||||
|
PackageLeafNode* packageNode = fPackageNodes.Head();
|
||||||
|
if (packageNode == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
const char* linkPath = packageNode->SymlinkPath();
|
||||||
|
if (linkPath == NULL) {
|
||||||
|
*bufferSize = 0;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t toCopy = std::min(strlen(linkPath), *bufferSize);
|
||||||
|
memcpy(buffer, linkPath, toCopy);
|
||||||
|
*bufferSize = toCopy;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
LeafNode::SymlinkPath() const
|
LeafNode::SymlinkPath() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
* Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef LEAF_NODE_H
|
#ifndef LEAF_NODE_H
|
||||||
@@ -35,6 +35,9 @@ public:
|
|||||||
size_t* bufferSize);
|
size_t* bufferSize);
|
||||||
virtual status_t Read(io_request* request);
|
virtual status_t Read(io_request* request);
|
||||||
|
|
||||||
|
virtual status_t ReadSymlink(void* buffer,
|
||||||
|
size_t* bufferSize);
|
||||||
|
|
||||||
const char* SymlinkPath() const;
|
const char* SymlinkPath() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
* Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef NODE_H
|
#ifndef NODE_H
|
||||||
@@ -60,6 +60,9 @@ public:
|
|||||||
size_t* bufferSize) = 0;
|
size_t* bufferSize) = 0;
|
||||||
virtual status_t Read(io_request* request) = 0;
|
virtual status_t Read(io_request* request) = 0;
|
||||||
|
|
||||||
|
virtual status_t ReadSymlink(void* buffer,
|
||||||
|
size_t* bufferSize) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
rw_lock fLock;
|
rw_lock fLock;
|
||||||
ino_t fID;
|
ino_t fID;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include "DebugSupport.h"
|
#include "DebugSupport.h"
|
||||||
#include "Directory.h"
|
#include "Directory.h"
|
||||||
#include "GlobalFactory.h"
|
#include "GlobalFactory.h"
|
||||||
#include "LeafNode.h"
|
|
||||||
#include "PackageFSRoot.h"
|
#include "PackageFSRoot.h"
|
||||||
#include "Volume.h"
|
#include "Volume.h"
|
||||||
|
|
||||||
@@ -315,17 +314,7 @@ packagefs_read_symlink(fs_volume* fsVolume, fs_vnode* fsNode, char* buffer,
|
|||||||
if (!S_ISLNK(node->Mode()))
|
if (!S_ISLNK(node->Mode()))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
const char* linkPath = dynamic_cast<LeafNode*>(node)->SymlinkPath();
|
return node->ReadSymlink(buffer, _bufferSize);
|
||||||
if (linkPath == NULL) {
|
|
||||||
*_bufferSize = 0;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t toCopy = std::min(strlen(linkPath), *_bufferSize);
|
|
||||||
memcpy(buffer, linkPath, toCopy);
|
|
||||||
*_bufferSize = toCopy;
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user