mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
r15760: - add RAW_READ_SMB2 => generic mapping
- Implement SMB2 Read metze
This commit is contained in:
parent
05ced31cb9
commit
d0ac0c5af4
@ -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:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user