nfs_cmd.c revision 593cc11b0ce1691880b59ee5a8bd6adcdc823490
/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/pathname.h>
#define NFSCMD_DR_TRYCNT 8
#ifdef nextdp
#endif
void
{
if (nfscmd_dh)
}
void
nfscmd_init(void)
{
}
void
nfscmd_fini(void)
{
}
/*
* nfscmd_send(arg, result)
*
* Send a command to the daemon listening on the door. The result is
* returned in the result pointer if the function return value is
* NFSCMD_ERR_SUCCESS. Otherwise it is the error value.
*/
int
{
int ntries = 0;
int last = 0;
/*
* The rendezvous point has not been established yet !
* This could mean that either mountd(1m) has not yet
* been started or that _this_ routine nuked the door
* handle after receiving an EINTR for a REVOKED door.
*
* Returning NFSAUTH_DROP will cause the NFS client
* to retransmit the request, so let's try to be more
* rescillient and attempt for ntries before we bail.
*/
if (++ntries % NFSCMD_DR_TRYCNT) {
goto retry;
}
return (NFSCMD_ERR_DROP);
}
case 0:
/* Success */
break;
case EAGAIN:
/* Need to retry a couple of times */
goto retry;
/* NOTREACHED */
case EINTR:
/*
* The server barfed and revoked
* the (existing) door on us; we
* want to wait to give smf(5) a
* chance to restart mountd(1m)
* and establish a new door handle.
*/
goto retry;
}
/*
* If the door was _not_ revoked on us,
* then more than likely we took an INTR,
* so we need to fail the operation.
*/
}
/*
* The only failure that can occur from getting
* the door info is EINVAL, so we let the code
* below handle it.
*/
/* FALLTHROUGH */
case EBADF:
case EINVAL:
default:
/*
* If we have a stale door handle, give smf a last
* chance to start it by sleeping for a little bit.
* If we're still hosed, we'll fail the call.
*
* Since we're going to reacquire the door handle
* upon the retry, we opt to sleep for a bit and
* _not_ to clear mountd_dh. If mountd restarted
* and was able to set mountd_dh, we should see
* the new instance; if not, we won't get caught
*/
if (!last) {
last++;
goto retry;
}
break;
}
}
/*
* nfscmd_findmap(export, addr)
*
* Find a characterset map for the specified client address.
* First try to find a cached entry. If not successful,
* ask mountd daemon running in userland.
*
* For most of the clients this function is NOOP, since
* EX_CHARMAP flag won't be set.
*/
struct charset_cache *
{
struct charset_cache *charset;
/*
* In debug kernel we want to know about strayed nulls.
* In non-debug kernel we behave gracefully.
*/
return (NULL);
return (NULL);
}
sizeof (struct sockaddr)) == 0)
break;
}
/* the slooow way - ask daemon */
return (charset);
}
/*
* nfscmd_insert_charmap(export, addr, name)
*
* Insert a new character set conversion map into the export structure
* for the share. The entry has the IP address of the client and the
* character set name.
*/
static struct charset_cache *
{
struct charset_cache *charset;
charset = (struct charset_cache *)
return (NULL);
}
return (charset);
}
/*
* nfscmd_charmap(response, sp, exi)
*
* Check to see if this client needs a character set conversion.
*/
static struct charset_cache *
{
int ret;
char *path;
struct charset_cache *charset;
return (NULL);
/*
* nfscmd_findmap() did not find one in the cache so make
* the request to the daemon. We need to add the entry in
* either case since we want negative as well as
* positive cacheing.
*/
if (ret == NFSCMD_ERR_SUCCESS)
else
return (charset);
}
/*
* nfscmd_convname(addr, export, name, inbound, size)
*
* Convert the given "name" string to the appropriate character set.
* If inbound is true, convert from the client character set to UTF-8.
* If inbound is false, convert from UTF-8 to the client characters set.
*
* In case of NFS v4 this is used for ill behaved clients, since
* according to the standard all file names should be utf-8 encoded
* on client-side.
*/
char *
{
char *newname;
char *holdname;
int err;
int ret;
return (name);
/* make sure we have more than enough space */
if (inbound)
else
}
return (newname);
}
/*
* nfscmd_convdirent()
*
* There is only one entry in the data. Convert to new charset, if
* required and only return a success if it fits.
*/
char *
{
char *newdata;
int err = 0;
char *iname;
char *oname;
struct charset_cache *charset;
return (data);
} else {
}
} else {
}
return (newdata);
}
/*
* nfscmd_convdirplus(addr, export, data, nents, maxsize, ndata)
*
* Convert the dirents in data into a new list of dirents in ndata.
*/
{
char *newdata;
size_t i;
char *iname;
char *oname;
int err;
struct charset_cache *charset;
return (0);
nsize = 0;
/*
* Copy the dp information if it fits. Then copy and
* convert the name in the entry.
*/
/* doesn't fit */
break;
switch (err) {
default:
case E2BIG:
break;
case EILSEQ:
skipped++;
continue;
}
}
/*
* What to do with other errors?
* For now, we return the unconverted string.
*/
}
}
/*
* nfscmd_countents(data, len)
*
* How many dirents are there in the data buffer?
*/
{
}
return (nents);
}
/*
* nfscmd_dropped_entrysize(dir, drop, nents)
*
* We need to drop "drop" entries from dir in order to fit in the
* buffer. How much do we reduce the overall size by?
*/
{
size_t i;
return (0);
}
return (size);
}