Blame tests/LTnfs.c

Packit Service 603f59
/*
Packit Service 603f59
 * LTnfs.c -- Lsof Test NFS tests
Packit Service 603f59
 *
Packit Service 603f59
 * V. Abell
Packit Service 603f59
 * Purdue University
Packit Service 603f59
 */
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/*
Packit Service 603f59
 * Copyright 2002 Purdue Research Foundation, West Lafayette, Indiana
Packit Service 603f59
 * 47907.  All rights reserved.
Packit Service 603f59
 *
Packit Service 603f59
 * Written by V. Abell.
Packit Service 603f59
 *
Packit Service 603f59
 * This software is not subject to any license of the American Telephone
Packit Service 603f59
 * and Telegraph Company or the Regents of the University of California.
Packit Service 603f59
 *
Packit Service 603f59
 * Permission is granted to anyone to use this software for any purpose on
Packit Service 603f59
 * any computer system, and to alter it and redistribute it freely, subject
Packit Service 603f59
 * to the following restrictions:
Packit Service 603f59
 *
Packit Service 603f59
 * 1. Neither the authors nor Purdue University are responsible for any
Packit Service 603f59
 *    consequences of the use of this software.
Packit Service 603f59
 *
Packit Service 603f59
 * 2. The origin of this software must not be misrepresented, either by
Packit Service 603f59
 *    explicit claim or by omission.  Credit to the authors and Purdue
Packit Service 603f59
 *    University must appear in documentation and sources.
Packit Service 603f59
 *
Packit Service 603f59
 * 3. Altered versions must be plainly marked as such, and must not be
Packit Service 603f59
 *    misrepresented as being the original software.
Packit Service 603f59
 *
Packit Service 603f59
 * 4. This notice may not be removed or altered.
Packit Service 603f59
 */
Packit Service 603f59
Packit Service 603f59
#ifndef lint
Packit Service 603f59
static char copyright[] =
Packit Service 603f59
"@(#) Copyright 2002 Purdue Research Foundation.\nAll rights reserved.\n";
Packit Service 603f59
#endif
Packit Service 603f59
Packit Service 603f59
#include "LsofTest.h"
Packit Service 603f59
#include "lsof_fields.h"
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/*
Packit Service 603f59
 * Pre-definitions that may be revoked by specific dialects
Packit Service 603f59
 */
Packit Service 603f59
Packit Service 603f59
#define	DO_TEST				/* do the test */
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
#if	defined(LT_DIAL_darwin)
Packit Service 603f59
/*
Packit Service 603f59
 * Darwin-specific items
Packit Service 603f59
 */
Packit Service 603f59
Packit Service 603f59
# if LT_VERS<800
Packit Service 603f59
#undef	DO_TEST
Packit Service 603f59
# endif	/* LT_VERS<800 */
Packit Service 603f59
#endif	/* defined(LT_DIAL_darwin) */
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/*
Packit Service 603f59
 * Globals
Packit Service 603f59
 */
Packit Service 603f59
Packit Service 603f59
int Fd = -1;			/* test file descriptor; open if >= 0 */
Packit Service 603f59
pid_t MyPid = (pid_t)0;		/* PID of this process */
Packit Service 603f59
int NFstat = 0;			/* NFS file status: 0 == closed
Packit Service 603f59
				 *		    1 == not created by this
Packit Service 603f59
				 *			 these and must not be
Packit Service 603f59
				 *			 unlinked
Packit Service 603f59
				 *		    2 == created by this test
Packit Service 603f59
				 *			 and must be unlinked
Packit Service 603f59
				 */
Packit Service 603f59
char *Path = (char *)NULL;	/* test file path; none if NULL */
Packit Service 603f59
char *Pn = (char *)NULL;	/* program name */
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/*
Packit Service 603f59
 * Local function prototypes
Packit Service 603f59
 */
Packit Service 603f59
Packit Service 603f59
_PROTOTYPE(static void cleanup,(void));
Packit Service 603f59
_PROTOTYPE(static char *FindNFSfile,(int *ff, char *szbuf));
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/*
Packit Service 603f59
 * Main program
Packit Service 603f59
 */
