xref: /titanic_44/usr/src/lib/libc/port/sys/sharefs.c (revision 7257d1b4d25bfac0c802847390e98a464fd787ac)
1a237e38eSth199096 /*
2a237e38eSth199096  * CDDL HEADER START
3a237e38eSth199096  *
4a237e38eSth199096  * The contents of this file are subject to the terms of the
5a237e38eSth199096  * Common Development and Distribution License (the "License").
6a237e38eSth199096  * You may not use this file except in compliance with the License.
7a237e38eSth199096  *
8a237e38eSth199096  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9a237e38eSth199096  * or http://www.opensolaris.org/os/licensing.
10a237e38eSth199096  * See the License for the specific language governing permissions
11a237e38eSth199096  * and limitations under the License.
12a237e38eSth199096  *
13a237e38eSth199096  * When distributing Covered Code, include this CDDL HEADER in each
14a237e38eSth199096  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15a237e38eSth199096  * If applicable, add the following below this CDDL HEADER, with the
16a237e38eSth199096  * fields enclosed by brackets "[]" replaced with your own identifying
17a237e38eSth199096  * information: Portions Copyright [yyyy] [name of copyright owner]
18a237e38eSth199096  *
19a237e38eSth199096  * CDDL HEADER END
20a237e38eSth199096  */
21a574db85Sraf 
22a237e38eSth199096 /*
23a574db85Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24a237e38eSth199096  * Use is subject to license terms.
25a237e38eSth199096  */
26a237e38eSth199096 
27a237e38eSth199096 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28a237e38eSth199096 
29*7257d1b4Sraf #include "lint.h"
30a237e38eSth199096 #include <sys/types.h>
31a237e38eSth199096 #include <sys/types32.h>
32a237e38eSth199096 #include <rpc/types.h>
33a237e38eSth199096 #include <sys/vfs.h>
34a237e38eSth199096 #include <strings.h>
35a237e38eSth199096 #include <sharefs/share.h>
36a237e38eSth199096 #include <sys/syscall.h>
37a237e38eSth199096 
38a237e38eSth199096 #include "libc.h"
39a237e38eSth199096 
40a237e38eSth199096 #define	SMAX(i, j)		\
41a237e38eSth199096 	if ((j) > (i)) {	\
42a237e38eSth199096 		(i) = (j);	\
43a237e38eSth199096 	}
44a237e38eSth199096 
45a237e38eSth199096 int
_sharefs(enum sharefs_sys_op opcode,struct share * sh)46a3175730Sth199096 _sharefs(enum sharefs_sys_op opcode, struct share *sh)
47a237e38eSth199096 {
48a237e38eSth199096 	uint32_t		i, j;
49a237e38eSth199096 
50a237e38eSth199096 	/*
51a237e38eSth199096 	 * We need to know the total size of the share
52a237e38eSth199096 	 * and also the largest element size. This is to
53a237e38eSth199096 	 * get enough buffer space to transfer from
54a237e38eSth199096 	 * userland to kernel.
55a237e38eSth199096 	 */
56a237e38eSth199096 	i = (sh->sh_path ? strlen(sh->sh_path) : 0);
57a237e38eSth199096 	sh->sh_size = i;
58a237e38eSth199096 
59a237e38eSth199096 	j = (sh->sh_res ? strlen(sh->sh_res) : 0);
60a237e38eSth199096 	sh->sh_size += j;
61a237e38eSth199096 	SMAX(i, j);
62a237e38eSth199096 
63a237e38eSth199096 	j = (sh->sh_fstype ? strlen(sh->sh_fstype) : 0);
64a237e38eSth199096 	sh->sh_size += j;
65a237e38eSth199096 	SMAX(i, j);
66a237e38eSth199096 
67a237e38eSth199096 	j = (sh->sh_opts ? strlen(sh->sh_opts) : 0);
68a237e38eSth199096 	sh->sh_size += j;
69a237e38eSth199096 	SMAX(i, j);
70a237e38eSth199096 
71a237e38eSth199096 	j = (sh->sh_descr ? strlen(sh->sh_descr) : 0);
72a237e38eSth199096 	sh->sh_size += j;
73a237e38eSth199096 	SMAX(i, j);
74a237e38eSth199096 
75a237e38eSth199096 	return (syscall(SYS_sharefs, opcode, sh, i));
76a237e38eSth199096 }
77