static status_t btrfs_io(fs_volume* _volume, fs_vnode* _node, void* _cookie, io_request* request) { Volume* volume = (Volume*)_volume->private_volume; Inode* inode = (Inode*)_node->private_node; #ifndef BTRFS_SHELL if (io_request_is_write(request) && volume->IsReadOnly()) { notify_io_request(request, B_READ_ONLY_DEVICE); return B_READ_ONLY_DEVICE; } #endif if (inode->FileCache() == NULL) { #ifndef BTRFS_SHELL notify_io_request(request, B_BAD_VALUE); #endif return B_BAD_VALUE; } // We lock the node here and will unlock it in the "finished" hook. rw_lock_read_lock(inode->Lock()); return do_iterative_fd_io(volume->Device(), request, iterative_io_get_vecs_hook, iterative_io_finished_hook, inode); }
static status_t udf_io(fs_volume *volume, fs_vnode *vnode, void *cookie, io_request *request) { if (io_request_is_write(request)) { notify_io_request(request, B_READ_ONLY_DEVICE); return B_READ_ONLY_DEVICE; } Icb *icb = (Icb *)vnode->private_node; if (icb->FileCache() == NULL) { notify_io_request(request, B_BAD_VALUE); return B_BAD_VALUE; } return do_iterative_fd_io(((Volume *)volume->private_volume)->Device(), request, iterative_io_get_vecs_hook, iterative_io_finished_hook, icb); }
static status_t packagefs_io(fs_volume* fsVolume, fs_vnode* fsNode, void* cookie, io_request* request) { Volume* volume = (Volume*)fsVolume->private_volume; Node* node = (Node*)fsNode->private_node; FUNCTION("volume: %p, node: %p (%" B_PRId64 "), cookie: %p, request: %p\n", volume, node, node->ID(), cookie, request); TOUCH(volume); if (io_request_is_write(request)) RETURN_ERROR(B_READ_ONLY_DEVICE); status_t error = node->Read(request); notify_io_request(request, error); return error; }
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)) { notify_io_request(request, B_READ_ONLY_DEVICE); return B_READ_ONLY_DEVICE; } if ((node->flags & ISO_IS_DIR) != 0) { notify_io_request(request, B_IS_A_DIRECTORY); return B_IS_A_DIRECTORY; } return do_iterative_fd_io(volume->fd, request, iterative_io_get_vecs_hook, iterative_io_finished_hook, node); }
void WorkQueue::JobIO(IORequestArgs* args) { ASSERT(args != NULL); uint64 offset = io_request_offset(args->fRequest); uint64 length = io_request_length(args->fRequest); size_t bufferLength = min_c(MAX_BUFFER_SIZE, length); char* buffer = reinterpret_cast<char*>(malloc(bufferLength)); if (buffer == NULL) { notify_io_request(args->fRequest, B_NO_MEMORY); args->fInode->EndAIOOp(); return; } status_t result; if (io_request_is_write(args->fRequest)) { if (offset + length > args->fInode->MaxFileSize()) length = args->fInode->MaxFileSize() - offset; uint64 position = 0; do { size_t size = 0; size_t thisBufferLength = min_c(bufferLength, length - position); result = read_from_io_request(args->fRequest, buffer, thisBufferLength); while (size < thisBufferLength && result == B_OK) { size_t bytesWritten = thisBufferLength - size; result = args->fInode->WriteDirect(NULL, offset + position + size, buffer + size, &bytesWritten); size += bytesWritten; } position += thisBufferLength; } while (position < length && result == B_OK); } else { bool eof = false; uint64 position = 0; do { size_t size = 0; size_t thisBufferLength = min_c(bufferLength, length - position); do { size_t bytesRead = thisBufferLength - size; result = args->fInode->ReadDirect(NULL, offset + position + size, buffer + size, &bytesRead, &eof); if (result != B_OK) break; result = write_to_io_request(args->fRequest, buffer + size, bytesRead); if (result != B_OK) break; size += bytesRead; } while (size < length && result == B_OK && !eof); position += thisBufferLength; } while (position < length && result == B_OK && !eof); } free(buffer); notify_io_request(args->fRequest, result); args->fInode->EndAIOOp(); }