da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
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 * CDDL HEADER END
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#endif /* _FAKE_KERNEL */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic int smb_drv_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbstatic int smb_drv_attach(dev_info_t *, ddi_attach_cmd_t);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbstatic int smb_drv_detach(dev_info_t *, ddi_detach_cmd_t);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbstatic int smb_drv_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * *****************************************************************************
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * ****************************** Global Variables *****************************
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * *****************************************************************************
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * These variables can only be changed through the /etc/system file.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * Maximum buffer size for NT: configurable based on the client environment.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * IR104720 Experiments with Windows 2000 indicate that we achieve better
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * SmbWriteX performance with a buffer size of 64KB instead of the 37KB used
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * with Windows NT4.0. Previous experiments with NT4.0 resulted in directory
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * listing problems so this buffer size is configurable based on the end-user
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * environment. When in doubt use 37KB.
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshint smb_oplock_min_timeout = OPLOCK_MIN_TIMEOUT;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * Maximum number of simultaneous authentication, share mapping, pipe open
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * requests to be processed.
12b65585e720714b31036daaa2b30eb76014048eGordon Rossint smb_ssetup_threshold = SMB_AUTHSVC_MAXTHREAD;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * Number of milliseconds that a request will be stalled if it comes in after
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * the maximum number of inflight operations are being proccessed.
08344b293eab865a57e4629b178f2003dced397eGordon Ross * Thread priorities used in smbsrv. Our threads spend most of their time
08344b293eab865a57e4629b178f2003dced397eGordon Ross * blocked on various conditions. However, if the system gets heavy load,
08344b293eab865a57e4629b178f2003dced397eGordon Ross * the scheduler has to choose an order to run these. We want the order:
08344b293eab865a57e4629b178f2003dced397eGordon Ross * (a) timers, (b) notifications, (c) workers, (d) receivers (and etc.)
08344b293eab865a57e4629b178f2003dced397eGordon Ross * where notifications are oplock and change notify work. Aside from this
08344b293eab865a57e4629b178f2003dced397eGordon Ross * relative ordering, smbsrv threads should run with a priority close to
08344b293eab865a57e4629b178f2003dced397eGordon Ross * that of normal user-space threads (thus minclsyspri below), just like
08344b293eab865a57e4629b178f2003dced397eGordon Ross * NFS and other "file service" kinds of processing.
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * *****************************************************************************
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * ********************** Static Variables / Module Linkage ********************
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * *****************************************************************************
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw 0, /* devo_refcnt */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MODREV_1, /* revision of the module, must be: MODREV_1 */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * ****************************************************************************
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * Module Interface
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * ****************************************************************************
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * ****************************************************************************
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * Pseudo Device Entry Points
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * ****************************************************************************
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/* ARGSUSED */
8622ec4569457733001d4982ef7f5b44427069beGordon Rosssmb_drv_open(dev_t *devp, int flag, int otyp, cred_t *cr)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Check caller's privileges.
8622ec4569457733001d4982ef7f5b44427069beGordon Ross * We need a unique minor per zone otherwise an smbd in any other
8622ec4569457733001d4982ef7f5b44427069beGordon Ross * zone will keep this minor open and we won't get a close call.
8622ec4569457733001d4982ef7f5b44427069beGordon Ross * The zone ID is good enough as a minor number.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Start SMB service state machine
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/* ARGSUSED */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsmb_drv_close(dev_t dev, int flag, int otyp, cred_t *credp)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb/* ARGSUSED */
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wrightsmb_drv_ioctl(dev_t drv, int cmd, intptr_t argp, int flags, cred_t *cred,
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright if (ddi_copyin((const void *)argp, &ioc_hdr, sizeof (smb_ioc_header_t),
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright if (smb_crc_gen((uint8_t *)&ioc_hdr, sizeof (ioc_hdr)) != crc)
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright if (ddi_copyin((const void *)argp, ioc, ioc_hdr.len, flags)) {
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb switch (cmd) {
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States case SMB_IOC_STOP:
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States rc = smb_server_stop();
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States break;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States case SMB_IOC_EVENT:
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States rc = smb_server_notify_event(&ioc->ioc_event);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States break;
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown rc = smb_server_session_close(&ioc->ioc_session);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh rc = smb_server_spooldoc(&ioc->ioc_spooldoc);
29bd28862cfb8abbd3a0f0a4b17e08bbc3652836Alan Wright if (ddi_copyout((const void *)ioc, (void *)argp, ioc_hdr.len,
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb return (rc);
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * ****************************************************************************
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * Pseudo Device Operations
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * ****************************************************************************
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb /* we only allow instance 0 to attach */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb /* create the minor node */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb " failed creating minor node");
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb/* ARGSUSED */
faa1795a28a5c712eed6d0a3f84d98c368a316c6jbsmb_drv_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb switch (cmd) {