/*
* 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 2014 Nexenta Systems, Inc. All rights reserved.
*/
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smb_fsops.h>
/*
* Write count bytes at the specified offset in a file. The offset is
* limited to 32-bits. If the count is zero, the file is truncated to
* the length specified by the offset.
*
* The response count indicates the actual number of bytes written, which
* will equal the requested count on success. If request and response
* counts differ but there is no error, the client will assume that the
* server encountered a resource issue.
*/
{
int rc;
smb_rw_param_t *, param);
}
void
{
}
{
int rc;
return (SDRC_ERROR);
}
} else {
return (SDRC_ERROR);
}
}
if (rc != 0) {
return (SDRC_ERROR);
}
}
/*
* Write count bytes to a file and then close the file. This function
* can only be used to write to 32-bit offsets and the client must set
* WordCount (6 or 12) correctly in order to locate the data to be
* written. If an error occurs on the write, the file should still be
* closed. If Count is 0, the file is truncated (or extended) to offset.
*
* If the last_write time is non-zero, last_write should be used to set
* the mtime. Otherwise the file system stamps the mtime. Failure to
* set mtime should not result in an error response.
*/
{
int rc;
} else {
}
smb_rw_param_t *, param);
}
void
{
}
{
int rc = 0;
return (SDRC_ERROR);
}
} else {
/*
* There may be a bug here: should this be "3.#B"?
*/
return (SDRC_ERROR);
}
}
if (rc != 0) {
return (SDRC_ERROR);
}
}
/*
* Write count bytes to a file at the specified offset and then unlock
* them. Write behind is safe because the client should have the range
* locked and this request is allowed to extend the file - note that
* offset is limited to 32-bits.
*
* Spec advice: it is an error for count to be zero. For compatibility,
* we take no action and return success.
*
* The SmbLockAndRead/SmbWriteAndUnlock sub-dialect is only valid on disk
* files. Reject any attempt to use it on other shares.
*
* The response count indicates the actual number of bytes written, which
* will equal the requested count on success. If request and response
* counts differ but there is no error, the client will assume that the
* server encountered a resource issue.
*/
{
int rc;
smb_rw_param_t *, param);
}
void
{
}
{
int rc = 0;
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
}
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
if (status != NT_STATUS_SUCCESS) {
return (SDRC_ERROR);
}
}
/*
* Write bytes to a file (SMB Core). This request was extended in
* LM 0.12 to support 64-bit offsets, indicated by sending a wct of
* 14, instead of 12, and including additional offset information.
*
* A ByteCount of 0 does not truncate the file - use SMB_COM_WRITE
* to truncate a file. A zero length merely transfers zero bytes.
*
* If bit 0 of WriteMode is set, Fid must refer to a disk file and
* the data must be on stable storage before responding.
*
* MS-SMB 3.3.5.8 update to LM 0.12 4.2.5:
* If CAP_LARGE_WRITEX is set, the byte count may be larger than the
* negotiated buffer size and the server is expected to write the
* number of bytes specified.
*/
{
int rc;
/* off_high not present */
} else {
rc = -1;
}
/*
* Work-around a Win7 bug, where it fails to set the
* CAP_LARGE_WRITEX flag during session setup. Assume
* a large write if the data remaining is >= 64k.
*/
smb_rw_param_t *, param);
}
void
{
}
{
int rc;
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
}
}
/*
*
* Returns errno values.
*/
int
{
int stability = 0;
int rc = 0;
case STYPE_DISKTREE:
case STYPE_PRINTQ:
if (!smb_node_is_dir(node)) {
if (rc != NT_STATUS_SUCCESS) {
return (EACCES);
}
}
}
if (rc)
return (rc);
/*
* Used to have code here to set mtime.
* We have just done a write, so we know
* the file system will update mtime.
* No need to do it again here.
*
* However, keep track of the fact that
* we have written data via this handle.
*/
if (!smb_node_is_dir(node))
break;
case STYPE_IPC:
break;
default:
break;
}
if (rc != 0)
return (rc);
return (rc);
}
/*
* Truncate a disk file to the specified offset.
* Typically, w_count will be zero here.
*
* Note that smb_write_andx cannot be used to reduce the file size so,
* if this is required, smb_write is called with a count of zero and
* the appropriate file length in offset. The file should be resized
* to the length specified by the offset.
*
* Returns errno values.
*/
static int
{
int rc;
return (0);
if (!smb_node_is_dir(node)) {
if (status != NT_STATUS_SUCCESS) {
return (EACCES);
}
}
if (rc != 0)
return (rc);
return (0);
}