/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <unistd.h>
#include <strings.h>
#include <string.h>
#include <limits.h>
#include <libnvpair.h>
#include <locale.h>
#include <sys/fs_reparse.h>
#include <rp_plugin.h>
#include <fcntl.h>
#include <priv.h>
#include <rpcsvc/nfs4_prot.h>
#include "ref_subr.h"
#ifndef TEXT_DOMAIN
#endif /* TEXT_DOMAIN */
extern int errno;
void
usage()
{
gettext("\tnfsref [-t type] add path location [location ...]\n"));
}
/*
* Copy a string from source to destination, escaping space
* with a backslash and escaping the escape character as well.
*/
int
{
int destlen = 0;
if (*sp == '\\') {
*dp++ = '\\';
*dp++ = '\\';
destlen++;
} else if (*sp == ' ') {
*dp++ = '\\';
*dp++ = ' ';
destlen++;
} else
destlen++;
sp++;
}
if (limit <= 0)
return (-1);
return (destlen);
}
int
{
/* Get an nvlist */
nvl = reparse_init();
return (ENOMEM);
/* Get the reparse point data, if the RP exists */
if (err == -1) {
notfound = 1;
err = 0;
} else {
return (errno);
}
} else {
}
/* Get any data into nvlist */
if (notfound == 0)
if (err != 0) {
return (err);
}
/*
* Accumulate multiple locations on the command line into 'buf'
*/
}
/* Add to the list */
if (err) {
return (err);
}
/* Get the new or modified symlink contents */
if (err)
return (err);
/* Delete first if found */
if (notfound == 0) {
if (err) {
return (err);
}
}
/* Finally, write out the reparse point */
if (err)
return (err);
"Warning: referrals do not work on this filesystem\n"));
if (notfound)
else
return (0);
}
int
{
char *cp;
char *svc_data;
int err;
/* Get an nvlist */
if (!(nvl = reparse_init()))
return (ENOMEM);
/* Get the symlink data (should be there) */
if (err == -1) {
return (errno);
}
/* Get the records into the nvlist */
if (err) {
return (err);
}
/* Remove from nvlist */
if (err) {
return (err);
}
/* Any list entries left? If so, turn nvlist back to string. */
if (err)
return (err);
} else {
}
/* Finally, delete and perhaps recreate the reparse point */
if (err) {
return (err);
}
if (err)
return (err);
}
return (err);
}
int
{
int err;
if (!(nvl = reparse_init()))
return (-1);
/* Get reparse point data */
if (err == -1)
return (errno);
/* Parse it to an nvlist */
if (err) {
return (err);
}
/* Look for entries of the requested service type */
break;
break;
}
return (ENOENT);
}
/* Get the service data and look it up */
if (err)
return (err);
XDR_DESTROY(&xdr);
return (ENOENT);
return (0);
}
extern char *optarg;
int
{
(void) textdomain(TEXT_DOMAIN);
type_set = 0; /* Lookup any nfs type */
/* Look for options (just the service type now) */
switch (c) {
case 't':
type_set = 1;
break;
default:
usage();
exit(1);
}
}
/* Make sure there's at least a command and one argument */
usage();
exit(1);
}
err = rp_plugin_init();
switch (err) {
case RP_OK:
break;
case RP_NO_PLUGIN_DIR:
gettext("Warning: no plugin directory, continuing...\n"));
break;
case RP_NO_PLUGIN:
gettext("Warning: no plugin found, continuing...\n"));
break;
case RP_NO_MEMORY:
gettext("rp_plugin_init failed, no memory\n"));
exit(0);
default:
exit(0);
}
usage();
exit(1);
}
} else {
usage();
exit(1);
}
if (err != 0)
return (err);
}