Packit Service 603f59
Packit Service 603f59
int
Packit Service 603f59
main(argc, argv)
Packit Service 603f59
    int argc;				/* argument count */
Packit Service 603f59
    char *argv[];			/* arguments */
Packit Service 603f59
{
Packit Service 603f59
    char buf[2048];			/* temporary buffer */
Packit Service 603f59
    char *em;				/* error message pointer */
Packit Service 603f59
    int ff;				/* FindNFSfile() file-found flag */
Packit Service 603f59
    int sz;				/* file size (if created) */
Packit Service 603f59
    char szbuf[32];			/* created test file size in ASCII */
Packit Service 603f59
    int ti;				/* temporary index */
Packit Service 603f59
    int xv = 0;				/* exit value */
Packit Service 603f59
/*
Packit Service 603f59
 * Get program name and PID, issue start message, and build space prefix.
Packit Service 603f59
 */
Packit Service 603f59
    if ((Pn = strrchr(argv[0], '/')))
Packit Service 603f59
	Pn++;
Packit Service 603f59
    else
Packit Service 603f59
	Pn = argv[0];
Packit Service 603f59
    MyPid = getpid();
Packit Service 603f59
    (void) printf("%s ... ", Pn);
Packit Service 603f59
    (void) fflush(stdout);
Packit Service 603f59
    PrtMsg((char *)NULL, Pn);
Packit Service 603f59
Packit Service 603f59
#if	!defined(DO_TEST)
Packit Service 603f59
/*
Packit Service 603f59
 * If the dialect has disabled the test, echo that result and exit with
Packit Service 603f59
 * a successful return code.
Packit Service 603f59
 */
Packit Service 603f59
    (void) PrtMsgX(LT_DONT_DO_TEST, Pn, cleanup, 0);
Packit Service 603f59
#endif	/* !defined(DO_TEST) */
Packit Service 603f59
Packit Service 603f59
/*
Packit Service 603f59
 * Process arguments.
Packit Service 603f59
 */
Packit Service 603f59
    if (ScanArg(argc, argv, "hp:", Pn))
Packit Service 603f59
	xv = 1;
Packit Service 603f59
    if (xv || LTopt_h) {
Packit Service 603f59
	(void) PrtMsg("usage: [-h] [-p path]", Pn);
Packit Service 603f59
	PrtMsg       ("       -h       print help (this panel)", Pn);
Packit Service 603f59
	PrtMsgX      ("       -p path  define test file path", Pn, cleanup, xv);
Packit Service 603f59
    }
Packit Service 603f59
/*
Packit Service 603f59
 * See if lsof can be executed and can access kernel memory.
Packit Service 603f59
 */
Packit Service 603f59
    if ((em = IsLsofExec()))
Packit Service 603f59
	(void) PrtMsgX(em, Pn, cleanup, 1);
Packit Service 603f59
    if ((em = CanRdKmem()))
Packit Service 603f59
	(void) PrtMsgX(em, Pn, cleanup, 1);
Packit Service 603f59
/*
Packit Service 603f59
 * Process the file path and open it.
Packit Service 603f59
 */
Packit Service 603f59
    if ((Path = LTopt_p)) {
Packit Service 603f59
Packit Service 603f59
    /*
Packit Service 603f59
     * The file path was supplied.  Open the file read-only.
Packit Service 603f59
     */
Packit Service 603f59
	if ((Fd = open(Path, O_RDONLY, 0400)) < 0) {
Packit Service 603f59
	    (void) fprintf(stderr, "ERROR!!!  can't read-only open %s\n",
Packit Service 603f59
		Path);
Packit Service 603f59
	    goto print_file_error;
Packit Service 603f59
	}
Packit Service 603f59
    /*
Packit Service 603f59
     * Record that an existing file is being used.  Clear its ASCII size.
Packit Service 603f59
     */
Packit Service 603f59
	NFstat = 1;
Packit Service 603f59
	szbuf[0] = '\0';
Packit Service 603f59
    } else {
Packit Service 603f59
Packit Service 603f59
    /*
Packit Service 603f59
     * The file path wasn't supplied with -p, so generate one.
Packit Service 603f59
     */
Packit Service 603f59
	(void) snprintf(buf, sizeof(buf) - 1, "./config.LTnfs%ld",
Packit Service 603f59
	    (long)MyPid);
Packit Service 603f59
	buf[sizeof(buf) - 1] = '\0';
Packit Service 603f59
	Path = MkStrCpy(buf, &ti);
Packit Service 603f59
    /*
Packit Service 603f59
     * Open a new test file at the specified path.
Packit Service 603f59
     */
Packit Service 603f59
	(void) unlink(Path);
Packit Service 603f59
	if ((Fd = open(Path, O_RDWR|O_CREAT, 0600)) < 0) {
Packit Service 603f59
	    (void) fprintf(stderr, "ERROR!!!  can't create %s\n", Path);
Packit Service 603f59
Packit Service 603f59
print_file_error:
Packit Service 603f59
Packit Service 603f59
	    MsgStat = 1;
Packit Service 603f59
	    (void) snprintf(buf, sizeof(buf) - 1, "      Errno %d: %s",
Packit Service 603f59
		errno, strerror(errno));
Packit Service 603f59
	    buf[sizeof(buf) - 1] = '\0';
Packit Service 603f59
	    (void) PrtMsgX(buf, Pn, cleanup, 1);
Packit Service 603f59
	}
Packit Service 603f59
	NFstat = 2;
Packit Service 603f59
    /*
Packit Service 603f59
     * Write the test file to its expected size.
Packit Service 603f59
     */
Packit Service 603f59
	sz = sizeof(buf);
Packit Service 603f59
	for (ti = 0; ti < sz; ti++) {
Packit Service 603f59
	    buf[ti] = (char)(ti & 0xff);
Packit Service 603f59
	}
Packit Service 603f59
	if (write(Fd, buf, sz) != sz) {
Packit Service 603f59
	    (void) fprintf(stderr, "ERROR!!!  can't write %d bytes to %s\n",
Packit Service 603f59
		sz, Path);
Packit Service 603f59
	    goto print_file_error;
Packit Service 603f59
	}
Packit Service 603f59
    /*
Packit Service 603f59
     * Fsync() the file.
Packit Service 603f59
     */
Packit Service 603f59
	if (fsync(Fd)) {
Packit Service 603f59
	    (void) fprintf(stderr, "ERROR!!!  can't fsync %s\n", Path);
Packit Service 603f59
	    goto print_file_error;
Packit Service 603f59
	}
Packit Service 603f59
   /*
Packit Service 603f59
    * Convert the file size to ASCII.
Packit Service 603f59
    */
Packit Service 603f59
	(void) snprintf(szbuf, sizeof(szbuf) - 1, "%d", sz);
Packit Service 603f59
	szbuf[sizeof(szbuf) - 1] = '\0';
Packit Service 603f59
    }
Packit Service 603f59
/*
Packit Service 603f59
 * Make sure the test file can be found on an NFS file system.
Packit Service 603f59
 */
Packit Service 603f59
    if ((em = FindNFSfile(&ff, szbuf))) {
Packit Service 603f59
Packit Service 603f59
    /*
Packit Service 603f59
     * Print the error message returned by FindNFSfile().
Packit Service 603f59
     */
Packit Service 603f59
	(void) PrtMsg(em, Pn);
Packit Service 603f59
	if (!ff) {
Packit Service 603f59
Packit Service 603f59
	/*
Packit Service 603f59
	 * If the file couldn't be found, print hints.
Packit Service 603f59
	 */
Packit Service 603f59
	    if (NFstat == 1) {
Packit Service 603f59
		(void) PrtMsg(
Packit Service 603f59
		    "Hint: this test must be able to open for read access",
Packit Service 603f59
		    Pn);
Packit Service 603f59
		(void) PrtMsg(
Packit Service 603f59
		    "the file at the path supplied with the -p option and",
Packit Service 603f59
		    Pn);
Packit Service 603f59
		(void) PrtMsg(
Packit Service 603f59
		    "that file must be a regular file (not a directory) on",
Packit Service 603f59
		    Pn);
Packit Service 603f59
		(void) PrtMsg(
Packit Service 603f59
		    "an NFS file system.\n",
Packit Service 603f59
		    Pn);
Packit Service 603f59
		(void) PrtMsgX(
Packit Service 603f59
		    "See 00FAQ and 00TEST for more information.",
Packit Service 603f59
		    Pn, cleanup, 1);
Packit Service 603f59
	    } else if (NFstat == 2) {
Packit Service 603f59
		(void) PrtMsg(
Packit Service 603f59
		    "Hint: the temporary path generated by this test might",
Packit Service 603f59
		    Pn);
Packit Service 603f59
		(void) PrtMsg(
Packit Service 603f59
		    "not be on an NFS file system, or this test might be",
Packit Service 603f59
		    Pn);
Packit Service 603f59
		(void) PrtMsg(
Packit Service 603f59
		    "unable to create a file on the NFS file system.\n",
Packit Service 603f59
		    Pn);
Packit Service 603f59
		(void) PrtMsg(
Packit Service 603f59
		    "As a work-around use the -p option to specify a path to",
Packit Service 603f59
		    Pn);
Packit Service 603f59
		(void) PrtMsg(
Packit Service 603f59
		    "a regular file (not a directory) on an NFS file system",
Packit Service 603f59
		    Pn);
Packit Service 603f59
		(void) PrtMsg(
Packit Service 603f59
		    "to which this test will have read access.\n",
Packit Service 603f59
		    Pn);
Packit Service 603f59
		(void) PrtMsgX(
Packit Service 603f59
		    "See 00FAQ and 00TEST for more information.",
Packit Service 603f59
		    Pn, cleanup, 1);
Packit Service 603f59
	    }
Packit Service 603f59
	}
Packit Service 603f59
    }
Packit Service 603f59
/*
Packit Service 603f59
 * Exit successfully.
Packit Service 603f59
 */
Packit Service 603f59
    (void) PrtMsgX("OK", Pn, cleanup, 0);
Packit Service 603f59
    return(0);
Packit Service 603f59
}
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/*
Packit Service 603f59
 * cleanup() -- release resources
Packit Service 603f59
 */
