smb_kdoor_srv.c revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Kernel door service
* It has dependency on the kernel door client interface because the downcall
* descriptor is required to be passed up to SMB daemon via door up-call.
*/
#include <smbsrv/smb_door_svc.h>
#include <smbsrv/smb_common_door.h>
/*
* Since the action performed by smb_kdoor_srv_callback might vary
* be set to the request type in the server procedure
* (i.e. smb_kdoor_svc). It will then be passed to the callback
* function when the kernel is done with the copyout operation.
*/
int smb_kdoor_cookie = -1;
extern smb_kdr_op_t smb_kdoorsrv_optab[];
/* forward declaration */
/*
* smb_kdoor_srv_start
*
* When driver is opened, this function should be called to create the
* kernel door. The door descriptor will then be passed up to the
* user-space SMB daemon.
*
* Returns 0 upon success otherwise non-zero
*/
int
{
int err;
int res;
int opcode = SMB_DR_SET_DWNCALL_DESC;
&smb_kdoor_cookie, 0, &smb_kdoor_hdl)) != 0) {
" failed(%d)", err);
return (err);
}
if (res != SMB_DR_OP_SUCCESS) {
" downcall descriptor res=%d", res);
return (EIO);
}
return (0);
}
/*
* smb_kdoor_srv_stop
*
* This function will stop the kernel door service when the driver is closed.
*/
void
{
if (smb_kdoor_hdl) {
}
}
/*
* smb_kdoor_srv_callback
*
* This callback function will be executed by the kernel after copyout()
* completes. Currently, this function only free the server buffer that
* was previously allocated in the smb_kdoor_srv(). It can be enhanced
* to perform any action based on the opcode if there is a need in the
* future.
*/
static void
{
/*LINTED E_FUNC_VAR_UNUSED*/
int *opcode;
if (cookie)
if (!arg)
return;
}
void
{
int opcode;
/*
* Be aware that *destfnp cannot be NULL even if there isn't
* any additional work after the kernel completes copyout() operation.
*/
*error = 0;
if (!dap) {
return;
}
/* The data_ptr points to user data */
/* initialize the returned data size to be 0 */
if (smb_kdr_is_valid_opcode(opcode) != 0) {
return;
}
switch (*error) {
case SMB_DR_OP_ERR_ENCODE:
break;
case SMB_DR_OP_ERR_DECODE:
break;
case SMB_DR_OP_ERR_EMPTYBUF:
== NULL) {
}
*error = 0;
break;
default:
}
}
}