1
0

Source code upload

This commit is contained in:
calmsacibis995
2022-09-29 17:59:04 +03:00
parent 72fa9da3d7
commit 8fc8fa8089
33399 changed files with 11964078 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
#
#!smake
#
# Makefile for the rpc.lockd subdirectory
#
# $Revision: 1.2 $
include ${ROOT}/usr/include/make/commondefs
LINTFLAGS= -woff 91,102
CTAGOPTS=-tw
# GENERATED_FILES is a list of all of the files generated by rpcgen
#
GENERATED_HFILES = lk_test.h
GENERATED_CFILES = lk_test_svc.c lk_test_xdr.c lk_test_clnt.c
GENERATED_FILES = $(GENERATED_HFILES) $(GENERATED_CFILES)
#
# SERVER_FILES is a list of files specific to the server
#
SERVER_FILES = lk_test_svc.c server_procs.c
SERVER_OBJS = ${SERVER_FILES:.c=.o}
#
# CLIENT_FILES is a list of files specific to the client
#
CLIENT_FILES = lk_test.c lk_test_clnt.c remoteops.c
CLIENT_OBJS = ${CLIENT_FILES:.c=.o}
#
# COMMON_FILES is a list of files common to the client and the server
#
COMMON_FILES = lk_test_xdr.c print.c fileops.c localops.c ../common/util.c
COMMON_OBJS = ${COMMON_FILES:.c=.o}
CFILES = $(GENERATED_CFILES) $(SERVER_FILES) $(CLIENT_FILES) $(COMMON_FILES)
LDIRT= $(GENERATED_FILES)
#
# PROGRAMS is a list of programs to be built
#
TARGETS = lk_test_svc lk_test
# define NDEBUG to turn off assertions
# define _IRIX for building on IRIX
# define _SUNOS for building on SunOS
#CFLAGS = -DNDEBUG
LCDEFS = -D_IRIX
LCOPTS = -g
LCINCS = -I../common
LIBS =
default: ${TARGETS}
include ${COMMONRULES}
lk_test_svc: $(GENERATED_FILES) $(SERVER_OBJS) $(COMMON_OBJS)
$(CCF) $(LCOPTS) $(LCDEFS) $(LDFLAGS) -o $@ $(SERVER_OBJS) $(COMMON_OBJS) $(LIBS)
lk_test: $(GENERATED_FILES) $(CLIENT_OBJS) $(COMMON_OBJS)
$(CCF) $(LCOPTS) $(LCDEFS) -o $@ $(CLIENT_OBJS) $(COMMON_OBJS) $(LDFLAGS) $(LIBS)
$(GENERATED_FILES): lk_test.x
${TOOLROOTSAFE} $(TOOLROOT)/usr/bin/rpcgen -P lk_test.x
install: default

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
#define OPEN_FLAGS O_RDWR
#define CREATE_FLAGS (OPEN_FLAGS | O_CREAT | O_TRUNC)
#define DEFAULT_MODE \
(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#define CREATE_MODE DEFAULT_MODE
int open_file_init(void);
int open_file(pathstr, int, int);
int close_file(pathstr);
bool_t locks_held(pathstr);
int verify_lock(struct verifyargs *);
void closeall(void);

View File

@@ -0,0 +1,90 @@
.TH LK_TEST 1 "" "Testing"
.SH NAME
lk_test \- test file and record locking functionality
.br
lk_test_svc \- file and record locking test server
.SH SYNOPSIS
.B lk_test
[-va] [localpath] [host:remotepath]
.br
.B lk_test_svc
.SH DESCRIPTION
.I lk_test
is an RPC client/server application designed to test the file
and record locking functionality of a UNIX file system. The client,
\fIlk_test\fP, and the server, \fIlk_test_svc\fP,
form a pair of processes cooperating in the testing. The
client is the active process in that the test phases are initiated by
the client. The server is passive, waiting for the client to make
requests of it.
.P
All testing is performed in the current working directory for each
process unless a directory or test file has been specified by the argument
.IR localpath .
If
.I host:remotepath
has been supplied, the host name and the remote directory are taken
to be
.I host
and
.I remotepath
respectively. Otherwise, the host name and the remote directory name
are determined from
.I localpath
or the current directory. This is done by extracting the information
from the mounted file system table.
.P
If the host and remote path are to be specified, the local path must
also be specified, even if it is ".".
.P
Testing is divided into two phases. In the first phase, exclusive
locking is tested. In the second phase, shared locking is tested.
The first phase tests the locking and unlocking of the entire file
and of a portion of the file followed by tests of record locking
(locking a range of bytes within the file), overlapping lock requests,
and lock boundaries. The second phase is similar to phase one with
variations for testing shared locking.
Where applicable, testing covers
.IR fcntl (2),
.IR lockf (3C),
and
.IR flock (3B).
.P
In all phases, verification of locking and unlocking is done by
requests to the process acting as the server.
.P
When testing a distributed file system such as NFS, the following
test scenarios must be executed (with three different systems):
.IP 1)
run
.B lk_test_svc
and
.B lk_test
on one client;
.IP 2)
run
.B lk_test_svc
on the file system server and
.B lk_test
on a single client;
.IP 3)
run
.B lk_test_svc
on one client and
.B lk_test
on a second client, with neither client being the file system server.
.SH OPTIONS
lk_test accepts the following options.
.TP 8
.B \-v
turn on verbose mode
.TP 8
.B \-a
use alternate lock verification. Alternate lock verification uses F_SETLK
to verify lock acquisition as opposed to F_GETLK.
.P
.I lk_test_svc
accepts no options from the command line. The
.B -v
option and the working directory name are passed to the server by the client
via an RPC call.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,116 @@
/* lk_test RPC interface definitions */
#ifdef RPC_HDR
%#include <sys/param.h>
%#if SVR4
%#include <sys/netconfig.h>
%#endif /* SVR4 */
#endif
/*
* Perform file and record locking tests
*/
typedef string pathstr<MAXPATHLEN>;
enum locktype {
LOCK_SHARED,
LOCK_EXCLUSIVE
};
enum lktest_stats {
FCNTL_SUCCESS,
FCNTL_SYSERROR
};
struct lockdesc {
long ld_offset; /* lock region start offset */
long ld_len; /* lock region length */
int ld_type; /* lock type */
int ld_pid; /* pid for lock holder */
int ld_sysid; /* sysid for lock hoder */
};
struct fcntlargs {
pathstr fa_name;
int fa_cmd;
struct lockdesc fa_lock;
};
union fcntlreply switch (lktest_stats stat) {
case FCNTL_SUCCESS:
struct lockdesc lock;
case FCNTL_SYSERROR:
int errno;
default:
void;
};
struct flockargs {
pathstr fa_name;
int fa_op;
};
struct lockfargs {
pathstr la_name;
int la_func;
long la_offset;
int la_size;
};
struct servopts {
int so_verbose;
int so_altverify;
pathstr so_directory;
};
struct verifyargs {
pathstr va_name;
struct lockdesc va_lock;
};
program LOCKTESTPROG {
version LKTESTVERS_ONE {
/*
* set the server options
*/
int
LKTESTPROC_SERVOPTS(struct servopts) = 1;
/*
* fcntl request
*/
fcntlreply
LKTESTPROC_FCNTL(struct fcntlargs) = 2;
/*
* lockf request
*/
int
LKTESTPROC_LOCKF(struct lockfargs) = 3;
/*
* flock request
*/
int
LKTESTPROC_FLOCK(struct flockargs) = 4;
/*
* check for any held locks
*/
bool
LKTESTPROC_HELD(pathstr) = 5;
/*
* verification
*/
bool
LKTESTPROC_VERIFY(struct verifyargs) = 6;
/*
* reset the server, closing all files and thus removing all locks
*/
int
LKTESTPROC_RESET(void) = 7;
} = 1;
} = 800001;

