first round of style cleanup on ramfs driver; change node _dir to pointer in ramfs_lookup function
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42036 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -109,6 +109,7 @@ ramfs_mount(dev_t nsid, const char* /*device*/, uint32 flags,
|
|||||||
RETURN_ERROR(B_OK);
|
RETURN_ERROR(B_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_unmount
|
// ramfs_unmount
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_unmount(fs_volume* _volume)
|
ramfs_unmount(fs_volume* _volume)
|
||||||
@@ -124,6 +125,7 @@ ramfs_unmount(fs_volume* _volume)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_read_fs_info
|
// ramfs_read_fs_info
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_read_fs_info(fs_volume* _volume, struct fs_info *info)
|
ramfs_read_fs_info(fs_volume* _volume, struct fs_info *info)
|
||||||
@@ -139,7 +141,8 @@ ramfs_read_fs_info(fs_volume* _volume, struct fs_info *info)
|
|||||||
info->total_blocks = volume->CountBlocks();
|
info->total_blocks = volume->CountBlocks();
|
||||||
info->free_blocks = volume->CountFreeBlocks();
|
info->free_blocks = volume->CountFreeBlocks();
|
||||||
info->device_name[0] = '\0';
|
info->device_name[0] = '\0';
|
||||||
strncpy(info->volume_name, volume->GetName(), sizeof(info->volume_name));
|
strncpy(info->volume_name, volume->GetName(),
|
||||||
|
sizeof(info->volume_name));
|
||||||
strcpy(info->fsh_name, "ramfs");
|
strcpy(info->fsh_name, "ramfs");
|
||||||
} else
|
} else
|
||||||
SET_ERROR(error, B_ERROR);
|
SET_ERROR(error, B_ERROR);
|
||||||
@@ -163,6 +166,7 @@ ramfs_write_fs_info(fs_volume* _volume, const struct fs_info *info, uint32 mask)
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_sync
|
// ramfs_sync
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_sync(fs_volume /*fs*/)
|
ramfs_sync(fs_volume /*fs*/)
|
||||||
@@ -177,14 +181,15 @@ ramfs_sync(fs_volume /*fs*/)
|
|||||||
|
|
||||||
// ramfs_lookup
|
// ramfs_lookup
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_lookup(fs_volume* _volume, fs_vnode _dir, const char *entryName, ino_t *vnid,
|
ramfs_lookup(fs_volume* _volume, fs_vnode* _dir, const char *entryName,
|
||||||
int *type)
|
ino_t *vnid, int *type)
|
||||||
{
|
{
|
||||||
// FUNCTION_START();
|
// FUNCTION_START();
|
||||||
Volume* volume = (Volume*)_volume->private_volume;
|
Volume* volume = (Volume*)_volume->private_volume;
|
||||||
|
|
||||||
Directory *dir = dynamic_cast<Directory*>((Node*)_dir);
|
Directory *dir = dynamic_cast<Directory*>((Node*)_dir);
|
||||||
FUNCTION(("dir: (%llu), entry: `%s'\n", (dir ? dir->GetID() : -1), entryName));
|
|
||||||
|
FUNCTION(("dir: (%llu), entry: `%s'\n", (dir ? dir->GetID() : -1),
|
||||||
|
entryName));
|
||||||
|
|
||||||
// check for non-directories
|
// check for non-directories
|
||||||
if (!dir)
|
if (!dir)
|
||||||
@@ -223,6 +228,7 @@ SET_ERROR(error, error);
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_read_vnode
|
// ramfs_read_vnode
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_read_vnode(fs_volume* _volume, ino_t vnid, fs_vnode* node, bool reenter)
|
ramfs_read_vnode(fs_volume* _volume, ino_t vnid, fs_vnode* node, bool reenter)
|
||||||
@@ -241,6 +247,7 @@ FUNCTION(("node: %Ld\n", vnid));
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_write_vnode
|
// ramfs_write_vnode
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_write_vnode(fs_volume /*fs*/, fs_vnode DARG(_node), bool /*reenter*/)
|
ramfs_write_vnode(fs_volume /*fs*/, fs_vnode DARG(_node), bool /*reenter*/)
|
||||||
@@ -256,6 +263,7 @@ ramfs_write_vnode(fs_volume /*fs*/, fs_vnode DARG(_node), bool /*reenter*/)
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_remove_vnode
|
// ramfs_remove_vnode
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_remove_vnode(fs_volume* _volume, fs_vnode _node, bool /*reenter*/)
|
ramfs_remove_vnode(fs_volume* _volume, fs_vnode _node, bool /*reenter*/)
|
||||||
@@ -279,9 +287,8 @@ ramfs_remove_vnode(fs_volume* _volume, fs_vnode _node, bool /*reenter*/)
|
|||||||
|
|
||||||
// ramfs_ioctl
|
// ramfs_ioctl
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_ioctl(fs_volume* _volume, fs_vnode /*node*/, fs_cookie /*cookie*/, uint32 cmd,
|
ramfs_ioctl(fs_volume* _volume, fs_vnode /*node*/, fs_cookie /*cookie*/,
|
||||||
void *buffer, size_t /*length*/)
|
uint32 cmd, void *buffer, size_t /*length*/)
|
||||||
|
|
||||||
{
|
{
|
||||||
FUNCTION_START();
|
FUNCTION_START();
|
||||||
Volume* volume = (Volume*)_volume->private_volume;
|
Volume* volume = (Volume*)_volume->private_volume;
|
||||||
@@ -327,16 +334,18 @@ PRINT((" RAMFS_IOCTL_DUMP_INDEX, `%s'\n", name));
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_set_flags
|
// ramfs_set_flags
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_set_flags(fs_volume /*fs*/, fs_vnode /*node*/, fs_cookie /*cookie*/,
|
ramfs_set_flags(fs_volume /*fs*/, fs_vnode /*node*/, fs_cookie /*cookie*/,
|
||||||
int /*flags*/)
|
int /*flags*/)
|
||||||
{
|
{
|
||||||
FUNCTION_START();
|
FUNCTION_START();
|
||||||
// TODO:...
|
// TODO : ramfs_set_flags
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_fsync
|
// ramfs_fsync
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_fsync(fs_volume /*fs*/, fs_vnode /*node*/)
|
ramfs_fsync(fs_volume /*fs*/, fs_vnode /*node*/)
|
||||||
@@ -345,6 +354,7 @@ ramfs_fsync(fs_volume /*fs*/, fs_vnode /*node*/)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_read_symlink
|
// ramfs_read_symlink
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_read_symlink(fs_volume* _volume, fs_vnode _node, char *buffer,
|
ramfs_read_symlink(fs_volume* _volume, fs_vnode _node, char *buffer,
|
||||||
@@ -378,6 +388,7 @@ ramfs_read_symlink(fs_volume* _volume, fs_vnode _node, char *buffer,
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_create_symlink
|
// ramfs_create_symlink
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_create_symlink(fs_volume* _volume, fs_vnode _dir, const char *name,
|
ramfs_create_symlink(fs_volume* _volume, fs_vnode _dir, const char *name,
|
||||||
@@ -435,6 +446,7 @@ ramfs_create_symlink(fs_volume* _volume, fs_vnode _dir, const char *name,
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_link
|
// ramfs_link
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_link(fs_volume* _volume, fs_vnode _dir, const char *name, fs_vnode _node)
|
ramfs_link(fs_volume* _volume, fs_vnode _dir, const char *name, fs_vnode _node)
|
||||||
@@ -478,6 +490,7 @@ ramfs_link(fs_volume* _volume, fs_vnode _dir, const char *name, fs_vnode _node)
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_unlink
|
// ramfs_unlink
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_unlink(fs_volume* _volume, fs_vnode _dir, const char *name)
|
ramfs_unlink(fs_volume* _volume, fs_vnode _dir, const char *name)
|
||||||
@@ -522,6 +535,7 @@ ramfs_unlink(fs_volume* _volume, fs_vnode _dir, const char *name)
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_rename
|
// ramfs_rename
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_rename(fs_volume* _volume, fs_vnode _oldDir, const char *oldName,
|
ramfs_rename(fs_volume* _volume, fs_vnode _oldDir, const char *oldName,
|
||||||
@@ -639,6 +653,7 @@ oldDir->GetID(), oldName, newDir->GetID(), newName));
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_access
|
// ramfs_access
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_access(fs_volume* _volume, fs_vnode _node, int mode)
|
ramfs_access(fs_volume* _volume, fs_vnode _node, int mode)
|
||||||
@@ -655,6 +670,7 @@ ramfs_access(fs_volume* _volume, fs_vnode _node, int mode)
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_read_stat
|
// ramfs_read_stat
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_read_stat(fs_volume* _volume, fs_vnode _node, struct stat *st)
|
ramfs_read_stat(fs_volume* _volume, fs_vnode _node, struct stat *st)
|
||||||
@@ -683,6 +699,7 @@ ramfs_read_stat(fs_volume* _volume, fs_vnode _node, struct stat *st)
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_write_stat
|
// ramfs_write_stat
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_write_stat(fs_volume* _volume, fs_vnode _node, const struct stat *st,
|
ramfs_write_stat(fs_volume* _volume, fs_vnode _node, const struct stat *st,
|
||||||
@@ -734,7 +751,8 @@ ramfs_write_stat(fs_volume* _volume, fs_vnode _node, const struct stat *st,
|
|||||||
// FileCookie
|
// FileCookie
|
||||||
class FileCookie {
|
class FileCookie {
|
||||||
public:
|
public:
|
||||||
FileCookie(int openMode) : fOpenMode(openMode), fLastNotificationTime(0) {}
|
FileCookie(int openMode) : fOpenMode(openMode),
|
||||||
|
fLastNotificationTime(0) {}
|
||||||
|
|
||||||
inline int GetOpenMode() { return fOpenMode; }
|
inline int GetOpenMode() { return fOpenMode; }
|
||||||
|
|
||||||
@@ -744,10 +762,12 @@ public:
|
|||||||
inline bool NotificationIntervalElapsed(bool set = false)
|
inline bool NotificationIntervalElapsed(bool set = false)
|
||||||
{
|
{
|
||||||
bigtime_t currentTime = system_time();
|
bigtime_t currentTime = system_time();
|
||||||
bool result = (currentTime - fLastNotificationTime
|
bool result = (currentTime
|
||||||
|
- fLastNotificationTime
|
||||||
> kNotificationInterval);
|
> kNotificationInterval);
|
||||||
if (set && result)
|
if (set && result)
|
||||||
fLastNotificationTime = currentTime;
|
fLastNotificationTime = currentTime;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,6 +776,7 @@ private:
|
|||||||
bigtime_t fLastNotificationTime;
|
bigtime_t fLastNotificationTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ramfs_create
|
// ramfs_create
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_create(fs_volume* _volume, fs_vnode _dir, const char *name, int openMode,
|
ramfs_create(fs_volume* _volume, fs_vnode _dir, const char *name, int openMode,
|
||||||
@@ -800,8 +821,7 @@ ramfs_create(fs_volume* _volume, fs_vnode _dir, const char *name, int openMode,
|
|||||||
} else if (!node->IsFile()) {
|
} else if (!node->IsFile()) {
|
||||||
SET_ERROR(error, B_NOT_ALLOWED);
|
SET_ERROR(error, B_NOT_ALLOWED);
|
||||||
// the user must have write permission for an existing entry
|
// the user must have write permission for an existing entry
|
||||||
} else if ((error = node->CheckPermissions(ACCESS_W))
|
} else if ((error = node->CheckPermissions(ACCESS_W)) == B_OK) {
|
||||||
== B_OK) {
|
|
||||||
// truncate, if requested
|
// truncate, if requested
|
||||||
if (openMode & O_TRUNC)
|
if (openMode & O_TRUNC)
|
||||||
error = node->SetSize(0);
|
error = node->SetSize(0);
|
||||||
@@ -841,6 +861,7 @@ ramfs_create(fs_volume* _volume, fs_vnode _dir, const char *name, int openMode,
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_open
|
// ramfs_open
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_open(fs_volume* _volume, fs_vnode _node, int openMode, fs_cookie *_cookie)
|
ramfs_open(fs_volume* _volume, fs_vnode _node, int openMode, fs_cookie *_cookie)
|
||||||
@@ -883,6 +904,7 @@ ramfs_open(fs_volume* _volume, fs_vnode _node, int openMode, fs_cookie *_cookie)
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_close
|
// ramfs_close
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_close(fs_volume* _volume, fs_vnode _node, fs_cookie /*cookie*/)
|
ramfs_close(fs_volume* _volume, fs_vnode _node, fs_cookie /*cookie*/)
|
||||||
@@ -902,6 +924,7 @@ ramfs_close(fs_volume* _volume, fs_vnode _node, fs_cookie /*cookie*/)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_free_cookie
|
// ramfs_free_cookie
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_free_cookie(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie _cookie)
|
ramfs_free_cookie(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie _cookie)
|
||||||
@@ -912,6 +935,7 @@ ramfs_free_cookie(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie _cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_read
|
// ramfs_read
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_read(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie, off_t pos,
|
ramfs_read(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie, off_t pos,
|
||||||
@@ -948,6 +972,7 @@ ramfs_read(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie, off_t pos,
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_write
|
// ramfs_write
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_write(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie, off_t pos,
|
ramfs_write(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie, off_t pos,
|
||||||
@@ -1002,7 +1027,8 @@ ramfs_write(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie, off_t pos,
|
|||||||
class DirectoryCookie {
|
class DirectoryCookie {
|
||||||
public:
|
public:
|
||||||
DirectoryCookie(Directory *directory = NULL)
|
DirectoryCookie(Directory *directory = NULL)
|
||||||
: fIterator(directory),
|
:
|
||||||
|
fIterator(directory),
|
||||||
fDotIndex(DOT_INDEX),
|
fDotIndex(DOT_INDEX),
|
||||||
// debugging
|
// debugging
|
||||||
fIteratorID(atomic_add(&fNextIteratorID, 1)),
|
fIteratorID(atomic_add(&fNextIteratorID, 1)),
|
||||||
@@ -1044,7 +1070,8 @@ fGetNextCounter++;
|
|||||||
}
|
}
|
||||||
PRINT(("EntryIterator %ld, GetNext() counter: %ld, entry: %p (%Ld)\n",
|
PRINT(("EntryIterator %ld, GetNext() counter: %ld, entry: %p (%Ld)\n",
|
||||||
fIteratorID, fGetNextCounter, fIterator.GetCurrent(),
|
fIteratorID, fGetNextCounter, fIterator.GetCurrent(),
|
||||||
(fIterator.GetCurrent() ? fIterator.GetCurrent()->GetNode()->GetID() : -1)));
|
(fIterator.GetCurrent()
|
||||||
|
? fIterator.GetCurrent()->GetNode()->GetID() : -1)));
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1073,8 +1100,11 @@ private:
|
|||||||
int32 fGetNextCounter;
|
int32 fGetNextCounter;
|
||||||
static vint32 fNextIteratorID;
|
static vint32 fNextIteratorID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
vint32 DirectoryCookie::fNextIteratorID = 0;
|
vint32 DirectoryCookie::fNextIteratorID = 0;
|
||||||
|
|
||||||
|
|
||||||
// ramfs_create_dir
|
// ramfs_create_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_create_dir(fs_volume* _volume, fs_vnode _dir, const char *name, int mode)
|
ramfs_create_dir(fs_volume* _volume, fs_vnode _dir, const char *name, int mode)
|
||||||
@@ -1131,6 +1161,7 @@ ramfs_create_dir(fs_volume* _volume, fs_vnode _dir, const char *name, int mode)
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_remove_dir
|
// ramfs_remove_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_remove_dir(fs_volume* _volume, fs_vnode _dir, const char *name)
|
ramfs_remove_dir(fs_volume* _volume, fs_vnode _dir, const char *name)
|
||||||
@@ -1175,6 +1206,7 @@ ramfs_remove_dir(fs_volume* _volume, fs_vnode _dir, const char *name)
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_open_dir
|
// ramfs_open_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_open_dir(fs_volume /*fs*/, fs_vnode _node, fs_cookie *_cookie)
|
ramfs_open_dir(fs_volume /*fs*/, fs_vnode _node, fs_cookie *_cookie)
|
||||||
@@ -1210,6 +1242,7 @@ FUNCTION(("dir: (%Lu)\n", node->GetID()));
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_close_dir
|
// ramfs_close_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_close_dir(fs_volume /*fs*/, fs_vnode DARG(_node), fs_cookie _cookie)
|
ramfs_close_dir(fs_volume /*fs*/, fs_vnode DARG(_node), fs_cookie _cookie)
|
||||||
@@ -1223,6 +1256,7 @@ FUNCTION(("dir: (%Lu)\n", ((Node*)_node)->GetID()));
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_free_dir_cookie
|
// ramfs_free_dir_cookie
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_free_dir_cookie(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie _cookie)
|
ramfs_free_dir_cookie(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie _cookie)
|
||||||
@@ -1233,6 +1267,7 @@ ramfs_free_dir_cookie(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie _cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_read_dir
|
// ramfs_read_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_read_dir(fs_volume* _volume, fs_vnode DARG(_node), fs_cookie _cookie,
|
ramfs_read_dir(fs_volume* _volume, fs_vnode DARG(_node), fs_cookie _cookie,
|
||||||
@@ -1269,13 +1304,16 @@ PRINT((" entry: `%s'\n", name));
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
*count = 0;
|
*count = 0;
|
||||||
|
|
||||||
cookie->Suspend();
|
cookie->Suspend();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
SET_ERROR(error, B_ERROR);
|
SET_ERROR(error, B_ERROR);
|
||||||
|
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_rewind_dir
|
// ramfs_rewind_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_rewind_dir(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie _cookie)
|
ramfs_rewind_dir(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie _cookie)
|
||||||
@@ -1324,6 +1362,7 @@ ramfs_open_attr_dir(fs_volume* _volume, fs_vnode _node, fs_cookie *cookie)
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_close_attr_dir
|
// ramfs_close_attr_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_close_attr_dir(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie cookie)
|
ramfs_close_attr_dir(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie cookie)
|
||||||
@@ -1336,6 +1375,7 @@ ramfs_close_attr_dir(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_free_attr_dir_cookie
|
// ramfs_free_attr_dir_cookie
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_free_attr_dir_cookie(fs_volume /*fs*/, fs_vnode /*_node*/,
|
ramfs_free_attr_dir_cookie(fs_volume /*fs*/, fs_vnode /*_node*/,
|
||||||
@@ -1349,6 +1389,7 @@ ramfs_free_attr_dir_cookie(fs_volume /*fs*/, fs_vnode /*_node*/,
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_read_attr_dir
|
// ramfs_read_attr_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_read_attr_dir(fs_volume* _volume, fs_vnode _node, fs_cookie cookie,
|
ramfs_read_attr_dir(fs_volume* _volume, fs_vnode _node, fs_cookie cookie,
|
||||||
@@ -1382,13 +1423,16 @@ ramfs_read_attr_dir(fs_volume* _volume, fs_vnode _node, fs_cookie cookie,
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
*count = 0;
|
*count = 0;
|
||||||
|
|
||||||
iterator->Suspend();
|
iterator->Suspend();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
SET_ERROR(error, B_ERROR);
|
SET_ERROR(error, B_ERROR);
|
||||||
|
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_rewind_attr_dir
|
// ramfs_rewind_attr_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_rewind_attr_dir(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie cookie)
|
ramfs_rewind_attr_dir(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie cookie)
|
||||||
@@ -1443,10 +1487,11 @@ private:
|
|||||||
bigtime_t fLastNotificationTime;
|
bigtime_t fLastNotificationTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ramfs_create_attr
|
// ramfs_create_attr
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_create_attr(fs_volume* _volume, fs_vnode _node, const char *name, uint32 type,
|
ramfs_create_attr(fs_volume* _volume, fs_vnode _node, const char *name,
|
||||||
int openMode, fs_cookie *_cookie)
|
uint32 type, int openMode, fs_cookie *_cookie)
|
||||||
{
|
{
|
||||||
|
|
||||||
Volume* volume = (Volume*)_volume->private_volume;
|
Volume* volume = (Volume*)_volume->private_volume;
|
||||||
@@ -1513,10 +1558,11 @@ ramfs_create_attr(fs_volume* _volume, fs_vnode _node, const char *name, uint32 t
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_open_attr
|
// ramfs_open_attr
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_open_attr(fs_volume* _volume, fs_vnode _node, const char *name, int openMode,
|
ramfs_open_attr(fs_volume* _volume, fs_vnode _node, const char *name,
|
||||||
fs_cookie *_cookie)
|
int openMode, fs_cookie *_cookie)
|
||||||
{
|
{
|
||||||
// FUNCTION_START();
|
// FUNCTION_START();
|
||||||
Volume* volume = (Volume*)_volume->private_volume;
|
Volume* volume = (Volume*)_volume->private_volume;
|
||||||
@@ -1572,6 +1618,7 @@ ramfs_open_attr(fs_volume* _volume, fs_vnode _node, const char *name, int openMo
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_close_attr
|
// ramfs_close_attr
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_close_attr(fs_volume* _volume, fs_vnode _node, fs_cookie cookie)
|
ramfs_close_attr(fs_volume* _volume, fs_vnode _node, fs_cookie cookie)
|
||||||
@@ -1592,6 +1639,7 @@ ramfs_close_attr(fs_volume* _volume, fs_vnode _node, fs_cookie cookie)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_free_attr_cookie
|
// ramfs_free_attr_cookie
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_free_attr_cookie(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie _cookie)
|
ramfs_free_attr_cookie(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie _cookie)
|
||||||
@@ -1602,6 +1650,7 @@ ramfs_free_attr_cookie(fs_volume /*fs*/, fs_vnode /*_node*/, fs_cookie _cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_read_attr
|
// ramfs_read_attr
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_read_attr(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie, off_t pos,
|
ramfs_read_attr(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie, off_t pos,
|
||||||
@@ -1632,10 +1681,11 @@ ramfs_read_attr(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie, off_t pos
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_write_attr
|
// ramfs_write_attr
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_write_attr(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie, off_t pos,
|
ramfs_write_attr(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie,
|
||||||
const void *buffer, size_t *bufferSize)
|
off_t pos, const void *buffer, size_t *bufferSize)
|
||||||
{
|
{
|
||||||
// FUNCTION_START();
|
// FUNCTION_START();
|
||||||
Volume* volume = (Volume*)_volume->private_volume;
|
Volume* volume = (Volume*)_volume->private_volume;
|
||||||
@@ -1647,7 +1697,8 @@ ramfs_write_attr(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie, off_t po
|
|||||||
const char *name = cookie->GetName();
|
const char *name = cookie->GetName();
|
||||||
if (name[0] == '\0' || !strcmp(name, "name")
|
if (name[0] == '\0' || !strcmp(name, "name")
|
||||||
|| !strcmp(name, "last_modified") || !strcmp(name, "size")) {
|
|| !strcmp(name, "last_modified") || !strcmp(name, "size")) {
|
||||||
//FUNCTION(("failed: node: %s, attribute: %s\n", node->GetName(), name));
|
// FUNCTION(("failed: node: %s, attribute: %s\n",
|
||||||
|
// node->GetName(), name));
|
||||||
RETURN_ERROR(B_NOT_ALLOWED);
|
RETURN_ERROR(B_NOT_ALLOWED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1675,9 +1726,11 @@ ramfs_write_attr(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie, off_t po
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
SET_ERROR(error, B_ERROR);
|
SET_ERROR(error, B_ERROR);
|
||||||
|
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_read_attr_stat
|
// ramfs_read_attr_stat
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_read_attr_stat(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie,
|
ramfs_read_attr_stat(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie,
|
||||||
@@ -1710,15 +1763,17 @@ ramfs_read_attr_stat(fs_volume* _volume, fs_vnode _node, fs_cookie _cookie,
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_rename_attr
|
// ramfs_rename_attr
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_rename_attr(fs_volume /*fs*/, fs_vnode /*_fromNode*/,
|
ramfs_rename_attr(fs_volume /*fs*/, fs_vnode /*_fromNode*/,
|
||||||
const char */*fromName*/, fs_vnode /*_toNode*/, const char */*toName*/)
|
const char */*fromName*/, fs_vnode /*_toNode*/, const char */*toName*/)
|
||||||
{
|
{
|
||||||
// TODO:...
|
// TODO : ramfs_rename_attr
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_remove_attr
|
// ramfs_remove_attr
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_remove_attr(fs_volume* _volume, fs_vnode _node, const char *name)
|
ramfs_remove_attr(fs_volume* _volume, fs_vnode _node, const char *name)
|
||||||
@@ -1751,6 +1806,7 @@ ramfs_remove_attr(fs_volume* _volume, fs_vnode _node, const char *name)
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
SET_ERROR(error, B_ERROR);
|
SET_ERROR(error, B_ERROR);
|
||||||
|
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1766,6 +1822,7 @@ public:
|
|||||||
int32 index_index;
|
int32 index_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ramfs_open_index_dir
|
// ramfs_open_index_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_open_index_dir(fs_volume* _volume, fs_cookie *_cookie)
|
ramfs_open_index_dir(fs_volume* _volume, fs_cookie *_cookie)
|
||||||
@@ -1788,6 +1845,7 @@ ramfs_open_index_dir(fs_volume* _volume, fs_cookie *_cookie)
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_close_index_dir
|
// ramfs_close_index_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_close_index_dir(fs_volume /*fs*/, fs_cookie /*_cookie*/)
|
ramfs_close_index_dir(fs_volume /*fs*/, fs_cookie /*_cookie*/)
|
||||||
@@ -1796,6 +1854,7 @@ ramfs_close_index_dir(fs_volume /*fs*/, fs_cookie /*_cookie*/)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_free_index_dir_cookie
|
// ramfs_free_index_dir_cookie
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_free_index_dir_cookie(fs_volume /*fs*/, fs_cookie _cookie)
|
ramfs_free_index_dir_cookie(fs_volume /*fs*/, fs_cookie _cookie)
|
||||||
@@ -1806,10 +1865,11 @@ ramfs_free_index_dir_cookie(fs_volume /*fs*/, fs_cookie _cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_read_index_dir
|
// ramfs_read_index_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_read_index_dir(fs_volume* _volume, fs_cookie _cookie, struct dirent *buffer,
|
ramfs_read_index_dir(fs_volume* _volume, fs_cookie _cookie,
|
||||||
size_t bufferSize, uint32 *count)
|
struct dirent *buffer, size_t bufferSize, uint32 *count)
|
||||||
{
|
{
|
||||||
FUNCTION_START();
|
FUNCTION_START();
|
||||||
Volume* volume = (Volume*)_volume->private_volume;
|
Volume* volume = (Volume*)_volume->private_volume;
|
||||||
@@ -1840,9 +1900,11 @@ ramfs_read_index_dir(fs_volume* _volume, fs_cookie _cookie, struct dirent *buffe
|
|||||||
*count = 0;
|
*count = 0;
|
||||||
} else
|
} else
|
||||||
SET_ERROR(error, B_ERROR);
|
SET_ERROR(error, B_ERROR);
|
||||||
|
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_rewind_index_dir
|
// ramfs_rewind_index_dir
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_rewind_index_dir(fs_volume /*fs*/, fs_cookie _cookie)
|
ramfs_rewind_index_dir(fs_volume /*fs*/, fs_cookie _cookie)
|
||||||
@@ -1853,6 +1915,7 @@ ramfs_rewind_index_dir(fs_volume /*fs*/, fs_cookie _cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_create_index
|
// ramfs_create_index
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_create_index(fs_volume* _volume, const char *name, uint32 type,
|
ramfs_create_index(fs_volume* _volume, const char *name, uint32 type,
|
||||||
@@ -1880,9 +1943,11 @@ ramfs_create_index(fs_volume* _volume, const char *name, uint32 type,
|
|||||||
SET_ERROR(error, B_ENTRY_NOT_FOUND);
|
SET_ERROR(error, B_ENTRY_NOT_FOUND);
|
||||||
} else
|
} else
|
||||||
SET_ERROR(error, B_ERROR);
|
SET_ERROR(error, B_ERROR);
|
||||||
|
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_remove_index
|
// ramfs_remove_index
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_remove_index(fs_volume* _volume, const char *name)
|
ramfs_remove_index(fs_volume* _volume, const char *name)
|
||||||
@@ -1912,6 +1977,7 @@ ramfs_remove_index(fs_volume* _volume, const char *name)
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_read_index_stat
|
// ramfs_read_index_stat
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_read_index_stat(fs_volume* _volume, const char *name, struct stat *st)
|
ramfs_read_index_stat(fs_volume* _volume, const char *name, struct stat *st)
|
||||||
@@ -1955,7 +2021,8 @@ ramfs_open_query(fs_volume* _volume, const char *queryString, uint32 flags,
|
|||||||
port_id port, uint32 token, fs_cookie *cookie)
|
port_id port, uint32 token, fs_cookie *cookie)
|
||||||
{
|
{
|
||||||
FUNCTION_START();
|
FUNCTION_START();
|
||||||
PRINT(("query = \"%s\", flags = %lu, port_id = %ld, token = %ld\n", queryString, flags, port, token));
|
PRINT(("query = \"%s\", flags = %lu, port_id = %ld, token = %ld\n",
|
||||||
|
queryString, flags, port, token));
|
||||||
|
|
||||||
Volume* volume = (Volume*)_volume->private_volume;
|
Volume* volume = (Volume*)_volume->private_volume;
|
||||||
|
|
||||||
@@ -1992,6 +2059,7 @@ ramfs_open_query(fs_volume* _volume, const char *queryString, uint32 flags,
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_close_query
|
// ramfs_close_query
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_close_query(fs_volume /*fs*/, fs_cookie /*cookie*/)
|
ramfs_close_query(fs_volume /*fs*/, fs_cookie /*cookie*/)
|
||||||
@@ -2000,6 +2068,7 @@ ramfs_close_query(fs_volume /*fs*/, fs_cookie /*cookie*/)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_free_query_cookie
|
// ramfs_free_query_cookie
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_free_query_cookie(fs_volume* _volume, fs_cookie cookie)
|
ramfs_free_query_cookie(fs_volume* _volume, fs_cookie cookie)
|
||||||
@@ -2021,6 +2090,7 @@ ramfs_free_query_cookie(fs_volume* _volume, fs_cookie cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ramfs_read_query
|
// ramfs_read_query
|
||||||
static status_t
|
static status_t
|
||||||
ramfs_read_query(fs_volume* _volume, fs_cookie cookie, struct dirent *buffer,
|
ramfs_read_query(fs_volume* _volume, fs_cookie cookie, struct dirent *buffer,
|
||||||
@@ -2046,6 +2116,7 @@ ramfs_read_query(fs_volume* _volume, fs_cookie cookie, struct dirent *buffer,
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: status_t (*rewind_query)(fs_volume fs, fs_cookie cookie);
|
// TODO: status_t (*rewind_query)(fs_volume fs, fs_cookie cookie);
|
||||||
|
|
||||||
|
|
||||||
@@ -2073,6 +2144,7 @@ ramfs_std_ops(int32 op, ...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static file_system_module_info sRamFSModuleInfo = {
|
static file_system_module_info sRamFSModuleInfo = {
|
||||||
{
|
{
|
||||||
"file_systems/ramfs" B_CURRENT_FS_API_VERSION,
|
"file_systems/ramfs" B_CURRENT_FS_API_VERSION,
|
||||||
@@ -2188,3 +2260,4 @@ module_info *modules[] = {
|
|||||||
(module_info *)&sRamFSModuleInfo,
|
(module_info *)&sRamFSModuleInfo,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user