t_kopen.c revision 746b01876e5bb0aa289cb6ff1991bc355e4385b6
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * CDDL HEADER START
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
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 *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * or http://www.opensolaris.org/os/licensing.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * See the License for the specific language governing permissions
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * and limitations under the License.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
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 *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * CDDL HEADER END
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Use is subject to license terms.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/* All Rights Reserved */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
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 *
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 */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews/*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Kernel TLI-like function to initialize a transport
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * endpoint using the protocol specified.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * Returns:
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * 0 on success and "tiptr" is set to a valid transport pointer,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * else a positive error code.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/param.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/types.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/proc.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/file.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/user.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/vnode.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/errno.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/stream.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/ioctl.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/stropts.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/strsubr.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/tihdr.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/timod.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/tiuser.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/t_kuser.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/kmem.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews#include <sys/cmn_err.h>
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsstatic t_scalar_t _t_setsize(t_scalar_t);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewsint
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewst_kopen(file_t *fp, dev_t rdev, int flags, TIUSER **tiptr, cred_t *cr)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews{
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews int madefp = 0;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews struct T_info_ack inforeq;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews int retval;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews vnode_t *vp;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews struct strioctl strioc;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews int error;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews TIUSER *ntiptr;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews int rtries = 0;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /*
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 */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (nfs_global_client_only != 0)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews cr = kcred;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(2, "t_kopen: fp %x, ", fp);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(2, "rdev %x, ", rdev);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(2, "flags %x\n", flags);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews *tiptr = NULL;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error = 0;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews retval = 0;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (fp == NULL) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (rdev == NODEV) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1, "t_kopen: null device\n", 0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews return (EINVAL);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * allocate a file pointer, but
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * no file descripter.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if ((error = falloc(NULL, flags, &fp, NULL)) != 0) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1, "t_kopen: falloc: %d\n", error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews return (error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /* Install proper cred in file */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (cr != fp->f_cred) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews crhold(cr);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews crfree(fp->f_cred);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews fp->f_cred = cr;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews vp = makespecvp(rdev, VCHR);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /*
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 */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews do {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if ((error = VOP_OPEN(&vp, flags, cr, NULL))
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews == EAGAIN) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews (void) delay(hz);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews } while (error == EAGAIN && ++rtries < 5);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (error) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1, "t_kopen: VOP_OPEN: %d\n", error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews unfalloc(fp);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews VN_RELE(vp);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews return (error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /*
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 */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews fp->f_vnode = vp;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews mutex_exit(&fp->f_tlock);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews madefp = 1;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews } else {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews vp = fp->f_vnode;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (vp->v_stream == NULL) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (madefp)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews (void) closef(fp);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1, "t_kopen: not a streams device\n", 0);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews return (ENOSTR);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * allocate a new transport structure
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ntiptr = kmem_alloc(TIUSERSZ, KM_SLEEP);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ntiptr->fp = fp;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ntiptr->flags = madefp ? MADE_FP : 0;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(2, "t_kopen: vp %x, ", vp);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(2, "stp %x\n", vp->v_stream);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * see if TIMOD is already pushed
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error = strioctl(vp, I_FIND, (intptr_t)"timod", 0, K_TO_K, cr, &retval);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (error) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews kmem_free(ntiptr, TIUSERSZ);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (madefp)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews (void) closef(fp);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1, "t_kopen: strioctl(I_FIND, timod): %d\n", error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews return (error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (retval == 0) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrewstryagain:
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error = strioctl(vp, I_PUSH, (intptr_t)"timod", 0, K_TO_K, cr,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews &retval);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (error) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews switch (error) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews case ENOSPC:
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews case EAGAIN:
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews case ENOSR:
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews /*
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * This probably means the master file
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews * should be tuned.
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews */
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews cmn_err(CE_WARN,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "t_kopen: I_PUSH of timod failed, error %d\n",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews (void) delay(hz);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error = 0;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews goto tryagain;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews default:
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews kmem_free(ntiptr, TIUSERSZ);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (madefp)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews (void) closef(fp);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1, "t_kopen: I_PUSH (timod): %d",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews return (error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews inforeq.PRIM_type = T_INFO_REQ;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strioc.ic_cmd = TI_GETINFO;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strioc.ic_timout = 0;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strioc.ic_dp = (char *)&inforeq;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strioc.ic_len = (int)sizeof (struct T_info_req);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error = strdoioctl(vp->v_stream, &strioc, FNATIVE, K_TO_K, cr, &retval);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (error) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews kmem_free(ntiptr, TIUSERSZ);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (madefp)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews (void) closef(fp);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1, "t_kopen: strdoioctl(T_INFO_REQ): %d\n", error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews return (error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (retval) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if ((retval & 0xff) == TSYSERR)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error = (retval >> 8) & 0xff;
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews else
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews error = t_tlitosyserr(retval & 0xff);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews kmem_free(ntiptr, TIUSERSZ);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (madefp)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews (void) closef(fp);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1, "t_kopen: strdoioctl(T_INFO_REQ): retval: 0x%x\n",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews retval);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews return (error);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (strioc.ic_len != sizeof (struct T_info_ack)) {
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews kmem_free(ntiptr, TIUSERSZ);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews if (madefp)
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews (void) closef(fp);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews KTLILOG(1,
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews "t_kopen: strioc.ic_len != sizeof (struct T_info_ack): %d\n",
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews strioc.ic_len);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews return (EPROTO);
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews }
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews
5c526acb82c882e41b655c31f5fa4425c87b671cMark Andrews ntiptr->tp_info.addr = _t_setsize(inforeq.ADDR_size);
ntiptr->tp_info.options = _t_setsize(inforeq.OPT_size);
ntiptr->tp_info.tsdu = _t_setsize(inforeq.TSDU_size);
ntiptr->tp_info.etsdu = _t_setsize(inforeq.ETSDU_size);
ntiptr->tp_info.connect = _t_setsize(inforeq.CDATA_size);
ntiptr->tp_info.discon = _t_setsize(inforeq.DDATA_size);
ntiptr->tp_info.servtype = inforeq.SERV_type;
*tiptr = ntiptr;
return (0);
}
#define DEFSIZE 128
static t_scalar_t
_t_setsize(t_scalar_t infosize)
{
switch (infosize) {
case -1:
return (DEFSIZE);
case -2:
return (0);
default:
return (infosize);
}
}