summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-05-20 19:03:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:08:15 -0500
commite23cc70a72e6582e91bcfdaf1d6ed2191e7e23a6 (patch)
tree874e55f837a108229fbd77c3a87a9070d530280b
parentf9ddc0dde562b0976a05fc6ca07ea8c9ce0bd284 (diff)
downloadsamba-e23cc70a72e6582e91bcfdaf1d6ed2191e7e23a6.tar.gz
samba-e23cc70a72e6582e91bcfdaf1d6ed2191e7e23a6.tar.bz2
samba-e23cc70a72e6582e91bcfdaf1d6ed2191e7e23a6.zip
r15760: - add RAW_READ_SMB2 => generic mapping
- Implement SMB2 Read metze (This used to be commit d0ac0c5af44ba5aa8b18106c2ac26c0d194e59b4)
-rw-r--r--source4/ntvfs/ntvfs_generic.c25
-rw-r--r--source4/smb_server/smb2/fileio.c40
2 files changed, 61 insertions, 4 deletions
diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c
index 119fef2c6d..922093a0a9 100644
--- a/source4/ntvfs/ntvfs_generic.c
+++ b/source4/ntvfs/ntvfs_generic.c
@@ -1165,13 +1165,16 @@ static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs,
{
switch (rd->generic.level) {
case RAW_READ_READ:
- rd->read.out.nread = rd2->generic.out.nread;
+ rd->read.out.nread = rd2->generic.out.nread;
break;
case RAW_READ_READBRAW:
- rd->readbraw.out.nread = rd2->generic.out.nread;
+ rd->readbraw.out.nread = rd2->generic.out.nread;
break;
case RAW_READ_LOCKREAD:
- rd->lockread.out.nread = rd2->generic.out.nread;
+ rd->lockread.out.nread = rd2->generic.out.nread;
+ break;
+ case RAW_READ_SMB2:
+ rd->smb2.out.data.length= rd2->generic.out.nread;
break;
default:
return NT_STATUS_INVALID_LEVEL;
@@ -1259,6 +1262,22 @@ _PUBLIC_ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs,
status = ntvfs->ops->read(ntvfs, req, rd2);
}
break;
+
+ case RAW_READ_SMB2:
+ if (rd->smb2.in.length > UINT16_MAX) {
+ DEBUG(0,("%s: mapping SMB2 => generic length to large %u!\n",
+ __FUNCTION__, rd->smb2.in.length));
+ status = NT_STATUS_FOOBAR;
+ goto done;
+ }
+ rd2->readx.in.file.ntvfs= rd->smb2.in.file.ntvfs;
+ rd2->readx.in.offset = rd->smb2.in.offset;
+ rd2->readx.in.mincnt = rd->smb2.in.length;
+ rd2->readx.in.maxcnt = rd->smb2.in.length;
+ rd2->readx.in.remaining = 0;
+ rd2->readx.out.data = rd->smb2.out.data.data;
+ status = ntvfs->ops->read(ntvfs, req, rd2);
+ break;
}
done:
diff --git a/source4/smb_server/smb2/fileio.c b/source4/smb_server/smb2/fileio.c
index e46a42c2d8..d190049631 100644
--- a/source4/smb_server/smb2/fileio.c
+++ b/source4/smb_server/smb2/fileio.c
@@ -148,9 +148,47 @@ void smb2srv_flush_recv(struct smb2srv_request *req)
SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_flush(req->ntvfs, io));
}
+static void smb2srv_read_send(struct ntvfs_request *ntvfs)
+{
+ struct smb2srv_request *req;
+ union smb_read *io;
+
+ SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_read);
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, True, 0));
+
+ SMB2SRV_CHECK(smb2_push_o16s32_blob(&req->out, 0x02, io->smb2.out.data));
+ SBVAL(req->out.body, 0x08, io->smb2.out.unknown1);
+ SCVAL(req->out.body, 0x10, 0);
+
+ smb2srv_send_reply(req);
+}
+
void smb2srv_read_recv(struct smb2srv_request *req)
{
- smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED);
+ union smb_read *io;
+
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x30, True);
+ SMB2SRV_TALLOC_IO_PTR(io, union smb_read);
+ SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_read_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
+
+ io->smb2.level = RAW_READ_SMB2;
+ io->smb2.in._pad = SVAL(req->in.body, 0x02);
+ io->smb2.in.length = IVAL(req->in.body, 0x04);
+ io->smb2.in.offset = BVAL(req->in.body, 0x08);
+ io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x10);
+ io->smb2.in.unknown1 = BVAL(req->in.body, 0x20);
+ io->smb2.in.unknown2 = BVAL(req->in.body, 0x28);
+ io->smb2.in._bug = CVAL(req->in.body, 0x30);
+
+ SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
+
+ /* preallocate the buffer for the backends */
+ io->smb2.out.data = data_blob_talloc(io, NULL, io->smb2.in.length);
+ if (io->smb2.out.data.length != io->smb2.in.length) {
+ SMB2SRV_CHECK(NT_STATUS_NO_MEMORY);
+ }
+
+ SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_read(req->ntvfs, io));
}
static void smb2srv_write_send(struct ntvfs_request *ntvfs)