/*
* 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_ioctl.h>
#ifdef _FAKE_KERNEL
#error "See libfksmbsrv"
#endif /* _FAKE_KERNEL */
/*
* *****************************************************************************
* ****************************** 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_sign_debug = 0;
#ifdef DEBUG
#else
0;
#endif
/*
* Maximum number of simultaneous authentication, share mapping, pipe open
* requests to be processed.
*/
/*
* Number of milliseconds that a request will be stalled if it comes in after
* the maximum number of inflight operations are being proccessed.
*/
/*
* Thread priorities used in smbsrv. Our threads spend most of their time
* blocked on various conditions. However, if the system gets heavy load,
* the scheduler has to choose an order to run these. We want the order:
* (a) timers, (b) notifications, (c) workers, (d) receivers (and etc.)
* where notifications are oplock and change notify work. Aside from this
* relative ordering, smbsrv threads should run with a priority close to
* that of normal user-space threads (thus minclsyspri below), just like
* NFS and other "file service" kinds of processing.
*/
/*
* *****************************************************************************
* ********************** 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,
};
MODREV_1, /* revision of the module, must be: MODREV_1 */
&modldrv, /* ptr to linkage structures */
NULL,
};
/*
* ****************************************************************************
* Module Interface
* ****************************************************************************
*/
int
_init(void)
{
int rc;
if ((rc = smb_server_g_init()) != 0) {
return (rc);
}
}
return (rc);
}
int
{
}
int
_fini(void)
{
int rc;
if (smb_server_get_count() != 0)
return (EBUSY);
}
return (rc);
}
/*
* ****************************************************************************
* Pseudo Device Entry Points
* ****************************************************************************
*/
/* ARGSUSED */
static int
{
/*
* Check caller's privileges.
*/
if (secpolicy_smb(cr) != 0)
return (EPERM);
/*
* We need a unique minor per zone otherwise an smbd in any other
* zone will keep this minor open and we won't get a close call.
* The zone ID is good enough as a minor number.
*/
if (zid < 0)
return (ENODEV);
/*
* 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_STOP:
rc = smb_server_stop();
break;
case SMB_IOC_EVENT:
break;
case SMB_IOC_GMTOFF:
break;
case SMB_IOC_SHARE:
break;
case SMB_IOC_UNSHARE:
break;
case SMB_IOC_SHAREINFO:
break;
case SMB_IOC_NUMOPEN:
break;
case SMB_IOC_SVCENUM:
break;
case SMB_IOC_SESSION_CLOSE:
break;
case SMB_IOC_FILE_CLOSE:
break;
case SMB_IOC_SPOOLDOC:
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);
}