rdcsrv.c revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifdef _SunOS_2_6
/*
* on 2.6 both dki_lock.h and rpc/types.h define bool_t so we
* anyway and make it look like we included it. Yuck.
*/
#define _RPC_TYPES_H
typedef int enum_t;
#else
#ifndef DS_DDICT
#endif
#endif /* _SunOS_2_6 */
#ifndef DS_DDICT
#else
#include "../contract.h"
#endif
#include <sys/nsc_thread.h>
#include "rdc_io.h"
#include "rdc_stub.h"
#include "rdc_ioctl.h"
#include "rdcsrv.h"
#if defined(_SunOS_5_6) || defined(_SunOS_5_7)
#else /* SunOS 5.8 or later */
/*
* SunOS 5.8 or later.
*
* RDC callout table
*
* This table is used by svc_getreq to dispatch a request with a given
*/
static SVC_CALLOUT rdcsrv_sc[] = {
};
static SVC_CALLOUT_TABLE rdcsrv_sct = {
};
#endif /* SunOS 5.8 or later */
static kmutex_t rdcsrv_lock;
static int rdcsrv_dup_error;
static int rdcsrv_registered;
static int rdcsrv_closing;
static int rdcsrv_refcnt;
long rdc_svc_count = 0;
static rdcsrv_t *rdcsrv_disptab;
/*
* Solaris module setup.
*/
extern struct mod_ops mod_miscops;
&mod_miscops, /* Type of module */
"nws:Remote Mirror kRPC:" ISS_VERSION_STR
};
static struct modlinkage modlinkage = {
&modlmisc,
};
int
_init(void)
{
int rc;
return (rc);
}
int
_fini(void)
{
int rc;
return (rc);
}
int
{
}
/*
* RDC kRPC server stub.
*/
void
rdcsrv_noproc(void)
{
;
}
static int
{
void (*fn)();
int dupstat;
switch (dupstat) {
case DUP_ERROR:
/* svcerr_systemerr does a freeargs */
break;
case DUP_INPROGRESS:
break;
case DUP_NEW:
case DUP_DROP:
break;
case DUP_DONE:
break;
}
return (dupstat);
}
/*
* rdcsrv_dispatch is the dispatcher routine for the RDC RPC protocol
*/
void
{
goto outdisp;
}
"rdcsrv_dispatch: unknown version %d",
/* svcerr_noproc does a freeargs on xprt */
goto done;
}
"rdcsrv_dispatch: bad proc number %d",
/* svcerr_noproc does a freeargs on xprt */
goto done;
case DUP_ERROR:
goto done;
/* NOTREACHED */
case DUP_INPROGRESS:
goto outdisp;
/* NOTREACHED */
default:
break;
}
} else {
}
done:
}
static int
{
/*LINTED*/
/*LINTED*/
#if defined(_SunOS_5_6) || defined(_SunOS_5_7)
#else
#endif
if (error) {
#ifdef DEBUG
#endif
return (error);
}
/*
* Set rdcstub's dispatch handle to rdcsrv_dispatch
*/
/*
* Create a transport endpoint and create one kernel thread to run the
* rdc service loop
*/
#if defined(_SunOS_5_6) || defined(_SunOS_5_7)
#else
{
#if defined(_SunOS_5_8)
struct svcpool_args p;
p.id = RDC_SVCPOOL_ID;
p.redline = 0;
p.qsize = 0;
p.timeout = 0;
p.stksize = 0;
p.max_same_xprt = 0;
error = svc_pool_create(&p);
if (error) {
"rdcsrv_create: svc_pool_create failed %d",
error);
return (error);
}
#endif
FALSE);
}
#endif
if (error) {
"rdcsrv_create: svc_tli_kcreate failed %d",
error);
return (error);
}
#if defined(_SunOS_5_6) || defined(_SunOS_5_7)
} else {
/*
* Register a cleanup routine in case the transport gets
* destroyed. If the registration fails for some reason,
* it means that the transport is already being destroyed.
* This shouldn't happen, but it's probably not worth a
* panic.
*/
(void *)rdcsrv_xprtclose)) {
#ifdef DEBUG
#else
#endif
"rdcsrv_create: couldn't set xprt callback");
goto done;
}
}
rdcstub_dispatch, 0);
if (!rc) {
"rdcsrv_create: svc_register(%d, %lu) failed",
RDC_PROGRAM, vers);
if (!error) {
}
}
}
#endif /* 5.6 or 5.7 */
if (!error) {
/* mark as registered with the kRPC subsystem */
rdcsrv_registered = 1;
}
done:
return (error);
}
#if defined(_SunOS_5_6) || defined(_SunOS_5_7)
/*
* Callback routine for when a transport is closed.
*/
static void
{
}
#endif
/*
* Private interface from the main RDC module.
*/
int
{
int rc = 0;
if (rc == 0) {
}
return (rc);
}
void
rdcsrv_unload(void)
{
/* Unset rdcstub's dispatch handle */
rdcsrv_closing = 1;
while (rdcsrv_refcnt > 0) {
}
rdcsrv_closing = 0;
rdcsrv_disptab = 0;
}