add direct-load method so that encfsctl cat can work with direct cipher paths

git-svn-id: http://encfs.googlecode.com/svn/trunk@19 db9cf616-1c43-0410-9cb8-a902689de0d6
This commit is contained in:
Valient Gough 2008-05-05 03:33:31 +00:00
parent 2123f3580f
commit 4b707677b5
3 changed files with 33 additions and 0 deletions

View File

@ -706,6 +706,22 @@ shared_ptr<FileNode> DirNode::renameNode( const char *from, const char *to,
return node;
}
shared_ptr<FileNode> DirNode::directLookup( const char *path )
{
return shared_ptr<FileNode>(
new FileNode( this,
config->fsSubVersion,
"unknown", path,
config->cipher, config->key,
config->blockSize, config->blockMACBytes,
config->blockMACRandBytes,
config->uniqueIV,
config->externalIVChaining,
config->forceDecode,
config->reverseEncryption,
config->allowHoles) );
}
shared_ptr<FileNode> DirNode::findOrCreate( const char *plainName)
{
shared_ptr<FileNode> node;

View File

@ -135,6 +135,10 @@ public:
shared_ptr<FileNode> openNode( const char *plaintextName,
const char *requestor, int flags, int *openResult );
/* For internal use - open a cipher file directly
*/
shared_ptr<FileNode> directLookup( const char *realPath );
std::string cipherPath( const char *plaintextPath );
std::string plainPath( const char *cipherPath );

View File

@ -334,6 +334,19 @@ int processContents( const shared_ptr<EncFS_Root> &rootInfo,
int errCode = 0;
shared_ptr<FileNode> node = rootInfo->root->openNode( path, "encfsctl",
O_RDONLY, &errCode );
if(!node)
{
// try opening directly, so a cipher-path can be passed in
node = rootInfo->root->directLookup( path );
if(node)
{
errCode = node->open( O_RDONLY );
if(errCode < 0)
node.reset();
}
}
if(!node)
{
cerr << "unable to open " << path << "\n";