smb_trans2_set_information.c revision faa1795a28a5c712eed6d0a3f84d98c368a316c6
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This file contains the common code used by
* Trans2SetFileInfo and Trans2SetPathInfo SMBs.
*/
#include <smbsrv/smb_incl.h>
#include <smbsrv/smb_fsops.h>
/*LINTED E_STATIC_UNUSED*/
/*LINTED E_STATIC_UNUSED*/
/*LINTED E_STATIC_UNUSED*/
/*LINTED E_STATIC_UNUSED*/
static unsigned short smb_info_passthru(unsigned short infolevel);
/*
* smb_trans2_set_information
*
* This is a common function called by both Trans2SetFileInfo
* and Trans2SetPathInfo.
*/
struct smb_request *sr,
{
case SMB_INFO_STANDARD:
case SMB_INFO_QUERY_EA_SIZE:
case SMB_INFO_QUERY_ALL_EAS:
/* This info level is not supported */
return (NT_STATUS_SUCCESS);
case SMB_SET_FILE_BASIC_INFO:
default:
break;
}
return (NT_STATUS_UNSUCCESSFUL);
}
/*
* smb_info_passthru
*
* SMB_INFO_PASSTHROUGH
* If the server supports information level request passing through,
* the client may add the information level with SMB_INFO_PASSTHROUGH
* and submit the file information in NT data format instead of SMB
* data format. Please refer to MSDN for related NT file information
* data structure.
*
* observed:
* 0x3EC = SMB_INFO_PASSTHROUGH + FileBasicInformation (4)
* 0x3F5 = SMB_INFO_PASSTHROUGH + FileDispositionInformation (13)
* 0x3FC = SMB_INFO_PASSTHROUGH + FileEndOfFileInformation (20)
*
* Based on network traces between two Win2K systems:
* FileBasicInformation <=> SMB_SET_FILE_BASIC_INFO
* FileDispositionInformation <=> SMB_SET_FILE_DISPOSITION_INFO
* FileEndOfFileInformation <=> SMB_SET_FILE_END_OF_FILE_INFO
*/
static unsigned short
smb_info_passthru(unsigned short infolevel)
{
if (infolevel <= SMB_INFO_PASSTHROUGH)
return (infolevel);
switch (infolevel) {
case FileBasicInformation:
return (SMB_SET_FILE_BASIC_INFO);
return (SMB_SET_FILE_DISPOSITION_INFO);
case FileEndOfFileInformation:
return (SMB_SET_FILE_END_OF_FILE_INFO);
}
return (infolevel);
}
/*
* smb_set_standard_info
*
* SMB_INFO_STANDARD & SMB_INFO_QUERY_EA_SIZE
*
* Data Block Encoding Description
* ================================== =================================
*
* SMB_DATE CreationDate; Date when file was created
* SMB_TIME CreationTime; Time when file was created
* SMB_DATE LastAccessDate; Date of last file access
* SMB_TIME LastAccessTime; Time of last file access
* SMB_DATE LastWriteDate; Date of last write to the file
* SMB_TIME LastWriteTime; Time of last write to the file
* ULONG DataSize; File Size
* ULONG AllocationSize; Size of filesystem allocation
* unit
* USHORT Attributes; File Attributes
* ULONG EaSize; Size of file's EA information
* (SMB_INFO_QUERY_EA_SIZE)
*/
static DWORD
struct smb_request *sr,
{
unsigned short Attributes;
unsigned int what = 0;
int rc;
&Creation, /* CreationDate/Time */
&LastAccess, /* LastAccessDate/Time */
&LastWrite, /* LastWriteDate/Time */
&DataSize, /* File Size */
&AllocationSize, /* Block Size */
&Attributes) != 0) { /* File Attributes */
return (NT_STATUS_DATA_ERROR);
}
if (DataSize != 0) {
}
/*
* IR101794 The behaviour when the time field is set to -1
* is not documented, so we'll assume it should be treated
* like 0.
*/
what |= SMB_AT_MTIME;
}
what |= SMB_AT_CRTIME;
}
what |= SMB_AT_ATIME;
}
if (Attributes != 0)
if (rc) {
}
return (status);
}
/*
* smb_set_basic_info
*
*/
static DWORD
struct smb_request *sr,
{
unsigned short Attributes;
unsigned int what = 0;
int rc;
&NT_Creation, /* CreationDate/Time */
&NT_LastAccess, /* LastAccessDate/Time */
&NT_LastWrite, /* LastWriteDate/Time */
&NT_Change, /* LastWriteDate/Time */
&Attributes) != 0) { /* File Attributes */
return (NT_STATUS_DATA_ERROR);
}
/*
* IR101794 The behaviour when the time field is set to -1
* is not documented, so we'll assume it should be treated
* like 0.
*/
what |= SMB_AT_CTIME;
}
what |= SMB_AT_CRTIME;
}
what |= SMB_AT_MTIME;
}
what |= SMB_AT_ATIME;
}
if (Attributes != 0)
if (rc) {
}
return (status);
}
/*
* smb_set_alloc_info
*
* Sets file allocation/end_of_file info
*/
static DWORD
struct smb_request *sr,
{
int rc;
return (NT_STATUS_UNSUCCESSFUL);
}
return (NT_STATUS_DATA_ERROR);
/*
* Ensure that the FS is consistent with the node cache
* because the size flag can get cleared by subsequent
* write requests without the inode ever being updated.
*/
}
}
return (status);
}
/*
* smb_set_disposition_info
*
* File should have been opened with DELETE access otherwise
* the operation is not permitted.
*
* NOTE: The node should be marked delete-on-close upon the receipt
* of the Trans2SetFileInfo(SetDispositionInfo) if mark_delete is set.
* It is different than both SmbNtCreateAndX and SmbNtTransact, which
* set delete-on-close on the ofile and defer setting the flag on the
* node until the file is closed.
*
* Observation of Windows 2000 indicates the following:
*
* 1) If a file is not opened with delete-on-close create options and
* the delete-on-close is set via Trans2SetFileInfo(SetDispositionInfo)
* using that open file handle, any subsequent open requests will fail
* with DELETE_PENDING.
*
* 2) If a file is opened with delete-on-close create options and the
* client attempts to unset delete-on-close via Trans2SetFileInfo
* (SetDispositionInfo) prior to the file close, any subsequent open
* requests will still fail with DELETE_PENDING after the file is closed.
*
* 3) If a file is opened with delete-on-close create options and that
* file handle (not the last open handle and the only file handle
* with delete-on-close set) is closed. Any subsequent open requests
* will fail with DELETE_PENDING. Unsetting delete-on-close via
* Trans2SetFileInfo(SetDispositionInfo) at this time will unset the
* node delete-on-close flag, which will result in the file not being
* removed even after the last file handle is closed.
*/
static DWORD
{
unsigned char mark_delete;
return (NT_STATUS_DATA_ERROR);
return (NT_STATUS_UNSUCCESSFUL);
}
if (mark_delete) {
return (NT_STATUS_UNSUCCESSFUL);
}
} else {
}
return (NT_STATUS_SUCCESS);
}