View File

@@ -0,0 +1,132 @@
/*
* local locking operations:
*
* fcntl
* flock
* lockf
*/
#include <sys/param.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <string.h>
#if !SVR4
#include <strings.h>
#endif /* !SVR4 */
#include <stdlib.h>
#include <assert.h>
#include <rpc/rpc.h>
#include "lk_test.h"
#include "print.h"
#include "util.h"
#include "fileops.h"
extern int errno;
extern char *Progname;
extern int Verbose;
/*
* Perform an fcntl(2) on a file on a local file system.
*/
/* ARGSUSED */
int
local_fcntl(struct fcntlargs *fap)
{
int status = 0;
struct flock fl;
int fd;
if (Verbose) {
printf("%s: local_fcntl: %s start %d len %d type %s\n",
Progname, lockcmd_to_str(fap->fa_cmd), (int)fap->fa_lock.ld_offset,
(int)fap->fa_lock.ld_len, locktype_to_str(fap->fa_lock.ld_type));
}
switch (fap->fa_cmd) {
case F_GETLK:
case F_SETLK:
case F_SETLKW:
if ( (fd = open_file(fap->fa_name, OPEN_FLAGS, DEFAULT_MODE))
== -1 ) {
(void)fprintf( stderr,
"%s: local_fcntl: unable to open %s\n",
Progname, fap->fa_name );
status = errno ? errno : -1;
} else {
fl.l_whence = SEEK_SET;
fl.l_start = fap->fa_lock.ld_offset;
fl.l_len = fap->fa_lock.ld_len;
fl.l_pid = getpid();
fl.l_type = fap->fa_lock.ld_type;
if ( fcntl( fd, fap->fa_cmd, &fl ) ) {
status = errno;
} else if (fap->fa_cmd == F_GETLK) {
fap->fa_lock.ld_offset = fl.l_start;
fap->fa_lock.ld_len = fl.l_len;
fap->fa_lock.ld_pid = fl.l_pid;
fap->fa_lock.ld_sysid = fl.l_sysid;
fap->fa_lock.ld_type = fl.l_type;
}
}
break;
default:
status = EINVAL;
}
return(status);
}
/*
* Perform an flock(3B) on a file on a local file system.
*/
/* ARGSUSED */
int
local_flock(struct flockargs *fap)
{
int status = 0;
int fd;
if ( (fd = open_file(fap->fa_name, OPEN_FLAGS, DEFAULT_MODE)) == -1 ) {
(void)fprintf( stderr, "%s: local_flock: unable to open %s\n",
Progname, fap->fa_name );
status = errno ? errno : -1;
} else {
if ( flock(fd, fap->fa_op) ) {
status = errno;
}
}
return(status);
}
/*
* Perform an lockf(3C) on a file on a local file system.
*/
/* ARGSUSED */
int
local_lockf(struct lockfargs *lap)
{
int status = 0;
int fd;
off_t offset;
if ( (fd = open_file(lap->la_name, OPEN_FLAGS, DEFAULT_MODE)) == -1 ) {
status = errno ? errno : -1;
(void)fprintf( stderr, "%s: local_lockf: unable to open %s\n",
Progname, lap->la_name );
} else if ((offset = lseek(fd, lap->la_offset, SEEK_SET)) == -1) {
status = errno;
(void)fprintf( stderr, "%s: local_lockf: unable to lseek %s: %s\n",
Progname, lap->la_name, strerror(status) );
} else if (offset != lap->la_offset) {
status = -1;
(void)fprintf( stderr,
"%s: local_lockf: bad lseek for %s: returned %d expected %d\n",
Progname, lap->la_name, offset, lap->la_offset );
} else if ( lockf( fd, lap->la_func, lap->la_size ) ) {
status = errno;
(void)fprintf( stderr, "%s: local_lockf: unable to lock %s: %s\n",
Progname, lap->la_name, strerror(status) );
}
return(status);
}

