smb_nt_create_andx.c revision faa1795a28a5c712eed6d0a3f84d98c368a316c6
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The contents of this file are subject to the terms of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Common Development and Distribution License (the "License").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You may not use this file except in compliance with the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * or http://www.opensolaris.org/os/licensing.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * When distributing Covered Code, include this CDDL HEADER in each
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If applicable, add the following below this CDDL HEADER, with the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fields enclosed by brackets "[]" replaced with your own identifying
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * information: Portions Copyright [yyyy] [name of copyright owner]
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER END
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Use is subject to license terms.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#pragma ident "%Z%%M% %I% %E% SMI"
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * This command is used to create or open a file or directory.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <smbsrv/smb_incl.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <smbsrv/smb_fsops.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <smbsrv/smb_vops.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smb_com_nt_create_andx
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * This command is used to create or open a file or directory.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Client Request Description
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ================================= ==================================
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * UCHAR WordCount; Count of parameter words = 24
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * UCHAR AndXCommand; Secondary command; 0xFF = None
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * UCHAR AndXReserved; Reserved (must be 0)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * USHORT AndXOffset; Offset to next command WordCount
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * UCHAR Reserved; Reserved (must be 0)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * USHORT NameLength; Length of Name[] in bytes
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ULONG Flags; Create bit set:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0x02 - Request an oplock
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0x04 - Request a batch oplock
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0x08 - Target of open must be
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * directory
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ULONG RootDirectoryFid; If non-zero, open is relative to
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * this directory
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ACCESS_MASK DesiredAccess; access desired
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * LARGE_INTEGER AllocationSize; Initial allocation size
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ULONG ExtFileAttributes; File attributes
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ULONG ShareAccess; Type of share access
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ULONG CreateDisposition; Action to take if file exists or
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * not
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ULONG CreateOptions; Options to use if creating a file
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ULONG ImpersonationLevel; Security QOS information
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * UCHAR SecurityFlags; Security tracking mode flags:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0x1 - SECURITY_CONTEXT_TRACKING
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0x2 - SECURITY_EFFECTIVE_ONLY
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * USHORT ByteCount; Length of byte parameters
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * STRING Name[]; File to open or create
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The DesiredAccess parameter is specified in section 3.7 on Access Mask
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Encoding.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If no value is specified, it still allows an application to query
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * attributes without actually accessing the file.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The ExtFIleAttributes parameter specifies the file attributes and flags
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * for the file. The parameter's value is the sum of allowed attributes and
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * flags defined in section 3.11 on Extended File Attribute Encoding
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The ShareAccess field Specifies how this file can be shared. This
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * parameter must be some combination of the following values:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Name Value Meaning
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0 Prevents the file from being shared.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * FILE_SHARE_READ 0x00000001 Other open operations can be performed on
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the file for read access.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * FILE_SHARE_WRITE 0x00000002 Other open operations can be performed on
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the file for write access.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * FILE_SHARE_DELETE 0x00000004 Other open operations can be performed on
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the file for delete access.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The CreateDisposition parameter can contain one of the following values:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CREATE_NEW Creates a new file. The function fails if the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * specified file already exists.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CREATE_ALWAYS Creates a new file. The function overwrites the file
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * if it exists.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * OPEN_EXISTING Opens the file. The function fails if the file does
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * not exist.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * OPEN_ALWAYS Opens the file, if it exists. If the file does not
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * exist, act like CREATE_NEW.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * TRUNCATE_EXISTING Opens the file. Once opened, the file is truncated so
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * that its size is zero bytes. The calling process must
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * open the file with at least GENERIC_WRITE access. The
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * function fails if the file does not exist.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The ImpersonationLevel parameter can contain one or more of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * following values:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SECURITY_ANONYMOUS Specifies to impersonate the client at the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Anonymous impersonation level.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SECURITY_IDENTIFICATION Specifies to impersonate the client at the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Identification impersonation level.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SECURITY_IMPERSONATION Specifies to impersonate the client at the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Impersonation impersonation level.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SECURITY_DELEGATION Specifies to impersonate the client at the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Delegation impersonation level.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The SecurityFlags parameter can have either of the following two flags
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * set:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SECURITY_CONTEXT_TRACKING Specifies that the security tracking mode is
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * dynamic. If this flag is not specified,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Security Tracking Mode is static.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SECURITY_EFFECTIVE_ONLY Specifies that only the enabled aspects of
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the client's security context are available
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * to the server. If you do not specify this
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * flag, all aspects of the client's security
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * context are available. This flag allows the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * client to limit the groups and privileges
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * that a server can use while impersonating the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * client.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The response is as follows:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Server Response Description
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ================================= ==================================
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * UCHAR WordCount; Count of parameter words = 26
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * UCHAR AndXCommand; Secondary 0xFF = None
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * command;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * UCHAR AndXReserved; MBZ
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * USHORT AndXOffset; Offset to next command WordCount
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * UCHAR OplockLevel; The oplock level granted
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0 - No oplock granted
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 1 - Exclusive oplock granted
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 2 - Batch oplock granted
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 3 - Level II oplock granted
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * USHORT Fid; The file ID
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ULONG CreateAction; The action taken
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * TIME CreationTime; The time the file was created
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * TIME LastAccessTime; The time the file was accessed
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * TIME LastWriteTime; The time the file was last written
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * TIME ChangeTime; The time the file was last changed
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ULONG ExtFileAttributes; The file attributes
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * LARGE_INTEGER AllocationSize; The number of bytes allocated
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * LARGE_INTEGER EndOfFile; The end of file offset
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * USHORT FileType;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * USHORT DeviceState; state of IPC device (e.g. pipe)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * BOOLEAN Directory; TRUE if this is a directory
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * USHORT ByteCount; = 0
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The following SMBs may follow SMB_COM_NT_CREATE_ANDX:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SMB_COM_READ SMB_COM_READ_ANDX
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SMB_COM_IOCTL
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
7b59d02d2a384be9a08087b14defadd214b3c1ddjbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_pre_nt_create_andx(smb_request_t *sr)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb struct open_param *op = &sr->arg.open;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb uint8_t SecurityFlags;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb uint32_t Flags;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb uint32_t ImpersonationLevel;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb uint16_t NameLength;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int rc;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb bzero(op, sizeof (sr->arg.open));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smbsr_decode_vwv(sr, "5.wlllqlllllb",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &NameLength,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &Flags,
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb &op->rootdirfid,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &op->desired_access,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &op->dsize,
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb &op->dattr,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &op->share_access,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &op->create_disposition,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &op->create_options,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &ImpersonationLevel,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &SecurityFlags);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if (rc == 0) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if (NameLength == 0) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb op->fqi.path = "\\";
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb } else if (NameLength >= MAXPATHLEN) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb smbsr_error(sr, NT_STATUS_OBJECT_PATH_NOT_FOUND,
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb ERRDOS, ERROR_PATH_NOT_FOUND);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb rc = -1;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb } else {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb rc = smbsr_decode_data(sr, "%#u", sr, NameLength,
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb &op->fqi.path);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (Flags) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (Flags & NT_CREATE_FLAG_REQUEST_OPLOCK) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (Flags & NT_CREATE_FLAG_REQUEST_OPBATCH) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->my_flags = MYF_BATCH_OPLOCK;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->my_flags = MYF_EXCLUSIVE_OPLOCK;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (Flags & NT_CREATE_FLAG_OPEN_TARGET_DIR)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->my_flags |= MYF_MUST_BE_DIRECTORY;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_2(op__NtCreateX__start, smb_request_t *, sr,
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb struct open_param *, op);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbvoid
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_post_nt_create_andx(smb_request_t *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb DTRACE_SMB_1(op__NtCreateX__done, smb_request_t *, sr);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb}
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_sdrc_t
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_com_nt_create_andx(struct smb_request *sr)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb{
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb struct open_param *op = &sr->arg.open;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb unsigned char OplockLevel;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb unsigned char DirFlag;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb smb_attr_t new_attr;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb smb_node_t *node;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb int rc;
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if ((op->create_options & FILE_DELETE_ON_CLOSE) &&
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb !(op->desired_access & DELETE)) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb smbsr_error(sr, NT_STATUS_INVALID_PARAMETER, 0, 0);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb }
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if (op->dattr & FILE_FLAG_WRITE_THROUGH)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->create_options |= FILE_WRITE_THROUGH;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if (op->dattr & FILE_FLAG_DELETE_ON_CLOSE)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->create_options |= FILE_DELETE_ON_CLOSE;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb if (op->rootdirfid == 0) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->fqi.dir_snode = sr->tid_tree->t_snode;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb sr->smb_fid = (ushort_t)op->rootdirfid;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->fid_ofile = smb_ofile_lookup_by_fid(sr->tid_tree,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_fid);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (sr->fid_ofile == NULL) {
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as smbsr_error(sr, NT_STATUS_INVALID_HANDLE,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ERRDOS, ERRbadfid);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->fqi.dir_snode = sr->fid_ofile->f_node;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smbsr_disconnect_file(sr);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjb if (smb_common_open(sr) != NT_STATUS_SUCCESS)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (STYPE_ISDSK(sr->tid_tree->t_res_type)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw switch (MYF_OPLOCK_TYPE(op->my_flags)) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case MYF_EXCLUSIVE_OPLOCK :
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw OplockLevel = 1;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case MYF_BATCH_OPLOCK :
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw OplockLevel = 2;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case MYF_LEVEL_II_OPLOCK :
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw OplockLevel = 3;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw case MYF_OPLOCK_NONE :
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw default:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw OplockLevel = 0;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw break;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (op->create_options & FILE_DELETE_ON_CLOSE)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw smb_preset_delete_on_close(sr->fid_ofile);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Set up the directory flag and ensure that
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * we don't return a stale file size.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw node = sr->fid_ofile->f_node;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (node->attr.sa_vattr.va_type == VDIR) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DirFlag = 1;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw new_attr.sa_vattr.va_size = 0;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DirFlag = 0;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw new_attr.sa_mask = SMB_AT_SIZE;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw (void) smb_fsop_getattr(sr, kcred, node, &new_attr);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw node->attr.sa_vattr.va_size = new_attr.sa_vattr.va_size;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
7b59d02d2a384be9a08087b14defadd214b3c1ddjb rc = smbsr_encode_result(sr, 34, 0, "bb.wbwlTTTTlqqwwbw",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 34,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->andx_com,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0x67,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw OplockLevel,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_fid,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->action_taken,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &node->attr.sa_crtime,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &node->attr.sa_vattr.va_atime,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &node->attr.sa_vattr.va_mtime,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw &node->attr.sa_vattr.va_ctime,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->dattr & FILE_ATTRIBUTE_MASK,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw new_attr.sa_vattr.va_size,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw new_attr.sa_vattr.va_size,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->ftype,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->devstate,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DirFlag,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* Named PIPE */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw OplockLevel = 0;
7b59d02d2a384be9a08087b14defadd214b3c1ddjb rc = smbsr_encode_result(sr, 34, 0, "bb.wbwlqqqqlqqwwbw",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 34,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->andx_com,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0x67,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw OplockLevel,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw sr->smb_fid,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->action_taken,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0LL,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0LL,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0LL,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0LL,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw SMB_FA_NORMAL,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0x1000LL,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0LL,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->ftype,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw op->devstate,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}