First walk through the userlandfs kernel add-on to port it to the Haiku

FS interface. Adjusted old hooks, but didn't add the new ones yet. The
module builds now at least.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20235 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2007-02-26 02:54:05 +00:00
parent b881d6401c
commit b12d25d15d
12 changed files with 2481 additions and 2350 deletions

File diff suppressed because it is too large Load Diff

View File

@ -81,26 +81,29 @@ FileSystem::GetPortPool()
// Mount
status_t
FileSystem::Mount(nspace_id id, const char* device, ulong flags,
const char* parameters, int32 len, Volume** _volume)
FileSystem::Mount(mount_id id, const char* device, uint32 flags,
const char* parameters, Volume** _volume)
{
// check initialization and parameters
if (InitCheck() != B_OK)
return InitCheck();
if (!_volume)
return B_BAD_VALUE;
// create volume
Volume* volume = new(nothrow) Volume(this, id);
if (!volume)
return B_NO_MEMORY;
// add volume to the volume list
fVolumeLock.Lock();
status_t error = fVolumes.PushBack(volume);
fVolumeLock.Unlock();
if (error != B_OK)
return error;
// mount volume
error = volume->Mount(device, flags, parameters, len);
error = volume->Mount(device, flags, parameters);
if (error != B_OK) {
fVolumeLock.Lock();
fVolumes.Remove(volume);
@ -108,12 +111,13 @@ FileSystem::Mount(nspace_id id, const char* device, ulong flags,
volume->RemoveReference();
return error;
}
*_volume = volume;
return error;
}
// Initialize
status_t
/*status_t
FileSystem::Initialize(const char* deviceName, const char* parameters,
size_t len)
{
@ -144,7 +148,7 @@ FileSystem::Initialize(const char* deviceName, const char* parameters,
if (reply->error != B_OK)
return reply->error;
return error;
}
}*/
// VolumeUnmounted
void
@ -157,7 +161,7 @@ FileSystem::VolumeUnmounted(Volume* volume)
// GetVolume
Volume*
FileSystem::GetVolume(nspace_id id)
FileSystem::GetVolume(mount_id id)
{
AutoLocker<Locker> _(fVolumeLock);
for (Vector<Volume*>::Iterator it = fVolumes.Begin();

View File

@ -3,7 +3,7 @@
#ifndef USERLAND_FS_FILE_SYSTEM_H
#define USERLAND_FS_FILE_SYSTEM_H
#include <fsproto.h>
#include <fs_interface.h>
#include "LazyInitializable.h"
#include "Locker.h"
@ -35,14 +35,14 @@ public:
RequestPortPool* GetPortPool();
status_t Mount(nspace_id id, const char* device,
status_t Mount(mount_id id, const char* device,
ulong flags, const char* parameters,
int32 len, Volume** volume);
status_t Initialize(const char* deviceName,
const char* parameters, size_t len);
Volume** volume);
// status_t Initialize(const char* deviceName,
// const char* parameters, size_t len);
void VolumeUnmounted(Volume* volume);
Volume* GetVolume(nspace_id id);
Volume* GetVolume(mount_id id);
const IOCtlInfo* GetIOCtlInfo(int command) const;

View File

@ -8,6 +8,8 @@
#include "Requests.h"
#include "Volume.h"
#include <NodeMonitor.h>
// VolumePutter
class VolumePutter {
public:
@ -140,7 +142,7 @@ KernelRequestHandler::_HandleRequest(NotifySelectEventRequest* request)
status_t result = B_OK;
if (fFileSystem->KnowsSelectSyncEntry(request->sync)) {
PRINT(("notify_select_event(%p, %lu)\n", request->sync, request->ref));
notify_select_event(request->sync, request->ref);
notify_select_event(request->sync, request->ref, request->event);
} else
result = B_BAD_VALUE;
// prepare the reply
@ -338,7 +340,7 @@ KernelRequestHandler::_HandleRequest(IsVNodeRemovedRequest* request)
// _GetVolume
status_t
KernelRequestHandler::_GetVolume(nspace_id id, Volume** volume)
KernelRequestHandler::_GetVolume(mount_id id, Volume** volume)
{
if (fVolume) {
if (fVolume->GetID() != id) {

View File

@ -3,7 +3,7 @@
#ifndef USERLAND_FS_KERNEL_REQUEST_HANDLER_H
#define USERLAND_FS_KERNEL_REQUEST_HANDLER_H
#include <fsproto.h>
#include <fs_interface.h>
#include "RequestHandler.h"
@ -59,7 +59,7 @@ private:
status_t _HandleRequest(UnremoveVNodeRequest* request);
status_t _HandleRequest(IsVNodeRemovedRequest* request);
status_t _GetVolume(nspace_id id, Volume** volume);
status_t _GetVolume(mount_id id, Volume** volume);
private:
FileSystem* fFileSystem;

View File

@ -202,16 +202,18 @@ Settings::GetIOCtlInfo(int command) const
void
Settings::Dump() const
{
PRINT(("Settings:\n"));
if (fIOCtlInfos) {
for (IOCtlInfoMap::Iterator it = fIOCtlInfos->GetIterator();
it.HasNext();) {
IOCtlInfoMap::Entry entry = it.Next();
IOCtlInfo* info = entry.value;
PRINT((" ioctl %d: buffer size: %ld, write buffer size: %ld\n",
info->command, info->bufferSize, info->writeBufferSize));
D(
PRINT(("Settings:\n"));
if (fIOCtlInfos) {
for (IOCtlInfoMap::Iterator it = fIOCtlInfos->GetIterator();
it.HasNext();) {
IOCtlInfoMap::Entry entry = it.Next();
IOCtlInfo* info = entry.value;
PRINT((" ioctl %d: buffer size: %ld, write buffer size: %ld\n",
info->command, info->bufferSize, info->writeBufferSize));
}
}
}
)
}
// _Init

View File

@ -14,18 +14,14 @@
typedef AutoLocker<UserlandFS::FileSystemMap> FileSystemLocker;
UserlandFS* volatile UserlandFS::sUserlandFS = NULL;
spinlock UserlandFS::sUserlandFSLock = 0;
vint32 UserlandFS::sMountedFileSystems = 0;
UserlandFS* UserlandFS::sUserlandFS = NULL;
// constructor
UserlandFS::UserlandFS()
: LazyInitializable(),
fPort(NULL),
: fPort(NULL),
fFileSystems(NULL),
fDebuggerCommandsAdded(false)
{
// beware what you do here: the caller holds a spin lock
}
// destructor
@ -50,88 +46,34 @@ PRINT(("UserlandFS::~UserlandFS()\n"))
KernelDebug::RemoveDebuggerCommands();
}
// RegisterUserlandFS
// InitUserlandFS
status_t
UserlandFS::RegisterUserlandFS(UserlandFS** _userlandFS)
UserlandFS::InitUserlandFS(UserlandFS** _userlandFS)
{
// first check, if there's already an instance
bool create = false;
// create the singleton instance
sUserlandFS = new(nothrow) UserlandFS;
if (!sUserlandFS)
return B_NO_MEMORY;
cpu_status cpuStatus = disable_interrupts();
acquire_spinlock(&sUserlandFSLock);
if (sUserlandFS)
sMountedFileSystems++;
else
create = true;
release_spinlock(&sUserlandFSLock);
restore_interrupts(cpuStatus);
// if there's not, create a new
status_t error = B_OK;
if (create) {
// first create an instance
// Note, that we can't even construct a LazyInitializable with a
// spinlock being held, since it allocates a semaphore, which may
// allocate memory, which will acquire a semaphore.
UserlandFS* userlandFS = new(nothrow) UserlandFS;
if (userlandFS) {
// now set the instance unless someone else beat us to it
bool deleteInstance = false;
cpu_status cpuStatus = disable_interrupts();
acquire_spinlock(&sUserlandFSLock);
sMountedFileSystems++;
if (sUserlandFS)
deleteInstance = true;
else
sUserlandFS = userlandFS;
release_spinlock(&sUserlandFSLock);
restore_interrupts(cpuStatus);
// delete the new instance, if there was one already
if (deleteInstance)
delete userlandFS;
} else
error = B_NO_MEMORY;
}
if (error != B_OK)
// init the thing
status_t error = sUserlandFS->_Init();
if (error != B_OK) {
delete sUserlandFS;
sUserlandFS = NULL;
return error;
}
// init the thing, if necessary
error = sUserlandFS->Access();
if (error == B_OK)
*_userlandFS = sUserlandFS;
else
UnregisterUserlandFS();
return error;
*_userlandFS = sUserlandFS;
return B_OK;
}
// UnregisterUserlandFS
// UninitUserlandFS
void
UserlandFS::UnregisterUserlandFS()
UserlandFS::UninitUserlandFS()
{
cpu_status cpuStatus = disable_interrupts();
acquire_spinlock(&sUserlandFSLock);
--sMountedFileSystems;
UserlandFS* userlandFS = NULL;
if (sMountedFileSystems == 0 && sUserlandFS) {
userlandFS = sUserlandFS;
sUserlandFS = NULL;
}
release_spinlock(&sUserlandFSLock);
restore_interrupts(cpuStatus);
// delete, if the last FS has been unmounted
if (userlandFS) {
userlandFS->~UserlandFS();
delete[] (uint8*)userlandFS;
}
delete sUserlandFS;
sUserlandFS = NULL;
}
// GetUserlandFS
@ -145,11 +87,10 @@ UserlandFS::GetUserlandFS()
status_t
UserlandFS::RegisterFileSystem(const char* name, FileSystem** _fileSystem)
{
// check initialization and parameters
if (InitCheck() != B_OK)
return InitCheck();
// check parameters
if (!name || !_fileSystem)
return B_BAD_VALUE;
// check, if we do already know this file system, and create it, if not
FileSystem* fileSystem;
{
@ -170,12 +111,14 @@ UserlandFS::RegisterFileSystem(const char* name, FileSystem** _fileSystem)
}
}
}
// prepare the file system
status_t error = fileSystem->Access();
if (error != B_OK) {
UnregisterFileSystem(fileSystem);
return error;
}
*_fileSystem = fileSystem;
return error;
}
@ -186,6 +129,7 @@ UserlandFS::UnregisterFileSystem(FileSystem* fileSystem)
{
if (!fileSystem)
return B_BAD_VALUE;
// find the FS and decrement its reference counter
bool deleteFS = false;
{
@ -197,6 +141,7 @@ UserlandFS::UnregisterFileSystem(FileSystem* fileSystem)
if (deleteFS)
fFileSystems->Remove(fileSystem->GetName());
}
// delete the FS, if the last reference has been removed
if (deleteFS)
delete fileSystem;
@ -210,13 +155,14 @@ UserlandFS::CountFileSystems() const
return fFileSystems->Size();
}
// FirstTimeInit
// _Init
status_t
UserlandFS::FirstTimeInit()
UserlandFS::_Init()
{
// add debugger commands
KernelDebug::AddDebuggerCommands();
fDebuggerCommandsAdded = true;
// create file system map
fFileSystems = new(nothrow) FileSystemMap;
if (!fFileSystems)
@ -224,6 +170,7 @@ UserlandFS::FirstTimeInit()
status_t error = fFileSystems->InitCheck();
if (error != B_OK)
RETURN_ERROR(error);
// find the dispatcher ports
port_id port = find_port(kUserlandFSDispatcherPortName);
if (port < 0)
@ -231,11 +178,13 @@ UserlandFS::FirstTimeInit()
port_id replyPort = find_port(kUserlandFSDispatcherReplyPortName);
if (replyPort < 0)
RETURN_ERROR(B_ERROR);
// create a reply port
// send a connection request
error = write_port(port, UFS_DISPATCHER_CONNECT, NULL, 0);
if (error != B_OK)
RETURN_ERROR(error);
// receive the reply
int32 replyCode;
Port::Info portInfo;
@ -247,12 +196,14 @@ UserlandFS::FirstTimeInit()
RETURN_ERROR(B_BAD_DATA);
if (bytesRead != sizeof(Port::Info))
RETURN_ERROR(B_BAD_DATA);
// create a request port
fPort = new(nothrow) RequestPort(&portInfo);
if (!fPort)
RETURN_ERROR(B_NO_MEMORY);
if ((error = fPort->InitCheck()) != B_OK)
RETURN_ERROR(error);
RETURN_ERROR(error);
}

View File

@ -6,7 +6,6 @@
#include <SupportDefs.h>
#include "HashMap.h"
#include "LazyInitializable.h"
#include "String.h"
namespace UserlandFSUtil {
@ -19,14 +18,14 @@ using UserlandFSUtil::RequestPort;
class FileSystem;
class UserlandFS : public LazyInitializable {
class UserlandFS {
private:
UserlandFS();
~UserlandFS();
public:
static status_t RegisterUserlandFS(UserlandFS** userlandFS);
static void UnregisterUserlandFS();
static status_t InitUserlandFS(UserlandFS** userlandFS);
static void UninitUserlandFS();
static UserlandFS* GetUserlandFS();
status_t RegisterFileSystem(const char* name,
@ -35,16 +34,14 @@ public:
int32 CountFileSystems() const;
protected:
virtual status_t FirstTimeInit();
private:
status_t _Init();
private:
friend class KernelDebug;
typedef SynchronizedHashMap<String, FileSystem*> FileSystemMap;
static UserlandFS* volatile sUserlandFS;
static spinlock sUserlandFSLock;
static vint32 sMountedFileSystems;
static UserlandFS* sUserlandFS;
RequestPort* fPort;
FileSystemMap* fFileSystems;

View File

@ -3,7 +3,7 @@
#ifndef USERLAND_FS_VOLUME_H
#define USERLAND_FS_VOLUME_H
#include <fsproto.h>
#include <fs_interface.h>
#include "Referencable.h"
@ -24,11 +24,11 @@ struct userlandfs_ioctl;
class Volume : public Referencable {
public:
Volume(FileSystem* fileSystem, nspace_id id);
Volume(FileSystem* fileSystem, mount_id id);
~Volume();
FileSystem* GetFileSystem() const;
nspace_id GetID() const;
mount_id GetID() const;
void* GetUserlandVolume() const;
vnode_id GetRootID() const;
@ -43,133 +43,143 @@ public:
status_t IsVNodeRemoved(vnode_id vnid);
// FS
status_t Mount(const char* device, ulong flags,
const char* parameters, int32 len);
status_t Mount(const char* device, uint32 flags,
const char* parameters);
status_t Unmount();
status_t Sync();
status_t ReadFSStat(fs_info* info);
status_t WriteFSStat(struct fs_info* info, long mask);
status_t ReadFSInfo(fs_info* info);
status_t WriteFSInfo(const struct fs_info* info,
uint32 mask);
// vnodes
status_t ReadVNode(vnode_id vnid, char reenter,
void** node);
status_t WriteVNode(void* node, char reenter);
status_t RemoveVNode(void* node, char reenter);
status_t Lookup(fs_vnode dir, const char* entryName,
vnode_id* vnid, int* type);
status_t ReadVNode(vnode_id vnid, bool reenter,
fs_vnode* node);
status_t WriteVNode(fs_vnode node, bool reenter);
status_t RemoveVNode(fs_vnode node, bool reenter);
// nodes
status_t FSync(void* node);
status_t ReadStat(void* node, struct stat* st);
status_t WriteStat(void* node, struct stat *st,
long mask);
status_t Access(void* node, int mode);
status_t IOCtl(fs_vnode node, fs_cookie cookie,
uint32 command, void *buffer, size_t size);
status_t SetFlags(fs_vnode node, fs_cookie cookie,
int flags);
status_t Select(fs_vnode node, fs_cookie cookie,
uint8 event, uint32 ref, selectsync* sync);
status_t Deselect(fs_vnode node, fs_cookie cookie,
uint8 event, selectsync* sync);
status_t FSync(fs_vnode node);
status_t ReadSymlink(fs_vnode node, char* buffer,
size_t bufferSize, size_t* bytesRead);
status_t CreateSymlink(fs_vnode dir, const char* name,
const char* target, int mode);
status_t Link(fs_vnode dir, const char* name,
fs_vnode node);
status_t Unlink(fs_vnode dir, const char* name);
status_t Rename(fs_vnode oldDir, const char* oldName,
fs_vnode newDir, const char* newName);
status_t Access(fs_vnode node, int mode);
status_t ReadStat(fs_vnode node, struct stat* st);
status_t WriteStat(fs_vnode node, const struct stat *st,
uint32 mask);
// files
status_t Create(void* dir, const char* name,
int openMode, int mode, vnode_id* vnid,
void** cookie);
status_t Open(void* node, int openMode, void** cookie);
status_t Close(void* node, void* cookie);
status_t FreeCookie(void* node, void* cookie);
status_t Read(void* node, void* cookie, off_t pos,
status_t Create(fs_vnode dir, const char* name,
int openMode, int mode, fs_cookie* cookie,
vnode_id* vnid);
status_t Open(fs_vnode node, int openMode,
fs_cookie* cookie);
status_t Close(fs_vnode node, fs_cookie cookie);
status_t FreeCookie(fs_vnode node, fs_cookie cookie);
status_t Read(fs_vnode node, fs_cookie cookie, off_t pos,
void* buffer, size_t bufferSize,
size_t* bytesRead);
status_t Write(void* node, void* cookie, off_t pos,
const void* buffer, size_t bufferSize,
size_t* bytesWritten);
status_t IOCtl(void* node, void* cookie, int command,
void *buffer, size_t size);
status_t SetFlags(void* node, void* cookie, int flags);
status_t Select(void* node, void* cookie, uint8 event,
uint32 ref, selectsync* sync);
status_t Deselect(void* node, void* cookie, uint8 event,
selectsync* sync);
// hard links / symlinks
status_t Link(void* dir, const char* name, void* node);
status_t Unlink(void* dir, const char* name);
status_t Symlink(void* dir, const char* name,
const char* target);
status_t ReadLink(void* node, char* buffer,
size_t bufferSize, size_t* bytesRead);
status_t Rename(void* oldDir, const char* oldName,
void* newDir, const char* newName);
status_t Write(fs_vnode node, fs_cookie cookie,
off_t pos, const void* buffer,
size_t bufferSize, size_t* bytesWritten);
// directories
status_t MkDir(void* dir, const char* name, int mode);
status_t RmDir(void* dir, const char* name);
status_t OpenDir(void* node, void** cookie);
status_t CloseDir(void* node, void* cookie);
status_t FreeDirCookie(void* node, void* cookie);
status_t ReadDir(void* node, void* cookie,
status_t CreateDir(fs_vnode dir, const char* name,
int mode, vnode_id *newDir);
status_t RemoveDir(fs_vnode dir, const char* name);
status_t OpenDir(fs_vnode node, fs_cookie* cookie);
status_t CloseDir(fs_vnode node, fs_vnode cookie);
status_t FreeDirCookie(fs_vnode node, fs_vnode cookie);
status_t ReadDir(fs_vnode node, fs_vnode cookie,
void* buffer, size_t bufferSize,
int32 count, int32* countRead);
status_t RewindDir(void* node, void* cookie);
status_t Walk(void* dir, const char* entryName,
char** resolvedPath, vnode_id* vnid);
uint32 count, uint32* countRead);
status_t RewindDir(fs_vnode node, fs_vnode cookie);
// attribute directories
status_t OpenAttrDir(fs_vnode node, fs_cookie *cookie);
status_t CloseAttrDir(fs_vnode node, fs_cookie cookie);
status_t FreeAttrDirCookie(fs_vnode node,
fs_cookie cookie);
status_t ReadAttrDir(fs_vnode node, fs_cookie cookie,
void* buffer, size_t bufferSize,
uint32 count, uint32* countRead);
status_t RewindAttrDir(fs_vnode node, fs_cookie cookie);
// attributes
status_t OpenAttrDir(void* node, void** cookie);
status_t CloseAttrDir(void* node, void* cookie);
status_t FreeAttrDirCookie(void* node, void* cookie);
status_t ReadAttrDir(void* node, void* cookie,
void* buffer, size_t bufferSize,
int32 count, int32* countRead);
status_t RewindAttrDir(void* node, void* cookie);
status_t ReadAttr(void* node, const char* name,
int type, off_t pos, void* buffer,
size_t bufferSize, size_t* bytesRead);
status_t WriteAttr(void* node, const char* name,
int type, off_t pos, const void* buffer,
status_t ReadAttr(fs_vnode node, fs_cookie cookie,
off_t pos, void* buffer, size_t bufferSize,
size_t* bytesRead);
status_t WriteAttr(fs_vnode node, fs_cookie cookie,
off_t pos, const void* buffer,
size_t bufferSize, size_t* bytesWritten);
status_t RemoveAttr(void* node, const char* name);
status_t RenameAttr(void* node, const char* oldName,
status_t ReadAttrStat(fs_vnode node, fs_cookie cookie,
struct stat *st);
status_t RenameAttr(fs_vnode oldNode,
const char* oldName, fs_vnode newNode,
const char* newName);
status_t StatAttr(void* node, const char* name,
struct attr_info* attrInfo);
status_t RemoveAttr(fs_vnode node, const char* name);
// indices
status_t OpenIndexDir(void** cookie);
status_t CloseIndexDir(void* cookie);
status_t FreeIndexDirCookie(void* cookie);
status_t ReadIndexDir(void* cookie, void* buffer,
size_t bufferSize, int32 count,
int32* countRead);
status_t RewindIndexDir(void* cookie);
status_t CreateIndex(const char* name, int type,
int flags);
status_t OpenIndexDir(fs_cookie *cookie);
status_t CloseIndexDir(fs_cookie cookie);
status_t FreeIndexDirCookie(fs_cookie cookie);
status_t ReadIndexDir(fs_cookie cookie, void* buffer,
size_t bufferSize, uint32 count,
uint32* countRead);
status_t RewindIndexDir(fs_cookie cookie);
status_t CreateIndex(const char* name, uint32 type,
uint32 flags);
status_t RemoveIndex(const char* name);
status_t RenameIndex(const char* oldName,
const char* newName);
status_t StatIndex(const char *name,
struct index_info* indexInfo);
status_t ReadIndexStat(const char *name,
struct stat *st);
// queries
status_t OpenQuery(const char* queryString,
ulong flags, port_id port, long token,
void** cookie);
status_t CloseQuery(void* cookie);
status_t FreeQueryCookie(void* cookie);
status_t ReadQuery(void* cookie, void* buffer,
size_t bufferSize, int32 count,
int32* countRead);
uint32 flags, port_id port, uint32 token,
fs_cookie *cookie);
status_t CloseQuery(fs_cookie cookie);
status_t FreeQueryCookie(fs_cookie cookie);
status_t ReadQuery(fs_cookie cookie, void* buffer,
size_t bufferSize, uint32 count,
uint32* countRead);
private:
status_t _Mount(const char* device, ulong flags,
const char* parameters, int32 len);
status_t _Mount(const char* device, uint32 flags,
const char* parameters);
status_t _Unmount();
status_t _WriteVNode(void* node, char reenter);
status_t _Close(void* node, void* cookie);
status_t _FreeCookie(void* node, void* cookie);
status_t _CloseDir(void* node, void* cookie);
status_t _FreeDirCookie(void* node, void* cookie);
status_t _Walk(void* dir, const char* entryName,
char** resolvedPath, vnode_id* vnid);
status_t _CloseAttrDir(void* node, void* cookie);
status_t _FreeAttrDirCookie(void* node, void* cookie);
status_t _CloseIndexDir(void* cookie);
status_t _FreeIndexDirCookie(void* cookie);
status_t _CloseQuery(void* cookie);
status_t _FreeQueryCookie(void* cookie);
status_t _Lookup(fs_vnode dir, const char* entryName,
vnode_id* vnid, int* type);
status_t _WriteVNode(fs_vnode node, bool reenter);
status_t _Close(fs_vnode node, fs_cookie cookie);
status_t _FreeCookie(fs_vnode node, fs_cookie cookie);
status_t _CloseDir(fs_vnode node, fs_vnode cookie);
status_t _FreeDirCookie(fs_vnode node, fs_vnode cookie);
status_t _CloseAttrDir(fs_vnode node, fs_cookie cookie);
status_t _FreeAttrDirCookie(fs_vnode node,
fs_cookie cookie);
status_t _CloseIndexDir(fs_cookie cookie);
status_t _FreeIndexDirCookie(fs_cookie cookie);
status_t _CloseQuery(fs_cookie cookie);
status_t _FreeQueryCookie(fs_cookie cookie);
status_t _SendRequest(RequestPort* port,
RequestAllocator* allocator,
@ -190,10 +200,10 @@ private:
class AutoIncrementer;
FileSystem* fFileSystem;
nspace_id fID;
mount_id fID;
void* fUserlandVolume;
vnode_id fRootID;
void* fRootNode;
fs_vnode fRootNode;
MountVNodeMap* fMountVNodes;
vint32 fOpenFiles;
vint32 fOpenDirectories;
@ -201,6 +211,9 @@ private:
vint32 fOpenIndexDirectories;
vint32 fOpenQueries;
VNodeCountMap* fVNodeCountMap;
// Tracks the number of new/get_vnode()
// calls to be balanced by the FS by
// corresponding put_vnode()s.
volatile bool fVNodeCountingEnabled;
};

View File

@ -44,14 +44,14 @@ MountVolumeRequest::GetAddressInfos(AddressInfo* infos, int32* count)
return B_OK;
}
// InitializeVolumeRequest
status_t
InitializeVolumeRequest::GetAddressInfos(AddressInfo* infos, int32* count)
{
ADD_STRING(device);
ADD_STRING(parameters);
return B_OK;
}
//// InitializeVolumeRequest
//status_t
//InitializeVolumeRequest::GetAddressInfos(AddressInfo* infos, int32* count)
//{
// ADD_STRING(device);
// ADD_STRING(parameters);
// return B_OK;
//}
// CreateRequest
status_t
@ -109,18 +109,18 @@ UnlinkRequest::GetAddressInfos(AddressInfo* infos, int32* count)
return B_OK;
}
// SymlinkRequest
// CreateSymlinkRequest
status_t
SymlinkRequest::GetAddressInfos(AddressInfo* infos, int32* count)
CreateSymlinkRequest::GetAddressInfos(AddressInfo* infos, int32* count)
{
ADD_NON_NULL_STRING(name);
ADD_NON_NULL_STRING(target);
return B_OK;
}
// ReadLinkReply
// ReadSymlinkReply
status_t
ReadLinkReply::GetAddressInfos(AddressInfo* infos, int32* count)
ReadSymlinkReply::GetAddressInfos(AddressInfo* infos, int32* count)
{
ADD_STRING(buffer);
return B_OK;
@ -135,17 +135,17 @@ RenameRequest::GetAddressInfos(AddressInfo* infos, int32* count)
return B_OK;
}
// MkDirRequest
// CreateDirRequest
status_t
MkDirRequest::GetAddressInfos(AddressInfo* infos, int32* count)
CreateDirRequest::GetAddressInfos(AddressInfo* infos, int32* count)
{
ADD_NON_NULL_STRING(name);
return B_OK;
}
// RmDirRequest
// RemoveDirRequest
status_t
RmDirRequest::GetAddressInfos(AddressInfo* infos, int32* count)
RemoveDirRequest::GetAddressInfos(AddressInfo* infos, int32* count)
{
ADD_NON_NULL_STRING(name);
return B_OK;
@ -159,22 +159,14 @@ ReadDirReply::GetAddressInfos(AddressInfo* infos, int32* count)
return B_OK;
}
// WalkRequest
// LookupRequest
status_t
WalkRequest::GetAddressInfos(AddressInfo* infos, int32* count)
LookupRequest::GetAddressInfos(AddressInfo* infos, int32* count)
{
ADD_NON_NULL_STRING(entryName);
return B_OK;
}
// WalkReply
status_t
WalkReply::GetAddressInfos(AddressInfo* infos, int32* count)
{
ADD_STRING(resolvedPath);
return B_OK;
}
// ReadAttrDirReply
status_t
ReadAttrDirReply::GetAddressInfos(AddressInfo* infos, int32* count)
@ -183,14 +175,6 @@ ReadAttrDirReply::GetAddressInfos(AddressInfo* infos, int32* count)
return B_OK;
}
// ReadAttrRequest
status_t
ReadAttrRequest::GetAddressInfos(AddressInfo* infos, int32* count)
{
ADD_NON_NULL_STRING(name);
return B_OK;
}
// ReadAttrReply
status_t
ReadAttrReply::GetAddressInfos(AddressInfo* infos, int32* count)
@ -203,7 +187,6 @@ ReadAttrReply::GetAddressInfos(AddressInfo* infos, int32* count)
status_t
WriteAttrRequest::GetAddressInfos(AddressInfo* infos, int32* count)
{
ADD_NON_NULL_STRING(name);
ADD_ADDRESS(buffer);
return B_OK;
}
@ -225,14 +208,6 @@ RenameAttrRequest::GetAddressInfos(AddressInfo* infos, int32* count)
return B_OK;
}
// StatAttrRequest
status_t
StatAttrRequest::GetAddressInfos(AddressInfo* infos, int32* count)
{
ADD_NON_NULL_STRING(name);
return B_OK;
}
// ReadIndexDirReply
status_t
ReadIndexDirReply::GetAddressInfos(AddressInfo* infos, int32* count)
@ -257,18 +232,9 @@ RemoveIndexRequest::GetAddressInfos(AddressInfo* infos, int32* count)
return B_OK;
}
// RenameIndexRequest
// ReadIndexStatRequest
status_t
RenameIndexRequest::GetAddressInfos(AddressInfo* infos, int32* count)
{
ADD_NON_NULL_STRING(oldName);
ADD_NON_NULL_STRING(newName);
return B_OK;
}
// StatIndexRequest
status_t
StatIndexRequest::GetAddressInfos(AddressInfo* infos, int32* count)
ReadIndexStatRequest::GetAddressInfos(AddressInfo* infos, int32* count)
{
ADD_NON_NULL_STRING(name);
return B_OK;
@ -499,37 +465,57 @@ UserlandFSUtil::is_kernel_request(uint32 type)
// FS
case MOUNT_VOLUME_REQUEST:
case UNMOUNT_VOLUME_REQUEST:
case INITIALIZE_VOLUME_REQUEST:
// case INITIALIZE_VOLUME_REQUEST:
case SYNC_VOLUME_REQUEST:
case READ_FS_STAT_REQUEST:
case WRITE_FS_STAT_REQUEST:
case READ_FS_INFO_REQUEST:
case WRITE_FS_INFO_REQUEST:
return true;
case MOUNT_VOLUME_REPLY:
case UNMOUNT_VOLUME_REPLY:
case INITIALIZE_VOLUME_REPLY:
// case INITIALIZE_VOLUME_REPLY:
case SYNC_VOLUME_REPLY:
case READ_FS_STAT_REPLY:
case WRITE_FS_STAT_REPLY:
case READ_FS_INFO_REPLY:
case WRITE_FS_INFO_REPLY:
return false;
// vnodes
case LOOKUP_REQUEST:
case READ_VNODE_REQUEST:
case WRITE_VNODE_REQUEST:
case FS_REMOVE_VNODE_REQUEST:
return true;
case LOOKUP_REPLY:
case READ_VNODE_REPLY:
case WRITE_VNODE_REPLY:
case FS_REMOVE_VNODE_REPLY:
return false;
// nodes
case IOCTL_REQUEST:
case SET_FLAGS_REQUEST:
case SELECT_REQUEST:
case DESELECT_REQUEST:
case FSYNC_REQUEST:
case READ_SYMLINK_REQUEST:
case CREATE_SYMLINK_REQUEST:
case LINK_REQUEST:
case UNLINK_REQUEST:
case RENAME_REQUEST:
case ACCESS_REQUEST:
case READ_STAT_REQUEST:
case WRITE_STAT_REQUEST:
case ACCESS_REQUEST:
return true;
case IOCTL_REPLY:
case SET_FLAGS_REPLY:
case SELECT_REPLY:
case DESELECT_REPLY:
case FSYNC_REPLY:
case READ_SYMLINK_REPLY:
case CREATE_SYMLINK_REPLY:
case LINK_REPLY:
case UNLINK_REPLY:
case RENAME_REPLY:
case ACCESS_REPLY:
case READ_STAT_REPLY:
case WRITE_STAT_REPLY:
case ACCESS_REPLY:
return false;
// files
case CREATE_REQUEST:
@ -538,10 +524,6 @@ UserlandFSUtil::is_kernel_request(uint32 type)
case FREE_COOKIE_REQUEST:
case READ_REQUEST:
case WRITE_REQUEST:
case IOCTL_REQUEST:
case SET_FLAGS_REQUEST:
case SELECT_REQUEST:
case DESELECT_REQUEST:
return true;
case CREATE_REPLY:
case OPEN_REPLY:
@ -549,65 +531,49 @@ UserlandFSUtil::is_kernel_request(uint32 type)
case FREE_COOKIE_REPLY:
case READ_REPLY:
case WRITE_REPLY:
case IOCTL_REPLY:
case SET_FLAGS_REPLY:
case SELECT_REPLY:
case DESELECT_REPLY:
return false;
// hard links / symlinks
case LINK_REQUEST:
case UNLINK_REQUEST:
case SYMLINK_REQUEST:
case READ_LINK_REQUEST:
case RENAME_REQUEST:
return true;
case LINK_REPLY:
case UNLINK_REPLY:
case SYMLINK_REPLY:
case READ_LINK_REPLY:
case RENAME_REPLY:
return false;
// directories
case MKDIR_REQUEST:
case RMDIR_REQUEST:
case CREATE_DIR_REQUEST:
case REMOVE_DIR_REQUEST:
case OPEN_DIR_REQUEST:
case CLOSE_DIR_REQUEST:
case FREE_DIR_COOKIE_REQUEST:
case READ_DIR_REQUEST:
case REWIND_DIR_REQUEST:
case WALK_REQUEST:
return true;
case MKDIR_REPLY:
case RMDIR_REPLY:
case CREATE_DIR_REPLY:
case REMOVE_DIR_REPLY:
case OPEN_DIR_REPLY:
case CLOSE_DIR_REPLY:
case FREE_DIR_COOKIE_REPLY:
case READ_DIR_REPLY:
case REWIND_DIR_REPLY:
case WALK_REPLY:
return false;
// attributes
// attribute directories
case OPEN_ATTR_DIR_REQUEST:
case CLOSE_ATTR_DIR_REQUEST:
case FREE_ATTR_DIR_COOKIE_REQUEST:
case READ_ATTR_DIR_REQUEST:
case REWIND_ATTR_DIR_REQUEST:
case READ_ATTR_REQUEST:
case WRITE_ATTR_REQUEST:
case REMOVE_ATTR_REQUEST:
case RENAME_ATTR_REQUEST:
case STAT_ATTR_REQUEST:
return true;
case OPEN_ATTR_DIR_REPLY:
case CLOSE_ATTR_DIR_REPLY:
case FREE_ATTR_DIR_COOKIE_REPLY:
case READ_ATTR_DIR_REPLY:
case REWIND_ATTR_DIR_REPLY:
return false;
// attributes
case READ_ATTR_REQUEST:
case WRITE_ATTR_REQUEST:
case READ_ATTR_STAT_REQUEST:
case RENAME_ATTR_REQUEST:
case REMOVE_ATTR_REQUEST:
return true;
case READ_ATTR_REPLY:
case WRITE_ATTR_REPLY:
case REMOVE_ATTR_REPLY:
case READ_ATTR_STAT_REPLY:
case RENAME_ATTR_REPLY:
case STAT_ATTR_REPLY:
case REMOVE_ATTR_REPLY:
return false;
// indices
case OPEN_INDEX_DIR_REQUEST:
@ -617,8 +583,7 @@ UserlandFSUtil::is_kernel_request(uint32 type)
case REWIND_INDEX_DIR_REQUEST:
case CREATE_INDEX_REQUEST:
case REMOVE_INDEX_REQUEST:
case RENAME_INDEX_REQUEST:
case STAT_INDEX_REQUEST:
case READ_INDEX_STAT_REQUEST:
return true;
case OPEN_INDEX_DIR_REPLY:
case CLOSE_INDEX_DIR_REPLY:
@ -627,8 +592,7 @@ UserlandFSUtil::is_kernel_request(uint32 type)
case REWIND_INDEX_DIR_REPLY:
case CREATE_INDEX_REPLY:
case REMOVE_INDEX_REPLY:
case RENAME_INDEX_REPLY:
case STAT_INDEX_REPLY:
case READ_INDEX_STAT_REPLY:
return false;
// queries
case OPEN_QUERY_REQUEST:
@ -691,37 +655,57 @@ UserlandFSUtil::is_userland_request(uint32 type)
// FS
case MOUNT_VOLUME_REQUEST:
case UNMOUNT_VOLUME_REQUEST:
case INITIALIZE_VOLUME_REQUEST:
// case INITIALIZE_VOLUME_REQUEST:
case SYNC_VOLUME_REQUEST:
case READ_FS_STAT_REQUEST:
case WRITE_FS_STAT_REQUEST:
case READ_FS_INFO_REQUEST:
case WRITE_FS_INFO_REQUEST:
return false;
case MOUNT_VOLUME_REPLY:
case UNMOUNT_VOLUME_REPLY:
case INITIALIZE_VOLUME_REPLY:
// case INITIALIZE_VOLUME_REPLY:
case SYNC_VOLUME_REPLY:
case READ_FS_STAT_REPLY:
case WRITE_FS_STAT_REPLY:
case READ_FS_INFO_REPLY:
case WRITE_FS_INFO_REPLY:
return true;
// vnodes
case LOOKUP_REQUEST:
case READ_VNODE_REQUEST:
case WRITE_VNODE_REQUEST:
case FS_REMOVE_VNODE_REQUEST:
return false;
case LOOKUP_REPLY:
case READ_VNODE_REPLY:
case WRITE_VNODE_REPLY:
case FS_REMOVE_VNODE_REPLY:
return true;
// nodes
case IOCTL_REQUEST:
case SET_FLAGS_REQUEST:
case SELECT_REQUEST:
case DESELECT_REQUEST:
case FSYNC_REQUEST:
case READ_SYMLINK_REQUEST:
case CREATE_SYMLINK_REQUEST:
case LINK_REQUEST:
case UNLINK_REQUEST:
case RENAME_REQUEST:
case ACCESS_REQUEST:
case READ_STAT_REQUEST:
case WRITE_STAT_REQUEST:
case ACCESS_REQUEST:
return false;
case IOCTL_REPLY:
case SET_FLAGS_REPLY:
case SELECT_REPLY:
case DESELECT_REPLY:
case FSYNC_REPLY:
case READ_SYMLINK_REPLY:
case CREATE_SYMLINK_REPLY:
case LINK_REPLY:
case UNLINK_REPLY:
case RENAME_REPLY:
case ACCESS_REPLY:
case READ_STAT_REPLY:
case WRITE_STAT_REPLY:
case ACCESS_REPLY:
return true;
// files
case CREATE_REQUEST:
@ -730,10 +714,6 @@ UserlandFSUtil::is_userland_request(uint32 type)
case FREE_COOKIE_REQUEST:
case READ_REQUEST:
case WRITE_REQUEST:
case IOCTL_REQUEST:
case SET_FLAGS_REQUEST:
case SELECT_REQUEST:
case DESELECT_REQUEST:
return false;
case CREATE_REPLY:
case OPEN_REPLY:
@ -741,65 +721,49 @@ UserlandFSUtil::is_userland_request(uint32 type)
case FREE_COOKIE_REPLY:
case READ_REPLY:
case WRITE_REPLY:
case IOCTL_REPLY:
case SET_FLAGS_REPLY:
case SELECT_REPLY:
case DESELECT_REPLY:
return true;
// hard links / symlinks
case LINK_REQUEST:
case UNLINK_REQUEST:
case SYMLINK_REQUEST:
case READ_LINK_REQUEST:
case RENAME_REQUEST:
return false;
case LINK_REPLY:
case UNLINK_REPLY:
case SYMLINK_REPLY:
case READ_LINK_REPLY:
case RENAME_REPLY:
return true;
// directories
case MKDIR_REQUEST:
case RMDIR_REQUEST:
case CREATE_DIR_REQUEST:
case REMOVE_DIR_REQUEST:
case OPEN_DIR_REQUEST:
case CLOSE_DIR_REQUEST:
case FREE_DIR_COOKIE_REQUEST:
case READ_DIR_REQUEST:
case REWIND_DIR_REQUEST:
case WALK_REQUEST:
return false;
case MKDIR_REPLY:
case RMDIR_REPLY:
case CREATE_DIR_REPLY:
case REMOVE_DIR_REPLY:
case OPEN_DIR_REPLY:
case CLOSE_DIR_REPLY:
case FREE_DIR_COOKIE_REPLY:
case READ_DIR_REPLY:
case REWIND_DIR_REPLY:
case WALK_REPLY:
return true;
// attributes
// attribute directories
case OPEN_ATTR_DIR_REQUEST:
case CLOSE_ATTR_DIR_REQUEST:
case FREE_ATTR_DIR_COOKIE_REQUEST:
case READ_ATTR_DIR_REQUEST:
case REWIND_ATTR_DIR_REQUEST:
case READ_ATTR_REQUEST:
case WRITE_ATTR_REQUEST:
case REMOVE_ATTR_REQUEST:
case RENAME_ATTR_REQUEST:
case STAT_ATTR_REQUEST:
return false;
case OPEN_ATTR_DIR_REPLY:
case CLOSE_ATTR_DIR_REPLY:
case FREE_ATTR_DIR_COOKIE_REPLY:
case READ_ATTR_DIR_REPLY:
case REWIND_ATTR_DIR_REPLY:
return true;
// attributes
case READ_ATTR_REQUEST:
case WRITE_ATTR_REQUEST:
case RENAME_ATTR_REQUEST:
case READ_ATTR_STAT_REQUEST:
case REMOVE_ATTR_REQUEST:
return false;
case READ_ATTR_REPLY:
case WRITE_ATTR_REPLY:
case REMOVE_ATTR_REPLY:
case READ_ATTR_STAT_REPLY:
case RENAME_ATTR_REPLY:
case STAT_ATTR_REPLY:
case REMOVE_ATTR_REPLY:
return true;
// indices
case OPEN_INDEX_DIR_REQUEST:
@ -809,8 +773,7 @@ UserlandFSUtil::is_userland_request(uint32 type)
case REWIND_INDEX_DIR_REQUEST:
case CREATE_INDEX_REQUEST:
case REMOVE_INDEX_REQUEST:
case RENAME_INDEX_REQUEST:
case STAT_INDEX_REQUEST:
case READ_INDEX_STAT_REQUEST:
return false;
case OPEN_INDEX_DIR_REPLY:
case CLOSE_INDEX_DIR_REPLY:
@ -819,8 +782,7 @@ UserlandFSUtil::is_userland_request(uint32 type)
case REWIND_INDEX_DIR_REPLY:
case CREATE_INDEX_REPLY:
case REMOVE_INDEX_REPLY:
case RENAME_INDEX_REPLY:
case STAT_INDEX_REPLY:
case READ_INDEX_STAT_REPLY:
return true;
// queries
case OPEN_QUERY_REQUEST: