nfs_dump.c revision 09b0d01c5bc323b8ee7043100e09aded27cc12ab
/*
* 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 2014 Gary Mills
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Dump memory to NFS swap file after a panic.
* We have no timeouts, context switches, etc.
*/
#include <sys/bootconf.h>
#include <nfs/nfs_clnt.h>
#include <sys/netconfig.h>
#include <sys/sysmacros.h>
#define RETRIES (5)
#define HDR_SIZE (256)
static struct knetconfig nfsdump_cf;
static struct netbuf nfsdump_addr;
static fhandle_t nfsdump_fhandle2;
static nfs_fh3 nfsdump_fhandle3;
static int nfsdump_maxcount;
static rpcvers_t nfsdump_version;
/*
* nonzero dumplog enables nd_log messages
*/
static int dumplog = 0;
static int nd_auth_marshall(XDR *);
/*PRINTFLIKE1*/
static void
{
if (dumplog) {
}
}
/* ARGSUSED */
int
{
int reply;
int badmsg;
int retry = 0;
int error;
int i;
nd_log("nfs_dump: addr=%p bn=%lld count=%lld\n",
return (error);
do {
if (error)
return (error);
do {
return (error);
if (!reply) {
retry++;
break;
}
retry = 0;
&badmsg);
if (error)
return (error);
} while (badmsg);
} while (retry);
}
return (0);
}
static int
{
int error;
if (*tiptr)
return (0);
/*
* If dump info hasn't yet been initialized (because dump
* device was chosen at user-level, rather than at boot time
* in nfs_swapvp) fill it in now.
*/
if (nfsdump_maxcount == 0) {
switch (nfsdump_version) {
case NFS_VERSION:
break;
case NFS_V3:
break;
default:
return (EIO);
}
nfsdump_maxcount = (int)dumpvp_size;
int v6 = 1;
nd_log("nfs_dump: not connectionless!\n");
== 0)) {
nd_log("nfs_dump: grabbing UDP major number\n");
nd_log("nfs_dump: making UDP device\n");
} else {
return (error);
}
}
}
nd_log("nfs_dump: calling t_kopen\n");
return (EIO);
}
nd_log("nfs_dump: calling bindresvport\n");
"\nnfs_dump: bindresvport failed: %m\n");
return (EIO);
}
} else {
nd_log("nfs_dump: calling t_kbind\n");
return (EIO);
}
}
return (0);
}
static int
{
static struct t_kunitdata sudata;
int procnum;
int error;
if (!dumpbuf) {
return (ENOMEM);
}
}
nd_log("nfs_dump: calling esballoc for header\n");
return (ENOBUFS);
}
return (EIO);
}
if (nfsdump_maxcount) {
/*
* Do not extend the dump file if it is also
* the swap file.
*/
if (offset >= nfsdump_maxcount) {
return (EIO);
}
}
switch (nfsdump_version) {
case NFS_VERSION:
!nd_auth_marshall(xdrp) ||
/*
* Following four values are:
* beginoffset
* offset
* length
* bytes array length
*/
return (EIO);
}
break;
case NFS_V3:
!nd_auth_marshall(xdrp) ||
/*
* Following four values are:
* offset
* count
* stable
* bytes array length
*/
return (EIO);
}
break;
default:
return (EIO);
}
return (ENOBUFS);
}
nd_log("nfs_dump: calling t_ksndudata\n");
return (error);
}
return (0);
}
static int
{
static struct nfsattrstat na;
static struct t_kunitdata rudata;
int uderr;
int type;
int error;
*badmsg = 0;
nd_log("nfs_dump: calling t_krcvudata\n");
*badmsg = 1;
return (0);
}
return (EIO);
}
*badmsg = 1;
return (0);
}
*badmsg = 1;
return (0);
}
/*
* Decode results.
*/
switch (nfsdump_version) {
case NFS_VERSION:
break;
case NFS_V3:
break;
default:
return (EIO);
}
return (EIO);
}
*badmsg = 1;
return (0);
}
return (EIO);
}
switch (nfsdump_version) {
case NFS_VERSION:
return (EIO);
}
break;
case NFS_V3:
return (EIO);
}
break;
default:
return (EIO);
}
/* free auth handle */
}
return (0);
}
static int
{
int error;
nd_log("nfs_dump: calling t_kspoll\n");
*eventp = 0;
/*
* Briefly enable interrupts before checking for a reply;
* the network transports do not yet support do_polled_io.
*/
int s = spl0();
splx(s);
"\nnfs_dump: t_kspoll failed: %m\n");
return (EIO);
}
runqueues();
}
return (EIO);
}
return (0);
}
static int
{
int credsize;
int hostnamelen;
if (!ptr) {
return (0);
}
/*
* We can do the fast path.
*/
return (1);
}