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