/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 1991-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <setjmp.h>
#include <string.h>
#include "snoop.h"
#include "snoop_nfs.h"
#include <rpcsvc/nfs_prot.h>
static char *perms(int);
static char *filetype(int);
static char *sum_readdirres(void);
static void detail_readdirres(void);
static void detail_diroparg(void);
static void nfscall2(int);
static void nfsreply2(int);
static void detail_mode(int);
static void detail_sattr(void);
static void interpret_nfs2(int, int, int, int, int, char *, int);
static char *procnames_short[] = {
"NULL2", /* 0 */
"GETATTR2", /* 1 */
"SETATTR2", /* 2 */
"ROOT2", /* 3 */
"LOOKUP2", /* 4 */
"READLINK2", /* 5 */
"READ2", /* 6 */
"WRITECACHE2", /* 7 */
"WRITE2", /* 8 */
"CREATE2", /* 9 */
"REMOVE2", /* 10 */
"RENAME2", /* 11 */
"LINK2", /* 12 */
"SYMLINK2", /* 13 */
"MKDIR2", /* 14 */
"RMDIR2", /* 15 */
"READDIR2", /* 16 */
"STATFS2", /* 17 */
};
static char *procnames_long[] = {
"Null procedure", /* 0 */
"Get file attributes", /* 1 */
"Set file attributes", /* 2 */
"Get root filehandle", /* 3 */
"Look up file name", /* 4 */
"Read from symbolic link", /* 5 */
"Read from file", /* 6 */
"Write to cache", /* 7 */
"Write to file", /* 8 */
"Create file", /* 9 */
"Remove file", /* 10 */
"Rename", /* 11 */
"Link", /* 12 */
"Make symbolic link", /* 13 */
"Make directory", /* 14 */
"Remove directory", /* 15 */
"Read from directory", /* 16 */
"Get filesystem attributes", /* 17 */
};
/* ARGSUSED */
void
char *data;
int len;
{
if (vers == 2) {
return;
}
if (vers == 3) {
return;
}
if (vers == 4) {
return;
}
}
static void
char *data;
int len;
{
char *line;
char *fh;
return;
line = get_sum_line();
"NFS C %s",
switch (proc) {
case NFSPROC_GETATTR:
case NFSPROC_READLINK:
case NFSPROC_STATFS:
case NFSPROC_SETATTR:
break;
case NFSPROC_LOOKUP:
case NFSPROC_REMOVE:
case NFSPROC_RMDIR:
case NFSPROC_CREATE:
case NFSPROC_MKDIR:
fh,
break;
case NFSPROC_WRITE:
(void) getxdr_long(); /* beginoff */
off = getxdr_long();
(void) getxdr_long(); /* totalcount */
sz = getxdr_long();
break;
case NFSPROC_RENAME:
fh,
fh,
break;
case NFSPROC_LINK:
fh,
break;
case NFSPROC_SYMLINK:
fh,
break;
case NFSPROC_READDIR:
fh, getxdr_u_long());
break;
case NFSPROC_READ:
off = getxdr_long();
sz = getxdr_long();
break;
default:
break;
}
} else {
switch (proc) {
case NFSPROC_CREATE:
case NFSPROC_MKDIR:
case NFSPROC_LOOKUP:
if (sum_nfsstat(line) == 0) {
}
break;
case NFSPROC_READLINK:
if (sum_nfsstat(line) == 0) {
}
break;
case NFSPROC_GETATTR:
case NFSPROC_SYMLINK:
case NFSPROC_STATFS:
case NFSPROC_SETATTR:
case NFSPROC_REMOVE:
case NFSPROC_RMDIR:
case NFSPROC_WRITE:
case NFSPROC_RENAME:
case NFSPROC_LINK:
(void) sum_nfsstat(line);
break;
case NFSPROC_READDIR:
if (sum_nfsstat(line) == 0) {
}
break;
case NFSPROC_READ:
if (sum_nfsstat(line) == 0) {
getxdr_long());
}
break;
default:
break;
}
}
}
show_space();
else
show_trailer();
}
}
/*
* Print out version 2 NFS call packets
*/
static void
int proc;
{
switch (proc) {
case NFSPROC_GETATTR:
case NFSPROC_READLINK:
case NFSPROC_STATFS:
detail_nfsfh();
break;
case NFSPROC_SETATTR:
detail_nfsfh();
detail_sattr();
break;
case NFSPROC_LOOKUP:
case NFSPROC_REMOVE:
case NFSPROC_RMDIR:
break;
case NFSPROC_MKDIR:
case NFSPROC_CREATE:
detail_sattr();
break;
case NFSPROC_WRITE:
detail_nfsfh();
(void) getxdr_long(); /* begoff */
(void) showxdr_long("Offset = %d");
(void) getxdr_long(); /* totalcount */
(void) showxdr_long("(%d bytes(s) of data)");
break;
case NFSPROC_RENAME:
break;
case NFSPROC_LINK:
detail_nfsfh();
break;
case NFSPROC_SYMLINK:
detail_sattr();
break;
case NFSPROC_READDIR:
detail_nfsfh();
(void) showxdr_u_long("Cookie = %lu");
(void) showxdr_long("Count = %d");
break;
case NFSPROC_READ:
detail_nfsfh();
(void) showxdr_long("Offset = %d");
(void) showxdr_long("Count = %d");
break;
default:
break;
}
}
/*
* Print out version 2 NFS reply packets
*/
static void
int proc;
{
switch (proc) {
case NFSPROC_GETATTR:
case NFSPROC_SETATTR:
case NFSPROC_WRITE:
/* attrstat */
if (detail_nfsstat() == 0) {
detail_fattr();
}
break;
case NFSPROC_LOOKUP:
case NFSPROC_CREATE:
case NFSPROC_MKDIR:
/* diropres */
if (detail_nfsstat() == 0) {
detail_nfsfh();
detail_fattr();
}
break;
case NFSPROC_READLINK:
/* readlinkres */
if (detail_nfsstat() == 0) {
}
break;
case NFSPROC_READ:
/* readres */
if (detail_nfsstat() == 0) {
detail_fattr();
(void) showxdr_long("(%d byte(s) of data)");
}
break;
case NFSPROC_REMOVE:
case NFSPROC_RENAME:
case NFSPROC_LINK:
case NFSPROC_SYMLINK:
case NFSPROC_RMDIR:
/* stat */
break;
case NFSPROC_READDIR:
/* readdirres */
if (detail_nfsstat() == 0)
break;
case NFSPROC_STATFS:
/* statfsres */
if (detail_nfsstat() == 0) {
(void) showxdr_long("Transfer size = %d");
(void) showxdr_long("Block size = %d");
(void) showxdr_long("Total blocks = %d");
(void) showxdr_long("Free blocks = %d");
(void) showxdr_long("Available blocks = %d");
}
break;
default:
break;
}
}
static void
{
detail_nfsfh();
}
/*
* V2 NFS protocol was implicitly linked with SunOS errnos.
* Some of the errno values changed in SVr4.
* Need to map errno value so that SVr4 snoop will interpret
* them correctly.
*/
static char *
{
switch (status) {
case NFS_OK: return ("OK");
case NFSERR_PERM: return ("Not owner");
case NFSERR_NOENT: return ("No such file or directory");
case NFSERR_IO: return ("I/O error");
case NFSERR_NXIO: return ("No such device or address");
case NFSERR_ACCES: return ("Permission denied");
case NFSERR_EXIST: return ("File exists");
case NFSERR_XDEV: return ("Cross-device link");
case NFSERR_NODEV: return ("No such device");
case NFSERR_NOTDIR: return ("Not a directory");
case NFSERR_ISDIR: return ("Is a directory");
case NFSERR_INVAL: return ("Invalid argument");
case NFSERR_FBIG: return ("File too large");
case NFSERR_NOSPC: return ("No space left on device");
case NFSERR_ROFS: return ("Read-only file system");
case NFSERR_OPNOTSUPP: return ("Operation not supported");
case NFSERR_NAMETOOLONG: return ("File name too long");
case NFSERR_NOTEMPTY: return ("Directory not empty");
case NFSERR_DQUOT: return ("Disc quota exceeded");
case NFSERR_STALE: return ("Stale NFS file handle");
case NFSERR_REMOTE: return ("Object is remote");
case NFSERR_WFLUSH: return ("write cache flushed");
default: return ("(unknown error)");
}
/* NOTREACHED */
}
int
char *line;
{
status = getxdr_long();
return (status);
}
int
{
int pos;
pos = getxdr_pos();
status = getxdr_long();
"Status = %lu (%s)",
return ((int)status);
}
int
int len;
{
int i, l;
int fh = 0;
for (i = 0; i < len; i += 4) {
l = getxdr_long();
fh ^= (l >> 16) ^ l;
}
return (fh);
}
char *
{
int fh;
return (buff);
}
void
{
int pos;
int fh;
pos = getxdr_pos();
}
static void
int mode;
{
char *str;
default: str = "?"; break;
}
" Setuid = %d, Setgid = %d, Sticky = %d",
}
void
{
fltype = getxdr_long();
mode = getxdr_long();
nlinks = getxdr_long();
uid = getxdr_long();
gid = getxdr_long();
size = getxdr_long();
blksz = getxdr_long();
rdev = getxdr_long();
blocks = getxdr_long();
fsid = getxdr_long();
fileid = getxdr_long();
"File type = %d (%s)",
"Link count = %d, UID = %d, GID = %d, Rdev = 0x%x",
"File size = %d, Block size = %d, No. of blocks = %d",
"File system id = %d, File id = %d",
(void) showxdr_date("Access time = %s");
(void) showxdr_date("Modification time = %s");
(void) showxdr_date("Inode change time = %s");
}
static void
{
int mode;
mode = getxdr_long();
(void) showxdr_long("UID = %d");
(void) showxdr_long("GID = %d");
(void) showxdr_long("Size = %d");
(void) showxdr_date("Access time = %s");
(void) showxdr_date("Modification time = %s");
}
static char *
filetype(n)
int n;
{
switch (n) {
case NFREG: return ("Regular File");
case NFDIR: return ("Directory");
case NFBLK: return ("Block special");
case NFCHR: return ("Character special");
case NFLNK: return ("Symbolic Link");
default: return ("?");
}
}
static char *
perms(n)
int n;
{
return (buff);
}
static char *
{
int entries = 0;
return (buff);
}
while (getxdr_long()) {
entries++;
(void) getxdr_long(); /* fileid */
(void) getxdr_u_long(); /* cookie */
}
return (buff);
}
static void
{
int entries = 0;
char *name;
" %d+ entries. (Frame is incomplete)",
entries);
return;
}
while (getxdr_long()) {
entries++;
fileid = getxdr_long();
cookie = getxdr_u_long();
" %7lu %7lu %s",
}
(void) showxdr_long("EOF = %d");
}
void
{
}