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#endif /* TEXT_DOMAIN */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow gettext("\tnfsref [-t type] add path location [location ...]\n"));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow fprintf(stderr, gettext("\tnfsref [-t type] remove path\n"));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow fprintf(stderr, gettext("\tnfsref [-t type] lookup path\n"));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Copy a string from source to destination, escaping space
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * with a backslash and escaping the escape character as well.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowaddref(char *sl_path, char *svc_type, int optind, int argc, char *argv[])
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Get an nvlist */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Get the reparse point data, if the RP exists */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Get any data into nvlist */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Accumulate multiple locations on the command line into 'buf'
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow len += add_escape(argv[i], buf, SYMLINK_MAX) + 2;
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Add to the list */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Get the new or modified symlink contents */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Delete first if found */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Finally, write out the reparse point */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (err == 0 && strcasecmp(sbuf.st_fstype, "ZFS") != 0)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow "Warning: referrals do not work on this filesystem\n"));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow printf(gettext("Created reparse point %s\n"), sl_path);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow printf(gettext("Added to reparse point %s\n"), sl_path);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow char uuid[UUID_PRINTABLE_STRING_LENGTH], path[256], loc[2048];
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Get an nvlist */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Get the symlink data (should be there) */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Get the records into the nvlist */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Remove from nvlist */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Any list entries left? If so, turn nvlist back to string. */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Finally, delete and perhaps recreate the reparse point */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow printf(gettext("Removed svc_type '%s' from %s\n"), svc_type, sl_path);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowlookup(char *sl_path, char *svc_type, int type_set)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Get reparse point data */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Parse it to an nvlist */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Look for entries of the requested service type */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow while ((curr = nvlist_next_nvpair(nvl, curr)) != NULL) {
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (type_set && strcasecmp(type, svc_type) == 0)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (!type_set && strncasecmp(type, "nfs", 3) == 0)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Get the service data and look it up */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow err = reparse_deref(type, svc_data, buf, &bufsize);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow xdrmem_create(&xdr, buf, bufsize, XDR_DECODE);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow svc_type = "nfs-basic"; /* Default from SMF some day */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Look for options (just the service type now) */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow while ((c = getopt(argc, argv, "t:")) != -1) {
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* Make sure there's at least a command and one argument */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow gettext("Warning: no plugin directory, continuing...\n"));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow gettext("Warning: no plugin found, continuing...\n"));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow gettext("rp_plugin_init failed, no memory\n"));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow gettext("rp_plugin_init failed, error %d\n"), err);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow err = addref(sl_path, svc_type, optind, argc, argv);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow fprintf(stderr, gettext("Command %s failed: %s\n"), command,