xref: /illumos-gate/usr/src/uts/common/fs/smbsrv/smb_opipe.c (revision 8622ec4569457733001d4982ef7f5b44427069be)
13db3f65cSamw /*
23db3f65cSamw  * CDDL HEADER START
33db3f65cSamw  *
43db3f65cSamw  * The contents of this file are subject to the terms of the
53db3f65cSamw  * Common Development and Distribution License (the "License").
63db3f65cSamw  * You may not use this file except in compliance with the License.
73db3f65cSamw  *
83db3f65cSamw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93db3f65cSamw  * or http://www.opensolaris.org/os/licensing.
103db3f65cSamw  * See the License for the specific language governing permissions
113db3f65cSamw  * and limitations under the License.
123db3f65cSamw  *
133db3f65cSamw  * When distributing Covered Code, include this CDDL HEADER in each
143db3f65cSamw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153db3f65cSamw  * If applicable, add the following below this CDDL HEADER, with the
163db3f65cSamw  * fields enclosed by brackets "[]" replaced with your own identifying
173db3f65cSamw  * information: Portions Copyright [yyyy] [name of copyright owner]
183db3f65cSamw  *
193db3f65cSamw  * CDDL HEADER END
203db3f65cSamw  */
213db3f65cSamw /*
22b7301bf5SGordon Ross  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
23148c5f43SAlan Wright  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
243db3f65cSamw  */
253db3f65cSamw 
263db3f65cSamw /*
273db3f65cSamw  * This module provides the interface to NDR RPC.
283db3f65cSamw  */
293db3f65cSamw 
303db3f65cSamw #include <sys/stat.h>
313db3f65cSamw #include <sys/door.h>
323db3f65cSamw #include <sys/door_data.h>
333db3f65cSamw #include <sys/uio.h>
343db3f65cSamw #include <sys/ksynch.h>
35bbf6f00cSJordan Brown #include <smbsrv/smb_kproto.h>
363db3f65cSamw #include <smbsrv/smb_xdr.h>
373db3f65cSamw 
383db3f65cSamw #define	SMB_OPIPE_ISOPEN(OPIPE)	\
399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	(((OPIPE)->p_hdr.dh_magic == SMB_OPIPE_HDR_MAGIC) && \
409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	((OPIPE)->p_hdr.dh_fid))
413db3f65cSamw 
423db3f65cSamw extern volatile uint32_t smb_fids;
433db3f65cSamw 
443db3f65cSamw static int smb_opipe_do_open(smb_request_t *, smb_opipe_t *);
459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static char *smb_opipe_lookup(const char *);
469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static int smb_opipe_sethdr(smb_opipe_t *, uint32_t, uint32_t);
479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static int smb_opipe_exec(smb_opipe_t *);
483db3f65cSamw static void smb_opipe_enter(smb_opipe_t *);
493db3f65cSamw static void smb_opipe_exit(smb_opipe_t *);
503db3f65cSamw 
513db3f65cSamw static int smb_opipe_door_call(smb_opipe_t *);
523db3f65cSamw static int smb_opipe_door_upcall(smb_opipe_t *);
533db3f65cSamw 
549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_opipe_t *
559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_opipe_alloc(smb_server_t *sv)
569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States {
579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_opipe_t	*opipe;
589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
59*8622ec45SGordon Ross 	opipe = kmem_cache_alloc(smb_cache_opipe, KM_SLEEP);
609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	bzero(opipe, sizeof (smb_opipe_t));
629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	mutex_init(&opipe->p_mutex, NULL, MUTEX_DEFAULT, NULL);
639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	cv_init(&opipe->p_cv, NULL, CV_DEFAULT, NULL);
649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_magic = SMB_OPIPE_MAGIC;
659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_server = sv;
669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_llist_enter(&sv->sv_opipe_list, RW_WRITER);
689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_llist_insert_tail(&sv->sv_opipe_list, opipe);
699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_llist_exit(&sv->sv_opipe_list);
709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	return (opipe);
729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States }
739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void
759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_opipe_dealloc(smb_opipe_t *opipe)
769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States {
779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_server_t *sv;
789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	SMB_OPIPE_VALID(opipe);
809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	sv = opipe->p_server;
819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	SMB_SERVER_VALID(sv);
829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_llist_enter(&sv->sv_opipe_list, RW_WRITER);
849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_llist_remove(&sv->sv_opipe_list, opipe);
859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_llist_exit(&sv->sv_opipe_list);
869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_magic = (uint32_t)~SMB_OPIPE_MAGIC;
889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_event_destroy(opipe->p_event);
899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	cv_destroy(&opipe->p_cv);
909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	mutex_destroy(&opipe->p_mutex);
919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
92*8622ec45SGordon Ross 	kmem_cache_free(smb_cache_opipe, opipe);
939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States }
949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
953db3f65cSamw /*
963db3f65cSamw  * smb_opipe_open
973db3f65cSamw  *
983db3f65cSamw  * Open a well-known RPC named pipe. This routine should be called if
993db3f65cSamw  * a file open is requested on a share of type STYPE_IPC.
1003db3f65cSamw  * If we recognize the pipe, we setup a new ofile.
1013db3f65cSamw  *
1023db3f65cSamw  * Returns 0 on success, Otherwise an NT status is returned to indicate
1033db3f65cSamw  * an error.
1043db3f65cSamw  */
1053db3f65cSamw int
1063db3f65cSamw smb_opipe_open(smb_request_t *sr)
1073db3f65cSamw {
108148c5f43SAlan Wright 	smb_arg_open_t	*op = &sr->sr_open;
1093db3f65cSamw 	smb_ofile_t *of;
1103db3f65cSamw 	smb_opipe_t *opipe;
1119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_doorhdr_t hdr;
1123db3f65cSamw 	smb_error_t err;
1133db3f65cSamw 	char *pipe_name;
1143db3f65cSamw 
115eb1d736bSafshin salek ardakani - Sun Microsystems - Irvine United States 	if ((pipe_name = smb_opipe_lookup(op->fqi.fq_path.pn_path)) == NULL)
1163db3f65cSamw 		return (NT_STATUS_OBJECT_NAME_NOT_FOUND);
1173db3f65cSamw 
118b7301bf5SGordon Ross 	/*
119b7301bf5SGordon Ross 	 * If printing is disabled, pretend spoolss does not exist.
120b7301bf5SGordon Ross 	 */
121b7301bf5SGordon Ross 	if (sr->sr_server->sv_cfg.skc_print_enable == 0 &&
122b7301bf5SGordon Ross 	    strcmp(pipe_name, "SPOOLSS") == 0)
123b7301bf5SGordon Ross 		return (NT_STATUS_OBJECT_NAME_NOT_FOUND);
124b7301bf5SGordon Ross 
125c8ec8eeaSjose borrego 	op->create_options = 0;
126c8ec8eeaSjose borrego 
1273b13a1efSThomas Keiser 	of = smb_ofile_open(sr, NULL, sr->smb_pid, op, SMB_FTYPE_MESG_PIPE,
1283b13a1efSThomas Keiser 	    SMB_UNIQ_FID(), &err);
1298b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States 
1303db3f65cSamw 	if (of == NULL)
1313db3f65cSamw 		return (err.status);
1323db3f65cSamw 
1338b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States 	if (!smb_tree_is_connected(sr->tid_tree)) {
1348b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States 		smb_ofile_close(of, 0);
1358b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States 		smb_ofile_release(of);
1368b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States 		return (NT_STATUS_OBJECT_NAME_NOT_FOUND);
1378b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States 	}
1388b2cc8acSafshin salek ardakani - Sun Microsystems - Irvine United States 
1393db3f65cSamw 	op->dsize = 0x01000;
1403db3f65cSamw 	op->dattr = FILE_ATTRIBUTE_NORMAL;
1413db3f65cSamw 	op->ftype = SMB_FTYPE_MESG_PIPE;
1423db3f65cSamw 	op->action_taken = SMB_OACT_LOCK | SMB_OACT_OPENED; /* 0x8001 */
1433db3f65cSamw 	op->devstate = SMB_PIPE_READMODE_MESSAGE
1443db3f65cSamw 	    | SMB_PIPE_TYPE_MESSAGE
1453db3f65cSamw 	    | SMB_PIPE_UNLIMITED_INSTANCES; /* 0x05ff */
1463db3f65cSamw 	op->fileid = of->f_fid;
1473db3f65cSamw 
1483db3f65cSamw 	sr->smb_fid = of->f_fid;
1493db3f65cSamw 	sr->fid_ofile = of;
1503db3f65cSamw 
1513db3f65cSamw 	opipe = of->f_pipe;
1523db3f65cSamw 	smb_opipe_enter(opipe);
1533db3f65cSamw 
1549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_server = of->f_server;
1553db3f65cSamw 	opipe->p_name = pipe_name;
1563db3f65cSamw 	opipe->p_doorbuf = kmem_zalloc(SMB_OPIPE_DOOR_BUFSIZE, KM_SLEEP);
1573db3f65cSamw 
1583db3f65cSamw 	/*
1593db3f65cSamw 	 * p_data points to the offset within p_doorbuf at which
1603db3f65cSamw 	 * data will be written or read.
1613db3f65cSamw 	 */
1629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_data = opipe->p_doorbuf + xdr_sizeof(smb_doorhdr_xdr, &hdr);
1633db3f65cSamw 
1643db3f65cSamw 	if (smb_opipe_do_open(sr, opipe) != 0) {
1653db3f65cSamw 		/*
1663db3f65cSamw 		 * On error, reset the header to clear the fid,
1673db3f65cSamw 		 * which avoids confusion when smb_opipe_close() is
1683db3f65cSamw 		 * called by smb_ofile_close().
1693db3f65cSamw 		 */
1709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		bzero(&opipe->p_hdr, sizeof (smb_doorhdr_t));
1713db3f65cSamw 		kmem_free(opipe->p_doorbuf, SMB_OPIPE_DOOR_BUFSIZE);
1723db3f65cSamw 		smb_opipe_exit(opipe);
173c8ec8eeaSjose borrego 		smb_ofile_close(of, 0);
1743db3f65cSamw 		return (NT_STATUS_NO_MEMORY);
1753db3f65cSamw 	}
1763db3f65cSamw 	smb_opipe_exit(opipe);
1773db3f65cSamw 	return (NT_STATUS_SUCCESS);
1783db3f65cSamw }
1793db3f65cSamw 
1803db3f65cSamw /*
1813db3f65cSamw  * smb_opipe_lookup
1823db3f65cSamw  *
1833db3f65cSamw  * Lookup a path to see if it's a well-known RPC named pipe that we support.
1843db3f65cSamw  * The full pipe path will be in the form \\PIPE\\SERVICE.  The first part
1853db3f65cSamw  * can be assumed, so all we need here are the service names.
1863db3f65cSamw  *
1871fcced4cSJordan Brown  * Returns a pointer to the pipe name (without any leading \'s) on success.
1883db3f65cSamw  * Otherwise returns a null pointer.
1893db3f65cSamw  */
1903db3f65cSamw static char *
1913db3f65cSamw smb_opipe_lookup(const char *path)
1923db3f65cSamw {
1933db3f65cSamw 	static char *named_pipes[] = {
1941fcced4cSJordan Brown 		"lsass",
1953db3f65cSamw 		"LSARPC",
1963db3f65cSamw 		"NETLOGON",
1973db3f65cSamw 		"SAMR",
1983db3f65cSamw 		"SPOOLSS",
1993db3f65cSamw 		"SRVSVC",
2003db3f65cSamw 		"SVCCTL",
2013db3f65cSamw 		"WINREG",
2023db3f65cSamw 		"WKSSVC",
2039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		"EVENTLOG",
2049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		"NETDFS"
2053db3f65cSamw 	};
2063db3f65cSamw 
2073db3f65cSamw 	const char *name;
2083db3f65cSamw 	int i;
2093db3f65cSamw 
2103db3f65cSamw 	if (path == NULL)
2113db3f65cSamw 		return (NULL);
2123db3f65cSamw 
2133db3f65cSamw 	name = path;
2143db3f65cSamw 	name += strspn(name, "\\");
215bbf6f00cSJordan Brown 	if (smb_strcasecmp(name, "PIPE", 4) == 0) {
2163db3f65cSamw 		path += 4;
2173db3f65cSamw 		name += strspn(name, "\\");
2183db3f65cSamw 	}
2193db3f65cSamw 
2203db3f65cSamw 	for (i = 0; i < sizeof (named_pipes) / sizeof (named_pipes[0]); ++i) {
221bbf6f00cSJordan Brown 		if (smb_strcasecmp(name, named_pipes[i], 0) == 0)
2223db3f65cSamw 			return (named_pipes[i]);
2233db3f65cSamw 	}
2243db3f65cSamw 
2253db3f65cSamw 	return (NULL);
2263db3f65cSamw }
2273db3f65cSamw 
2283db3f65cSamw /*
2293db3f65cSamw  * Initialize the opipe header and context, and make the door call.
2303db3f65cSamw  */
2313db3f65cSamw static int
2323db3f65cSamw smb_opipe_do_open(smb_request_t *sr, smb_opipe_t *opipe)
2333db3f65cSamw {
2341fcced4cSJordan Brown 	smb_netuserinfo_t *userinfo = &opipe->p_user;
2353db3f65cSamw 	smb_user_t *user = sr->uid_user;
236*8622ec45SGordon Ross 	smb_server_t *sv = sr->sr_server;
2373db3f65cSamw 	uint8_t *buf = opipe->p_doorbuf;
2383db3f65cSamw 	uint32_t buflen = SMB_OPIPE_DOOR_BUFSIZE;
2393db3f65cSamw 	uint32_t len;
2403db3f65cSamw 
241*8622ec45SGordon Ross 	if ((opipe->p_event = smb_event_create(sv, SMB_EVENT_TIMEOUT)) == NULL)
2429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		return (-1);
2439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
2441fcced4cSJordan Brown 	smb_user_netinfo_init(user, userinfo);
2451fcced4cSJordan Brown 	len = xdr_sizeof(smb_netuserinfo_xdr, userinfo);
2463db3f65cSamw 
2479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	bzero(&opipe->p_hdr, sizeof (smb_doorhdr_t));
2489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_hdr.dh_magic = SMB_OPIPE_HDR_MAGIC;
2499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_hdr.dh_flags = SMB_DF_SYSSPACE;
2509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_hdr.dh_fid = smb_event_txid(opipe->p_event);
2513db3f65cSamw 
2529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	if (smb_opipe_sethdr(opipe, SMB_OPIPE_OPEN, len) == -1)
2533db3f65cSamw 		return (-1);
2543db3f65cSamw 
2559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	len = xdr_sizeof(smb_doorhdr_xdr, &opipe->p_hdr);
2563db3f65cSamw 	buf += len;
2573db3f65cSamw 	buflen -= len;
2583db3f65cSamw 
2591fcced4cSJordan Brown 	if (smb_netuserinfo_encode(userinfo, buf, buflen, NULL) == -1)
2603db3f65cSamw 		return (-1);
2613db3f65cSamw 
2623db3f65cSamw 	return (smb_opipe_door_call(opipe));
2633db3f65cSamw }
2643db3f65cSamw 
2653db3f65cSamw /*
2663db3f65cSamw  * smb_opipe_close
2673db3f65cSamw  *
2683db3f65cSamw  * Called whenever an IPC file/pipe is closed.
2693db3f65cSamw  */
2703db3f65cSamw void
2713db3f65cSamw smb_opipe_close(smb_ofile_t *of)
2723db3f65cSamw {
2733db3f65cSamw 	smb_opipe_t *opipe;
2743db3f65cSamw 
2753db3f65cSamw 	ASSERT(of);
2763db3f65cSamw 	ASSERT(of->f_ftype == SMB_FTYPE_MESG_PIPE);
2773db3f65cSamw 
2783db3f65cSamw 	opipe = of->f_pipe;
2799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	SMB_OPIPE_VALID(opipe);
2809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
281*8622ec45SGordon Ross 	(void) smb_server_cancel_event(of->f_server, opipe->p_hdr.dh_fid);
2823db3f65cSamw 	smb_opipe_enter(opipe);
2833db3f65cSamw 
2843db3f65cSamw 	if (SMB_OPIPE_ISOPEN(opipe)) {
2859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		(void) smb_opipe_sethdr(opipe, SMB_OPIPE_CLOSE, 0);
2863db3f65cSamw 		(void) smb_opipe_door_call(opipe);
2879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		bzero(&opipe->p_hdr, sizeof (smb_doorhdr_t));
2883db3f65cSamw 		kmem_free(opipe->p_doorbuf, SMB_OPIPE_DOOR_BUFSIZE);
2893db3f65cSamw 	}
2903db3f65cSamw 
2911fcced4cSJordan Brown 	smb_user_netinfo_fini(&opipe->p_user);
2923db3f65cSamw 	smb_opipe_exit(opipe);
2933db3f65cSamw }
2943db3f65cSamw 
2953db3f65cSamw static int
2969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_opipe_sethdr(smb_opipe_t *opipe, uint32_t cmd, uint32_t datalen)
2973db3f65cSamw {
2989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_hdr.dh_op = cmd;
2999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_hdr.dh_txid = opipe->p_hdr.dh_fid;
3009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_hdr.dh_datalen = datalen;
3019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_hdr.dh_resid = 0;
3029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_hdr.dh_door_rc = EINVAL;
3033db3f65cSamw 
3049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	return (smb_doorhdr_encode(&opipe->p_hdr, opipe->p_doorbuf,
3053db3f65cSamw 	    SMB_OPIPE_DOOR_BUFSIZE));
3063db3f65cSamw }
3073db3f65cSamw 
3083db3f65cSamw /*
3093db3f65cSamw  * smb_opipe_transact
3103db3f65cSamw  *
3113db3f65cSamw  * This is the entry point for RPC bind and request transactions.
3123db3f65cSamw  * The fid is an arbitrary id used to associate RPC requests with a
3133db3f65cSamw  * particular binding handle.
3143db3f65cSamw  *
3153db3f65cSamw  * If the data to be returned is larger than the client expects, we
3163db3f65cSamw  * return as much as the client can handle and report a buffer overflow
3173db3f65cSamw  * warning, which informs the client that we have more data to return.
3183db3f65cSamw  * The residual data remains in the pipe until the client claims it or
3193db3f65cSamw  * closes the pipe.
3203db3f65cSamw  */
3213db3f65cSamw smb_sdrc_t
3223db3f65cSamw smb_opipe_transact(smb_request_t *sr, struct uio *uio)
3233db3f65cSamw {
3243db3f65cSamw 	smb_xa_t *xa;
3253db3f65cSamw 	smb_opipe_t *opipe;
3263db3f65cSamw 	struct mbuf *mhead;
3273db3f65cSamw 	int mdrcnt;
3283db3f65cSamw 	int nbytes;
3293db3f65cSamw 	int rc;
3303db3f65cSamw 
3313db3f65cSamw 	if ((rc = smb_opipe_write(sr, uio)) != 0) {
3323db3f65cSamw 		if (rc == EBADF)
3333db3f65cSamw 			smbsr_error(sr, NT_STATUS_INVALID_HANDLE,
3343db3f65cSamw 			    ERRDOS, ERROR_INVALID_HANDLE);
3353db3f65cSamw 		else
3363db3f65cSamw 			smbsr_error(sr, NT_STATUS_INTERNAL_ERROR,
3373db3f65cSamw 			    ERRDOS, ERROR_INTERNAL_ERROR);
3383db3f65cSamw 		return (SDRC_ERROR);
3393db3f65cSamw 	}
3403db3f65cSamw 
3419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe = sr->fid_ofile->f_pipe;
3429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
3439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	if ((rc = smb_opipe_exec(opipe)) != 0) {
3449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		smbsr_error(sr, NT_STATUS_INTERNAL_ERROR,
3459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		    ERRDOS, ERROR_INTERNAL_ERROR);
3469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		return (SDRC_ERROR);
3479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	}
3489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
3493db3f65cSamw 	xa = sr->r_xa;
3503db3f65cSamw 	mdrcnt = xa->smb_mdrcnt;
3513db3f65cSamw 	smb_opipe_enter(opipe);
3523db3f65cSamw 
3539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	if (smb_opipe_sethdr(opipe, SMB_OPIPE_READ, mdrcnt) == -1) {
3543db3f65cSamw 		smb_opipe_exit(opipe);
3553db3f65cSamw 		smbsr_error(sr, NT_STATUS_INTERNAL_ERROR,
3563db3f65cSamw 		    ERRDOS, ERROR_INTERNAL_ERROR);
3573db3f65cSamw 		return (SDRC_ERROR);
3583db3f65cSamw 	}
3593db3f65cSamw 
3603db3f65cSamw 	rc = smb_opipe_door_call(opipe);
3619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	nbytes = opipe->p_hdr.dh_datalen;
3623db3f65cSamw 
3633db3f65cSamw 	if (rc != 0) {
3643db3f65cSamw 		smb_opipe_exit(opipe);
3653db3f65cSamw 		smbsr_error(sr, NT_STATUS_INTERNAL_ERROR,
3663db3f65cSamw 		    ERRDOS, ERROR_INTERNAL_ERROR);
3673db3f65cSamw 		return (SDRC_ERROR);
3683db3f65cSamw 	}
3693db3f65cSamw 
3703db3f65cSamw 	if (nbytes) {
3713db3f65cSamw 		mhead = smb_mbuf_get(opipe->p_data, nbytes);
3723db3f65cSamw 		xa->rep_data_mb.max_bytes = nbytes;
3733db3f65cSamw 		MBC_ATTACH_MBUF(&xa->rep_data_mb, mhead);
3743db3f65cSamw 	}
3753db3f65cSamw 
3769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	if (opipe->p_hdr.dh_resid) {
3773db3f65cSamw 		/*
3783db3f65cSamw 		 * The pipe contains more data than mdrcnt, warn the
3793db3f65cSamw 		 * client that there is more data in the pipe.
3803db3f65cSamw 		 * Typically, the client will call SmbReadX, which
3813db3f65cSamw 		 * will call smb_opipe_read, to get the data.
3823db3f65cSamw 		 */
3833db3f65cSamw 		smbsr_warn(sr, NT_STATUS_BUFFER_OVERFLOW,
3843db3f65cSamw 		    ERRDOS, ERROR_MORE_DATA);
3853db3f65cSamw 	}
3863db3f65cSamw 
3873db3f65cSamw 	smb_opipe_exit(opipe);
3883db3f65cSamw 	return (SDRC_SUCCESS);
3893db3f65cSamw }
3903db3f65cSamw 
3913db3f65cSamw /*
3923db3f65cSamw  * smb_opipe_write
3933db3f65cSamw  *
3943db3f65cSamw  * Write RPC request data to the pipe.  The client should call smb_opipe_read
3953db3f65cSamw  * to complete the exchange and obtain the RPC response.
3963db3f65cSamw  *
3973db3f65cSamw  * Returns 0 on success or an errno on failure.
3983db3f65cSamw  */
3993db3f65cSamw int
4003db3f65cSamw smb_opipe_write(smb_request_t *sr, struct uio *uio)
4013db3f65cSamw {
4023db3f65cSamw 	smb_opipe_t *opipe;
4033db3f65cSamw 	uint32_t buflen;
4043db3f65cSamw 	uint32_t len;
4053db3f65cSamw 	int rc;
4063db3f65cSamw 
4073db3f65cSamw 	ASSERT(sr->fid_ofile);
4083db3f65cSamw 	ASSERT(sr->fid_ofile->f_ftype == SMB_FTYPE_MESG_PIPE);
4093db3f65cSamw 
4103db3f65cSamw 	opipe = sr->fid_ofile->f_pipe;
4119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	SMB_OPIPE_VALID(opipe);
4123db3f65cSamw 	smb_opipe_enter(opipe);
4133db3f65cSamw 
4143db3f65cSamw 	if (!SMB_OPIPE_ISOPEN(opipe)) {
4153db3f65cSamw 		smb_opipe_exit(opipe);
4163db3f65cSamw 		return (EBADF);
4173db3f65cSamw 	}
4183db3f65cSamw 
4199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	rc = smb_opipe_sethdr(opipe, SMB_OPIPE_WRITE, uio->uio_resid);
4209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	len = xdr_sizeof(smb_doorhdr_xdr, &opipe->p_hdr);
4213db3f65cSamw 	if (rc == -1 || len == 0) {
4223db3f65cSamw 		smb_opipe_exit(opipe);
4233db3f65cSamw 		return (ENOMEM);
4243db3f65cSamw 	}
4253db3f65cSamw 
4263db3f65cSamw 	buflen = SMB_OPIPE_DOOR_BUFSIZE - len;
4273db3f65cSamw 	(void) uiomove((caddr_t)opipe->p_data, buflen, UIO_WRITE, uio);
4283db3f65cSamw 
4293db3f65cSamw 	rc = smb_opipe_door_call(opipe);
4303db3f65cSamw 
4313db3f65cSamw 	smb_opipe_exit(opipe);
4323db3f65cSamw 	return ((rc == 0) ? 0 : EIO);
4333db3f65cSamw }
4343db3f65cSamw 
4353db3f65cSamw /*
4363db3f65cSamw  * smb_opipe_read
4373db3f65cSamw  *
4383db3f65cSamw  * This interface may be called because smb_opipe_transact could not return
4393db3f65cSamw  * all of the data in the original transaction or to form the second half
4403db3f65cSamw  * of a transaction set up using smb_opipe_write.  Either way, we just need
4413db3f65cSamw  * to read data from the pipe and return it.
4423db3f65cSamw  *
4433db3f65cSamw  * The response data is encoded into raw_data as required by the smb_read
4443db3f65cSamw  * functions.  The uio_resid value indicates the number of bytes read.
4453db3f65cSamw  */
4463db3f65cSamw int
4473db3f65cSamw smb_opipe_read(smb_request_t *sr, struct uio *uio)
4483db3f65cSamw {
4493db3f65cSamw 	smb_opipe_t *opipe;
4503db3f65cSamw 	struct mbuf *mhead;
4513db3f65cSamw 	uint32_t nbytes;
4523db3f65cSamw 	int rc;
4533db3f65cSamw 
4543db3f65cSamw 	ASSERT(sr->fid_ofile);
4553db3f65cSamw 	ASSERT(sr->fid_ofile->f_ftype == SMB_FTYPE_MESG_PIPE);
4563db3f65cSamw 
4573db3f65cSamw 	opipe = sr->fid_ofile->f_pipe;
4589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	SMB_OPIPE_VALID(opipe);
4599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
4609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	if ((rc = smb_opipe_exec(opipe)) != 0)
4619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		return (EIO);
4629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
4633db3f65cSamw 	smb_opipe_enter(opipe);
4643db3f65cSamw 
4653db3f65cSamw 	if (!SMB_OPIPE_ISOPEN(opipe)) {
4663db3f65cSamw 		smb_opipe_exit(opipe);
4673db3f65cSamw 		return (EBADF);
4683db3f65cSamw 	}
4693db3f65cSamw 
4709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	if (smb_opipe_sethdr(opipe, SMB_OPIPE_READ, uio->uio_resid) == -1) {
4713db3f65cSamw 		smb_opipe_exit(opipe);
4723db3f65cSamw 		return (ENOMEM);
4733db3f65cSamw 	}
4743db3f65cSamw 
4753db3f65cSamw 	rc = smb_opipe_door_call(opipe);
4769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	nbytes = opipe->p_hdr.dh_datalen;
4773db3f65cSamw 
4783db3f65cSamw 	if (rc != 0 || nbytes > uio->uio_resid) {
4793db3f65cSamw 		smb_opipe_exit(opipe);
4803db3f65cSamw 		return (EIO);
4813db3f65cSamw 	}
4823db3f65cSamw 
4833db3f65cSamw 	if (nbytes) {
4843db3f65cSamw 		mhead = smb_mbuf_get(opipe->p_data, nbytes);
4853db3f65cSamw 		MBC_SETUP(&sr->raw_data, nbytes);
4863db3f65cSamw 		MBC_ATTACH_MBUF(&sr->raw_data, mhead);
4873db3f65cSamw 		uio->uio_resid -= nbytes;
4883db3f65cSamw 	}
4893db3f65cSamw 
4903db3f65cSamw 	smb_opipe_exit(opipe);
4913db3f65cSamw 	return (rc);
4923db3f65cSamw }
4933db3f65cSamw 
4949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static int
4959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_opipe_exec(smb_opipe_t *opipe)
4969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States {
4979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	uint32_t	len;
4989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	int		rc;
4999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
5009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_opipe_enter(opipe);
5019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
5029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	rc = smb_opipe_sethdr(opipe, SMB_OPIPE_EXEC, 0);
5039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	len = xdr_sizeof(smb_doorhdr_xdr, &opipe->p_hdr);
5049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	if (rc == -1 || len == 0) {
5059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		smb_opipe_exit(opipe);
5069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		return (ENOMEM);
5079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	}
5089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
5099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	if ((rc = smb_opipe_door_call(opipe)) == 0)
5109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		rc = smb_event_wait(opipe->p_event);
5119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
5129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_opipe_exit(opipe);
5139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	return (rc);
5149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States }
5159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
5163db3f65cSamw /*
5173db3f65cSamw  * Named pipe I/O is serialized per fid to ensure that each request
5183db3f65cSamw  * has exclusive opipe access for the duration of the request.
5193db3f65cSamw  */
5203db3f65cSamw static void
5213db3f65cSamw smb_opipe_enter(smb_opipe_t *opipe)
5223db3f65cSamw {
5233db3f65cSamw 	mutex_enter(&opipe->p_mutex);
5243db3f65cSamw 
5253db3f65cSamw 	while (opipe->p_busy)
5263db3f65cSamw 		cv_wait(&opipe->p_cv, &opipe->p_mutex);
5273db3f65cSamw 
5283db3f65cSamw 	opipe->p_busy = 1;
5293db3f65cSamw 	mutex_exit(&opipe->p_mutex);
5303db3f65cSamw }
5313db3f65cSamw 
5329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /*
5339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States  * Exit busy state.  If we have exec'd an RPC, we may have
5349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States  * to wait for notification that processing has completed.
5359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States  */
5363db3f65cSamw static void
5373db3f65cSamw smb_opipe_exit(smb_opipe_t *opipe)
5383db3f65cSamw {
5393db3f65cSamw 	mutex_enter(&opipe->p_mutex);
5403db3f65cSamw 	opipe->p_busy = 0;
5413db3f65cSamw 	cv_signal(&opipe->p_cv);
5423db3f65cSamw 	mutex_exit(&opipe->p_mutex);
5433db3f65cSamw }
5443db3f65cSamw 
5453db3f65cSamw /*
5463db3f65cSamw  * opipe door client (to user space door server).
5473db3f65cSamw  */
5483db3f65cSamw void
549*8622ec45SGordon Ross smb_opipe_door_init(smb_server_t *sv)
5503db3f65cSamw {
551*8622ec45SGordon Ross 	sv->sv_opipe_door_id = -1;
552*8622ec45SGordon Ross 	mutex_init(&sv->sv_opipe_door_mutex, NULL, MUTEX_DEFAULT, NULL);
553*8622ec45SGordon Ross 	cv_init(&sv->sv_opipe_door_cv, NULL, CV_DEFAULT, NULL);
5543db3f65cSamw }
5553db3f65cSamw 
5563db3f65cSamw void
557*8622ec45SGordon Ross smb_opipe_door_fini(smb_server_t *sv)
5583db3f65cSamw {
559*8622ec45SGordon Ross 	smb_opipe_door_close(sv);
560*8622ec45SGordon Ross 	cv_destroy(&sv->sv_opipe_door_cv);
561*8622ec45SGordon Ross 	mutex_destroy(&sv->sv_opipe_door_mutex);
5623db3f65cSamw }
5633db3f65cSamw 
5643db3f65cSamw /*
5653db3f65cSamw  * Open the (user space) door.  If the door is already open,
5663db3f65cSamw  * close it first because the door-id has probably changed.
5673db3f65cSamw  */
5683db3f65cSamw int
569*8622ec45SGordon Ross smb_opipe_door_open(smb_server_t *sv, int door_id)
5703db3f65cSamw {
571*8622ec45SGordon Ross 	smb_opipe_door_close(sv);
5723db3f65cSamw 
573*8622ec45SGordon Ross 	mutex_enter(&sv->sv_opipe_door_mutex);
574*8622ec45SGordon Ross 	sv->sv_opipe_door_ncall = 0;
5753db3f65cSamw 
576*8622ec45SGordon Ross 	if (sv->sv_opipe_door_hd == NULL) {
577*8622ec45SGordon Ross 		sv->sv_opipe_door_id = door_id;
578*8622ec45SGordon Ross 		sv->sv_opipe_door_hd = door_ki_lookup(door_id);
5793db3f65cSamw 	}
5803db3f65cSamw 
581*8622ec45SGordon Ross 	mutex_exit(&sv->sv_opipe_door_mutex);
582*8622ec45SGordon Ross 	return ((sv->sv_opipe_door_hd == NULL)  ? -1 : 0);
5833db3f65cSamw }
5843db3f65cSamw 
5853db3f65cSamw /*
5863db3f65cSamw  * Close the (user space) door.
5873db3f65cSamw  */
5883db3f65cSamw void
589*8622ec45SGordon Ross smb_opipe_door_close(smb_server_t *sv)
5903db3f65cSamw {
591*8622ec45SGordon Ross 	mutex_enter(&sv->sv_opipe_door_mutex);
5923db3f65cSamw 
593*8622ec45SGordon Ross 	if (sv->sv_opipe_door_hd != NULL) {
594*8622ec45SGordon Ross 		while (sv->sv_opipe_door_ncall > 0)
595*8622ec45SGordon Ross 			cv_wait(&sv->sv_opipe_door_cv,
596*8622ec45SGordon Ross 			    &sv->sv_opipe_door_mutex);
5973db3f65cSamw 
598*8622ec45SGordon Ross 		door_ki_rele(sv->sv_opipe_door_hd);
599*8622ec45SGordon Ross 		sv->sv_opipe_door_hd = NULL;
6003db3f65cSamw 	}
6013db3f65cSamw 
602*8622ec45SGordon Ross 	mutex_exit(&sv->sv_opipe_door_mutex);
6033db3f65cSamw }
6043db3f65cSamw 
6053db3f65cSamw /*
6063db3f65cSamw  * opipe door call interface.
6073db3f65cSamw  * Door serialization and call reference accounting is handled here.
6083db3f65cSamw  */
6093db3f65cSamw static int
6103db3f65cSamw smb_opipe_door_call(smb_opipe_t *opipe)
6113db3f65cSamw {
6123db3f65cSamw 	int rc;
613*8622ec45SGordon Ross 	smb_server_t *sv = opipe->p_server;
6143db3f65cSamw 
615*8622ec45SGordon Ross 	mutex_enter(&sv->sv_opipe_door_mutex);
6163db3f65cSamw 
617*8622ec45SGordon Ross 	if (sv->sv_opipe_door_hd == NULL) {
618*8622ec45SGordon Ross 		mutex_exit(&sv->sv_opipe_door_mutex);
6193db3f65cSamw 
620*8622ec45SGordon Ross 		if (smb_opipe_door_open(sv, sv->sv_opipe_door_id) != 0)
6213db3f65cSamw 			return (-1);
6223db3f65cSamw 
623*8622ec45SGordon Ross 		mutex_enter(&sv->sv_opipe_door_mutex);
6243db3f65cSamw 	}
6253db3f65cSamw 
626*8622ec45SGordon Ross 	sv->sv_opipe_door_ncall++;
627*8622ec45SGordon Ross 	mutex_exit(&sv->sv_opipe_door_mutex);
6283db3f65cSamw 
6293db3f65cSamw 	rc = smb_opipe_door_upcall(opipe);
6303db3f65cSamw 
631*8622ec45SGordon Ross 	mutex_enter(&sv->sv_opipe_door_mutex);
632*8622ec45SGordon Ross 	if ((--sv->sv_opipe_door_ncall) == 0)
633*8622ec45SGordon Ross 		cv_signal(&sv->sv_opipe_door_cv);
634*8622ec45SGordon Ross 	mutex_exit(&sv->sv_opipe_door_mutex);
6353db3f65cSamw 	return (rc);
6363db3f65cSamw }
6373db3f65cSamw 
6383db3f65cSamw /*
6393db3f65cSamw  * Door upcall wrapper - handles data marshalling.
6403db3f65cSamw  * This function should only be called by smb_opipe_door_call.
6413db3f65cSamw  */
6423db3f65cSamw static int
6433db3f65cSamw smb_opipe_door_upcall(smb_opipe_t *opipe)
6443db3f65cSamw {
645*8622ec45SGordon Ross 	smb_server_t *sv = opipe->p_server;
6463db3f65cSamw 	door_arg_t da;
6479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	smb_doorhdr_t hdr;
6483db3f65cSamw 	int i;
6493db3f65cSamw 	int rc;
6503db3f65cSamw 
6513db3f65cSamw 	da.data_ptr = (char *)opipe->p_doorbuf;
6523db3f65cSamw 	da.data_size = SMB_OPIPE_DOOR_BUFSIZE;
6533db3f65cSamw 	da.desc_ptr = NULL;
6543db3f65cSamw 	da.desc_num = 0;
6553db3f65cSamw 	da.rbuf = (char *)opipe->p_doorbuf;
6563db3f65cSamw 	da.rsize = SMB_OPIPE_DOOR_BUFSIZE;
6573db3f65cSamw 
6583db3f65cSamw 	for (i = 0; i < 3; ++i) {
659*8622ec45SGordon Ross 		if (smb_server_is_stopping(sv))
6609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 			return (-1);
6619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
662*8622ec45SGordon Ross 		if ((rc = door_ki_upcall_limited(sv->sv_opipe_door_hd,
663*8622ec45SGordon Ross 		    &da, NULL, SIZE_MAX, 0)) == 0)
6643db3f65cSamw 			break;
6653db3f65cSamw 
6663db3f65cSamw 		if (rc != EAGAIN && rc != EINTR)
6673db3f65cSamw 			return (-1);
6683db3f65cSamw 	}
6693db3f65cSamw 
6709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	/* Check for door_return(NULL, 0, NULL, 0) */
6719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	if (rc != 0 || da.data_size == 0 || da.rsize == 0)
6723db3f65cSamw 		return (-1);
6733db3f65cSamw 
6749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	if (smb_doorhdr_decode(&hdr, (uint8_t *)da.data_ptr, da.rsize) == -1)
6753db3f65cSamw 		return (-1);
6763db3f65cSamw 
6779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	if ((hdr.dh_magic != SMB_OPIPE_HDR_MAGIC) ||
6789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	    (hdr.dh_fid != opipe->p_hdr.dh_fid) ||
6799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	    (hdr.dh_op != opipe->p_hdr.dh_op) ||
6809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	    (hdr.dh_door_rc != 0) ||
6819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	    (hdr.dh_datalen > SMB_OPIPE_DOOR_BUFSIZE)) {
6823db3f65cSamw 		return (-1);
6833db3f65cSamw 	}
6843db3f65cSamw 
6859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_hdr.dh_datalen = hdr.dh_datalen;
6869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	opipe->p_hdr.dh_resid = hdr.dh_resid;
6873db3f65cSamw 	return (0);
6883db3f65cSamw }
689