2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * CDDL HEADER START
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * The contents of this file are subject to the terms of the
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Common Development and Distribution License (the "License").
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * You may not use this file except in compliance with the License.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * or http://www.opensolaris.org/os/licensing.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * See the License for the specific language governing permissions
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * and limitations under the License.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * When distributing Covered Code, include this CDDL HEADER in each
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * If applicable, add the following below this CDDL HEADER, with the
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * fields enclosed by brackets "[]" replaced with your own identifying
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * information: Portions Copyright [yyyy] [name of copyright owner]
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * CDDL HEADER END
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Use is subject to license terms.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * str_to_utf8 - converts a null-terminated C string to a utf8 string
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Converts a utf8 string to a C string.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * kmem_allocs a new string if not supplied
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowutf8_to_str(utf8string *str, uint_t *lenp, char *s)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * At least check for embedded nulls
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow for (i = 0; i < len; i++) {
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow for (i = 0; i < fsl->locations.locations_len; i++) {
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow for (j = 0; j < fs->server.server_len; j++) {
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow s = utf8_to_str(&fs->server.server_val[j], &l, NULL);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow for (j = 0; j < fs->rootpath.pathname4_len; j++) {
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow s = utf8_to_str(&fs->rootpath.pathname4_val[j],
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * There is a kernel copy of this routine in nfs4_srv.c.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Changes should be kept in sync.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlownfs4_create_components(char *path, component4 *comp4)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow plen = strlen(path) + 1; /* include the terminator */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* count number of components in the path */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow for (nxtc = path; nxtc < ori_path + plen; nxtc++) {
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (*nxtc == '/' || *nxtc == '\0' || *nxtc == '\n') {
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * There is a kernel copy of this routine in nfs4_srv.c.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Changes should be kept in sync.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowmake_pathname4(char *path, pathname4 *pathname)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* count number of components to alloc buffer */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if ((ncomp = nfs4_create_components(path, NULL)) == 0) {
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow comp4 = calloc(ncomp * sizeof (component4), 1);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* copy components into allocated buffer */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowxdr_component4(register XDR *xdrs, component4 *objp)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowxdr_utf8string(register XDR *xdrs, utf8string *objp)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow return (xdr_bytes(xdrs, (char **)&objp->utf8string_val,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow (uint_t *)&objp->utf8string_len, NFS4_MAX_UTF8STRING));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowxdr_pathname4(register XDR *xdrs, pathname4 *objp)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (!xdr_array(xdrs, (char **)&objp->pathname4_val,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow (uint_t *)&objp->pathname4_len, NFS4_MAX_PATHNAME4,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow sizeof (component4), (xdrproc_t)xdr_component4))
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowxdr_fs_location4(register XDR *xdrs, fs_location4 *objp)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (!xdr_array(xdrs, (char **)&objp->server.server_val,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow sizeof (utf8string), (xdrproc_t)xdr_utf8string))
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowxdr_fs_locations4(register XDR *xdrs, fs_locations4 *objp)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (!xdr_array(xdrs, (char **)&objp->locations.locations_val,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow (uint_t *)&objp->locations.locations_len, ~0,