a237e38e9161f0acd6451439d4a7dd597e66291dth/*
a237e38e9161f0acd6451439d4a7dd597e66291dth * CDDL HEADER START
a237e38e9161f0acd6451439d4a7dd597e66291dth *
a237e38e9161f0acd6451439d4a7dd597e66291dth * The contents of this file are subject to the terms of the
a237e38e9161f0acd6451439d4a7dd597e66291dth * Common Development and Distribution License (the "License").
a237e38e9161f0acd6451439d4a7dd597e66291dth * You may not use this file except in compliance with the License.
a237e38e9161f0acd6451439d4a7dd597e66291dth *
a237e38e9161f0acd6451439d4a7dd597e66291dth * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a237e38e9161f0acd6451439d4a7dd597e66291dth * or http://www.opensolaris.org/os/licensing.
a237e38e9161f0acd6451439d4a7dd597e66291dth * See the License for the specific language governing permissions
a237e38e9161f0acd6451439d4a7dd597e66291dth * and limitations under the License.
a237e38e9161f0acd6451439d4a7dd597e66291dth *
a237e38e9161f0acd6451439d4a7dd597e66291dth * When distributing Covered Code, include this CDDL HEADER in each
a237e38e9161f0acd6451439d4a7dd597e66291dth * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a237e38e9161f0acd6451439d4a7dd597e66291dth * If applicable, add the following below this CDDL HEADER, with the
a237e38e9161f0acd6451439d4a7dd597e66291dth * fields enclosed by brackets "[]" replaced with your own identifying
a237e38e9161f0acd6451439d4a7dd597e66291dth * information: Portions Copyright [yyyy] [name of copyright owner]
a237e38e9161f0acd6451439d4a7dd597e66291dth *
a237e38e9161f0acd6451439d4a7dd597e66291dth * CDDL HEADER END
a237e38e9161f0acd6451439d4a7dd597e66291dth */
a574db851cdc636fc3939b68e80d79fe7fbd57f2raf
a237e38e9161f0acd6451439d4a7dd597e66291dth/*
a574db851cdc636fc3939b68e80d79fe7fbd57f2raf * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
a237e38e9161f0acd6451439d4a7dd597e66291dth * Use is subject to license terms.
a237e38e9161f0acd6451439d4a7dd597e66291dth */
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth#pragma ident "%Z%%M% %I% %E% SMI"
a237e38e9161f0acd6451439d4a7dd597e66291dth
7257d1b4d25bfac0c802847390e98a464fd787acraf#include "lint.h"
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <sys/types.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <sys/types32.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <rpc/types.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <sys/vfs.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <strings.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <sharefs/share.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <sys/syscall.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth#include "libc.h"
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth#define SMAX(i, j) \
a237e38e9161f0acd6451439d4a7dd597e66291dth if ((j) > (i)) { \
a237e38e9161f0acd6451439d4a7dd597e66291dth (i) = (j); \
a237e38e9161f0acd6451439d4a7dd597e66291dth }
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dthint
a3175730a459223fb8f26a2915aa0a31f6b36f98th_sharefs(enum sharefs_sys_op opcode, struct share *sh)
a237e38e9161f0acd6451439d4a7dd597e66291dth{
a237e38e9161f0acd6451439d4a7dd597e66291dth uint32_t i, j;
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth /*
a237e38e9161f0acd6451439d4a7dd597e66291dth * We need to know the total size of the share
a237e38e9161f0acd6451439d4a7dd597e66291dth * and also the largest element size. This is to
a237e38e9161f0acd6451439d4a7dd597e66291dth * get enough buffer space to transfer from
a237e38e9161f0acd6451439d4a7dd597e66291dth * userland to kernel.
a237e38e9161f0acd6451439d4a7dd597e66291dth */
a237e38e9161f0acd6451439d4a7dd597e66291dth i = (sh->sh_path ? strlen(sh->sh_path) : 0);
a237e38e9161f0acd6451439d4a7dd597e66291dth sh->sh_size = i;
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth j = (sh->sh_res ? strlen(sh->sh_res) : 0);
a237e38e9161f0acd6451439d4a7dd597e66291dth sh->sh_size += j;
a237e38e9161f0acd6451439d4a7dd597e66291dth SMAX(i, j);
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth j = (sh->sh_fstype ? strlen(sh->sh_fstype) : 0);
a237e38e9161f0acd6451439d4a7dd597e66291dth sh->sh_size += j;
a237e38e9161f0acd6451439d4a7dd597e66291dth SMAX(i, j);
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth j = (sh->sh_opts ? strlen(sh->sh_opts) : 0);
a237e38e9161f0acd6451439d4a7dd597e66291dth sh->sh_size += j;
a237e38e9161f0acd6451439d4a7dd597e66291dth SMAX(i, j);
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth j = (sh->sh_descr ? strlen(sh->sh_descr) : 0);
a237e38e9161f0acd6451439d4a7dd597e66291dth sh->sh_size += j;
a237e38e9161f0acd6451439d4a7dd597e66291dth SMAX(i, j);
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth return (syscall(SYS_sharefs, opcode, sh, i));
a237e38e9161f0acd6451439d4a7dd597e66291dth}