The VM fs interface has changed to better match the one of the device interface.

Added a new fs call for the file cache.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8851 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-09-04 17:48:11 +00:00
parent 33657fc8ac
commit 14d725bb50
4 changed files with 45 additions and 37 deletions

View File

@ -810,7 +810,7 @@ bootfs_ioctl(fs_volume _fs, fs_vnode _v, fs_cookie _cookie, ulong op, void *buf,
}
static status_t
static bool
bootfs_can_page(fs_volume _fs, fs_vnode _v)
{
struct bootfs_vnode *v = _v;
@ -818,44 +818,46 @@ bootfs_can_page(fs_volume _fs, fs_vnode _v)
TRACE(("bootfs_canpage: vnode %p\n", v));
if (v->stream.type == S_IFREG)
return 1;
else
return 0;
return true;
return false;
}
static ssize_t
bootfs_read_pages(fs_volume _fs, fs_vnode _v, iovecs *vecs, off_t pos)
static status_t
bootfs_read_pages(fs_volume _fs, fs_vnode _v, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes)
{
struct bootfs_vnode *v = _v;
unsigned int i;
TRACE(("bootfs_readpage: fs_cookie %p vnode %p, vecs %p, pos 0x%Ld\n", _fs, v, vecs, pos));
for (i = 0; i < vecs->num; i++) {
for (i = 0; i < count; i++) {
if (pos >= v->stream.u.file.len) {
memset(vecs->vec[i].iov_base, 0, vecs->vec[i].iov_len);
pos += vecs->vec[i].iov_len;
memset(vecs[i].iov_base, 0, vecs[i].iov_len);
pos += vecs[i].iov_len;
} else {
unsigned int copy_len;
copy_len = min(vecs->vec[i].iov_len, v->stream.u.file.len - pos);
copy_len = min(vecs[i].iov_len, v->stream.u.file.len - pos);
memcpy(vecs->vec[i].iov_base, v->stream.u.file.start + pos, copy_len);
memcpy(vecs[i].iov_base, v->stream.u.file.start + pos, copy_len);
if (copy_len < vecs->vec[i].iov_len)
memset((char *)vecs->vec[i].iov_base + copy_len, 0, vecs->vec[i].iov_len - copy_len);
if (copy_len < vecs[i].iov_len) {
memset((char *)vecs[i].iov_base + copy_len, 0, vecs[i].iov_len - copy_len);
*_numBytes = v->stream.u.file.len - pos;
}
pos += vecs->vec[i].iov_len;
pos += vecs[i].iov_len;
}
}
return EPERM;
return B_OK;
}
static ssize_t
bootfs_write_pages(fs_volume _fs, fs_vnode _v, iovecs *vecs, off_t pos)
static status_t
bootfs_write_pages(fs_volume _fs, fs_vnode _v, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes)
{
TRACE(("bootfs_writepage: fs_cookie %p vnode %p, vecs %p, pos %Ld \n", _fs, _v, vecs, pos));
@ -970,6 +972,8 @@ file_system_info gBootFileSystem = {
&bootfs_read_pages,
&bootfs_write_pages,
NULL, // get_file_map()
/* common */
&bootfs_ioctl,
&bootfs_fsync,

View File

@ -1200,22 +1200,22 @@ pipefs_ioctl(fs_volume _volume, fs_vnode _vnode, fs_cookie _cookie, ulong op,
}
static status_t
static bool
pipefs_can_page(fs_volume _volume, fs_vnode _v)
{
return -1;
return false;
}
static ssize_t
pipefs_read_pages(fs_volume _volume, fs_vnode _v, iovecs *vecs, off_t pos)
static status_t
pipefs_read_pages(fs_volume _volume, fs_vnode _v, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes)
{
return EPERM;
}
static ssize_t
pipefs_write_pages(fs_volume _volume, fs_vnode _v, iovecs *vecs, off_t pos)
static status_t
pipefs_write_pages(fs_volume _volume, fs_vnode _v, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes)
{
return EPERM;
}
@ -1293,6 +1293,8 @@ file_system_info gPipeFileSystem = {
&pipefs_read_pages,
&pipefs_write_pages,
NULL, // get_file_map()
/* common */
&pipefs_ioctl,
&pipefs_fsync,

View File

@ -698,22 +698,22 @@ rootfs_ioctl(fs_volume _fs, fs_vnode _v, fs_cookie _cookie, ulong op, void *buf,
}
static status_t
static bool
rootfs_can_page(fs_volume _fs, fs_vnode _v)
{
return -1;
return false;
}
static ssize_t
rootfs_read_pages(fs_volume _fs, fs_vnode _v, iovecs *vecs, off_t pos)
static status_t
rootfs_read_pages(fs_volume _fs, fs_vnode _v, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes)
{
return EPERM;
}
static ssize_t
rootfs_write_pages(fs_volume _fs, fs_vnode _v, iovecs *vecs, off_t pos)
static status_t
rootfs_write_pages(fs_volume _fs, fs_vnode _v, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes)
{
return EPERM;
}
@ -939,6 +939,8 @@ file_system_info gRootFileSystem = {
&rootfs_read_pages,
&rootfs_write_pages,
NULL, // get_file_map()
/* common */
&rootfs_ioctl,
&rootfs_fsync,

View File

@ -1570,7 +1570,7 @@ vfs_put_vnode_ptr(void *_vnode)
}
ssize_t
bool
vfs_can_page(void *_vnode)
{
struct vnode *vnode = (struct vnode *)_vnode;
@ -1580,29 +1580,29 @@ vfs_can_page(void *_vnode)
if (FS_CALL(vnode, can_page))
return FS_CALL(vnode, can_page)(vnode->mount->cookie, vnode->private_node);
return 0;
return false;
}
ssize_t
vfs_read_page(void *_vnode, iovecs *vecs, off_t pos)
status_t
vfs_read_pages(void *_vnode, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes)
{
struct vnode *vnode = (struct vnode *)_vnode;
FUNCTION(("vfs_readpage: vnode %p, vecs %p, pos %Ld\n", vnode, vecs, pos));
return FS_CALL(vnode, read_pages)(vnode->mount->cookie, vnode->private_node, vecs, pos);
return FS_CALL(vnode, read_pages)(vnode->mount->cookie, vnode->private_node, pos, vecs, count, _numBytes);
}
ssize_t
vfs_write_page(void *_vnode, iovecs *vecs, off_t pos)
status_t
vfs_write_pages(void *_vnode, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes)
{
struct vnode *vnode = (struct vnode *)_vnode;
FUNCTION(("vfs_writepage: vnode %p, vecs %p, pos %Ld\n", vnode, vecs, pos));
return FS_CALL(vnode, write_pages)(vnode->mount->cookie, vnode->private_node, vecs, pos);
return FS_CALL(vnode, write_pages)(vnode->mount->cookie, vnode->private_node, pos, vecs, count, _numBytes);
}