smb_init.c revision b1352070d318187b41b088da3533692976f3f225
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <smbsrv/smb_incl.h>
#include <smbsrv/smb_door_svc.h>
#include <smbsrv/smb_ioctl.h>
#include <smbsrv/smb_kproto.h>
/*
* *****************************************************************************
* ****************************** Global Variables *****************************
* *****************************************************************************
*
*/
/*
* Maximum buffer size for NT: configurable based on the client environment.
* IR104720 Experiments with Windows 2000 indicate that we achieve better
* SmbWriteX performance with a buffer size of 64KB instead of the 37KB used
* with Windows NT4.0. Previous experiments with NT4.0 resulted in directory
* listing problems so this buffer size is configurable based on the end-user
* environment. When in doubt use 37KB.
*/
int smb_maxbufsize = SMB_NT_MAXBUF;
int smb_flush_required = 1;
int smb_dirsymlink_enable = 1;
int smb_sign_debug = 0;
#ifdef DEBUG
#else
0;
#endif
/*
* *****************************************************************************
* ********************** Static Variables / Module Linkage ********************
* *****************************************************************************
*/
smb_drv_open, /* cb_open */
smb_drv_close, /* cb_close */
nodev, /* cb_strategy */
nodev, /* cb_print */
nodev, /* cb_dump */
nodev, /* cb_read */
nodev, /* cb_write */
smb_drv_ioctl, /* cb_ioctl */
nodev, /* cb_devmap */
nodev, /* cb_mmap */
nodev, /* cb_segmap */
nochpoll, /* cb_chpoll */
ddi_prop_op, /* cb_prop_op */
NULL, /* cb_streamtab */
D_MP, /* cb_flag */
CB_REV, /* cb_rev */
nodev, /* cb_aread */
nodev, /* cb_awrite */
};
DEVO_REV, /* devo_rev */
0, /* devo_refcnt */
smb_drv_getinfo, /* devo_getinfo */
nulldev, /* devo_identify */
nulldev, /* devo_probe */
smb_drv_attach, /* devo_attach */
smb_drv_detach, /* devo_detach */
nodev, /* devo_reset */
&cbops, /* devo_cb_ops */
NULL, /* devo_bus_ops */
NULL, /* devo_power */
ddi_quiesce_not_needed, /* devo_quiesce */
};
&mod_driverops, /* drv_modops */
"CIFS Server Protocol", /* drv_linkinfo */
&devops,
};
static struct modlinkage modlinkage = {
MODREV_1, /* revision of the module, must be: MODREV_1 */
&modldrv, /* ptr to linkage structures */
NULL,
};
/*
* ****************************************************************************
* Module Interface
* ****************************************************************************
*/
int
_init(void)
{
int rc;
rc = smb_server_svc_init();
if (rc == 0) {
if (rc != 0)
(void) smb_server_svc_fini();
}
return (rc);
}
int
{
}
int
_fini(void)
{
int rc;
if (rc == 0)
rc = smb_server_svc_fini();
return (rc);
}
/*
* ****************************************************************************
* Pseudo Device Entry Points
* ****************************************************************************
*/
/* ARGSUSED */
static int
{
/*
* Check caller's privileges.
*/
if (secpolicy_smb(credp) != 0)
return (EPERM);
/*
* Start SMB service state machine
*/
return (smb_server_create());
}
/* ARGSUSED */
static int
{
return (smb_server_delete());
}
/* ARGSUSED */
static int
int *retval)
{
int rc = 0;
return (EFAULT);
return (EFAULT);
return (EFAULT);
}
switch (cmd) {
case SMB_IOC_CONFIG:
break;
case SMB_IOC_START:
break;
case SMB_IOC_NBT_LISTEN:
break;
case SMB_IOC_TCP_LISTEN:
break;
case SMB_IOC_NBT_RECEIVE:
rc = smb_server_nbt_receive();
break;
case SMB_IOC_TCP_RECEIVE:
rc = smb_server_tcp_receive();
break;
case SMB_IOC_GMTOFF:
break;
case SMB_IOC_SHARE:
break;
case SMB_IOC_UNSHARE:
break;
case SMB_IOC_USER_NUMBER:
break;
case SMB_IOC_USER_LIST:
break;
default:
break;
}
flags))
}
return (rc);
}
/*
* ****************************************************************************
* Pseudo Device Operations
* ****************************************************************************
*/
static int
{
if (cmd == DDI_ATTACH) {
/* we only allow instance 0 to attach */
if (ddi_get_instance(dip) == 0) {
/* create the minor node */
DDI_PSEUDO, 0) == DDI_SUCCESS) {
smb_drv_dip = dip;
return (DDI_SUCCESS);
} else {
" failed creating minor node");
}
}
}
return (DDI_FAILURE);
}
static int
{
if (cmd == DDI_DETACH) {
smb_drv_dip = NULL;
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
/* ARGSUSED */
static int
{
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
*result = smb_drv_dip;
return (DDI_SUCCESS);
case DDI_INFO_DEVT2INSTANCE:
return (DDI_SUCCESS);
default:
break;
}
return (DDI_FAILURE);
}