View File

@@ -0,0 +1,3 @@
int local_fcntl(struct fcntlargs *fap);
int local_flock(struct flockargs *fap);
int local_lockf(struct lockfargs *lap);

View File

@@ -0,0 +1,116 @@
#include <sys/param.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/fcntl.h>
#include <sys/errno.h>
#include <sys/signal.h>
#include <sys/file.h>
#include <rpc/rpc.h>
#include <rpc/svc.h>
#include "lk_test.h"
extern char *Progname;
extern int Verbose;
extern int errno;
static char *
flockop_to_str(int op)
{
static char opstr[25];
opstr[0] = 0;
if (op & LOCK_SH) {
strcat(opstr, "LOCK_SH ");
}
if (op & LOCK_EX) {
strcat(opstr, "LOCK_EX ");
}
if (op & LOCK_NB) {
strcat(opstr, "LOCK_NB ");
}
if (op & LOCK_UN) {
strcat(opstr, "LOCK_UN ");
}
return(opstr);
}
void
print_flockargs( struct flockargs *fap, char *leader )
{
printf( "%sfilename = %s\n", leader, fap->fa_name );
printf( "%s op = %s\n", leader, flockop_to_str( fap->fa_op ) );
}
static char *
fcntlcmd_to_str(int cmd)
{
static char *cmdstr = "UNKNOWN";
switch (cmd) {
case F_GETLK:
cmdstr = "F_GETLK";
break;
case F_SETLK:
cmdstr = "F_SETLK";
break;
default:
cmdstr = "ILLEGAL";
}
return(cmdstr);
}
void
print_fcntlargs( struct fcntlargs *fap, char *leader )
{
printf( "%sfilename = %s\n", leader, fap->fa_name );
printf( "%s cmd = %s\n", leader, fcntlcmd_to_str( fap->fa_cmd ) );
printf( "%s offset = %d\n", leader, fap->fa_lock.ld_offset );
printf( "%s len = %d\n", leader, fap->fa_lock.ld_len );
printf( "%s type = %s\n", leader,
locktype_to_str(fap->fa_lock.ld_type) );
}
void
print_verifyargs( struct verifyargs *vap, char *leader )
{
printf( "%sfilename = %s\n", leader, vap->va_name );
printf( "%s offset = %d\n", leader, vap->va_lock.ld_offset );
printf( "%s len = %d\n", leader, vap->va_lock.ld_len );
printf( "%s type = %s\n", leader,
locktype_to_str(vap->va_lock.ld_type) );
}
static char *
lockfunc_to_str( int func )
{
static char *funcstr = "UNKNOWN";
switch (func) {
case F_ULOCK:
funcstr = "F_ULOCK";
break;
case F_LOCK:
funcstr = "F_LOCK";
break;
case F_TLOCK:
funcstr = "F_TLOCK";
break;
case F_TEST:
funcstr = "F_TEST";
break;
default:
funcstr = "ILLEGAL";
}
return(funcstr);
}
void
print_lockfargs( struct lockfargs *lap, char *leader )
{
printf( "%sfilename = %s\n", leader, lap->la_name );
printf( "%s cmd = %s\n", leader, lockfunc_to_str( lap->la_func ) );
printf( "%s offset = %d\n", leader, lap->la_offset );
printf( "%s len = %d\n", leader, lap->la_size );
}

