ramfs: Adapt to current kernel FS APIs and fully fix the build.
This commit is contained in:
@@ -18,6 +18,7 @@ KernelAddon ramfs
|
|||||||
BlockAllocatorAreaBucket.cpp
|
BlockAllocatorAreaBucket.cpp
|
||||||
BlockReferenceManager.cpp
|
BlockReferenceManager.cpp
|
||||||
DataContainer.cpp
|
DataContainer.cpp
|
||||||
|
DebugSupport.cpp
|
||||||
Directory.cpp
|
Directory.cpp
|
||||||
Entry.cpp
|
Entry.cpp
|
||||||
EntryIterator.cpp
|
EntryIterator.cpp
|
||||||
@@ -36,3 +37,6 @@ KernelAddon ramfs
|
|||||||
SymLink.cpp
|
SymLink.cpp
|
||||||
Volume.cpp
|
Volume.cpp
|
||||||
;
|
;
|
||||||
|
|
||||||
|
SEARCH on [ FGristFiles DebugSupport.cpp ]
|
||||||
|
+= [ FDirName $(HAIKU_TOP) src add-ons kernel file_systems shared ] ;
|
||||||
|
|||||||
@@ -61,22 +61,6 @@ private:
|
|||||||
char *fString;
|
char *fString;
|
||||||
};
|
};
|
||||||
|
|
||||||
// strnlen
|
|
||||||
size_t
|
|
||||||
strnlen(const char *str, size_t maxLen)
|
|
||||||
{
|
|
||||||
if (str) {
|
|
||||||
size_t origMaxLen = maxLen;
|
|
||||||
while (maxLen > 0 && *str != '\0') {
|
|
||||||
maxLen--;
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
return origMaxLen - maxLen;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class String
|
\class String
|
||||||
\brief A very simple string class.
|
\brief A very simple string class.
|
||||||
|
|||||||
@@ -133,7 +133,6 @@ class EntryListenerTree : public _EntryListenerTree {};
|
|||||||
Volume::Volume(fs_volume* volume)
|
Volume::Volume(fs_volume* volume)
|
||||||
:
|
:
|
||||||
fVolume(volume),
|
fVolume(volume),
|
||||||
fID(0),
|
|
||||||
fNextNodeID(kRootParentID + 1),
|
fNextNodeID(kRootParentID + 1),
|
||||||
fNodeTable(NULL),
|
fNodeTable(NULL),
|
||||||
fDirectoryEntryTable(NULL),
|
fDirectoryEntryTable(NULL),
|
||||||
@@ -170,16 +169,15 @@ Volume::Mount(uint32 flags)
|
|||||||
{
|
{
|
||||||
Unmount();
|
Unmount();
|
||||||
|
|
||||||
// check the locker's semaphores
|
// check the lockers
|
||||||
if (fLocker.Sem() < 0)
|
if (fLocker.InitCheck() < 0)
|
||||||
return fLocker.Sem();
|
return fLocker.InitCheck();
|
||||||
if (fIteratorLocker.Sem() < 0)
|
if (fIteratorLocker.InitCheck() < 0)
|
||||||
return fIteratorLocker.Sem();
|
return fIteratorLocker.InitCheck();
|
||||||
if (fQueryLocker.Sem() < 0)
|
if (fQueryLocker.InitCheck() < 0)
|
||||||
return fQueryLocker.Sem();
|
return fQueryLocker.InitCheck();
|
||||||
|
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
fID = id;
|
|
||||||
// create a block allocator
|
// create a block allocator
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
fBlockAllocator = new(nothrow) BlockAllocator(kDefaultAreaSize);
|
fBlockAllocator = new(nothrow) BlockAllocator(kDefaultAreaSize);
|
||||||
@@ -291,7 +289,6 @@ Volume::Unmount()
|
|||||||
delete fBlockAllocator;
|
delete fBlockAllocator;
|
||||||
fBlockAllocator = NULL;
|
fBlockAllocator = NULL;
|
||||||
}
|
}
|
||||||
fID = 0;
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,7 +346,7 @@ Volume::NewVNode(Node *node)
|
|||||||
{
|
{
|
||||||
status_t error = NodeAdded(node);
|
status_t error = NodeAdded(node);
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
error = new_vnode(GetID(), node->GetID(), node);
|
error = new_vnode(FSVolume(), node->GetID(), node, &gRamFSVnodeOps);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
NodeRemoved(node);
|
NodeRemoved(node);
|
||||||
}
|
}
|
||||||
@@ -362,7 +359,8 @@ Volume::PublishVNode(Node *node)
|
|||||||
{
|
{
|
||||||
status_t error = NodeAdded(node);
|
status_t error = NodeAdded(node);
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
error = publish_vnode(GetID(), node->GetID(), node);
|
error = publish_vnode(FSVolume(), node->GetID(), node, &gRamFSVnodeOps,
|
||||||
|
node->GetMode(), 0);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
NodeRemoved(node);
|
NodeRemoved(node);
|
||||||
}
|
}
|
||||||
@@ -373,7 +371,7 @@ Volume::PublishVNode(Node *node)
|
|||||||
status_t
|
status_t
|
||||||
Volume::GetVNode(ino_t id, Node **node)
|
Volume::GetVNode(ino_t id, Node **node)
|
||||||
{
|
{
|
||||||
return (fMounted ? get_vnode(GetID(), id, (void**)node) : B_BAD_VALUE);
|
return (fMounted ? get_vnode(FSVolume(), id, (void**)node) : B_BAD_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetVNode
|
// GetVNode
|
||||||
@@ -384,7 +382,7 @@ Volume::GetVNode(Node *node)
|
|||||||
status_t error = (fMounted ? GetVNode(node->GetID(), &dummy)
|
status_t error = (fMounted ? GetVNode(node->GetID(), &dummy)
|
||||||
: B_BAD_VALUE );
|
: B_BAD_VALUE );
|
||||||
if (error == B_OK && dummy != node) {
|
if (error == B_OK && dummy != node) {
|
||||||
FATAL(("Two Nodes have the same ID: %Ld!\n", node->GetID()));
|
FATAL("Two Nodes have the same ID: %Ld!\n", node->GetID());
|
||||||
PutVNode(dummy);
|
PutVNode(dummy);
|
||||||
error = B_ERROR;
|
error = B_ERROR;
|
||||||
}
|
}
|
||||||
@@ -395,14 +393,14 @@ Volume::GetVNode(Node *node)
|
|||||||
status_t
|
status_t
|
||||||
Volume::PutVNode(ino_t id)
|
Volume::PutVNode(ino_t id)
|
||||||
{
|
{
|
||||||
return (fMounted ? put_vnode(GetID(), id) : B_BAD_VALUE);
|
return (fMounted ? put_vnode(FSVolume(), id) : B_BAD_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutVNode
|
// PutVNode
|
||||||
status_t
|
status_t
|
||||||
Volume::PutVNode(Node *node)
|
Volume::PutVNode(Node *node)
|
||||||
{
|
{
|
||||||
return (fMounted ? put_vnode(GetID(), node->GetID()) : B_BAD_VALUE);
|
return (fMounted ? put_vnode(FSVolume(), node->GetID()) : B_BAD_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveVNode
|
// RemoveVNode
|
||||||
@@ -410,7 +408,7 @@ status_t
|
|||||||
Volume::RemoveVNode(Node *node)
|
Volume::RemoveVNode(Node *node)
|
||||||
{
|
{
|
||||||
if (fMounted)
|
if (fMounted)
|
||||||
return remove_vnode(GetID(), node->GetID());
|
return remove_vnode(FSVolume(), node->GetID());
|
||||||
status_t error = NodeRemoved(node);
|
status_t error = NodeRemoved(node);
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
delete node;
|
delete node;
|
||||||
@@ -421,7 +419,7 @@ Volume::RemoveVNode(Node *node)
|
|||||||
status_t
|
status_t
|
||||||
Volume::UnremoveVNode(Node *node)
|
Volume::UnremoveVNode(Node *node)
|
||||||
{
|
{
|
||||||
return (fMounted ? unremove_vnode(GetID(), node->GetID()) : B_BAD_VALUE);
|
return (fMounted ? unremove_vnode(FSVolume(), node->GetID()) : B_BAD_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeAdded
|
// NodeAdded
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
status_t Mount(uint32 flags);
|
status_t Mount(uint32 flags);
|
||||||
status_t Unmount();
|
status_t Unmount();
|
||||||
|
|
||||||
dev_t GetID() const { return fID; }
|
dev_t GetID() const { return fVolume != NULL ? fVolume->id : -1; }
|
||||||
fs_volume* FSVolume() const { return fVolume; }
|
fs_volume* FSVolume() const { return fVolume; }
|
||||||
|
|
||||||
off_t GetBlockSize() const;
|
off_t GetBlockSize() const;
|
||||||
@@ -183,7 +183,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
typedef DoublyLinkedList<Query> QueryList;
|
typedef DoublyLinkedList<Query> QueryList;
|
||||||
|
|
||||||
dev_t fID;
|
|
||||||
ino_t fNextNodeID;
|
ino_t fNextNodeID;
|
||||||
NodeTable *fNodeTable;
|
NodeTable *fNodeTable;
|
||||||
DirectoryEntryTable *fDirectoryEntryTable;
|
DirectoryEntryTable *fDirectoryEntryTable;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
extern struct fs_vnode_ops gRamFSVnodeOps;
|
||||||
const size_t kMaxIndexKeyLength = 256;
|
const size_t kMaxIndexKeyLength = 256;
|
||||||
|
|
||||||
#endif // RAM_FS_H
|
#endif // RAM_FS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user