xref: /onnv-gate/usr/src/lib/libc/port/sys/sharefs.c (revision 6812:febeba71273d)
13957Sth199096 /*
23957Sth199096  * CDDL HEADER START
33957Sth199096  *
43957Sth199096  * The contents of this file are subject to the terms of the
53957Sth199096  * Common Development and Distribution License (the "License").
63957Sth199096  * You may not use this file except in compliance with the License.
73957Sth199096  *
83957Sth199096  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93957Sth199096  * or http://www.opensolaris.org/os/licensing.
103957Sth199096  * See the License for the specific language governing permissions
113957Sth199096  * and limitations under the License.
123957Sth199096  *
133957Sth199096  * When distributing Covered Code, include this CDDL HEADER in each
143957Sth199096  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153957Sth199096  * If applicable, add the following below this CDDL HEADER, with the
163957Sth199096  * fields enclosed by brackets "[]" replaced with your own identifying
173957Sth199096  * information: Portions Copyright [yyyy] [name of copyright owner]
183957Sth199096  *
193957Sth199096  * CDDL HEADER END
203957Sth199096  */
215891Sraf 
223957Sth199096 /*
235891Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
243957Sth199096  * Use is subject to license terms.
253957Sth199096  */
263957Sth199096 
273957Sth199096 #pragma ident	"%Z%%M%	%I%	%E% SMI"
283957Sth199096 
29*6812Sraf #include "lint.h"
303957Sth199096 #include <sys/types.h>
313957Sth199096 #include <sys/types32.h>
323957Sth199096 #include <rpc/types.h>
333957Sth199096 #include <sys/vfs.h>
343957Sth199096 #include <strings.h>
353957Sth199096 #include <sharefs/share.h>
363957Sth199096 #include <sys/syscall.h>
373957Sth199096 
383957Sth199096 #include "libc.h"
393957Sth199096 
403957Sth199096 #define	SMAX(i, j)		\
413957Sth199096 	if ((j) > (i)) {	\
423957Sth199096 		(i) = (j);	\
433957Sth199096 	}
443957Sth199096 
453957Sth199096 int
_sharefs(enum sharefs_sys_op opcode,struct share * sh)464995Sth199096 _sharefs(enum sharefs_sys_op opcode, struct share *sh)
473957Sth199096 {
483957Sth199096 	uint32_t		i, j;
493957Sth199096 
503957Sth199096 	/*
513957Sth199096 	 * We need to know the total size of the share
523957Sth199096 	 * and also the largest element size. This is to
533957Sth199096 	 * get enough buffer space to transfer from
543957Sth199096 	 * userland to kernel.
553957Sth199096 	 */
563957Sth199096 	i = (sh->sh_path ? strlen(sh->sh_path) : 0);
573957Sth199096 	sh->sh_size = i;
583957Sth199096 
593957Sth199096 	j = (sh->sh_res ? strlen(sh->sh_res) : 0);
603957Sth199096 	sh->sh_size += j;
613957Sth199096 	SMAX(i, j);
623957Sth199096 
633957Sth199096 	j = (sh->sh_fstype ? strlen(sh->sh_fstype) : 0);
643957Sth199096 	sh->sh_size += j;
653957Sth199096 	SMAX(i, j);
663957Sth199096 
673957Sth199096 	j = (sh->sh_opts ? strlen(sh->sh_opts) : 0);
683957Sth199096 	sh->sh_size += j;
693957Sth199096 	SMAX(i, j);
703957Sth199096 
713957Sth199096 	j = (sh->sh_descr ? strlen(sh->sh_descr) : 0);
723957Sth199096 	sh->sh_size += j;
733957Sth199096 	SMAX(i, j);
743957Sth199096 
753957Sth199096 	return (syscall(SYS_sharefs, opcode, sh, i));
763957Sth199096 }
77