t_kopen.c revision 746b01876e5bb0aa289cb6ff1991bc355e4385b6
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * CDDL HEADER START
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * The contents of this file are subject to the terms of the
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Common Development and Distribution License (the "License").
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * You may not use this file except in compliance with the License.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * See the License for the specific language governing permissions
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * and limitations under the License.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * When distributing Covered Code, include this CDDL HEADER in each
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * If applicable, add the following below this CDDL HEADER, with the
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * fields enclosed by brackets "[]" replaced with your own identifying
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * information: Portions Copyright [yyyy] [name of copyright owner]
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * CDDL HEADER END
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Use is subject to license terms.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/* All Rights Reserved */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * University Copyright- Copyright (c) 1982, 1986, 1988
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * The Regents of the University of California
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * All Rights Reserved
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * University Acknowledgment- Portions of this document are derived from
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * software developed by the University of California, Berkeley, and its
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * contributors.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Kernel TLI-like function to initialize a transport
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * endpoint using the protocol specified.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * 0 on success and "tiptr" is set to a valid transport pointer,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * else a positive error code.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewst_kopen(file_t *fp, dev_t rdev, int flags, TIUSER **tiptr, cred_t *cr)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Special case for install: miniroot needs to be able to access files
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * via NFS as though it were always in the global zone.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * allocate a file pointer, but
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * no file descripter.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if ((error = falloc(NULL, flags, &fp, NULL)) != 0) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* Install proper cred in file */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * this will call the streams open for us.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Want to retry if error is EAGAIN, the streams open routine
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * might fail due to temporarely out of memory.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * fp is completely initialized so drop the write lock.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * I actually don't need any locking on fp in here since
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * there is no fd pointing at it. However, since I could
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * call closef if there is an error and closef requires
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * the fp read locked, I will acquire the read lock here
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * and make sure I release it before I leave this routine.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1, "t_kopen: not a streams device\n", 0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * allocate a new transport structure
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * see if TIMOD is already pushed
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error = strioctl(vp, I_FIND, (intptr_t)"timod", 0, K_TO_K, cr, &retval);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1, "t_kopen: strioctl(I_FIND, timod): %d\n", error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error = strioctl(vp, I_PUSH, (intptr_t)"timod", 0, K_TO_K, cr,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * This probably means the master file
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * should be tuned.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "t_kopen: I_PUSH of timod failed, error %d\n",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strioc.ic_len = (int)sizeof (struct T_info_req);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error = strdoioctl(vp->v_stream, &strioc, FNATIVE, K_TO_K, cr, &retval);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1, "t_kopen: strdoioctl(T_INFO_REQ): %d\n", error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1, "t_kopen: strdoioctl(T_INFO_REQ): retval: 0x%x\n",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (strioc.ic_len != sizeof (struct T_info_ack)) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "t_kopen: strioc.ic_len != sizeof (struct T_info_ack): %d\n",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ntiptr->tp_info.addr = _t_setsize(inforeq.ADDR_size);
static t_scalar_t
switch (infosize) {
return (DEFSIZE);
return (infosize);