/*
* 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 (c) 1991, 1999 by Sun Microsystems, Inc.
* All rights reserved.
*/
#ident "%Z%%M% %I% %E% SMI" /* SunOS */
#include <setjmp.h>
#include <string.h>
#include "snoop.h"
#include "snoop_nfs.h"
#include <rpcsvc/nfs_prot.h>
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
static void nfscall3(int);
static void nfsreply3(int);
static char *perms(int);
static char *filetype(int);
static char *sum_access(void);
static char *sum_readdirres(void);
static char *sum_readdirplusres(void);
static char *sum_createhow(void);
static char *sum_stablehow(void);
static void detail_sattr3(void);
static void detail_diropargs3(void);
static void detail_readdirres(void);
static void detail_readdirplusres(void);
static void detail_fattr3(void);
static void detail_access(void);
static void detail_mode(int);
static void detail_wcc_attr(void);
static void detail_pre_op_attr(char *);
static void detail_wcc_data(char *);
static void skip_postop(void);
static void skip_wcc_data(void);
static void skip_sattr3(void);
#define DONT_CHANGE 0
#define UNCHECKED 0
#define UNSTABLE 0
static char *procnames_short[] = {
"NULL3", /* 0 */
"GETATTR3", /* 1 */
"SETATTR3", /* 2 */
"LOOKUP3", /* 3 */
"ACCESS3", /* 4 */
"READLINK3", /* 5 */
"READ3", /* 6 */
"WRITE3", /* 7 */
"CREATE3", /* 8 */
"MKDIR3", /* 9 */
"SYMLINK3", /* 10 */
"MKNOD3", /* 11 */
"REMOVE3", /* 12 */
"RMDIR3", /* 13 */
"RENAME3", /* 14 */
"LINK3", /* 15 */
"READDIR3", /* 16 */
"READDIRPLUS3", /* 17 */
"FSSTAT3", /* 18 */
"FSINFO3", /* 19 */
"PATHCONF3", /* 20 */
"COMMIT3", /* 21 */
};
static char *procnames_long[] = {
"Null procedure", /* 0 */
"Get file attributes", /* 1 */
"Set file attributes", /* 2 */
"Look up file name", /* 3 */
"Check access permission", /* 4 */
"Read from symbolic link", /* 5 */
"Read from file", /* 6 */
"Write to file", /* 7 */
"Create file", /* 8 */
"Make directory", /* 9 */
"Make symbolic link", /* 10 */
"Make special file", /* 11 */
"Remove file", /* 12 */
"Remove directory", /* 13 */
"Rename", /* 14 */
"Link", /* 15 */
"Read from directory", /* 16 */
"Read from directory - plus", /* 17 */
"Get filesystem statistics", /* 18 */
"Get filesystem information", /* 19 */
"Get POSIX information", /* 20 */
"Commit to stable storage", /* 21 */
};
void
char *data;
int len;
{
char *line;
return;
line = get_sum_line();
switch (proc) {
case NFSPROC3_GETATTR:
case NFSPROC3_READLINK:
case NFSPROC3_FSSTAT:
case NFSPROC3_FSINFO:
case NFSPROC3_PATHCONF:
break;
case NFSPROC3_SETATTR:
break;
case NFSPROC3_READDIR:
fh = sum_nfsfh3();
off = getxdr_u_longlong();
(void) getxdr_u_longlong();
sz = getxdr_u_long();
break;
case NFSPROC3_READDIRPLUS:
fh = sum_nfsfh3();
off = getxdr_u_longlong();
(void) getxdr_u_longlong();
sz = getxdr_u_long();
"%s Cookie=%llu for %lu/%lu",
break;
case NFSPROC3_ACCESS:
fh = sum_nfsfh3();
fh, sum_access());
break;
case NFSPROC3_LOOKUP:
case NFSPROC3_REMOVE:
case NFSPROC3_RMDIR:
case NFSPROC3_MKDIR:
fh = sum_nfsfh3();
break;
case NFSPROC3_CREATE:
fh = sum_nfsfh3();
break;
case NFSPROC3_MKNOD:
fh = sum_nfsfh3();
how = getxdr_long();
break;
case NFSPROC3_READ:
fh = sum_nfsfh3();
off = getxdr_u_longlong();
sz = getxdr_u_long();
break;
case NFSPROC3_WRITE:
fh = sum_nfsfh3();
off = getxdr_u_longlong();
sz = getxdr_u_long();
break;
case NFSPROC3_SYMLINK:
fh = sum_nfsfh3();
skip_sattr3();
break;
case NFSPROC3_RENAME:
fh = sum_nfsfh3();
fh = sum_nfsfh3();
break;
case NFSPROC3_LINK:
fh = sum_nfsfh3();
fh = sum_nfsfh3();
break;
case NFSPROC3_COMMIT:
fh = sum_nfsfh3();
off = getxdr_u_longlong();
sz = getxdr_u_long();
break;
default:
break;
}
} else {
switch (proc) {
case NFSPROC3_LOOKUP:
break;
case NFSPROC3_CREATE:
case NFSPROC3_MKDIR:
case NFSPROC3_SYMLINK:
case NFSPROC3_MKNOD:
if (getxdr_bool())
sum_nfsfh3());
}
break;
case NFSPROC3_READLINK:
skip_postop();
}
break;
case NFSPROC3_GETATTR:
case NFSPROC3_SETATTR:
case NFSPROC3_REMOVE:
case NFSPROC3_RMDIR:
case NFSPROC3_RENAME:
case NFSPROC3_LINK:
case NFSPROC3_FSSTAT:
case NFSPROC3_FSINFO:
case NFSPROC3_PATHCONF:
(void) sum_nfsstat3(line);
break;
case NFSPROC3_ACCESS:
skip_postop();
sum_access());
}
break;
case NFSPROC3_WRITE:
sz = getxdr_u_long();
sz, sum_stablehow());
}
break;
case NFSPROC3_READDIR:
break;
case NFSPROC3_READ:
skip_postop();
getxdr_u_long());
if (getxdr_bool())
}
break;
case NFSPROC3_READDIRPLUS:
break;
case NFSPROC3_COMMIT:
(void) sum_nfsstat3(line);
break;
default:
break;
}
}
}
show_space();
else
show_trailer();
}
}
/*
* Print out version 3 NFS call packets
*/
static void
int proc;
{
int h;
switch (proc) {
case NFSPROC3_GETATTR:
case NFSPROC3_READLINK:
case NFSPROC3_FSINFO:
case NFSPROC3_FSSTAT:
case NFSPROC3_PATHCONF:
break;
case NFSPROC3_SETATTR:
if (getxdr_bool())
(void) showxdr_date_ns("Guard = %s");
break;
case NFSPROC3_LOOKUP:
case NFSPROC3_REMOVE:
case NFSPROC3_RMDIR:
break;
case NFSPROC3_ACCESS:
break;
case NFSPROC3_MKDIR:
break;
case NFSPROC3_CREATE:
h = getxdr_u_long();
if (h == EXCLUSIVE)
else {
}
break;
case NFSPROC3_MKNOD:
h = getxdr_u_long();
filetype(h));
switch (h) {
case NF3CHR:
case NF3BLK:
showxdr_u_long("Major = %lu");
showxdr_u_long("Minor = %lu");
break;
case NF3SOCK:
case NF3FIFO:
break;
}
break;
case NFSPROC3_WRITE:
(void) showxdr_u_longlong("Offset = %llu");
(void) showxdr_u_long("Size = %lu");
sum_stablehow());
break;
case NFSPROC3_RENAME:
break;
case NFSPROC3_LINK:
break;
case NFSPROC3_SYMLINK:
break;
case NFSPROC3_READDIR:
(void) showxdr_u_longlong("Cookie = %llu");
(void) showxdr_u_long("Count = %lu");
break;
case NFSPROC3_READDIRPLUS:
(void) showxdr_u_longlong("Cookie = %llu");
(void) showxdr_u_long("Dircount = %lu");
(void) showxdr_u_long("Maxcount = %lu");
break;
case NFSPROC3_READ:
case NFSPROC3_COMMIT:
(void) showxdr_u_longlong("Offset = %llu");
(void) showxdr_long("Count = %lu");
break;
default:
break;
}
}
/*
* Print out version 3 NFS reply packets
*/
static void
int proc;
{
int bits;
switch (proc) {
case NFSPROC3_GETATTR:
if (detail_nfsstat3() == NFS3_OK) {
}
break;
case NFSPROC3_SETATTR:
(void) detail_nfsstat3();
detail_wcc_data("");
break;
case NFSPROC3_WRITE:
if (detail_nfsstat3() == NFS3_OK) {
detail_wcc_data("");
(void) showxdr_u_long("Count = %lu bytes written");
sum_stablehow());
} else
detail_wcc_data("");
break;
case NFSPROC3_LOOKUP:
if (detail_nfsstat3() == NFS3_OK) {
detail_post_op_attr("(object)");
}
detail_post_op_attr("(directory)");
break;
case NFSPROC3_CREATE:
case NFSPROC3_MKDIR:
case NFSPROC3_SYMLINK:
case NFSPROC3_MKNOD:
if (detail_nfsstat3() == NFS3_OK) {
if (getxdr_bool())
else
"(No file handle available)");
detail_post_op_attr("");
}
detail_wcc_data("");
break;
case NFSPROC3_READLINK:
if (detail_nfsstat3() == NFS3_OK) {
detail_post_op_attr("");
} else
detail_post_op_attr("");
break;
case NFSPROC3_READ:
if (detail_nfsstat3() == NFS3_OK) {
detail_post_op_attr("");
(void) showxdr_u_long("Count = %lu bytes read");
(void) showxdr_bool("End of file = %s");
} else
detail_post_op_attr("");
break;
case NFSPROC3_ACCESS:
if (detail_nfsstat3() == NFS3_OK) {
detail_post_op_attr("");
sum_access());
} else
detail_post_op_attr("");
break;
case NFSPROC3_REMOVE:
case NFSPROC3_RMDIR:
(void) detail_nfsstat3();
detail_wcc_data("");
break;
case NFSPROC3_RENAME:
(void) detail_nfsstat3();
detail_wcc_data("(from directory)");
detail_wcc_data("(to directory)");
break;
case NFSPROC3_LINK:
(void) detail_nfsstat3();
detail_post_op_attr("");
detail_wcc_data("");
break;
case NFSPROC3_READDIR:
if (detail_nfsstat3() == NFS3_OK) {
} else
detail_post_op_attr("");
break;
case NFSPROC3_READDIRPLUS:
if (detail_nfsstat3() == NFS3_OK) {
} else
detail_post_op_attr("");
break;
case NFSPROC3_FSSTAT:
if (detail_nfsstat3() == NFS3_OK) {
detail_post_op_attr("");
(void) showxdr_u_longlong(
"Total space = %llu bytes");
(void) showxdr_u_longlong(
"Available space = %llu bytes");
(void) showxdr_u_longlong(
"Available space - this user = %llu bytes");
(void) showxdr_u_longlong(
"Total file slots = %llu");
(void) showxdr_u_longlong(
"Available file slots = %llu");
(void) showxdr_u_longlong(
"Available file slots - this user = %llu");
(void) showxdr_u_long("Invariant time = %lu sec");
} else
detail_post_op_attr("");
break;
case NFSPROC3_FSINFO:
if (detail_nfsstat3() == NFS3_OK) {
detail_post_op_attr("");
(void) show_line("Read transfer sizes:");
(void) showxdr_u_long(" Maximum = %lu bytes");
(void) showxdr_u_long(" Preferred = %lu bytes");
(void) showxdr_u_long(
" Suggested multiple = %lu bytes");
(void) show_line("Write transfer sizes:");
(void) showxdr_u_long(" Maximum = %lu bytes");
(void) showxdr_u_long(" Preferred = %lu bytes");
(void) showxdr_u_long(
" Suggested multiple = %lu bytes");
(void) show_line("Directory read size:");
(void) showxdr_u_long(" Preferred = %lu bytes");
(void) show_line("File system limits:");
(void) showxdr_u_longlong(
" Max file size = %llu bytes");
(void) showxdr_date_ns(
" Server minimum time discrimination = %s sec");
"Hard links supported",
"(hard links not supported)"));
"Symbolic links supported",
"(symbolic links not supported)"));
"Pathconf cannot vary per file",
"(pathconf can vary per file)"));
"Server can always set file times",
"(server cannot always set file times)"));
} else
detail_post_op_attr("");
break;
case NFSPROC3_PATHCONF:
if (detail_nfsstat3() == NFS3_OK) {
detail_post_op_attr("");
(void) showxdr_u_long("Link max = %lu");
(void) showxdr_u_long("Name max = %lu");
(void) showxdr_bool("No trunc = %s");
(void) showxdr_bool("Chown restricted = %s");
(void) showxdr_bool("Case insensitive = %s");
(void) showxdr_bool("Case preserving = %s");
} else
detail_post_op_attr("");
break;
case NFSPROC3_COMMIT:
if (detail_nfsstat3() == NFS3_OK) {
detail_wcc_data("");
} else
detail_wcc_data("");
break;
default:
break;
}
}
static void
{
}
int
char *line;
{
char *p;
status = getxdr_long();
switch (status) {
case NFS3_OK: p = "OK"; break;
case NFS3ERR_PERM: p = "Not owner"; break;
case NFS3ERR_NOENT: p = "No such file or directory"; break;
case NFS3ERR_IO: p = "I/O error"; break;
case NFS3ERR_NXIO: p = "No such device or address"; break;
case NFS3ERR_ACCES: p = "Permission denied"; break;
case NFS3ERR_EXIST: p = "File exists"; break;
case NFS3ERR_XDEV: p = "Attempted cross-device link"; break;
case NFS3ERR_NODEV: p = "No such device"; break;
case NFS3ERR_NOTDIR: p = "Not a directory"; break;
case NFS3ERR_ISDIR: p = "Is a directory"; break;
case NFS3ERR_INVAL: p = "Invalid argument"; break;
case NFS3ERR_FBIG: p = "File too large"; break;
case NFS3ERR_NOSPC: p = "No space left on device"; break;
case NFS3ERR_ROFS: p = "Read-only file system"; break;
case NFS3ERR_MLINK: p = "Too many links"; break;
case NFS3ERR_NAMETOOLONG:p = "File name too long"; break;
case NFS3ERR_NOTEMPTY: p = "Directory not empty"; break;
case NFS3ERR_DQUOT: p = "Disc quota exceeded"; break;
case NFS3ERR_STALE: p = "Stale NFS file handle"; break;
case NFS3ERR_REMOTE: p = "Too many levels of remote in path"; break;
case NFS3ERR_BADHANDLE: p = "Illegal NFS file handle"; break;
case NFS3ERR_NOT_SYNC: p = "Update synch mismatch"; break;
case NFS3ERR_BAD_COOKIE:p = "Readdir cookie is stale"; break;
case NFS3ERR_NOTSUPP: p = "Operation not supported"; break;
case NFS3ERR_TOOSMALL: p = "Buffer/request too small"; break;
case NFS3ERR_SERVERFAULT:p = "Server fault"; break;
case NFS3ERR_BADTYPE: p = "Bad type"; break;
case NFS3ERR_JUKEBOX: p = "File is temporarily unavailable"; break;
default: p = "(unknown error)"; break;
}
return (status);
}
int
{
int pos;
pos = getxdr_pos();
return ((int)status);
}
static void
{
if (getxdr_bool())
}
static void
{
if (getxdr_bool() > 0)
skip_postop();
}
static void
{
if (getxdr_bool() > 0)
if (getxdr_bool() > 0)
if (getxdr_bool() > 0)
if (getxdr_bool() > 0)
if (getxdr_bool() > 0)
if (getxdr_bool() > 0)
}
char *
{
int len;
int fh;
len = getxdr_long();
return (buff);
}
void
{
int pos;
int i, l, len;
int fh;
len = getxdr_long();
pos = getxdr_pos();
i = 0;
while (i < len) {
(void) showxdr_hex(l, " %s");
i += l;
}
}
static char *
{
int bits;
bits = getxdr_u_long();
buff[0] = '\0';
if (bits & ACCESS3_READ)
if (bits & ACCESS3_LOOKUP)
if (bits & ACCESS3_MODIFY)
if (bits & ACCESS3_EXTEND)
if (bits & ACCESS3_DELETE)
if (bits & ACCESS3_EXECUTE)
if (buff[0] != '\0')
return (buff);
}
static void
{
}
static void
int mode;
{
" Setuid = %d, Setgid = %d, Sticky = %d",
}
static void
{
fltype = getxdr_u_long();
mode = getxdr_u_long();
nlinks = getxdr_u_long();
uid = getxdr_u_long();
gid = getxdr_u_long();
size = getxdr_u_longlong();
used = getxdr_u_longlong();
major = getxdr_u_long();
minor = getxdr_u_long();
fsid = getxdr_u_longlong();
fileid = getxdr_u_longlong();
" File type = %d (%s)",
" Link count = %u, User ID = %u, Group ID = %u",
" File size = %llu, Used = %llu",
" Special: Major = %u, Minor = %u",
" File system id = %llu, File id = %llu",
(void) showxdr_date_ns(" Last access time = %s");
(void) showxdr_date_ns(" Modification time = %s");
(void) showxdr_date_ns(" Attribute change time = %s");
(void) show_line("");
}
static void
{
int t;
if (getxdr_bool())
else
if (getxdr_bool())
(void) showxdr_long("User ID = %d");
else
if (getxdr_bool())
(void) showxdr_long("Group ID = %d");
else
if (getxdr_bool())
(void) showxdr_u_longlong("Size = %llu");
else
if ((t = getxdr_u_long()) == SET_TO_CLIENT_TIME)
(void) showxdr_date("Access time = %s (set to client time)");
else if (t == SET_TO_SERVER_TIME)
"Access time = (set to server time)");
else
if ((t = getxdr_u_long()) == SET_TO_CLIENT_TIME) {
(void) showxdr_date(
"Modification time = %s (set to client time)");
} else if (t == SET_TO_SERVER_TIME)
"Modification time = (set to server time)");
else
"Modification time = (do not set)");
(void) show_line("");
}
static char *
filetype(n)
int n;
{
switch (n) {
case NF3REG:
return ("Regular File");
case NF3DIR:
return ("Directory");
case NF3BLK:
return ("Block special");
case NF3CHR:
return ("Character special");
case NF3LNK:
return ("Symbolic Link");
case NF3SOCK:
return ("Unix domain socket");
case NF3FIFO:
return ("Named pipe");
default:
return ("?");
}
/* NOTREACHED */
}
static char *
perms(n)
int n;
{
return (buff);
}
static void
{
(void) showxdr_u_longlong(" Size = %llu bytes");
(void) showxdr_date_ns(" Modification time = %s");
(void) showxdr_date_ns(" Attribute change time = %s");
(void) show_line("");
}
static void
char *str;
{
if (getxdr_bool()) {
"Pre-operation attributes: %s", str);
} else
"Pre-operation attributes: %s (not available)", str);
}
void
char *str;
{
if (getxdr_bool()) {
"Post-operation attributes: %s", str);
} else
"Post-operation attributes: %s (not available)", str);
}
static void
char *str;
{
}
static char *
{
static int entries;
entries = 0;
return (buff);
}
skip_postop();
while (getxdr_bool()) {
entries++;
}
return (buff);
}
static char *
{
static int entries;
int skip;
entries = 0;
return (buff);
}
skip_postop();
while (getxdr_bool()) {
entries++;
skip_postop(); /* post-op */
if (getxdr_bool()) {
skip = getxdr_long();
}
}
return (buff);
}
static void
{
static int entries;
char *name;
entries = 0;
detail_post_op_attr("");
(void) show_line("");
" %d+ entries. (Frame is incomplete)",
entries);
return;
}
while (getxdr_bool()) {
entries++;
fileid = getxdr_u_longlong();
cookie = getxdr_u_longlong();
" %10llu %10llu %s",
}
(void) showxdr_bool("EOF = %s");
}
static void
{
static int entries;
entries = 0;
detail_post_op_attr("");
(void) show_line("");
" %d+ entries. (Frame is incomplete)",
entries);
return;
}
while (getxdr_bool()) {
entries++;
"------------------ entry #%d",
entries);
(void) showxdr_u_longlong("File ID = %llu");
(void) showxdr_u_longlong("Cookie = %llu");
detail_post_op_attr("");
if (getxdr_bool())
else
"(No file handle available)");
}
(void) show_line("");
(void) showxdr_bool("EOF = %s");
}
static char *
{
long how;
how = getxdr_long();
switch (how) {
case UNCHECKED:
return ("UNCHECKED");
case GUARDED:
return ("GUARDED");
case EXCLUSIVE:
return ("EXCLUSIVE");
default:
return ("?");
}
/* NOTREACHED */
}
static char *
{
long stable;
stable = getxdr_long();
switch (stable) {
case UNSTABLE:
return ("ASYNC");
case DATA_SYNC:
return ("DSYNC");
case FILE_SYNC:
return ("FSYNC");
default:
return ("?");
}
/* NOTREACHED */
}