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 Thurlowboolean_t nfs_basic_supports_svc(const char *);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowint nfs_basic_deref(const char *, const char *, char *, size_t *);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowint nfs_basic_form(const char *, const char *, char *, size_t *);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * What service type does this module support?
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Does this module support a particular service type?
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow return (!strncasecmp(svc_type, SERVICE_TYPE, strlen(SERVICE_TYPE)));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Take a string with a set of locations like this:
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * host1:/path1 host2:/path2 host3:/path3
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * and convert it to an fs_locations4 for the deref routine.
2457156514cfa0601bd17503b32b85ace84513a8Robert Thurlow int fsl_count = 0, escape = 0, delimiter = 0;
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Count fs_location entries by counting spaces.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Remember that escaped spaces ("\ ") may exist.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * We mark the location boundaries with null bytes.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Variable use:
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * escape - set if we have found a backspace,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * part of either "\ " or "\\"
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * delimiter - set if we have found a space and
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * used to skip multiple spaces
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow printf("get_fs_locations: fsl_count %d\n", fsl_count);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Alloc space for everything */
2457156514cfa0601bd17503b32b85ace84513a8Robert Thurlow fsl_array = calloc(fsl_count, sizeof (fs_location4));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Copy input, removing escapes from host:/path/to/my\ files
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow while ((sp && *sp && (sp - buf < len)) || gothost) {
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Drop leading spaces */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Look for the rightmost colon for host */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow printf("get_fs_locations: skipping %s\n", sp);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (fsl_array[i].server.server_val == NULL) {
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow for (j = 0; j < i; j++)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* End of string should mean a pathname */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow (void) make_pathname4(buf2, &fsl_array[i].rootpath);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Skip a single escape character */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Plain char, just copy it */
2457156514cfa0601bd17503b32b85ace84513a8Robert Thurlow * If we're still expecting a path name, we don't have a
2457156514cfa0601bd17503b32b85ace84513a8Robert Thurlow * server:/path pair and should discard the server and
2457156514cfa0601bd17503b32b85ace84513a8Robert Thurlow * note that we got fewer locations than expected.
2457156514cfa0601bd17503b32b85ace84513a8Robert Thurlow * If we have zero entries, we never got a whole server:/path
2457156514cfa0601bd17503b32b85ace84513a8Robert Thurlow * pair, and so cannot have anything else allocated.
2457156514cfa0601bd17503b32b85ace84513a8Robert Thurlow * Make sure we reflect the right number of locations.
2457156514cfa0601bd17503b32b85ace84513a8Robert Thurlow if (fsl_count < result->locations.locations_len)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Deref function for nfs-basic service type returns an fs_locations4.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlownfs_basic_deref(const char *svc_type, const char *svc_data, char *buf,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if ((!svc_type) || (!svc_data) || (!buf) || (!bufsz) || (*bufsz == 0))
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow printf("nfs_basic_deref: past get_fs_locations()\n");
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow slen = xdr_sizeof(xdr_fs_locations4, (void *)fsl);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow printf("nfs_basic_deref: past buffer check\n");
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow xdrmem_create(&xdr, buf, *bufsz, XDR_ENCODE);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow printf("nfs_basic_deref: past xdr_fs_locations4() and done\n");
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Form function for nfs-basic service type.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlownfs_basic_form(const char *svc_type, const char *svc_data, char *buf,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if ((!svc_type) || (!svc_data) || (!buf) || (*bufsz == 0))