* Copyright 2001-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#include "Volume.h"
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include "FileSystem.h"
#include "kernel_emu.h"
Volume::Volume(FileSystem* fileSystem, dev_t id)
: fFileSystem(fileSystem),
fID(id)
{
fFileSystem->RegisterVolume(this);
}
Volume::~Volume()
{
fFileSystem->UnregisterVolume(this);
}
UserlandFS::FileSystem*
Volume::GetFileSystem() const
{
return fFileSystem;
}
dev_t
Volume::GetID() const
{
return fID;
}
status_t
Volume::Mount(const char* device, uint32 flags, const char* parameters,
ino_t* rootID)
{
return B_BAD_VALUE;
}
status_t
Volume::Unmount()
{
return B_BAD_VALUE;
}
status_t
Volume::Sync()
{
return B_BAD_VALUE;
}
status_t
Volume::ReadFSInfo(fs_info* info)
{
return B_BAD_VALUE;
}
status_t
Volume::WriteFSInfo(const struct fs_info* info, uint32 mask)
{
return B_BAD_VALUE;
}
status_t
Volume::Lookup(void* dir, const char* entryName, ino_t* vnid)
{
return B_BAD_VALUE;
}
status_t
Volume::GetVNodeType(void* node, int* type)
{
return B_UNSUPPORTED;
}
status_t
Volume::GetVNodeName(void* node, char* buffer, size_t bufferSize)
{
struct stat st;
status_t error = ReadStat(node, &st);
if (error != B_OK)
return error;
ino_t parentID;
error = Lookup(node, "..", &parentID);
if (error != B_OK)
return error;
void* parentNode;
error = UserlandFS::KernelEmu::get_vnode(GetID(), parentID, &parentNode);
UserlandFS::KernelEmu::put_vnode(GetID(), parentID);
if (error != B_OK)
return error;
void* cookie;
error = OpenDir(parentNode, &cookie);
if (error == B_OK) {
while (true) {
char _entry[sizeof(struct dirent) + B_FILE_NAME_LENGTH];
struct dirent* entry = (struct dirent*)_entry;
uint32 num;
error = ReadDir(parentNode, cookie, entry, sizeof(_entry), 1, &num);
if (error != B_OK)
break;
if (num == 0) {
error = B_ENTRY_NOT_FOUND;
break;
}
if (st.st_ino == entry->d_ino) {
size_t nameLen = strnlen(entry->d_name, B_FILE_NAME_LENGTH);
if (nameLen < bufferSize) {
memcpy(buffer, entry->d_name, nameLen);
buffer[nameLen] = '\0';
} else
error = B_BUFFER_OVERFLOW;
break;
}
}
CloseDir(parentNode, cookie);
FreeDirCookie(parentNode, cookie);
}
UserlandFS::KernelEmu::put_vnode(GetID(), parentID);
return error;
}
status_t
Volume::ReadVNode(ino_t vnid, bool reenter, void** node, int* type,
uint32* flags, FSVNodeCapabilities* _capabilities)
{
return B_BAD_VALUE;
}
status_t
Volume::WriteVNode(void* node, bool reenter)
{
return B_BAD_VALUE;
}
status_t
Volume::RemoveVNode(void* node, bool reenter)
{
return B_BAD_VALUE;
}
status_t
Volume::DoIO(void* node, void* cookie, const IORequestInfo& requestInfo)
{
return B_BAD_VALUE;
}
status_t
Volume::CancelIO(void* node, void* cookie, int32 ioRequestID)
{
return B_BAD_VALUE;
}
status_t
Volume::IterativeIOGetVecs(void* cookie, int32 requestID, off_t offset,
size_t size, struct file_io_vec* vecs, size_t* _count)
{
return B_BAD_VALUE;
}
status_t
Volume::IterativeIOFinished(void* cookie, int32 requestID, status_t status,
bool partialTransfer, size_t bytesTransferred)
{
return B_BAD_VALUE;
}
status_t
Volume::IOCtl(void* node, void* cookie, uint32 command, void *buffer,
size_t size)
{
return B_BAD_VALUE;
}
status_t
Volume::SetFlags(void* node, void* cookie, int flags)
{
return B_BAD_VALUE;
}
status_t
Volume::Select(void* node, void* cookie, uint8 event, selectsync* sync)
{
return B_BAD_VALUE;
}
status_t
Volume::Deselect(void* node, void* cookie, uint8 event, selectsync* sync)
{
return B_BAD_VALUE;
}
status_t
Volume::FSync(void* node)
{
return B_BAD_VALUE;
}
status_t
Volume::ReadSymlink(void* node, char* buffer, size_t bufferSize,
size_t* bytesRead)
{
return B_BAD_VALUE;
}
status_t
Volume::CreateSymlink(void* dir, const char* name, const char* target,
int mode)
{
return B_BAD_VALUE;
}
status_t
Volume::Link(void* dir, const char* name, void* node)
{
return B_BAD_VALUE;
}
status_t
Volume::Unlink(void* dir, const char* name)
{
return B_BAD_VALUE;
}
status_t
Volume::Rename(void* oldDir, const char* oldName, void* newDir,
const char* newName)
{
return B_BAD_VALUE;
}
status_t
Volume::Access(void* node, int mode)
{
return B_BAD_VALUE;
}
status_t
Volume::ReadStat(void* node, struct stat* st)
{
return B_BAD_VALUE;
}
status_t
Volume::WriteStat(void* node, const struct stat *st, uint32 mask)
{
return B_BAD_VALUE;
}
status_t
Volume::Create(void* dir, const char* name, int openMode, int mode,
void** cookie, ino_t* vnid)
{
return B_BAD_VALUE;
}
status_t
Volume::Open(void* node, int openMode, void** cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::Close(void* node, void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::FreeCookie(void* node, void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::Read(void* node, void* cookie, off_t pos, void* buffer,
size_t bufferSize, size_t* bytesRead)
{
return B_BAD_VALUE;
}
status_t
Volume::Write(void* node, void* cookie, off_t pos, const void* buffer,
size_t bufferSize, size_t* bytesWritten)
{
return B_BAD_VALUE;
}
status_t
Volume::CreateDir(void* dir, const char* name, int mode)
{
return B_BAD_VALUE;
}
status_t
Volume::RemoveDir(void* dir, const char* name)
{
return B_BAD_VALUE;
}
status_t
Volume::OpenDir(void* node, void** cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::CloseDir(void* node, void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::FreeDirCookie(void* node, void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::ReadDir(void* node, void* cookie, void* buffer, size_t bufferSize,
uint32 count, uint32* countRead)
{
return B_BAD_VALUE;
}
status_t
Volume::RewindDir(void* node, void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::OpenAttrDir(void* node, void** cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::CloseAttrDir(void* node, void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::FreeAttrDirCookie(void* node, void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::ReadAttrDir(void* node, void* cookie, void* buffer,
size_t bufferSize, uint32 count, uint32* countRead)
{
return B_BAD_VALUE;
}
status_t
Volume::RewindAttrDir(void* node, void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::CreateAttr(void* node, const char* name, uint32 type, int openMode,
void** cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::OpenAttr(void* node, const char* name, int openMode,
void** cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::CloseAttr(void* node, void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::FreeAttrCookie(void* node, void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::ReadAttr(void* node, void* cookie, off_t pos, void* buffer,
size_t bufferSize, size_t* bytesRead)
{
return B_BAD_VALUE;
}
status_t
Volume::WriteAttr(void* node, void* cookie, off_t pos,
const void* buffer, size_t bufferSize, size_t* bytesWritten)
{
return B_BAD_VALUE;
}
status_t
Volume::ReadAttrStat(void* node, void* cookie, struct stat *st)
{
return B_BAD_VALUE;
}
status_t
Volume::WriteAttrStat(void* node, void* cookie, const struct stat* st,
int statMask)
{
return B_BAD_VALUE;
}
status_t
Volume::RenameAttr(void* oldNode, const char* oldName, void* newNode,
const char* newName)
{
return B_BAD_VALUE;
}
status_t
Volume::RemoveAttr(void* node, const char* name)
{
return B_BAD_VALUE;
}
status_t
Volume::OpenIndexDir(void** cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::CloseIndexDir(void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::FreeIndexDirCookie(void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::ReadIndexDir(void* cookie, void* buffer, size_t bufferSize,
uint32 count, uint32* countRead)
{
return B_BAD_VALUE;
}
status_t
Volume::RewindIndexDir(void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::CreateIndex(const char* name, uint32 type, uint32 flags)
{
return B_BAD_VALUE;
}
status_t
Volume::RemoveIndex(const char* name)
{
return B_BAD_VALUE;
}
status_t
Volume::ReadIndexStat(const char *name, struct stat *st)
{
return B_BAD_VALUE;
}
status_t
Volume::OpenQuery(const char* queryString, uint32 flags, port_id port,
uint32 token, void** cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::CloseQuery(void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::FreeQueryCookie(void* cookie)
{
return B_BAD_VALUE;
}
status_t
Volume::ReadQuery(void* cookie, void* buffer, size_t bufferSize,
uint32 count, uint32* countRead)
{
return B_BAD_VALUE;
}
status_t
Volume::RewindQuery(void* cookie)
{
return B_BAD_VALUE;
}