ReadResponse ReadFile(const string &path, size_t size, off_t offset) { ReadRequest request; request.set_path(path); request.set_size(size); request.set_offset(offset); ReadResponse response; ClientContext context; Status status = stub_->ReadFile(&context, request, &response); if (status.ok()) { return response; } // TODO: Do someting on failure here return response; }
status_t Inode::WaitForReadRequest(ReadRequest& request) { // add the entry to wait on thread_prepare_to_block(thread_get_current_thread(), B_CAN_INTERRUPT, THREAD_BLOCK_TYPE_OTHER, "fifo read request"); request.SetNotified(false); // wait mutex_unlock(&fRequestLock); status_t status = thread_block(); // Before going to lock again, we need to make sure no one tries to // unblock us. Otherwise that would screw with mutex_lock(). request.SetNotified(true); mutex_lock(&fRequestLock); return status; }
ReadRequest MessageUtils::create_read_request(const vfs::Object& obj, const uint64_t size, const uint64_t offset) { ReadRequest msg; msg.set_object_id(obj.id.str()); msg.set_object_type(static_cast<uint32_t>(obj.type)); msg.set_size(size); msg.set_offset(offset); msg.CheckInitialized(); return msg; }