Packit Service 603f59
Packit Service 603f59
static void
Packit Service 603f59
cleanup()
Packit Service 603f59
{
Packit Service 603f59
    if (Fd >= 0) {
Packit Service 603f59
	(void) close(Fd);
Packit Service 603f59
	Fd = -1;
Packit Service 603f59
	if (Path) {
Packit Service 603f59
	    if (NFstat == 2)
Packit Service 603f59
		(void) unlink(Path);
Packit Service 603f59
	    Path = (char *)NULL;
Packit Service 603f59
	}
Packit Service 603f59
    }
Packit Service 603f59
}
Packit Service 603f59
Packit Service 603f59
Packit Service 603f59
/*
Packit Service 603f59
 * FindNFSfile() -- find the NFS file with lsof
Packit Service 603f59
 */
Packit Service 603f59
Packit Service 603f59
static char *
Packit Service 603f59
FindNFSfile(ff, szbuf)
Packit Service 603f59
    int *ff;				/* file-found response receptor */
Packit Service 603f59
    char *szbuf;			/* expected file size in ASCII (if
Packit Service 603f59
					 * the file was created by this test */
Packit Service 603f59
{
Packit Service 603f59
    char buf[2048];			/* temporary buffer */
Packit Service 603f59
    char *cem;				/* current error message pointer */
Packit Service 603f59
    LTfldo_t *cmdp;			/* command pointer */
Packit Service 603f59
    LTfldo_t *devp;			/* device pointer */
Packit Service 603f59
    LTfldo_t *fop;			/* field output pointer */
Packit Service 603f59
    char ibuf[64];			/* inode number buffer */
Packit Service 603f59
    LTfldo_t *inop;			/* inode number pointer */
Packit Service 603f59
    LTdev_t lsofdc;			/* lsof device components */
Packit Service 603f59
    int nf;				/* number of fields */
Packit Service 603f59
    char nlkbuf[32];			/* link count buffer */
Packit Service 603f59
    LTfldo_t *nlkp;			/* nlink pointer */
Packit Service 603f59
    char *opv[5];			/* option vector for ExecLsof() */
Packit Service 603f59
    char *pem = (char *)NULL;		/* previous error message pointer */
Packit Service 603f59
    pid_t pid;				/* PID */
Packit Service 603f59
    int pids = 0;			/* PID found status */
Packit Service 603f59
    struct stat sb;			/* stat(2) buffer */
Packit Service 603f59
    LTdev_t stdc;			/* stat(2) device components */
Packit Service 603f59
    LTfldo_t *szp;			/* size pointer */
Packit Service 603f59
    char *tcp;				/* temporary character pointer */
Packit Service 603f59
    int ti;				/* temporary integer */
Packit Service 603f59
    LTfldo_t *typ;			/* file type pointer */
Packit Service 603f59
/*
Packit Service 603f59
 * Check the argument pointers.
Packit Service 603f59
 *
Packit Service 603f59
 * Set the file-found response false.
Packit Service 603f59
 */
Packit Service 603f59
    if (!ff || !szbuf)
Packit Service 603f59
	(void) PrtMsgX("ERROR!!!  missing argument to FindNFSfile()",
Packit Service 603f59
		       Pn, cleanup, 1);
Packit Service 603f59
    *ff = 0;
Packit Service 603f59
/*
Packit Service 603f59
 * Get test file's information.
Packit Service 603f59
 */
Packit Service 603f59
    if (stat(Path, &sb)) {
Packit Service 603f59
	(void) snprintf(buf, sizeof(buf) - 1,
Packit Service 603f59
	    "ERROR!!!  can't stat(2) %s: %s", Path, strerror(errno));
Packit Service 603f59
	buf[sizeof(buf) - 1] = '\0';
Packit Service 603f59
	PrtMsgX(buf, Pn, cleanup, 1);
Packit Service 603f59
    }
Packit Service 603f59
/*
Packit Service 603f59
 * Extract components from test file's stat buffer.
Packit Service 603f59
 */
Packit Service 603f59
    if ((cem = ConvStatDev(&sb.st_dev, &stdc)))
Packit Service 603f59
	PrtMsgX(cem, Pn, cleanup, 1);
Packit Service 603f59
    (void) snprintf(ibuf, sizeof(ibuf) - 1, "%u", (unsigned int)sb.st_ino);
Packit Service 603f59
    ibuf[sizeof(ibuf) - 1] = '\0';
Packit Service 603f59
    (void) snprintf(nlkbuf, sizeof(nlkbuf) - 1, "%d", (int)sb.st_nlink);
Packit Service 603f59
    nlkbuf[sizeof(nlkbuf) - 1] = '\0';
Packit Service 603f59
/*
Packit Service 603f59
 * Complete the option vector and start lsof execution.
Packit Service 603f59
 */
Packit Service 603f59
    ti = 0;
Packit Service 603f59
    opv[ti++] = "-s";
Packit Service 603f59
    opv[ti++] = "-Na";
Packit Service 603f59
Packit Service 603f59
#if	defined(USE_LSOF_C_OPT)
Packit Service 603f59
    opv[ti++] = "-C";
Packit Service 603f59
#endif	/* defined(USE_LSOF_C_OPT) */
Packit Service 603f59
Packit Service 603f59
    opv[ti++] = Path;
Packit Service 603f59
    opv[ti] = (char *)NULL;
Packit Service 603f59
    if ((cem = ExecLsof(opv)))
Packit Service 603f59
	return(cem);
Packit Service 603f59
/*
Packit Service 603f59
 * Read lsof output.
Packit Service 603f59
 */
Packit Service 603f59
    while (!*ff && (fop = RdFrLsof(&nf, &cem))) {
Packit Service 603f59
	if (cem) {
Packit Service 603f59
	    if (pem)
Packit Service 603f59
		(void) PrtMsg(pem, Pn);
Packit Service 603f59
	    return(cem);
Packit Service 603f59
	}
Packit Service 603f59
	switch (fop->ft) {
Packit Service 603f59
	case LSOF_FID_PID:
Packit Service 603f59
Packit Service 603f59
	/*
Packit Service 603f59
	 * This is a process information line.
Packit Service 603f59
	 */
Packit Service 603f59
	    pid = (pid_t)atoi(fop->v);
Packit Service 603f59
	    pids = 1;
Packit Service 603f59
	    cmdp = (LTfldo_t *)NULL;
Packit Service 603f59
	    for (fop++, ti = 1; ti < nf; fop++, ti++) {
Packit Service 603f59
		switch (fop->ft) {
Packit Service 603f59
		case LSOF_FID_CMD:
Packit Service 603f59
		    cmdp = fop;
Packit Service 603f59
		    break;
Packit Service 603f59
		}
Packit Service 603f59
	    }
Packit Service 603f59
	    if (!cmdp || (pid != MyPid))
Packit Service 603f59
		pids = 0;
Packit Service 603f59
	    break;
Packit Service 603f59
	case LSOF_FID_FD:
Packit Service 603f59
Packit Service 603f59
	/*
Packit Service 603f59
	 * This is a file descriptor line.  Make sure its number matches the
Packit Service 603f59
	 * test file's descriptor number.
Packit Service 603f59
	 */
Packit Service 603f59
	    if (!pids)
Packit Service 603f59
		break;
Packit Service 603f59
	    for (ti = 0, tcp = fop->v; *tcp; tcp++) {
Packit Service 603f59
Packit Service 603f59
	    /*
Packit Service 603f59
	     * Convert file descriptor to a number.
Packit Service 603f59
	     */
Packit Service 603f59
		if (*tcp == ' ')
Packit Service 603f59
		    continue;
Packit Service 603f59
		if (((int)*tcp < (int)'0') || ((int)*tcp > (int)'9')) {
Packit Service 603f59
		    ti = -1;
Packit Service 603f59
		    break;
Packit Service 603f59
		}
Packit Service 603f59
		ti = (ti * 10) + (int)*tcp - (int)'0'; 
Packit Service 603f59
	    }
Packit Service 603f59
	    if (Fd != ti)
Packit Service 603f59
		break;
Packit Service 603f59
	/*
Packit Service 603f59
	 * Scan for device, inode, nlink, offset, size and type fields.
Packit Service 603f59
	 */
Packit Service 603f59
	    devp = inop = nlkp, szp = typ = (LTfldo_t *)NULL;
Packit Service 603f59
	    for (fop++, ti = 1; ti < nf; fop++, ti++) {
Packit Service 603f59
		switch (fop->ft) {
Packit Service 603f59
		case LSOF_FID_DEVN:
Packit Service 603f59
		    devp = fop;
Packit Service 603f59
		    break;
Packit Service 603f59
		case LSOF_FID_INODE:
Packit Service 603f59
		    inop = fop;
Packit Service 603f59
		    break;
Packit Service 603f59
		case LSOF_FID_NLINK:
Packit Service 603f59
		    nlkp = fop;
Packit Service 603f59
		    break;
Packit Service 603f59
		case LSOF_FID_OFFSET:
Packit Service 603f59
		    break;
Packit Service 603f59
		case LSOF_FID_SIZE:
Packit Service 603f59
		    szp = fop;
Packit Service 603f59
		    break;
Packit Service 603f59
		case LSOF_FID_TYPE:
Packit Service 603f59
		    typ = fop;
Packit Service 603f59
		    break;
Packit Service 603f59
		}
Packit Service 603f59
	    }
Packit Service 603f59
	/*
Packit Service 603f59
	 * Check the device, inode, and type of the file.
Packit Service 603f59
	 */
Packit Service 603f59
	    if (!devp || !inop || !typ)
Packit Service 603f59
		break;
Packit Service 603f59
	    if (strcasecmp(typ->v, "reg") && strcasecmp(typ->v, "vreg"))
Packit Service 603f59
		break;
Packit Service 603f59
	    if ((cem = ConvLsofDev(devp->v, &lsofdc))) {
Packit Service 603f59
		if (pem)
Packit Service 603f59
		    (void) PrtMsg(pem, Pn);
Packit Service 603f59
		pem = cem;
Packit Service 603f59
		break;
Packit Service 603f59
	    }
Packit Service 603f59
	    if ((stdc.maj != lsofdc.maj)
Packit Service 603f59
	    ||  (stdc.min != lsofdc.min)
Packit Service 603f59
	    ||  (stdc.unit != lsofdc.unit)
Packit Service 603f59
	    ||  strcmp(inop->v, ibuf)
Packit Service 603f59
	    ) {
Packit Service 603f59
		break;
Packit Service 603f59
	    }
Packit Service 603f59
	/*
Packit Service 603f59
	 * Indicate the file was found.
Packit Service 603f59
	 */
Packit Service 603f59
	    *ff = 1;
Packit Service 603f59
	/*
Packit Service 603f59
	 * Check the link count.
Packit Service 603f59
	 */
Packit Service 603f59
	    if (!nlkp) {
Packit Service 603f59
		(void) snprintf(buf, sizeof(buf) - 1,
Packit Service 603f59
		    "ERROR!!!  lsof didn't report a link count for %s", Path);
Packit Service 603f59
		buf[sizeof(buf) - 1] = '\0';
Packit Service 603f59
		cem = MkStrCpy(buf, &ti);
Packit Service 603f59
		if (pem)
Packit Service 603f59
		    (void) PrtMsg(pem, Pn);
Packit Service 603f59
		pem = cem;
Packit Service 603f59
		break;
Packit Service 603f59
	    }
Packit Service 603f59
	    if (strcmp(nlkp->v, nlkbuf)) {
Packit Service 603f59
		(void) snprintf(buf, sizeof(buf) - 1,
Packit Service 603f59
		    "ERROR!!!  wrong link count: expected %s, got %s",
Packit Service 603f59
		    nlkbuf, nlkp->v);
Packit Service 603f59
		buf[sizeof(buf) - 1] = '\0';
Packit Service 603f59
		cem = MkStrCpy(buf, &ti);
Packit Service 603f59
		if (pem)
Packit Service 603f59
		    (void) PrtMsg(pem, Pn);
Packit Service 603f59
		pem = cem;
Packit Service 603f59
		break;
Packit Service 603f59
	    }
Packit Service 603f59
	/*
Packit Service 603f59
	 * If the file was created by this test, check its size.
Packit Service 603f59
	 */
Packit Service 603f59
	    if (NFstat == 2) {
Packit Service 603f59
		if (!szp) {
Packit Service 603f59
		    (void) snprintf(buf, sizeof(buf) - 1,
Packit Service 603f59
			"ERROR!!!  lsof didn't report a size for %s", Path);
Packit Service 603f59
		    buf[sizeof(buf) - 1] = '\0';
Packit Service 603f59
		    cem = MkStrCpy(buf, &ti);
Packit Service 603f59
		    if (pem)
Packit Service 603f59
			(void) PrtMsg(pem, Pn);
Packit Service 603f59
		    pem = cem;
Packit Service 603f59
		    break;
Packit Service 603f59
		}
Packit Service 603f59
		if (strcmp(szp->v, szbuf)) {
Packit Service 603f59
		    (void) snprintf(buf, sizeof(buf) - 1,
Packit Service 603f59
			"ERROR!!!  wrong file size: expected %s, got %s",
Packit Service 603f59
			szbuf, szp->v);
Packit Service 603f59
		    buf[sizeof(buf) - 1] = '\0';
Packit Service 603f59
		    cem = MkStrCpy(buf, &ti);
Packit Service 603f59
		    if (pem)
Packit Service 603f59
			(void) PrtMsg(pem, Pn);
Packit Service 603f59
		    pem = cem;
Packit Service 603f59
		    break;
Packit Service 603f59
		}
Packit Service 603f59
	    }
Packit Service 603f59
	/*
Packit Service 603f59
	 * The requested file was located.  Return the previous error message
Packit Service 603f59
	 * pointer.  (It will be NULL if no error was detected.)
Packit Service 603f59
	 */
Packit Service 603f59
	    (void) StopLsof();
Packit Service 603f59
	    return(pem);
Packit Service 603f59
	}
Packit Service 603f59
    }
Packit Service 603f59
/*
Packit Service 603f59
 * The test file wasn't found.
Packit Service 603f59
 */
Packit Service 603f59
    (void) StopLsof();
Packit Service 603f59
    if (pem)
Packit Service 603f59
	(void) PrtMsg(pem, Pn);
Packit Service 603f59
    (void) snprintf(buf, sizeof(buf) - 1,
Packit Service 603f59
	"ERROR!!!  test file %s not found by lsof", Path);
Packit Service 603f59
    buf[sizeof(buf) - 1] = '\0';
Packit Service 603f59
    return(MkStrCpy(buf, &ti);;
Packit Service 603f59
}