/* read from a file */ static NTSTATUS cvfs_read(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_read *io) { struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (io->generic.level != RAW_READ_GENERIC && p->map_generic) { return ntvfs_map_read(ntvfs, req, io); } SETUP_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_read(p->tree, io); } c_req = smb_raw_read_send(p->tree, io); ASYNC_RECV_TAIL(io, async_read); }
} int async_read(struct async_context *c) { if (!c->io_read) { c->io_read = talloc(c->tree, union smb_read); c->io_read->readx.level = RAW_READ_READX; c->io_read->readx.in.file.fnum = c->fd; c->io_read->readx.in.offset = 0; c->io_read->readx.in.mincnt = sizeof(c->buffer); c->io_read->readx.in.maxcnt = sizeof(c->buffer); c->io_read->readx.in.remaining = 0; c->io_read->readx.in.read_for_execute = False; c->io_read->readx.out.data = (uint8_t *)c->buffer; } c->rreq = smb_raw_read_send(c->tree, c->io_read); if (!c->rreq) { if (c->cb_error) c->cb_error(c->cb_ctx, ASYNC_READ, NT_STATUS_NO_MEMORY); return 0; } c->rreq->transport->options.request_timeout = 0; c->rreq->async.fn = async_read_recv; c->rreq->async.private = c; return 1; } int async_open(struct async_context *c, const char *fn, int open_mode) { DEBUG(1, ("IN: async_open(%s, %d)\n", fn, open_mode));
/**************************************************************************** low level read operation (sync interface) ****************************************************************************/ _PUBLIC_ NTSTATUS smb_raw_read(struct smbcli_tree *tree, union smb_read *parms) { struct smbcli_request *req = smb_raw_read_send(tree, parms); return smb_raw_read_recv(req, parms); }