/*
* 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) 1999 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <errno.h>
#include <malloc.h>
#include <strings.h>
#include <stddef.h>
#include <search.h>
#include <syslog.h>
#include <libintl.h>
#include <unistd.h>
#include <netconfig.h>
#include <netdir.h>
#include <assert.h>
#include "fhtab.h"
#include "nfslogd.h"
/*
* How long should an entry stay in the list before being forced
* out and a trans log entry printed
*/
extern char *addrtoname(void *);
struct transentry {
/*
* Action taken by server before transfer was made -- noaction,
* compressed, tar or uncompressed.
*/
#define TRANS_OPTION_NOACTION 0
char *pathname;
int nfsvers;
char *netid;
char *principal_name;
union {
} fh_u;
};
struct nfslog_trans_file {
/* timestamp of the last transaction processed for this file */
/* 'current' time that last trans was processed */
};
static void nfslog_print_trans_logentry(struct transentry *,
struct nfslog_trans_file *);
static struct netbuf *
{
return (NULL);
return (NULL);
}
return (pnewnb);
}
static void
{
}
static struct transentry *
{
/* failure message or action */
return (NULL);
}
return (pte);
}
static struct transentry *
struct transentry *te_list,
struct transentry *entry)
{
/*
* First check for any non-filehandle comparisons that may be needed.
*/
case TRANS_OPER_REMOVE:
case TRANS_OPER_RENAME:
/* if path names match, then return */
return (pte);
}
}
return (NULL);
default:
break;
}
/* If the file handles match, then we have a hit */
sizeof (fhandle_t)) == 0) {
case TRANS_OPER_READ:
case TRANS_OPER_WRITE:
return (pte);
}
break;
default:
return (pte);
}
}
} else {
case TRANS_OPER_READ:
case TRANS_OPER_WRITE:
return (pte);
}
break;
default:
return (pte);
}
}
}
/*
* XXX - should compare more of the information to make sure
* it is a match.
*/
/*
* other operation types do not generate an entry for
* further analysis
*/
case TRANS_OPER_READ:
case TRANS_OPER_WRITE:
break;
default:
return (NULL);
}
return (NULL); /* NULL signifies insertion and no record found */
}
static void
{
}
/*
* nfslog_trans_file_free - frees a record
*/
static void
{
return;
if (debug)
(void) printf("freeing transpath '%s'\n",
}
}
/*
* On success returns a pointer to the trans_file that matches
* 'path', 'output_type' and 'transtolog'. The reference count for this
* object is incremented as well.
* Returns NULL if it is not in the list.
*/
static struct nfslog_trans_file *
char *path,
{
if (debug)
return (tfp);
}
}
return (NULL);
}
/*
* nfslog_close_trans_file - decrements the reference count on
* this object. On last reference it closes transfile and
* frees resources
*/
static void
{
return;
}
}
/*
* Disconnect from list
*/
/*
* Adjust the head of the list if appropriate
*/
if (tf == trans_file_head)
}
/*
* nfslog_open_trans_file - open the output trans file and mallocs.
* The object is then inserted at the beginning of the global
* transfile list.
* Returns 0 for success, error else.
*
* *error contains the last error encountered on this object. It can
* be used to avoid reporting the same error endlessly, by comparing
* the current error to the last error. It is reset to the current error
* code on return.
*/
void *
char *transpath,
int *error)
{
return (transrec);
}
return (NULL);
}
}
return (NULL);
}
}
return (NULL);
}
if (transrec->te_list_v3_read)
if (transrec->te_list_v3_write)
if (transrec->te_list_v2_read)
if (transrec->te_list_v2_write)
return (NULL);
}
/*
* Indicate what transaction types to log
*/
/*
* Indicate whether to print 'full' or 'basic' version
* of the transactions
*/
/*
* Insert at the beginning of the list.
*/
if (trans_file_head != NULL)
if (debug)
return (transrec);
}
void
struct nfslog_trans_file *tf,
{
/*
* If we have not seen a transaction on this file for
* a long time, then we need to flush everything out since
* we may not be getting anything else in for awhile.
*/
force_flush = TRUE;
if (force_flush == TRUE ||
goto restart1;
}
}
if (force_flush == TRUE ||
goto restart2;
}
}
if (force_flush == TRUE ||
goto restart3;
}
}
if (force_flush == TRUE ||
goto restart4;
}
}
}
/*
* Flushes outstanding transactions to disk, and closes
* the transaction log.
*/
void
{
*transcookie = NULL;
}
static struct transentry *
struct nfslog_trans_file *tf,
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
} else {
}
/* prep the struct for insertion */
if (logrec->re_principal_name)
else
/* free this since entry was found (not inserted) */
pte->totalbytes +=
pte->lastupdate =
if (pte->totalbytes <
}
}
} else {
}
return (pte);
}
static struct transentry *
struct nfslog_trans_file *tf,
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
} else {
}
if (logrec->re_principal_name)
else
/*
* if the write would have increased the total byte count
* over the filesize, then generate a log entry and remove
* the write record and insert the new one.
*/
} else {
/* free this since entry was found (not inserted) */
pte->lastupdate =
}
}
}
return (pte);
}
static struct transentry *
struct nfslog_trans_file *tf,
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
/*
* should check the size of the file to see if it
* is being truncated below current eof. if so
* a record should be generated.... XXX
*/
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_setattr2");
} else {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
}
}
return (newte);
}
static struct transentry *
struct nfslog_trans_file *tf,
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_create2");
} else {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
else
/*
* if the file is being truncated on create, we need to flush
*/
}
}
}
return (newte);
}
static struct transentry *
struct nfslog_trans_file *tf,
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_remove2");
} else {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
}
}
}
}
return (newte);
}
static struct transentry *
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_mkdir2");
} else {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
return (newte);
}
static struct transentry *
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_rmdir2");
} else {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
return (newte);
}
static struct transentry *
struct nfslog_trans_file *tf,
char *fhpath,
char *path1,
char *path2)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_rename from");
fhpath, "trans_rename to");
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
/* switch path names for the file for renames */
}
}
}
}
/* check for NULL malloc */
if (tpath1) {
}
return (newte);
}
static struct transentry *
char *fhpath,
char *path1,
char *path2)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_link from");
fhpath, "trans_link to");
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
/* check for NULL malloc */
if (tpath1) {
}
return (newte);
}
static struct transentry *
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_symlink");
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
if (tpath1)
return (newte);
}
static struct transentry *
struct nfslog_trans_file *tf,
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_read3");
} else {
}
/* prep the struct for insertion */
if (logrec->re_principal_name)
else
/* free this since entry was found (not inserted) */
pte->lastupdate =
if (pte->totalbytes <
}
}
} else {
}
return (pte);
}
static struct transentry *
struct nfslog_trans_file *tf,
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_write3");
} else {
}
if (logrec->re_principal_name)
else
/*
* if the write would have increased the total byte count
* over the filesize, then generate a log entry and remove
* the write record and insert the new one.
*/
} else {
/* free this since entry was found (not inserted) */
pte->lastupdate =
}
}
}
return (pte);
}
static struct transentry *
struct nfslog_trans_file *tf,
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
/*
* should check the size of the file to see if it
* is being truncated below current eof. if so
* a record should be generated.... XXX
*/
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_setattr3");
} else {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
}
}
return (newte);
}
static struct transentry *
struct nfslog_trans_file *tf,
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_create3");
} else {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
else
newte->totalbytes =
}
}
}
return (newte);
}
static struct transentry *
struct nfslog_trans_file *tf,
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_remove3");
} else {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
}
}
}
}
return (newte);
}
static struct transentry *
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_mkdir3");
} else {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
return (newte);
}
static struct transentry *
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_rmdir3");
} else {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
return (newte);
}
static struct transentry *
struct nfslog_trans_file *tf,
char *fhpath,
char *path1,
char *path2)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
/* switch path names for the file for renames */
}
}
}
}
/* check for NULL malloc */
if (tpath1) {
}
return (newte);
}
static struct transentry *
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
fhpath, "trans_mknod3");
} else {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
return (newte);
}
static struct transentry *
char *fhpath,
char *path1,
char *path2)
{
/* LINTED */
/* LINTED */
return (NULL);
return (NULL);
if (!path1) {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
/* check for NULL malloc */
if (tpath1) {
}
return (newte);
}
static struct transentry *
char *fhpath,
char *path1)
{
/* LINTED */
/* LINTED */
char *name;
return (NULL);
return (NULL);
if (path1) {
} else {
}
if (logrec->re_principal_name)
else
newte->totalbytes = 0;
/* check for NULL malloc */
return (newte);
}
/*
* nfslog_process_trans_rec - processes the record in the buffer and outputs
* to the trans log.
* Return 0 for success, errno else.
*/
int
{
/* ignore programs other than nfs */
return (0);
/* update the timestamp for use later in the timeout sequences */
/* current time of this processing */
/* ignore anything that is not a read or write */
case NFS_VERSION:
case RFS_READ:
break;
case RFS_WRITE:
break;
case RFS_SETATTR:
break;
case RFS_REMOVE:
break;
case RFS_MKDIR:
break;
case RFS_RMDIR:
break;
case RFS_CREATE:
break;
case RFS_RENAME:
break;
case RFS_LINK:
break;
case RFS_SYMLINK:
break;
default:
break;
}
break;
case NFS_V3:
case NFSPROC3_READ:
break;
case NFSPROC3_WRITE:
break;
case NFSPROC3_SETATTR:
break;
case NFSPROC3_REMOVE:
break;
case NFSPROC3_MKDIR:
break;
case NFSPROC3_RMDIR:
break;
case NFSPROC3_CREATE:
break;
case NFSPROC3_RENAME:
break;
case NFSPROC3_MKNOD:
break;
case NFSPROC3_LINK:
break;
case NFSPROC3_SYMLINK:
break;
default:
break;
}
break;
default:
break;
}
}
return (0);
}
static void
struct nfslog_trans_file *tf)
{
char *remotehost;
char datatype;
char transoption;
char *optype;
char *prin;
int prinid;
} else {
}
case TRANS_OPER_READ:
"read" : "o");
break;
case TRANS_OPER_WRITE:
"write" : "i");
break;
case TRANS_OPER_REMOVE:
"remove" : "?");
break;
case TRANS_OPER_MKDIR:
"mkdir" : "?");
break;
case TRANS_OPER_CREATE:
"create" : "?");
break;
case TRANS_OPER_RMDIR:
"rmdir" : "?");
break;
case TRANS_OPER_SETATTR:
"setattr" : "?");
break;
case TRANS_OPER_RENAME:
"rename" : "?");
break;
case TRANS_OPER_MKNOD:
"mknod" : "?");
break;
case TRANS_OPER_LINK:
"link" : "?");
break;
case TRANS_OPER_SYMLINK:
"symlink" : "?");
break;
default:
optype = "?";
break;
}
prinid = 0;
prin = "*";
} else {
prinid = 1;
}
"%.24s %d %s %d %s %c %c %s %c %ld %s %d %s\n",
'r', /* anonymous == 'a', guest == 'g', real == 'r'), */
/* authenticated ? authuser : "*" */
prin);
}