smb_read.c revision 55bf511df53aad0fdb7eb3fa349f0308cc05234c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <smbsrv/smb_incl.h>
#include <smbsrv/smb_fsops.h>
typedef struct smb_read_param {
/*
* Read bytes from a file or named pipe (SMB Core).
*
* The requested count specifies the number of bytes desired. Offset
* is limited to 32 bits, so this client request is inappropriate for
* files with 64 bit offsets.
*
* On return, count is the number of bytes actually being returned, which
* may be less than the count requested only if a read specifies bytes
* beyond the current file size. In this case only the bytes that exist
* are returned. A read completely beyond the end of file results in a
* response of length zero. This is the only circumstance when a zero
* length response is generated. A count returned which is less than the
* count requested is the end of file indicator.
*/
int
{
int rc;
if (rc != 0) {
/* NOTREACHED */
}
/* NOTREACHED */
}
/* NOTREACHED */
}
return (SDRC_NORMAL_REPLY);
}
/*
* Lock and read bytes from a file (SMB Core Plus). The SmbLockAndRead/
* SmbLockAndWrite sub-dialect is only valid on disk files: reject any
* attempt to use it on non-disk shares.
*
* The requested count specifies the number of bytes desired. Offset
* specifies the offset in the file of the first byte to be locked then
* read. Note that offset is limited to 32 bits, so this client request
* is inappropriate for files with 64 bit offsets.
*
* As with SMB_LOCK_BYTE_RANGE request, if the lock cannot be granted
* immediately an error should be returned to the client. If an error
* occurs on the lock, the bytes should not be read.
*
* On return, count is the number of bytes actually being returned, which
* may be less than the count requested only if a read specifies bytes
* beyond the current file size. In this case only the bytes that exist
* are returned. A read completely beyond the end of file results in a
* response of length zero. This is the only circumstance when a zero
* length response is generated. A count returned which is less than the
* count requested is the end of file indicator.
*/
int
{
int rc;
/* NOTREACHED */
}
if (rc != 0) {
/* NOTREACHED */
}
/* NOTREACHED */
}
if (result != NT_STATUS_SUCCESS) {
}
/* NOTREACHED */
}
return (SDRC_NORMAL_REPLY);
}
/*
* The SMB_COM_READ_RAW protocol is a negotiated option introduced in
* SMB Core Plus to maximize performance when reading a large block
* of data from a server. This request was extended in LM 0.12 to
* support 64-bit offsets; the server can indicate support by setting
* CAP_LARGE_FILES in the negotiated capabilities.
*
* The client must guarantee that there is (and will be) no other request
* to the server for the duration of the SMB_COM_READ_RAW, since the
* server response has no header or trailer. To help ensure that there
* are no interruptions, we block all I/O for the session during read raw.
*
* If this is the first SMB request received since we sent an oplock break
* to this client, we don't know if it's safe to send the raw data because
* the requests may have crossed on the wire and the client may have
* interpreted the oplock break as part of the raw data. To avoid problems,
* we send a zero length session packet, which will force the client to
* retry the read.
*
* Read errors are handled by sending a zero length response.
*/
int
{
int rc;
&timeout);
} else {
&off_high);
}
if (rc != 0) {
/* NOTREACHED */
}
/* NOTREACHED */
}
/*
* XXX Do we need to handle errors here? What if we have an
* access error (either permissions or range lock violations?
*/
}
}
if (rc != 0) {
} else {
}
return (SDRC_NO_REPLY);
return (SDRC_NO_REPLY);
ASSERT(0);
return (SDRC_DROP_VC);
ASSERT(0);
return (SDRC_NO_REPLY);
return (SDRC_NO_REPLY);
default:
ASSERT(0);
return (SDRC_DROP_VC);
}
}
/*
* Read bytes from a file (SMB Core). This request was extended in
* LM 0.12 to support 64-bit offsets, indicated by sending a wct of
* 12 and including additional offset information.
*/
int
{
int rc;
} else {
}
if (rc != 0) {
/* NOTREACHED */
}
/* NOTREACHED */
}
/* NOTREACHED */
}
/*
* Ensure that the next response offset is zero
* if there is no secondary command.
*/
/*
* The STYPE_IPC response format is different.
* The unknown value (2) may be to indicate that it
* is a follow-up to an earlier RPC transaction.
*/
12, /* wct */
secondary, /* Secondary andx command */
offset2, /* offset to next */
0, /* must be 0 */
60, /* Offset from start to data */
VAR_BCC, /* BCC marker */
0x02, /* unknown */
} else {
12, /* wct */
secondary, /* Secondary andx command */
offset2, /* offset to next */
-1, /* must be -1 */
59, /* Offset from start to data */
VAR_BCC, /* BCC marker */
}
return (SDRC_NORMAL_REPLY);
}
/*
* protocol read functions should lookup the fid before calling this
* function. We can't move the fid lookup here because lock-and-read
* requires the fid to do locking before attempting the read.
*
* Returns errno values.
*/
int
{
struct vardata_block *vdb;
int rc;
case STYPE_DISKTREE:
if (rc != NT_STATUS_SUCCESS) {
break;
}
}
break;
case STYPE_IPC:
break;
default:
break;
}
if (rc != 0)
return (rc);
/*
* mincnt is only used by read-raw and is typically
* zero. If mincnt is greater than zero and the
* number of bytes read is less than mincnt, tell
* the client that we read nothing.
*/
}
return (rc);
}
/*
* The Read Block Multiplexed protocol is used to maximize performance
* when reading a large block of data from server to client while still
* allowing other operations to take place between the client and server
* in parallel.
*
* The mpx sub protocol is not supported because we support only
* connection oriented transports and NT supports SMB_COM_READ_MPX
* only over connectionless transports.
*/
/*ARGSUSED*/
int
{
return (SDRC_UNIMPLEMENTED);
}
/*ARGSUSED*/
int
{
return (SDRC_UNIMPLEMENTED);
}