View File

@@ -0,0 +1,4 @@
void print_flockargs(struct flockargs *, char *);
void print_fcntlargs(struct fcntlargs *, char *);
void print_verifyargs( struct verifyargs *vap, char *leader );
void print_lockfargs( struct lockfargs *lap, char *leader );

View File

@@ -0,0 +1,163 @@
#define _RPCGEN_CLNT
#include <sys/param.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/errno.h>
#include <string.h>
#if !SVR4
#include <strings.h>
#endif /* !SVR4 */
#include <stdlib.h>
#include <unistd.h>
#include <sys/fcntl.h>
#include <rpc/rpc.h>
#include <assert.h>
#include <sys/stat.h>
#include "lk_test.h"
#include "print.h"
#include "util.h"
#include "fileops.h"
extern char *Progname;
extern int errno;
int
server_fcntl( fcntlargs *fap, CLIENT *clnt )
{
struct fcntlreply *replyp;
int status = 0;
assert( valid_addresses( (caddr_t)fap, sizeof(struct fcntlargs) ) &&
valid_addresses( (caddr_t)clnt, sizeof(CLIENT) ) );
if ( replyp = lktestproc_fcntl_1( fap, clnt ) ) {
switch (replyp->stat) {
case FCNTL_SYSERROR:
status = replyp->fcntlreply_u.errno;
break;
case FCNTL_SUCCESS:
if (fap->fa_cmd == F_GETLK) {
fap->fa_lock = replyp->fcntlreply_u.lock;
}
break;
default:
fprintf(stderr, "%s: server_fcntl: unknown reply value %d\n",
Progname, replyp->stat);
status = -1;
}
} else {
fprintf( stderr, "%s: ", Progname );
clnt_perror( clnt, "server_fcntl: lktestproc_fcntl_1 returned NULL" );
status = -1;
}
return( status );
}
int
server_flock( flockargs *fap, CLIENT *clnt )
{
int *replyp;
int status;
assert( valid_addresses( (caddr_t)fap, sizeof(struct flockargs) ) &&
valid_addresses( (caddr_t)clnt, sizeof(CLIENT) ) );
if ( replyp = lktestproc_flock_1( fap, clnt ) ) {
status = *replyp;
} else {
fprintf( stderr, "%s: ", Progname );
clnt_perror( clnt, "server_flock: lktestproc_flock_1 returned NULL" );
status = -1;
}
return( status );
}
int
server_lockf( lockfargs *lap, CLIENT *clnt )
{
int *replyp;
int status;
assert( valid_addresses( (caddr_t)lap, sizeof(struct lockfargs) ) &&
valid_addresses( (caddr_t)clnt, sizeof(CLIENT) ) );
if ( replyp = lktestproc_lockf_1( lap, clnt ) ) {
status = *replyp;
} else {
fprintf( stderr, "%s: ", Progname );
clnt_perror( clnt, "server_lockf: lktestproc_lockf_1 returned NULL" );
status = -1;
}
return( status );
}
int
set_server_opts( servopts *sop, CLIENT *clnt )
{
int *statusp;
int status;
assert( valid_addresses( (caddr_t)sop, sizeof(struct servopts) ) &&
valid_addresses( (caddr_t)clnt, sizeof(CLIENT) ) );
if ( statusp = lktestproc_servopts_1( sop, clnt ) ) {
status = *statusp;
} else {
fprintf( stderr, "%s: ", Progname );
clnt_perror( clnt, "server_lock: lktestproc_servopts_1 returned NULL" );
status = -1;
}
return( status );
}
bool_t
server_verify( verifyargs *vap, CLIENT *clnt )
{
bool_t *statusp;
int status;
assert( valid_addresses( (caddr_t)vap, sizeof(struct verifyargs) ) &&
valid_addresses( (caddr_t)clnt, sizeof(CLIENT) ) );
if ( statusp = lktestproc_verify_1( vap, clnt ) ) {
status = *statusp;
} else {
fprintf( stderr, "%s: ", Progname );
clnt_perror( clnt,
"server_verify_lock: lktestproc_verify_1 returned NULL" );
status = 0;
}
return( status );
}
bool_t
server_held( pathstr *file_name, CLIENT *clnt )
{
bool_t *statusp;
int status;
assert( valid_addresses( (caddr_t)file_name, 1 ) &&
valid_addresses( (caddr_t)clnt, sizeof(CLIENT) ) );
if ( statusp = lktestproc_held_1( file_name, clnt ) ) {
status = *statusp;
} else {
fprintf( stderr, "%s: ", Progname );
clnt_perror( clnt,
"server_locks_held: lktestproc_held_1 returned NULL" );
status = -1;
}
return( status );
}
int
reset_server( CLIENT *clnt )
{
int *statusp;
int status;
if ( statusp = lktestproc_reset_1( NULL, clnt ) ) {
status = *statusp;
} else {
fprintf( stderr, "%s: ", Progname );
clnt_perror( clnt, "reset_server: lktestproc_reset_1 returned NULL" );
status = -1;
}
return( status );
}

