* Added support for the io() hook. Not yet tested.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30906 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-05-28 21:37:39 +00:00
parent f0c050f60e
commit 41b1980691
2 changed files with 53 additions and 1 deletions

View File

@ -76,10 +76,13 @@ struct rock_ridge_attributes {
uint8 slVer;
};
struct iso9660_volume;
struct iso9660_inode {
/* Most drivers will probably want the first things defined here. */
ino_t id;
ino_t parID; // parent vnode ID.
struct iso9660_volume* volume;
void *cache; // for file cache
// End of members other drivers will definitely want.

View File

@ -38,6 +38,9 @@
#include "iso9660.h"
#include "iso9660_identify.h"
// TODO: temporary solution as long as there is no public I/O requests API
#include <io_requests.h>
//#define TRACE_ISO9660
#ifdef TRACE_ISO9660
@ -55,6 +58,33 @@ extern fs_volume_ops gISO9660VolumeOps;
extern fs_vnode_ops gISO9660VnodeOps;
//! fs_io() callback hook
static status_t
iterative_io_get_vecs_hook(void* cookie, io_request* request, off_t offset,
size_t size, struct file_io_vec* vecs, size_t* _count)
{
iso9660_inode* node = (iso9660_inode*)cookie;
vecs->offset = offset + node->startLBN[FS_DATA_FORMAT]
* node->volume->logicalBlkSize[FS_DATA_FORMAT];
vecs->length = size;
*_count = 1;
return B_OK;
}
//! fs_io() callback hook
static status_t
iterative_io_finished_hook(void* cookie, io_request* request, status_t status,
bool partialTransfer, size_t bytesTransferred)
{
// nothing to do here...
return B_OK;
}
// #pragma mark - Scanning
@ -349,7 +379,9 @@ fs_read_vnode(fs_volume* _volume, ino_t vnodeID, fs_vnode* _node,
return result;
}
newNode->volume = volume;
newNode->id = vnodeID;
_node->private_node = newNode;
_node->ops = &gISO9660VnodeOps;
*_type = newNode->attr.stat[FS_DATA_FORMAT].st_mode
@ -418,6 +450,23 @@ fs_read_pages(fs_volume* _volume, fs_vnode* _node, void* _cookie, off_t pos,
}
static status_t
fs_io(fs_volume* _volume, fs_vnode* _node, void* _cookie, io_request* request)
{
iso9660_volume* volume = (iso9660_volume*)_volume->private_volume;
iso9660_inode* node = (iso9660_inode*)_node->private_node;
if (io_request_is_write(request))
return B_READ_ONLY_DEVICE;
if ((node->flags & ISO_IS_DIR) != 0)
return EISDIR;
return do_iterative_fd_io(volume->fd, request, iterative_io_get_vecs_hook,
iterative_io_finished_hook, node);
}
static status_t
fs_read_stat(fs_volume* _volume, fs_vnode* _node, struct stat* st)
{
@ -660,7 +709,7 @@ fs_vnode_ops gISO9660VnodeOps = {
&fs_read_pages,
NULL,
NULL, // io()
&fs_io,
NULL, // cancel_io()
/* cache file access */