mirror of
https://review.haiku-os.org/haiku
synced 2024-11-23 07:18:40 +01:00
kernel/fs: Implement do_fd_io using do_iterative_fd_io.
We need to hold a reference to the file descriptor throughout the I/O operation, which do_iterative_fd_io already takes care of. So just modify it to handle not having the additional callbacks. Nothing actually uses do_fd_io at present, though it will be in the next commits.
This commit is contained in:
parent
8f88247e04
commit
e829154ffe
@ -301,8 +301,14 @@ do_synchronous_iterative_vnode_io(struct vnode* vnode, void* openCookie,
|
||||
while (error == B_OK && vecLength > 0) {
|
||||
file_io_vec fileVecs[8];
|
||||
size_t fileVecCount = 8;
|
||||
if (getVecs != NULL) {
|
||||
error = getVecs(cookie, request, offset, vecLength, fileVecs,
|
||||
&fileVecCount);
|
||||
} else {
|
||||
fileVecs[0].offset = offset;
|
||||
fileVecs[0].length = vecLength;
|
||||
fileVecCount = 1;
|
||||
}
|
||||
if (error != B_OK || fileVecCount == 0)
|
||||
break;
|
||||
|
||||
@ -330,6 +336,7 @@ do_synchronous_iterative_vnode_io(struct vnode* vnode, void* openCookie,
|
||||
bool partial = length > 0;
|
||||
size_t bytesTransferred = request->Length() - length;
|
||||
request->SetTransferredBytes(partial, bytesTransferred);
|
||||
if (finished != NULL)
|
||||
finished(cookie, request, error, partial, bytesTransferred);
|
||||
request->SetStatusAndNotify(error);
|
||||
return error;
|
||||
@ -469,16 +476,7 @@ vfs_asynchronous_write_pages(struct vnode* vnode, void* cookie, off_t pos,
|
||||
status_t
|
||||
do_fd_io(int fd, io_request* request)
|
||||
{
|
||||
struct vnode* vnode;
|
||||
file_descriptor* descriptor = get_fd_and_vnode(fd, &vnode, true);
|
||||
if (descriptor == NULL) {
|
||||
request->SetStatusAndNotify(B_FILE_ERROR);
|
||||
return B_FILE_ERROR;
|
||||
}
|
||||
|
||||
FileDescriptorPutter descriptorPutter(descriptor);
|
||||
|
||||
return vfs_vnode_io(vnode, descriptor->cookie, request);
|
||||
return do_iterative_fd_io(fd, request, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -493,6 +491,7 @@ do_iterative_fd_io(int fd, io_request* request, iterative_io_get_vecs getVecs,
|
||||
struct vnode* vnode;
|
||||
file_descriptor* descriptor = get_fd_and_vnode(fd, &vnode, true);
|
||||
if (descriptor == NULL) {
|
||||
if (finished != NULL)
|
||||
finished(cookie, request, B_FILE_ERROR, true, 0);
|
||||
request->SetStatusAndNotify(B_FILE_ERROR);
|
||||
return B_FILE_ERROR;
|
||||
@ -526,11 +525,13 @@ do_iterative_fd_io(int fd, io_request* request, iterative_io_get_vecs getVecs,
|
||||
&iterationCookie->next_finished_cookie);
|
||||
|
||||
request->SetFinishedCallback(&do_iterative_fd_io_finish, iterationCookie);
|
||||
if (getVecs != NULL)
|
||||
request->SetIterationCallback(&do_iterative_fd_io_iterate, iterationCookie);
|
||||
|
||||
descriptorPutter.Detach();
|
||||
// From now on the descriptor is put by our finish callback.
|
||||
|
||||
if (getVecs != NULL) {
|
||||
bool partialTransfer = false;
|
||||
status_t error = do_iterative_fd_io_iterate(iterationCookie, request,
|
||||
&partialTransfer);
|
||||
@ -543,6 +544,9 @@ do_iterative_fd_io(int fd, io_request* request, iterative_io_get_vecs getVecs,
|
||||
request->SetStatusAndNotify(error);
|
||||
return error;
|
||||
}
|
||||
} else {
|
||||
return vfs_vnode_io(vnode, descriptor->cookie, request);
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user