View File

@@ -0,0 +1,7 @@
int server_fcntl( fcntlargs *fap, CLIENT *clnt );
int server_flock( flockargs *fap, CLIENT *clnt );
int server_lockf( lockfargs *lap, CLIENT *clnt );
int set_server_opts( servopts *sop, CLIENT *clnt );
bool_t server_verify( verifyargs *vap, CLIENT *clnt );
bool_t server_held( pathstr *file_name, CLIENT *clnt );
int reset_server( CLIENT *clnt );

View File

@@ -0,0 +1,244 @@
#define _RPCGEN_SVC
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <rpc/rpc.h>
#include <sys/fcntl.h>
#include "lk_test.h"
#include "print.h"
#include "util.h"
#include "fileops.h"
#include "localops.h"
char *Progname = "lk_test_svc";
int Verbose = 0;
int AlternateVerify = 0; /* user alternate verification method */
static int Fileinit_done = 0;
static char *Starting_directory = NULL;
extern int errno;
/*
* set the server options: verbose mode value and working directory
* return 0 on success, -1 on failure
*/
int *
lktestproc_servopts_1( struct servopts *sop, struct svc_req *rqstp )
{
static int status = 0;
char *curdir = NULL;
if ( Verbose > 1 ) {
printf( "%s: lktestproc_servopts_1\n", Progname );
}
if ( !Fileinit_done ) {
open_file_init();
Fileinit_done = 1;
}
assert( valid_addresses( (caddr_t)sop, sizeof(struct servopts) ) );
Verbose = sop->so_verbose;
AlternateVerify = sop->so_altverify;
if ( !Starting_directory &&
!(Starting_directory = getcwd( NULL, MAXPATHLEN )) ) {
status = -1;
if ( Verbose ) {
(void)fprintf( stderr, "%s: unable to get current directory: ",
Progname );
perror( "getcwd" );
}
} else if ( sop->so_directory && (strcmp( sop->so_directory, "." ) != 0) ) {
if ( (status = chdir( sop->so_directory )) && Verbose ) {
(void)fprintf( stderr, "%s: unable to change directory: ",
Progname );
perror( sop->so_directory );
} else if ( Verbose ) {
printf( "%s: lktestproc_servopts_1:\n", Progname );
printf( "\t Verbose = %d\n", Verbose );
printf( "\t dir = %s\n", sop->so_directory );
}
} else if ( Verbose ) {
curdir = getcwd( NULL, MAXPATHLEN );
printf( "%s: lktestproc_servopts_1:\n", Progname );
printf( "\t Verbose = %d\n", Verbose );
printf( "\t dir = %s\n", curdir );
free( curdir );
}
if ( Verbose > 1 ) {
printf( "%s: lktestproc_servopts_1: return %d\n", Progname, status );
}
return( &status );
}
fcntlreply *
lktestproc_fcntl_1( struct fcntlargs *fap, struct svc_req *rqstp )
{
int error = 0;
static fcntlreply reply;
assert( valid_addresses( (caddr_t)fap, sizeof(struct fcntlargs) ) );
if ( Verbose ) {
printf( "%s: lktestproc_fcntl_1: \n", Progname );
print_fcntlargs( fap, "\t" );
if ( Verbose > 1 ) {
print_svcreq( rqstp, "\t" );
}
}
if ( !Fileinit_done ) {
open_file_init();
Fileinit_done = 1;
}
bzero(&reply, sizeof(reply));
error = local_fcntl( fap );
if ( Verbose > 1 ) {
printf( "%s: lktestproc_fcntl_1: return %d\n", Progname, error );
}
if (error) {
reply.stat = FCNTL_SYSERROR;
reply.fcntlreply_u.errno = error;
} else if (fap->fa_cmd == F_GETLK) {
reply.stat = FCNTL_SUCCESS;
reply.fcntlreply_u.lock = fap->fa_lock;
} else {
reply.stat = FCNTL_SUCCESS;
}
return( &reply );
}
int *
lktestproc_flock_1( struct flockargs *flap, struct svc_req *rqstp )
{
static int error;
assert( valid_addresses( (caddr_t)flap, sizeof(struct flockargs) ) );
if ( Verbose ) {
printf( "%s: lktestproc_flock_1: \n", Progname );
print_flockargs( flap, "\t" );
if ( Verbose > 1 ) {
print_svcreq( rqstp, "\t" );
}
}
if ( !Fileinit_done ) {
open_file_init();
Fileinit_done = 1;
}
error = local_flock( flap );
if ( Verbose > 1 ) {
printf( "%s: lktestproc_flock_1: return %d\n", Progname, error );
}
return( &error );
}
int *
lktestproc_lockf_1( struct lockfargs *lfap, struct svc_req *rqstp )
{
static int error;
assert( valid_addresses( (caddr_t)lfap, sizeof(struct lockfargs) ) );
if ( Verbose ) {
printf( "%s: lktestproc_lockf_1: \n", Progname );
print_lockfargs( lfap, "\t" );
if ( Verbose > 1 ) {
print_svcreq( rqstp, "\t" );
}
}
if ( !Fileinit_done ) {
open_file_init();
Fileinit_done = 1;
}
error = local_lockf( lfap );
if ( Verbose > 1 ) {
printf( "%s: lktestproc_lockf_1: return %d\n", Progname, error );
}
return( &error );
}
bool_t *
lktestproc_held_1(pathstr *name, struct svc_req *rqstp)
{
static bool_t status;
assert( valid_addresses( (caddr_t)name, sizeof(*name) ) &&
valid_addresses( (caddr_t)*name, 1 ) );
if ( Verbose ) {
printf( "%s: lktestproc_held_1: \n", Progname );
printf( "\tfilename = %s\n", *name );
if ( Verbose > 1 ) {
print_svcreq( rqstp, "\t" );
}
}
if ( !Fileinit_done ) {
open_file_init();
Fileinit_done = 1;
}
status = locks_held( *name );
if ( Verbose > 1 ) {
printf( "%s: lktestproc_held_1: return %d\n", Progname, status );
}
return( &status );
}
bool_t *
lktestproc_verify_1(verifyargs *vap, struct svc_req *rqstp)
{
static bool_t status;
assert( valid_addresses((caddr_t)vap, sizeof(verifyargs)));
if (Verbose) {
printf( "%s: lktestproc_verify_1 \n", Progname );
print_verifyargs(vap, "\t");
if ( Verbose > 1 ) {
print_svcreq( rqstp, "\t" );
}
}
if ( !Fileinit_done ) {
open_file_init();
Fileinit_done = 1;
}
status = verify_lock( vap );
if ( Verbose > 1 ) {
printf( "%s: lktestproc_verify_1: return %d\n", Progname, status );
}
return(&status);
}
/* ARGSUSED */
int *
lktestproc_reset_1( void *argp, struct svc_req *rqstp )
{
static int status = 0;
closeall();
if ( !Starting_directory ) {
if ( !(Starting_directory = getcwd( NULL, MAXPATHLEN )) ) {
status = -1;
if ( Verbose ) {
(void)fprintf( stderr, "%s: unable to get current directory: ",
Progname );
perror( "getcwd" );
}
} else if ( Verbose ) {
printf( "%s: lktestproc_reset_1:\n", Progname );
printf( "\tdir = %s\n", Starting_directory );
}
} else if ( status = chdir( Starting_directory ) ) {
if ( Verbose ) {
(void)fprintf( stderr, "%s: unable to chdir back to %s: ",
Progname, Starting_directory );
perror( "chdir" );
}
if ( errno ) {
status = errno;
} else {
status = -1;
}
} else if ( Verbose ) {
printf( "%s: lktestproc_reset_1:\n", Progname );
printf( "\tdir = %s\n", Starting_directory );
}
Verbose = 0;
return( &status );
}