This patch implements the PVM File Server (PVMFS) functionality for the PVM System, version 3.3.4. Use to following to add it to your PVM software: % cd $PVM_ROOT % patch -p < this_file Then read the Readme.fs in $PVM_ROOT. Chris -------- Christopher G. Phillips pefv700@pe.utexas.edu *** pvm3.ornl/Makefile Thu Aug 25 18:03:30 1994 --- Makefile Sun Jul 24 18:03:38 1994 *************** *** 15,23 **** BINDIR = $(TOPBINDIR)/$(PVM_ARCH) SHELL = /bin/sh ! default: s c f g ! all: s f c g m clean: cd src; ../lib/aimk clean --- 15,23 ---- BINDIR = $(TOPBINDIR)/$(PVM_ARCH) SHELL = /bin/sh ! default: s c f fs l ! all: s f c g m fs l clean: cd src; ../lib/aimk clean *************** *** 24,29 **** --- 24,31 ---- cd console; ../lib/aimk clean cd libfpvm; ../lib/aimk clean cd pvmgs; ../lib/aimk clean + cd pvmfs; ../lib/aimk clean + cd libc; ../lib/aimk clean $(LIBDIR): - mkdir $(LIBDIR) *************** *** 60,62 **** --- 62,71 ---- m: cd xep; ../lib/aimk + ## build pvmfs ## + fs: + cd pvmfs; ../lib/aimk install + + ## build libc ## + l: + cd libc; ../lib/aimk install *** /dev/null Thu Aug 25 19:19:25 1994 --- Readme.fs Thu Aug 25 23:29:42 1994 *************** *** 0 **** --- 1,215 ---- + PVMFS - PVM File Server + + + PVMFS is a PVM task process which facilitates I/O for programs + utilizing the Parallel Virtual Machine system (see pvm(1PVM)) on a + cluster of workstations. The file server presents a common file system + and support for coordinated I/O to its parent and siblings. + + + ------------------------------------------------------------------------ + + + Making PVMFS + + + If you don't have an ANSI C compiler, compile ccwrap and regress + in libc/cc and make them accessible via your PATH. + + Then, do the following (where ``sharfile'' is probably called pvm333fs.shar): + + % cd $PVM_ROOT + % sh sharfile + % patch -p < patches/pvm333fs.patch + + Finally, + + % make + + Typing ``make'' in your PVM_ROOT directory will, by default, compile + the new system call handling code as well as the file server. If you, + for whatever reason, *don't* want the file server support, don't + #define PVMFS as it now is in various Makefile.aimk's. + + One caveat is that you have to prepare libc/pvmerrno.[ch] for all of + the machines you will ever want to use in your virtual machine. A perl + script, libc/pvmerrno.pl is provided to make this easier. cd to libc + and type + + % cd $PVM_ROOT/libc + % pvmerrno.pl + + which is usually + + % pvmerrno.pl /usr/include/sys/errno.h + + (If you don't have perl, basically you want to add every E* constant to + libc/pvmerrno.[ch] just like the others already there.) + + Take libc/pvmerrno.[ch] to every other machine and do the same thing. + What these files do is provide a mapping from one machine's errno + constants to another's. In libc/$PVM_ARCH, the file errnoconf.h is + created. This file deals with compilers not liking multiple case + statements with the same value (such as if EAGAIN == EWOULDBLOCK).) + + There are cases which fool pvmerrno.pl. These will present + themselves as compiler errors and should be fairly easy to fix. + + For the RS6K, there is another problem. Because of the unusual + linking required, you will need to make things out of the normal order. + Try + % make l + % make f + % make + + Hopefully, this will work. + + + ------------------------------------------------------------------------ + + + Examples + + + There are two example programs to run to check whether the linking is + good and to peruse example programming with the file server. These are + under $PVM_ROOT/fsexamples and are called io and iot. + + io contains programs that read and write files using the various I/O + modes with UNIX, ANSI C, and FORTRAN functions. You can just type + ``aimk'' and it will try to run all the example programs. Besides each + individual program, ``aimk c'' will do the UNIX examples, ``aimk stdc'' + the ANSI C examples (files named *_stdc_[rw].c), and ``aimk f'' the + FORTRAN examples (files named *_f_[rw].f). These all use the files + [01]_w and 01_r (although not directly). + + ###WARNING: Some of the cases, especially if they don't use + buffering, can take a long time on a loaded system. If this is + a problem, decrease the number of lines in 01_r, 0_w, and 1_w. + All of the examples are designed to run on just one host, + although if you coordinate the making of the executables (io + and fio), you can run on multiple hosts. + + The shell script ``test2'' is provided to test these using two hosts in + the virtual machine. The syntax is + + machine1% test2 machine2 [target] + + where target is as when using aimk above. + + iot is like perl in that it can be interactive and its syntax resembles + the calling of UNIX system calls. Unless DEBUG is #defined, it runs + one process on the current host and another as given by argv[1] (or + both on the current host if argc == 1. The (remote) spawned process + actually reads the input and has the file server perform the requested + actions. Type a system call name followed by a space if you want to + know the syntax. Also, reads and writes use an anonymous buffer so you + can read and then write the stuff you read. Use aimk to make iot. + + + ----------------------------------------------------------------------- + + + Notes + + + There's a new -f option to the kill command of the console program. It + kills the file server whose tid is specified and all processes with + that fstid. + + If you're interested, you can #define DEBUG in the Makefile.aimk's in + src and pvmfs (this affects src/lpvm.c and pvmfs/fs.c), create the + named pipe /tmp/fspipe and run the file server in a debugger. + + Also, you can #define TRACE and set the global variable pvmdebug + nonzero and system calls (and some POSIX calls like opendir) will print + out a trace (it may be bypassed in write). It's amazing how often the + RS6K and SUN4 FORTRAN libraries call isatty... + + If you don't want a file server (as we don't for the console process), + just don't call pvm_usefs with a nonzero argument. By default, you + don't get a file server (unless your parent has one). + + + ----------------------------------------------------------------------- + + + Bugs + + + The POSIX terminal I/O tc* functions aren't implemented. And you + don't want to ask about ioctl :-) + + File locking, which must be implemented in the file server because of + pid considerations, isn't. + + Writing binary data should be fun. You potentially have to know how to + convert from one architecture's format to another's. + + The most important thing to get right when using the file server is the + linking. Look at the Makefile*'s for the examples. Note that all of + the true system calls (and some other functions easily emulated) are in + libc/syscalls.c. libc/posix.c has functions that are *not* system + calls and cannot be called indirectly using syscall (like opendir). If + you want to call opendir via the file server and then *locally* later, + you're out of luck. + + + ----------------------------------------------------------------------- + + + FORTRAN hints + + + When you use shared files (other than mode PvmIomodeIndividual), + you should not specify STATUS = 'new' for output files. The reason + is that the file server will remember that it has opened a file, but + isn't smart enough to lie about a call to access. Use 'unknown' + and make sure the file is empty when you start up your program. + + ftruncate has been disabled for shared files because, when you use + 'unknown' and then write to a file, some FORTRAN I/O libraries + immediately do an lseek followed by an ftruncate. When these are + done by multiple processes, data can be lost. + + The SyncBC mode will currently only work for reading if your FORTRAN + I/O libraries all use the same size. + + Be aware of buffering!!! + + + ----------------------------------------------------------------------- + + + Porting Notes + + + As I said above, the most important thing to get right is the linking. + It's not good to think your FORTRAN code is trying to open a file via + the file server when it's really not because the linking is wrong. + Take some super-small C and FORTRAN programs and use the compiler's + (-v) option (if any) during the linking to see all of the libraries and + stuff in the argument list to ld. Generally speaking, satisfy all of + the FORTRAN references first and have the system call trapping code + last (assuming a ``left-to-right'' linker). The SUN4 and ALPHA are + examples. + + If your system has unusual linking, put this stuff in + libc/$PVM_ARCH/Mfile. The RS6K is one example. + + When you've figured out the linking, set ARCHFFSLIB (and ARCHFSLIB if + really weird) in conf/$PVM_ARCH.def. + + You need to find out what return and argument types your system's read, + readv, write, writev, and select take and make appropriate changes to + libc/argtypes.h. + + + Enjoy! + + + Chris + ---------- + + Christopher G. Phillips + pefv700@pe.utexas.edu *** pvm3.ornl/conf/ALPHA.def Thu Aug 25 18:03:31 1994 --- conf/ALPHA.def Sun Jul 24 18:07:44 1994 *************** *** 4,6 **** --- 4,8 ---- ARCHLIB = HASRANLIB = t PVM_ARCH = ALPHA + ARCHFFSLIB = -lUfor -lfor -lFutil -lm -lots + SCC = cc -std1 *** pvm3.ornl/conf/CNVXN.def Thu Aug 25 18:03:34 1994 --- conf/CNVXN.def Sun Jul 24 18:08:29 1994 *************** *** 4,6 **** --- 4,9 ---- ARCHLIB = HASRANLIB = t PVM_ARCH = CNVXN + ARCHFFSLIB = -lU77 -lF77 -lI77 -lD77 -lmathC2 #-llfs + SCC = cc + FC = fc *** pvm3.ornl/conf/CRAY.def Thu Aug 25 18:03:35 1994 --- conf/CRAY.def Sun Jul 24 18:09:05 1994 *************** *** 4,6 **** --- 4,9 ---- ARCHLIB = HASRANLIB = f PVM_ARCH = CRAY + ARCHFFSLIB = -Wl"-D dupentry=caution,note,note" + SCC = cc + FC = $(CF) *** pvm3.ornl/conf/PMAX.def Thu Aug 25 18:03:41 1994 --- conf/PMAX.def Sun Jul 24 18:09:33 1994 *************** *** 4,6 **** --- 4,8 ---- ARCHLIB = HASRANLIB = t PVM_ARCH = PMAX + ARCHFFSLIB = -lUfor -lfor -lutil -li -lots -lm + SCC = ccwrap cc *** pvm3.ornl/conf/RS6K.def Tue Sep 06 10:17:41 1994 --- conf/RS6K.def Tue Sep 06 10:40:33 1994 *************** *** 5,7 **** --- 5,10 ---- HASRANLIB = t PVM_ARCH = RS6K RWBSPECIAL = |sed '/^.include \"pvm3.h\"/d' |sed '/^.include \"pvm_consts.h\"/d' + ARCHFFSLIB = + ARCHFSLIB = -L$(PVM_ROOT)/libc/RS6K -L$(PVM_ROOT)/lib/RS6K -bI:$(PVM_ROOT)/libc/RS6K/syscall.exp -bnodelcsect -bnso -lxlf -lm -lfpvm3 -lpvm3 -lpvmfs -bI:/lib/syscalls.exp + SCC = cc *** pvm3.ornl/conf/SUN4.def Thu Aug 25 18:03:44 1994 --- conf/SUN4.def Sun Jul 24 18:11:21 1994 *************** *** 4,6 **** --- 4,11 ---- ARCHLIB = HASRANLIB = t PVM_ARCH = SUN4 + #ARCHFFSLIB = -L$(PVM_ROOT)/libc/$(PVM_ARCH) + ARCHFFSLIB = -L/usr/lang/SC1.0/cg87 -L/usr/lang/SC1.0 -lF77 -lm + #SCC = gcc -ansi + SCC = ccwrap cc + CC = cc *** pvm3.ornl/console/Makefile.aimk Fri Aug 26 14:33:07 1994 --- console/Makefile.aimk Mon Jul 25 14:48:09 1994 *************** *** 11,18 **** PVMIDIR = ../../include PVMLDIR = ../../lib/$(PVM_ARCH) PVMLIB = -lpvm3 ! CFLAGS = -g -DIMA_$(PVM_ARCH) -I$(PVMIDIR) -L$(PVMLDIR) $(ARCHCFLAGS) ! LIBS = $(PVMLIB) $(ARCHLIB) OBJ = cons.o cmds.o job.o tevfmt.o default: pvm --- 11,18 ---- PVMIDIR = ../../include PVMLDIR = ../../lib/$(PVM_ARCH) PVMLIB = -lpvm3 ! CFLAGS = -g -DIMA_$(PVM_ARCH) -I$(PVMIDIR) -L$(PVMLDIR) $(ARCHCFLAGS) -DPVMFS ! LIBS = $(PVMLIB) $(ARCHLIB) $(ARCHFSLIB) OBJ = cons.o cmds.o job.o tevfmt.o default: pvm *** pvm3.ornl/console/cmds.c Thu Aug 25 18:03:50 1994 --- console/cmds.c Mon Jul 25 16:11:55 1994 *************** *** 437,442 **** --- 437,445 ---- "kill KILL - Terminate tasks", "kill Syntax: kill [ options ] tid ...", "kill Options: -c kill children of tid", + #ifdef PVMFS + "kill -f kill children of fstid", + #endif /* PVMFS */ "lookup-LOOKUP - Find entry in database", "lookup-Syntax: lookup name index|-1", *************** *** 456,462 **** "ps A.OUT executable name", "ps TID task id", "ps PTID parent task id", ! "ps PTID task process id", "ps FLAG status", "ps FLAG values:", "ps c task connected to pvmd", --- 459,468 ---- "ps A.OUT executable name", "ps TID task id", "ps PTID parent task id", ! "ps PID task process id", ! #ifdef PVMFS ! "ps FSTID file server task id", ! #endif /* PVMFS */ "ps FLAG status", "ps FLAG values:", "ps c task connected to pvmd", *************** *** 638,643 **** --- 644,652 ---- char *p; int host = 0; int cflg = 0; + #ifdef PVMFS + int fflg = 0; + #endif /* PVMFS */ struct pvmtaskinfo *tip; int ntask; *************** *** 650,655 **** --- 659,670 ---- cflg = 1; break; + #ifdef PVMFS + case 'f': + fflg = 1; + break; + #endif /* PVMFS */ + case '-': break; *************** *** 664,670 **** --- 679,689 ---- return; } + #ifdef PVMFS + if ((cflg || fflg) && pvm_tasks(host, &ntask, &tip) < 0) + #else if (cflg && pvm_tasks(host, &ntask, &tip) < 0) + #endif /* PVMFS */ return 1; while (ac > 1) { *************** *** 679,684 **** --- 698,713 ---- pvm_kill(tid2); } + #ifdef PVMFS + } else if (fflg) { + for (i = 0; i < ntask; i++) + if (tip[i].ti_fstid == tid) { + tid2 = tip[i].ti_tid; + if (tid2 != mytid) + pvm_kill(tid2); + } + #endif /* PVMFS */ + } else { if (tid == mytid) printf("t%x: that's me.\n", tid); *************** *** 987,995 **** --- 1016,1030 ---- print_task_hdr(lflg) int lflg; { + #ifdef PVMFS if (lflg) + fputs(" HOST TID PTID FSTID PID FLAG COMMAND\n", + stdout); + #else + if (lflg) fputs(" HOST TID PTID PID FLAG COMMAND\n", stdout); + #endif /* PVMFS */ else fputs(" HOST TID FLAG COMMAND\n", stdout); *************** *** 1025,1034 **** --- 1060,1079 ---- printf(" %8x", tip->ti_ptid); else printf(" -"); + #ifdef PVMFS + if (tip->ti_fstid) + printf(" %8x", tip->ti_fstid); + else + printf(" -"); + #endif /* PVMFS */ printf(" %6d", tip->ti_pid); } printf(" %9s", task_flags(tip->ti_flag)); + #ifdef PVMFS + printf(" %-11s", tip->ti_a_out[0] ? tip->ti_a_out : "-"); + #else printf(" %-12s", tip->ti_a_out[0] ? tip->ti_a_out : "-"); + #endif /* PVMFS */ return 0; } *** /dev/null Thu Aug 25 19:19:25 1994 --- doc/fsarches Mon Jul 25 16:26:43 1994 *************** *** 0 **** --- 1,11 ---- + PVMFS 1.1 Supported Architectures + December 17, 1993 + + PVM name Machine and OS + -------- -------------- + ALPHA DEC Alpha/OSF-1 + CNVXN Convex using native f.p. + CRAY Cray + PMAX DEC/Mips arch (3100, 5000, etc.) + RS6K IBM/RS6000 + SUN4 Sun 4, 4c, sparc, etc. *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/CNVXN/Makefile Sun Jul 24 18:14:55 1994 *************** *** 0 **** --- 1,640 ---- + # Imports: + # PVM_ARCH = the official pvm-name of your processor + # ARCHCFLAGS = special cc flags + # ARCHFFSLIB = special libs needed for getting the FORTRAN library to use pvmfs + # + SHELL = /bin/sh + PVMIDIR = ../../../include + PVMLDIR = ../../../lib/$(PVM_ARCH) + PVMFSLDIR= ../../../libc/$(PVM_ARCH) + PVMLIB = -lpvm3 + CFLAGS = -g -I$(PVMIDIR) -DIMA_$(PVM_ARCH) $(ARCHCFLAGS) -I../../../src -DPVMFS + FFLAGS = -g + FSOBJS = $(PVMFSLDIR)/syscalls.o $(PVMFSLDIR)/pvmerrno.o $(PVMFSLDIR)/posix.o + LIBS = -g -L$(PVMLDIR) $(PVMLIB) + FLIBS1 = $(ARCHFFSLIB) + FLIBS2 = -g -L$(PVMLDIR) -lfpvm3 $(PVMLIB) + OBJS = io.o startup.o wait4fs.o + FOBJS = fio.o fstartup.o wait4fs.o + + include ../../../conf/CNVXN.def + + all: c stdc f + + c: common_r common_w independent_r independent_w syncBC_r syncBC_w \ + syncseq_r syncseq_w + + stdc: common_stdc_r common_stdc_w independent_stdc_r independent_stdc_w \ + syncBC_stdc_r syncBC_stdc_w syncseq_stdc_r syncseq_stdc_w + + f: common_f_r common_f_w independent_f_r independent_f_w \ + syncBC_f_r syncBC_f_w syncseq_f_r syncseq_f_w + + files: mkfiles + @if [ ! -f 01_r ]; \ + then \ + mkfiles; \ + mv 01_r 0_w 1_w ..; \ + else \ + exit 0; \ + fi + + mkfiles: mkfiles.o + $(CC) -o $@ mkfiles.o + + mkfiles.o: ../mkfiles.c + $(SCC) -c ../mkfiles.c + + io: $(OBJS) $(PVMLDIR)/libpvm3.a $(FSOBJS) files + $(SCC) -o $@ $(OBJS) $(FSOBJS) $(LIBS) + rm -f $(HOME)/pvm3/bin/$(PVM_ARCH)/$@ + -ln -s `pwd`/$@ $(HOME)/pvm3/bin/$(PVM_ARCH) + + fio: $(FOBJS) $(PVMLDIR)/libpvm3.a $(PVMLDIR)/libfpvm3.a $(FSOBJS) files + $(CC) -o $@ $(FOBJS) $(FLIBS1) $(FSOBJS) $(FLIBS2) -lc -llfs + rm -f $(HOME)/pvm3/bin/$(PVM_ARCH)/$@ + -ln -s `pwd`/$@ $(HOME)/pvm3/bin/$(PVM_ARCH) + + io.o: ../io.c + $(SCC) $(CFLAGS) -c ../io.c + + fio.o: ../fio.f + $(FC) $(FFLAGS) -c ../fio.f + + startup.o: ../startup.c + $(SCC) $(CFLAGS) -c ../startup.c + + fstartup.o: ../fstartup.f + $(FC) $(FFLAGS) -c ../fstartup.f + + wait4fs.o: ../wait4fs.c + $(SCC) $(CFLAGS) -c ../wait4fs.c + + common_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../common_r.c ../io.c; \ + cp ../common_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_r ok <======================"; \ + fi + + common_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../common_w.c ../io.c; \ + cp ../common_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_w ok <======================"; \ + fi + + independent_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../independent_r.c ../io.c; \ + cp ../independent_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> independent_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_r ok <======================"; \ + fi + + independent_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../independent_w.c ../io.c; \ + cp ../independent_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`wc -l < ../0.out`; \ + wc3=`wc -l < ../1.out`; \ + if [ $$wc1 -ne $$wc2 -o $$wc1 -ne $$wc3 ]; \ + then \ + echo "======================> independent_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_w ok <======================"; \ + fi + + syncBC_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_r.c ../io.c; \ + cp ../syncBC_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> syncBC_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_r ok <======================"; \ + fi + + syncBC_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_w.c ../io.c; \ + cp ../syncBC_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @cmp -s ../0.out ../file; \ + if [ $$? -ne 0 ]; \ + then \ + echo "======================> syncBC_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_w ok <======================"; \ + fi + + syncseq_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_r.c ../io.c; \ + cp ../syncseq_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_r ok <======================"; \ + fi + + syncseq_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_w.c ../io.c; \ + cp ../syncseq_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_w ok <======================"; \ + fi + + common_stdc_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_stdc_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../common_stdc_r.c ../io.c; \ + cp ../common_stdc_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_stdc_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_stdc_r ok <======================"; \ + fi + + common_stdc_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_stdc_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../common_stdc_w.c ../io.c; \ + cp ../common_stdc_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_stdc_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_stdc_w ok <======================"; \ + fi + + independent_stdc_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_stdc_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../independent_stdc_r.c ../io.c; \ + cp ../independent_stdc_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> independent_stdc_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_stdc_r ok <======================"; \ + fi + + independent_stdc_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_stdc_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../independent_stdc_w.c ../io.c; \ + cp ../independent_stdc_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`wc -l < ../0.out`; \ + wc3=`wc -l < ../1.out`; \ + if [ $$wc1 -ne $$wc2 -o $$wc1 -ne $$wc3 ]; \ + then \ + echo "======================> independent_stdc_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_stdc_w ok <======================"; \ + fi + + syncBC_stdc_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_stdc_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_stdc_r.c ../io.c; \ + cp ../syncBC_stdc_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> syncBC_stdc_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_stdc_r ok <======================"; \ + fi + + syncBC_stdc_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_stdc_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_stdc_w.c ../io.c; \ + cp ../syncBC_stdc_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @cmp -s ../0.out ../file; \ + if [ $$? -ne 0 ]; \ + then \ + echo "======================> syncBC_stdc_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_stdc_w ok <======================"; \ + fi + + syncseq_stdc_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_stdc_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_stdc_r.c ../io.c; \ + cp ../syncseq_stdc_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_stdc_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_stdc_r ok <======================"; \ + fi + + syncseq_stdc_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_stdc_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_stdc_w.c ../io.c; \ + cp ../syncseq_stdc_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_stdc_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_stdc_w ok <======================"; \ + fi + + common_f_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_f_r.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../common_f_r.f ../fio.f; \ + cp ../common_f_r.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + touch ../0.out ../1.out ../2.out + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_f_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_f_r ok <======================"; \ + fi + + common_f_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_f_w.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../common_f_w.f ../fio.f; \ + cp ../common_f_w.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + touch ../file + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_f_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_f_w ok <======================"; \ + fi + + independent_f_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_f_r.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../independent_f_r.f ../fio.f; \ + cp ../independent_f_r.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + touch ../0.out ../1.out ../2.out + ./fio + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> independent_f_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_f_r ok <======================"; \ + fi + + independent_f_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_f_w.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../independent_f_w.f ../fio.f; \ + cp ../independent_f_w.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + touch ../file + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`wc -l < ../0.out`; \ + wc3=`wc -l < ../1.out`; \ + if [ $$wc1 -ne $$wc2 -o $$wc1 -ne $$wc3 ]; \ + then \ + echo "======================> independent_f_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_f_w ok <======================"; \ + fi + + syncBC_f_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_f_r.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_f_r.f ../fio.f; \ + cp ../syncBC_f_r.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + touch ../0.out ../1.out ../2.out + ./fio + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> syncBC_f_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_f_r ok <======================"; \ + fi + + syncBC_f_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_f_w.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_f_w.f ../fio.f; \ + cp ../syncBC_f_w.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + touch ../file + ./fio + @cmp -s ../0.out ../file; \ + if [ $$? -ne 0 ]; \ + then \ + echo "======================> syncBC_f_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_f_w ok <======================"; \ + fi + + syncseq_f_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_f_r.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_f_r.f ../fio.f; \ + cp ../syncseq_f_r.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + touch ../0.out ../1.out ../2.out + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_f_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_f_r ok <======================"; \ + fi + + syncseq_f_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_f_w.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_f_w.f ../fio.f; \ + cp ../syncseq_f_w.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + touch ../file + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_f_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_f_w ok <======================"; \ + fi + + clean: + rm -f $(OBJS) io $(FOBJS) fio mkfiles mkfiles.o ../01_r ../0_w ../1_w *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/Makefile.aimk Sun Jul 24 18:14:53 1994 *************** *** 0 **** --- 1,638 ---- + # Imports: + # PVM_ARCH = the official pvm-name of your processor + # ARCHCFLAGS = special cc flags + # ARCHFFSLIB = special libs needed for getting the FORTRAN library to use pvmfs + # + SHELL = /bin/sh + PVMIDIR = ../../../include + PVMLDIR = ../../../lib/$(PVM_ARCH) + PVMFSLDIR= ../../../libc/$(PVM_ARCH) + PVMLIB = -lpvm3 + CFLAGS = -g -I$(PVMIDIR) -DIMA_$(PVM_ARCH) $(ARCHCFLAGS) -I../../../src -DPVMFS + FFLAGS = -g + FSOBJS = $(PVMFSLDIR)/syscalls.o $(PVMFSLDIR)/pvmerrno.o $(PVMFSLDIR)/posix.o + LIBS = -L$(PVMLDIR) $(PVMLIB) + FLIBS1 = $(ARCHFFSLIB) + FLIBS2 = -L$(PVMLDIR) -lfpvm3 $(PVMLIB) + OBJS = io.o startup.o wait4fs.o + FOBJS = fio.o fstartup.o wait4fs.o + + all: c stdc f + + c: common_r common_w independent_r independent_w syncBC_r syncBC_w \ + syncseq_r syncseq_w + + stdc: common_stdc_r common_stdc_w independent_stdc_r independent_stdc_w \ + syncBC_stdc_r syncBC_stdc_w syncseq_stdc_r syncseq_stdc_w + + f: common_f_r common_f_w independent_f_r independent_f_w \ + syncBC_f_r syncBC_f_w syncseq_f_r syncseq_f_w + + files: mkfiles + @if [ ! -f 01_r ]; \ + then \ + mkfiles; \ + mv 01_r 0_w 1_w ..; \ + else \ + exit 0; \ + fi + + mkfiles: mkfiles.o + $(CC) -o $@ mkfiles.o + + mkfiles.o: ../mkfiles.c + $(SCC) -c ../mkfiles.c + + io: $(OBJS) $(PVMLDIR)/libpvm3.a $(FSOBJS) files + $(SCC) -o $@ $(OBJS) $(FSOBJS) $(LIBS) + rm -f $(HOME)/pvm3/bin/$(PVM_ARCH)/$@ + -ln -s `pwd`/$@ $(HOME)/pvm3/bin/$(PVM_ARCH) + + fio: $(FOBJS) $(PVMLDIR)/libpvm3.a $(PVMLDIR)/libfpvm3.a $(FSOBJS) files + $(FC) -o $@ $(FOBJS) $(FLIBS1) $(FSOBJS) $(FLIBS2) + rm -f $(HOME)/pvm3/bin/$(PVM_ARCH)/$@ + -ln -s `pwd`/$@ $(HOME)/pvm3/bin/$(PVM_ARCH) + + io.o: ../io.c + $(SCC) $(CFLAGS) -c ../io.c + + fio.o: ../fio.f + $(FC) $(FFLAGS) -c ../fio.f + + startup.o: ../startup.c + $(SCC) $(CFLAGS) -c ../startup.c + + fstartup.o: ../fstartup.f + $(FC) $(FFLAGS) -c ../fstartup.f + + wait4fs.o: ../wait4fs.c + $(SCC) $(CFLAGS) -c ../wait4fs.c + + common_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../common_r.c ../io.c; \ + cp ../common_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_r ok <======================"; \ + fi + + common_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../common_w.c ../io.c; \ + cp ../common_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_w ok <======================"; \ + fi + + independent_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../independent_r.c ../io.c; \ + cp ../independent_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> independent_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_r ok <======================"; \ + fi + + independent_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../independent_w.c ../io.c; \ + cp ../independent_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`wc -l < ../0.out`; \ + wc3=`wc -l < ../1.out`; \ + if [ $$wc1 -ne $$wc2 -o $$wc1 -ne $$wc3 ]; \ + then \ + echo "======================> independent_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_w ok <======================"; \ + fi + + syncBC_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_r.c ../io.c; \ + cp ../syncBC_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> syncBC_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_r ok <======================"; \ + fi + + syncBC_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_w.c ../io.c; \ + cp ../syncBC_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @cmp -s ../0.out ../file; \ + if [ $$? -ne 0 ]; \ + then \ + echo "======================> syncBC_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_w ok <======================"; \ + fi + + syncseq_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_r.c ../io.c; \ + cp ../syncseq_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_r ok <======================"; \ + fi + + syncseq_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_w.c ../io.c; \ + cp ../syncseq_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_w ok <======================"; \ + fi + + common_stdc_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_stdc_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../common_stdc_r.c ../io.c; \ + cp ../common_stdc_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_stdc_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_stdc_r ok <======================"; \ + fi + + common_stdc_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_stdc_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../common_stdc_w.c ../io.c; \ + cp ../common_stdc_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_stdc_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_stdc_w ok <======================"; \ + fi + + independent_stdc_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_stdc_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../independent_stdc_r.c ../io.c; \ + cp ../independent_stdc_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> independent_stdc_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_stdc_r ok <======================"; \ + fi + + independent_stdc_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_stdc_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../independent_stdc_w.c ../io.c; \ + cp ../independent_stdc_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`wc -l < ../0.out`; \ + wc3=`wc -l < ../1.out`; \ + if [ $$wc1 -ne $$wc2 -o $$wc1 -ne $$wc3 ]; \ + then \ + echo "======================> independent_stdc_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_stdc_w ok <======================"; \ + fi + + syncBC_stdc_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_stdc_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_stdc_r.c ../io.c; \ + cp ../syncBC_stdc_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> syncBC_stdc_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_stdc_r ok <======================"; \ + fi + + syncBC_stdc_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_stdc_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_stdc_w.c ../io.c; \ + cp ../syncBC_stdc_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @cmp -s ../0.out ../file; \ + if [ $$? -ne 0 ]; \ + then \ + echo "======================> syncBC_stdc_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_stdc_w ok <======================"; \ + fi + + syncseq_stdc_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_stdc_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_stdc_r.c ../io.c; \ + cp ../syncseq_stdc_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_stdc_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_stdc_r ok <======================"; \ + fi + + syncseq_stdc_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_stdc_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_stdc_w.c ../io.c; \ + cp ../syncseq_stdc_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_stdc_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_stdc_w ok <======================"; \ + fi + + common_f_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_f_r.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../common_f_r.f ../fio.f; \ + cp ../common_f_r.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + touch ../0.out ../1.out ../2.out + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_f_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_f_r ok <======================"; \ + fi + + common_f_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_f_w.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../common_f_w.f ../fio.f; \ + cp ../common_f_w.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + touch ../file + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_f_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_f_w ok <======================"; \ + fi + + independent_f_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_f_r.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../independent_f_r.f ../fio.f; \ + cp ../independent_f_r.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + touch ../0.out ../1.out ../2.out + ./fio + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> independent_f_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_f_r ok <======================"; \ + fi + + independent_f_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_f_w.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../independent_f_w.f ../fio.f; \ + cp ../independent_f_w.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + touch ../file + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`wc -l < ../0.out`; \ + wc3=`wc -l < ../1.out`; \ + if [ $$wc1 -ne $$wc2 -o $$wc1 -ne $$wc3 ]; \ + then \ + echo "======================> independent_f_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_f_w ok <======================"; \ + fi + + syncBC_f_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_f_r.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_f_r.f ../fio.f; \ + cp ../syncBC_f_r.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + touch ../0.out ../1.out ../2.out + ./fio + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> syncBC_f_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_f_r ok <======================"; \ + fi + + syncBC_f_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_f_w.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_f_w.f ../fio.f; \ + cp ../syncBC_f_w.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + touch ../file + ./fio + @cmp -s ../0.out ../file; \ + if [ $$? -ne 0 ]; \ + then \ + echo "======================> syncBC_f_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_f_w ok <======================"; \ + fi + + syncseq_f_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_f_r.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_f_r.f ../fio.f; \ + cp ../syncseq_f_r.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + touch ../0.out ../1.out ../2.out + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_f_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_f_r ok <======================"; \ + fi + + syncseq_f_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_f_w.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_f_w.f ../fio.f; \ + cp ../syncseq_f_w.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + touch ../file + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_f_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_f_w ok <======================"; \ + fi + + clean: + rm -f $(OBJS) io $(FOBJS) fio mkfiles mkfiles.o ../01_r ../0_w ../1_w *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/RS6K/Makefile Sun Jul 24 18:14:55 1994 *************** *** 0 **** --- 1,639 ---- + # Imports: + # PVM_ARCH = the official pvm-name of your processor + # ARCHCFLAGS = special cc flags + # ARCHFFSLIB = special libs needed for getting the FORTRAN library to use pvmfs + # + SHELL = /bin/sh + PVMIDIR = ../../../include + PVMLDIR = ../../../lib/$(PVM_ARCH) + PVMFSLDIR= ../../../libc/$(PVM_ARCH) + PVMLIB = -lpvm3 + CFLAGS = -g -I$(PVMIDIR) -DIMA_$(PVM_ARCH) $(ARCHCFLAGS) -I../../../src -DPVMFS + FFLAGS = -g + FSOBJS = $(PVMFSLDIR)/syscalls.o $(PVMFSLDIR)/pvmerrno.o $(PVMFSLDIR)/posix.o + LIBS = -g -L$(PVMLDIR) $(PVMLIB) $(ARCHFSLIB) + FLIBS2 = -g $(ARCHFSLIB) + OBJS = io.o startup.o wait4fs.o + FOBJS = fio.o fstartup.o wait4fs.o + + include ../../../conf/$(PVM_ARCH).def + + all: c stdc f + + c: common_r common_w independent_r independent_w syncBC_r syncBC_w \ + syncseq_r syncseq_w + + stdc: common_stdc_r common_stdc_w independent_stdc_r independent_stdc_w \ + syncBC_stdc_r syncBC_stdc_w syncseq_stdc_r syncseq_stdc_w + + f: common_f_r common_f_w independent_f_r independent_f_w \ + syncBC_f_r syncBC_f_w syncseq_f_r syncseq_f_w + + files: mkfiles + @if [ ! -f 01_r ]; \ + then \ + mkfiles; \ + mv 01_r 0_w 1_w ..; \ + else \ + exit 0; \ + fi + + mkfiles: mkfiles.o + $(CC) -o $@ mkfiles.o + + mkfiles.o: ../mkfiles.c + $(SCC) -c ../mkfiles.c + + io: $(OBJS) $(PVMLDIR)/libpvm3.a $(FSOBJS) files + $(SCC) -o $@ $(OBJS) $(FSOBJS) $(LIBS) + rm -f $(HOME)/pvm3/bin/$(PVM_ARCH)/$@ + -ln -s `pwd`/$@ $(HOME)/pvm3/bin/$(PVM_ARCH) + + fio: $(FOBJS) $(PVMLDIR)/libpvm3.a $(PVMLDIR)/libfpvm3.a $(FSOBJS) files + $(FC) -o $@ $(FOBJS) $(FLIBS1) $(FSOBJS) $(FLIBS2) + rm -f $(HOME)/pvm3/bin/$(PVM_ARCH)/$@ + -ln -s `pwd`/$@ $(HOME)/pvm3/bin/$(PVM_ARCH) + + io.o: ../io.c + $(SCC) $(CFLAGS) -c ../io.c + + fio.o: ../fio.f + $(FC) $(FFLAGS) -c ../fio.f + + startup.o: ../startup.c + $(SCC) $(CFLAGS) -c ../startup.c + + fstartup.o: ../fstartup.f + $(FC) $(FFLAGS) -c ../fstartup.f + + wait4fs.o: ../wait4fs.c + $(SCC) $(CFLAGS) -c ../wait4fs.c + + common_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../common_r.c ../io.c; \ + cp ../common_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_r ok <======================"; \ + fi + + common_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../common_w.c ../io.c; \ + cp ../common_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_w ok <======================"; \ + fi + + independent_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../independent_r.c ../io.c; \ + cp ../independent_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> independent_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_r ok <======================"; \ + fi + + independent_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../independent_w.c ../io.c; \ + cp ../independent_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`wc -l < ../0.out`; \ + wc3=`wc -l < ../1.out`; \ + if [ $$wc1 -ne $$wc2 -o $$wc1 -ne $$wc3 ]; \ + then \ + echo "======================> independent_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_w ok <======================"; \ + fi + + syncBC_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_r.c ../io.c; \ + cp ../syncBC_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> syncBC_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_r ok <======================"; \ + fi + + syncBC_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_w.c ../io.c; \ + cp ../syncBC_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @cmp -s ../0.out ../file; \ + if [ $$? -ne 0 ]; \ + then \ + echo "======================> syncBC_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_w ok <======================"; \ + fi + + syncseq_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_r.c ../io.c; \ + cp ../syncseq_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_r ok <======================"; \ + fi + + syncseq_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_w.c ../io.c; \ + cp ../syncseq_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_w ok <======================"; \ + fi + + common_stdc_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_stdc_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../common_stdc_r.c ../io.c; \ + cp ../common_stdc_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_stdc_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_stdc_r ok <======================"; \ + fi + + common_stdc_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_stdc_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../common_stdc_w.c ../io.c; \ + cp ../common_stdc_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_stdc_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_stdc_w ok <======================"; \ + fi + + independent_stdc_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_stdc_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../independent_stdc_r.c ../io.c; \ + cp ../independent_stdc_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> independent_stdc_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_stdc_r ok <======================"; \ + fi + + independent_stdc_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_stdc_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../independent_stdc_w.c ../io.c; \ + cp ../independent_stdc_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`wc -l < ../0.out`; \ + wc3=`wc -l < ../1.out`; \ + if [ $$wc1 -ne $$wc2 -o $$wc1 -ne $$wc3 ]; \ + then \ + echo "======================> independent_stdc_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_stdc_w ok <======================"; \ + fi + + syncBC_stdc_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_stdc_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_stdc_r.c ../io.c; \ + cp ../syncBC_stdc_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> syncBC_stdc_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_stdc_r ok <======================"; \ + fi + + syncBC_stdc_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_stdc_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_stdc_w.c ../io.c; \ + cp ../syncBC_stdc_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @cmp -s ../0.out ../file; \ + if [ $$? -ne 0 ]; \ + then \ + echo "======================> syncBC_stdc_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_stdc_w ok <======================"; \ + fi + + syncseq_stdc_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_stdc_r.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_stdc_r.c ../io.c; \ + cp ../syncseq_stdc_r.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + ./io 3 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_stdc_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_stdc_r ok <======================"; \ + fi + + syncseq_stdc_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_stdc_w.c ../io.c; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_stdc_w.c ../io.c; \ + cp ../syncseq_stdc_w.c ../io.c; \ + fi + (cd ..; ../../lib/aimk io) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + ./io 2 + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_stdc_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_stdc_w ok <======================"; \ + fi + + common_f_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_f_r.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../common_f_r.f ../fio.f; \ + cp ../common_f_r.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + touch ../0.out ../1.out ../2.out + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_f_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_f_r ok <======================"; \ + fi + + common_f_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../common_f_w.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../common_f_w.f ../fio.f; \ + cp ../common_f_w.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + touch ../file + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> common_f_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> common_f_w ok <======================"; \ + fi + + independent_f_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_f_r.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../independent_f_r.f ../fio.f; \ + cp ../independent_f_r.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + touch ../0.out ../1.out ../2.out + ./fio + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> independent_f_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_f_r ok <======================"; \ + fi + + independent_f_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../independent_f_w.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../independent_f_w.f ../fio.f; \ + cp ../independent_f_w.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + touch ../file + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`wc -l < ../0.out`; \ + wc3=`wc -l < ../1.out`; \ + if [ $$wc1 -ne $$wc2 -o $$wc1 -ne $$wc3 ]; \ + then \ + echo "======================> independent_f_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> independent_f_w ok <======================"; \ + fi + + syncBC_f_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_f_r.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_f_r.f ../fio.f; \ + cp ../syncBC_f_r.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + touch ../0.out ../1.out ../2.out + ./fio + @diff=`(cmp ../0.out ../file; cmp ../1.out ../file; cmp ../2.out ../file) | wc -l`; \ + if [ $$diff -ne 0 ]; \ + then \ + echo "======================> syncBC_f_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_f_r ok <======================"; \ + fi + + syncBC_f_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncBC_f_w.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../syncBC_f_w.f ../fio.f; \ + cp ../syncBC_f_w.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + touch ../file + ./fio + @cmp -s ../0.out ../file; \ + if [ $$? -ne 0 ]; \ + then \ + echo "======================> syncBC_f_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncBC_f_w ok <======================"; \ + fi + + syncseq_f_r: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_f_r.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_f_r.f ../fio.f; \ + cp ../syncseq_f_r.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../01_r ../file + rm -f ../0.out ../1.out ../2.out + touch ../0.out ../1.out ../2.out + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[0-2].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_f_r problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_f_r ok <======================"; \ + fi + + syncseq_f_w: + @echo "#######################" TESTING $@ "#######################" + @if cmp -s ../syncseq_f_w.f ../fio.f; \ + then \ + exit 0; \ + else \ + echo cp ../syncseq_f_w.f ../fio.f; \ + cp ../syncseq_f_w.f ../fio.f; \ + fi + (cd ..; ../../lib/aimk fio) + cp ../0_w ../0.out + cp ../1_w ../1.out + rm -f ../file + touch ../file + ./fio + @wc1=`wc -l < ../file`; \ + wc2=`cat ../[01].out | wc -l`; \ + if [ $$wc1 -ne $$wc2 ]; \ + then \ + echo "======================> syncseq_f_w problem <======================"; \ + exit 1; \ + else \ + echo "======================> syncseq_f_w ok <======================"; \ + fi + + clean: + rm -f $(OBJS) io $(FOBJS) fio mkfiles mkfiles.o ../01_r ../0_w ../1_w *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/common_f_r.f Sun Jul 24 18:14:53 1994 *************** *** 0 **** --- 1,80 ---- + program common_f_r + include '../../include/fpvm3.h' + integer stderr + parameter (stderr = 0) + common /mvp/ tids(3), nodes, me, parent + integer tids, nodes, me, parent + integer startup + integer ierr + character*31 buf, infile, outfile + character*1 cme + + nodes = 3 + me = startup('fio') + + infile = '../file' + call pvmfsetdefiomode(PvmIomodeCommon, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(10, file = infile, status = 'old', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', infile + call pvmfexit(ierr) + stop + endif + + if (me .eq. 0) then + cme = '0' + else if (me .eq. 1) then + cme = '1' + else + cme = '2' + endif + + outfile = '../' // cme // '.out' + call pvmfsetdefiomode(PvmIomodeIndividual, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(11, file = outfile, status = 'unknown', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', outfile + call pvmfexit(ierr) + stop + endif + + 10 read(10, '(A31)', iostat = ierr, err = 30, end = 20) buf + write(11, '(A31)', iostat = ierr, err = 40) buf + go to 10 + + 20 close(10, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', infile + call pvmfexit(ierr) + stop + endif + close(11, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', outfile + call pvmfexit(ierr) + stop + endif + call pvmfexit(ierr) + call wait4fs + stop + + 30 write(stderr, 50) infile, ': read error' + call pvmfexit(ierr) + stop + 40 write(stderr, 50) outfile, ': write error' + call pvmfexit(ierr) + stop + + 50 format(1x, A, A) + + end *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/common_f_w.f Sun Jul 24 18:14:53 1994 *************** *** 0 **** --- 1,80 ---- + program common_f_w + include '../../include/fpvm3.h' + integer stderr + parameter (stderr = 0) + common /mvp/ tids(3), nodes, me, parent + integer tids, nodes, me, parent + integer startup + integer ierr + character*31 buf, infile, outfile + character*1 cme + + nodes = 2 + me = startup('fio') + + outfile = '../file' + call pvmfsetdefiomode(PvmIomodeCommon, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(10, file = outfile, status = 'unknown', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', outfile + call pvmfexit(ierr) + stop + endif + + if (me .eq. 0) then + cme = '0' + else if (me .eq. 1) then + cme = '1' + else + cme = '2' + endif + + infile = '../' // cme // '.out' + call pvmfsetdefiomode(PvmIomodeIndividual, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(11, file = infile, status = 'old', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', infile + call pvmfexit(ierr) + stop + endif + + 10 read(11, '(A31)', iostat = ierr, err = 30, end = 20) buf + write(10, '(A31)', iostat = ierr, err = 40) buf + go to 10 + + 20 close(11, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', infile + call pvmfexit(ierr) + stop + endif + close(10, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', outfile + call pvmfexit(ierr) + stop + endif + call pvmfexit(ierr) + call wait4fs + stop + + 30 write(stderr, 50) infile, ': read error' + call pvmfexit(ierr) + stop + 40 write(stderr, 50) outfile, ': write error' + call pvmfexit(ierr) + stop + + 50 format(1x, A, A) + + end *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/common_r.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,56 ---- + #include + #include + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + int fdr; + int fdw; + char buf[32]; + char wfile[BUFSIZ]; + int nbytes; + + me = startup(&argc, argv); + + pvm_setdefiomode(PvmIomodeCommon); + if ((fdr = open("../file", O_RDONLY)) == -1) { + perror("../file"); + EXIT(1); + } + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fdw = open(wfile, O_CREAT | O_TRUNC | O_WRONLY, 0600)) == -1) { + perror(wfile); + EXIT(1); + } + + do { + if ((nbytes = read(fdr, buf, sizeof buf)) > 0) + if (write(fdw, buf, nbytes) == -1) { + perror("write"); + EXIT(1); + } + } while (nbytes > 0); + if (nbytes == -1) { + perror("read"); + EXIT(1); + } + + if (close(fdr) == -1) + perror("../file"); + if (close(fdw) == -1) + perror(wfile); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/common_stdc_r.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,54 ---- + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + FILE *fpr; + FILE *fpw; + char buf[32]; + char wfile[BUFSIZ]; + size_t nbytes; + + me = startup(&argc, argv); + + pvm_setdefiomode(PvmIomodeCommon); + if ((fpr = fopen("../file", "r")) == NULL) { + perror("../file"); + EXIT(1); + } + + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fpw = fopen(wfile, "w")) == NULL) { + perror(wfile); + EXIT(1); + } + + while (nbytes = fread(buf, sizeof *buf, sizeof buf, fpr)) { + if (fwrite(buf, sizeof *buf, nbytes, fpw) != nbytes) { + perror("fwrite"); + EXIT(1); + } + } + if (ferror(fpr)) { + perror("fread"); + EXIT(1); + } + + if (fclose(fpr) == EOF) + perror("../file"); + if (fclose(fpw) == EOF) + perror(wfile); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/common_stdc_w.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,54 ---- + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + FILE *fpr; + FILE *fpw; + char buf[32]; + char wfile[BUFSIZ]; + size_t nbytes; + + me = startup(&argc, argv); + + pvm_setdefiomode(PvmIomodeCommon); + if ((fpw = fopen("../file", "w")) == NULL) { + perror("../file"); + EXIT(1); + } + + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fpr = fopen(wfile, "r")) == NULL) { + perror(wfile); + EXIT(1); + } + + while (nbytes = fread(buf, sizeof *buf, sizeof buf, fpr)) { + if (fwrite(buf, sizeof *buf, nbytes, fpw) != nbytes) { + perror("fwrite"); + EXIT(1); + } + } + if (ferror(fpr)) { + perror("fread"); + EXIT(1); + } + + if (fclose(fpr) == EOF) + perror(wfile); + if (fclose(fpw) == EOF) + perror("../file"); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/common_w.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,56 ---- + #include + #include + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + int fdr; + int fdw; + char buf[32]; + char wfile[BUFSIZ]; + int nbytes; + + me = startup(&argc, argv); + + pvm_setdefiomode(PvmIomodeCommon); + if ((fdw = open("../file", O_CREAT | O_TRUNC | O_WRONLY, 0600)) + == -1) { + perror("../file"); + EXIT(1); + } + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fdr = open(wfile, O_RDONLY)) == -1) { + perror(wfile); + EXIT(1); + } + + while ((nbytes = read(fdr, buf, sizeof buf)) > 0) { + if (write(fdw, buf, nbytes) == -1) { + perror("write"); + EXIT(1); + } + } + if (nbytes == -1) { + perror("read"); + EXIT(1); + } + + if (close(fdr) == -1) + perror(wfile); + if (close(fdw) == -1) + perror("../file"); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/fstartup.f Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,122 ---- + C + C Author: Christopher G. Phillips + C Copyright (C) 1993 All Rights Reserved + C + C NOTICE + C + C Permission to use, copy, modify, and distribute this software and + C its documentation for any purpose and without fee is hereby granted + C provided that the above copyright notice appear in all copies and + C that both the copyright notice and this permission notice appear in + C supporting documentation. + C + C The author makes no representations about the suitability of this + C software for any purpose. This software is provided ``as is'' + C without express or implied warranty. + C + + subroutine standdown(num_spawned) + common /mvp/ tids(3), nodes, me, parent + integer tids, nodes, me, parent + integer num_spawned + + do 10 i = 2, num_spawned + if (tids(i) .ge. 0) then + call pvmfkill(tids(i), idummy) + endif + 10 continue + + write(0, *) 'Shutting down...' + stop + end + + subroutine gsync + include '../../include/fpvm3.h' + integer gsync_type + parameter(gsync_type = 32765) + common /mvp/ tids(3), nodes, me, parent + integer tids, nodes, me, parent + integer i, info + + if (nodes .gt. 1) then + if (me .eq. 0) then + do 10 i = 2, nodes + call pvmfrecv(-1, gsync_type, info) + 10 continue + call pvmfinitsend(PVMDEFAULT, info) + call pvmfmcast(nodes - 1, tids(2), + + gsync_type + 1, info) + else + call pvmfinitsend(PVMDEFAULT, info) + call pvmfsend(parent, gsync_type, info) + call pvmfrecv(parent, gsync_type + 1, info) + endif + endif + + return + end + + integer function startup(task) + include '../../include/fpvm3.h' + integer gsync_type + parameter(gsync_type = 16777216) + common /mvp/ tids(3), nodes, me, parent + integer tids, nodes, me, parent + character*(*) task + + integer mytid, numt + + call pvmfusefs(1, info) + if (info .lt. 0) then + call pvmfperror('pvmfusefs', info) + stop + endif + + call pvmfmytid(mytid) + if (mytid .lt. 0) then + call pvmfperror('pvmfmytid', mytid) + stop + endif + + call pvmfparent(parent) + if (parent .lt. 0) then + if (nodes .gt. 1) then + tids(1) = mytid + + c call pvmfspawn(task, PVMDEFAULT + PVMDEBUG, '*', + call pvmfspawn(task, PVMDEFAULT, '*', + + nodes - 1, tids(2), numt) + if (numt .ne. nodes - 1) then + call standdown(nodes - 1) + endif + + call pvmfinitsend(PVMDEFAULT, info) + if (info .lt. 0) call standdown(nodes - 1) + call pvmfpack(INTEGER4, nodes, 1, 1, info) + if (info .lt. 0) call standdown(nodes - 1) + call pvmfpack(INTEGER4, tids, nodes, 1, info) + if (info .lt. 0) call standdown(nodes - 1) + call pvmfmcast(nodes - 1, tids(2), 32767, info) + if (info .lt. 0) call standdown(nodes - 1) + endif + me = 0 + else + call pvmfrecv(parent, 32767, info) + if (info .lt. 0) call standdown(0) + call pvmfunpack(INTEGER4, nodes, 1, 1, info) + if (info .lt. 0) call standdown(0) + call pvmfunpack(INTEGER4, tids, nodes, 1, info) + if (info .lt. 0) call standdown(0) + + do 10 i = 2, nodes + if (tids(i) .eq. mytid) then + me = i - 1 + endif + 10 continue + endif + + call gsync + + startup = me + return + end *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/independent_f_r.f Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,80 ---- + program independent_f_r + include '../../include/fpvm3.h' + integer stderr + parameter (stderr = 0) + common /mvp/ tids(3), nodes, me, parent + integer tids, nodes, me, parent + integer startup + integer ierr + character*31 buf, infile, outfile + character*1 cme + + nodes = 3 + me = startup('fio') + + infile = '../file' + call pvmfsetdefiomode(PvmIomodeIndependent, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(10, file = infile, status = 'old', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', infile + call pvmfexit(ierr) + stop + endif + + if (me .eq. 0) then + cme = '0' + else if (me .eq. 1) then + cme = '1' + else + cme = '2' + endif + + outfile = '../' // cme // '.out' + call pvmfsetdefiomode(PvmIomodeIndividual, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(11, file = outfile, status = 'unknown', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', outfile + call pvmfexit(ierr) + stop + endif + + 10 read(10, '(A31)', iostat = ierr, err = 30, end = 20) buf + write(11, '(A31)', iostat = ierr, err = 40) buf + go to 10 + + 20 close(10, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', infile + call pvmfexit(ierr) + stop + endif + close(11, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', outfile + call pvmfexit(ierr) + stop + endif + call pvmfexit(ierr) + call wait4fs + stop + + 30 write(stderr, 50) infile, ': read error' + call pvmfexit(ierr) + stop + 40 write(stderr, 50) outfile, ': write error' + call pvmfexit(ierr) + stop + + 50 format(1x, A, A) + + end *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/independent_f_w.f Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,80 ---- + program independent_f_w + include '../../include/fpvm3.h' + integer stderr + parameter (stderr = 0) + common /mvp/ tids(3), nodes, me, parent + integer tids, nodes, me, parent + integer startup + integer ierr + character*31 buf, infile, outfile + character*1 cme + + nodes = 2 + me = startup('fio') + + outfile = '../file' + call pvmfsetdefiomode(PvmIomodeIndependent, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(10, file = outfile, status = 'unknown', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', outfile + call pvmfexit(ierr) + stop + endif + + if (me .eq. 0) then + cme = '0' + else if (me .eq. 1) then + cme = '1' + else + cme = '2' + endif + + infile = '../' // cme // '.out' + call pvmfsetdefiomode(PvmIomodeIndividual, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(11, file = infile, status = 'old', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', infile + call pvmfexit(ierr) + stop + endif + + 10 read(11, '(A31)', iostat = ierr, err = 30, end = 20) buf + write(10, '(A31)', iostat = ierr, err = 40) buf + go to 10 + + 20 close(11, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', infile + call pvmfexit(ierr) + stop + endif + close(10, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', outfile + call pvmfexit(ierr) + stop + endif + call pvmfexit(ierr) + call wait4fs + stop + + 30 write(stderr, 50) infile, ': read error' + call pvmfexit(ierr) + stop + 40 write(stderr, 50) outfile, ': write error' + call pvmfexit(ierr) + stop + + 50 format(1x, A, A) + + end *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/independent_r.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,55 ---- + #include + #include + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + int fdr; + int fdw; + char buf[32]; + char wfile[BUFSIZ]; + int nbytes; + + me = startup(&argc, argv); + + pvm_setdefiomode(PvmIomodeIndependent); + if ((fdr = open("../file", O_RDONLY)) == -1) { + perror("../file"); + EXIT(1); + } + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fdw = open(wfile, O_CREAT | O_TRUNC | O_WRONLY, 0600)) == -1) { + perror(wfile); + EXIT(1); + } + do { + if ((nbytes = read(fdr, buf, sizeof buf)) > 0) + if (write(fdw, buf, nbytes) == -1) { + perror("write"); + EXIT(1); + } + } while (nbytes > 0); + if (nbytes == -1) { + perror("read"); + EXIT(1); + } + + if (close(fdr) == -1) + perror("../file"); + if (close(fdw) == -1) + perror(wfile); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/independent_stdc_r.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,55 ---- + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + FILE *fpr; + FILE *fpw; + char buf[32]; + char wfile[BUFSIZ]; + size_t nbytes; + + me = startup(&argc, argv); + + pvm_setdefiomode(PvmIomodeIndependent); + if ((fpr = fopen("../file", "r")) == NULL) { + perror("../file"); + EXIT(1); + } + + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fpw = fopen(wfile, "w")) == NULL) { + perror(wfile); + EXIT(1); + } + + while (nbytes = fread(buf, sizeof *buf, sizeof buf, fpr)) { + if (fwrite(buf, sizeof *buf, nbytes, fpw) != nbytes) { + perror("fwrite"); + EXIT(1); + } + } + + if (ferror(fpr)) { + perror("fread"); + EXIT(1); + } + + if (fclose(fpr) == EOF) + perror("../file"); + if (fclose(fpw) == EOF) + perror(wfile); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/independent_stdc_w.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,54 ---- + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + FILE *fpr; + FILE *fpw; + char buf[32]; + char wfile[BUFSIZ]; + size_t nbytes; + + me = startup(&argc, argv); + + pvm_setdefiomode(PvmIomodeIndependent); + if ((fpw = fopen("../file", "w")) == NULL) { + perror("../file"); + EXIT(1); + } + + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fpr = fopen(wfile, "r")) == NULL) { + perror(wfile); + EXIT(1); + } + + while (nbytes = fread(buf, sizeof *buf, sizeof buf, fpr)) { + if (fwrite(buf, sizeof *buf, nbytes, fpw) != nbytes) { + perror("fwrite"); + EXIT(1); + } + } + if (ferror(fpr)) { + perror("fread"); + EXIT(1); + } + + if (fclose(fpr) == EOF) + perror(wfile); + if (fclose(fpw) == EOF) + perror("../file"); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/independent_w.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,56 ---- + #include + #include + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + int fdr; + int fdw; + char buf[32]; + char wfile[BUFSIZ]; + int nbytes; + + me = startup(&argc, argv); + + pvm_setdefiomode(PvmIomodeIndependent); + if ((fdw = open("../file", O_CREAT | O_TRUNC | O_WRONLY, 0600)) + == -1) { + perror("../file"); + EXIT(1); + } + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fdr = open(wfile, O_RDONLY)) == -1) { + perror(wfile); + EXIT(1); + } + + while ((nbytes = read(fdr, buf, sizeof buf)) > 0) { + if (write(fdw, buf, nbytes) == -1) { + perror("write"); + EXIT(1); + } + } + if (nbytes == -1) { + perror("read"); + EXIT(1); + } + + if (close(fdr) == -1) + perror(wfile); + if (close(fdw) == -1) + perror("../file"); + + EXIT2(0); + } *** /dev/null Mon Aug 29 14:27:25 1994 --- fsexamples/io/test2 Mon Aug 29 14:17:23 1994 *************** *** 0 **** --- 1,51 ---- + #!/bin/sh + + if [ $# -eq 1 ] + then + machine=$1 + target="common_r common_w independent_r independent_w syncBC_r \ + syncBC_w syncseq_r syncseq_w \ + common_stdc_r common_stdc_w independent_stdc_r independent_stdc_w \ + syncBC_stdc_r syncBC_stdc_w syncseq_stdc_r syncseq_stdc_w \ + common_f_r common_f_w independent_f_r independent_f_w \ + syncBC_f_r syncBC_f_w syncseq_f_r syncseq_f_w" + elif [ $# -eq 2 ] + then + machine=$1 + target=$2 + else + echo Usage: $0 marchine [target] + exit 1 + fi + + if [ X$target = "Xc" ] + then + target="common_r common_w independent_r independent_w syncBC_r \ + syncBC_w syncseq_r syncseq_w" + elif [ X$target = "Xstdc" ] + then + target="common_stdc_r common_stdc_w independent_stdc_r \ + independent_stdc_w syncBC_stdc_r syncBC_stdc_w syncseq_stdc_r \ + syncseq_stdc_w" + elif [ X$target = "Xf" ] + then + target="common_f_r common_f_w independent_f_r independent_f_w \ + syncBC_f_r syncBC_f_w syncseq_f_r syncseq_f_w" + fi + + for i in $target + do + if `echo $i | grep '_f_[rw]$' > /dev/null` + then + p=f + s=f + else + p="" + s=c + fi + echo "Target is $i <---------------------------------------------" + rsh $machine "cd \$PVM_ROOT/fsexamples/io; cp $i.$s ${p}io.$s; \ + \$PVM_ROOT/lib/aimk ${p}io; echo $machine done" + $PVM_ROOT/lib/aimk $i + ls -l *out file + done *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/mkfiles.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,101 ---- + #include + #include + + #define FILENAME1 "0_w" + #define FILENAME2 "1_w" + #define FILENAME3 "01_r" + + #define STRING1 "XXXXXabcdefghijklmnopqrstuvwxyz" + #define STRING2 "XXXXXABCDEFGHIJKLMNOPQRSTUVWXYZ" + + #define NUMBER1 "XXXXX11111111111111111111111111" + #define NUMBER2 "XXXXX22222222222222222222222222" + #define NUMBER3 "XXXXX33333333333333333333333333" + #define NUMBER4 "XXXXX44444444444444444444444444" + #define NUMBER5 "XXXXX55555555555555555555555555" + #define NUMBER6 "XXXXX66666666666666666666666666" + #define NUMBER7 "XXXXX77777777777777777777777777" + #define NUMBER8 "XXXXX88888888888888888888888888" + + #define LINES1 1024 + #define LINES2 1024 + #define LINES3 1536 /* must be a multiple of 8 */ + + #define MAX(a,b) ((a) > (b) ? (a) : (b)) + + int + main(int argc, char **argv) + { + FILE *fp1, *fp2, *fp3; + char string1[33], string2[33], number[8][33]; + char line[6]; + int max; + int i, j; + + if ((fp1 = fopen(FILENAME1, "w")) == NULL) { + perror(FILENAME1); + exit(1); + } + if ((fp2 = fopen(FILENAME2, "w")) == NULL) { + perror(FILENAME2); + exit(1); + } + if ((fp3 = fopen(FILENAME3, "w")) == NULL) { + perror(FILENAME3); + exit(1); + } + + max = MAX(LINES1, LINES2); + max = MAX(max, LINES3); + + strcpy(string1, STRING1); + strcat(string1, "\n"); + strcpy(string2, STRING2); + strcat(string2, "\n"); + + strcpy(number[0], NUMBER1); + strcpy(number[1], NUMBER2); + strcpy(number[2], NUMBER3); + strcpy(number[3], NUMBER4); + strcpy(number[4], NUMBER5); + strcpy(number[5], NUMBER6); + strcpy(number[6], NUMBER7); + strcpy(number[7], NUMBER8); + strcat(number[0], "\n"); + strcat(number[1], "\n"); + strcat(number[2], "\n"); + strcat(number[3], "\n"); + strcat(number[4], "\n"); + strcat(number[5], "\n"); + strcat(number[6], "\n"); + strcat(number[7], "\n"); + + for (i = j = 0; i < max; i++, j++) { + sprintf(line, "%05d", i + 1); + if (i < LINES1) { + memcpy(string1, line, 5); + if (fputs(string1, fp1) == EOF) { + perror(FILENAME1); + exit(1); + } + } + if (i < LINES2) { + memcpy(string2, line, 5); + if (fputs(string2, fp2) == EOF) { + perror(FILENAME2); + exit(1); + } + } + if (i < LINES3) { + if (j == 8) + j = 0; + memcpy(number[j], line, 5); + if (fputs(number[j], fp3) == EOF) { + perror(FILENAME3); + exit(1); + } + } + } + + exit(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/startup.c Mon Aug 29 14:26:53 1994 *************** *** 0 **** --- 1,195 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #include + #include + #include + #include + #include "pvm3.h" + + #ifndef MAXHOSTNAMELEN + #define MAXHOSTNAMELEN 100 + #endif + + static int *tids; + static int nodes; + static int me; + static int parent; + extern int pvm_errno; + static char *program_name; + + static void + usage(void) + { + fprintf(stderr, "Usage: %s nodes ...\n", program_name); + exit(1); + } + + static void + say_hello(void) + { + char hostname[MAXHOSTNAMELEN]; + + fflush(stdout); + pvm_setiomode(fileno(stdout), PvmIomodeCommon); + pvm_setiomode(fileno(stderr), PvmIomodeCommon); + if (gethostname(hostname, sizeof hostname) == -1) + strcpy(hostname, "Unknown"); + printf("Hello world from node %d running on %s!\n", me, hostname); + fflush(stdout); + } + + static void + standdown(int num_spawned, char *s) + { + int i; + extern int pvmmyfstid; + + pvmmyfstid = 0; + if (s) + pvm_perror(s); + else if (num_spawned == 0) + pvm_perror("pvm_spawn"); + + for (i = 1; i < num_spawned; i++) + if (tids[i] < 0) { + pvm_errno = tids[i]; + pvm_perror("pvm_spawn"); + } else if (pvm_kill(tids[i]) < 0) + pvm_perror("pvm_kill"); + + exit(1); + } + + #define GSYNC_TYPE 0x11000000 + + void + gsync(void) + { + int i; + + if (nodes > 1) { + if (me == 0) { + for (i = 1; i < nodes; i++) + pvm_recv(-1, GSYNC_TYPE); + pvm_initsend(PvmDataDefault); + pvm_mcast(&tids[1], nodes - 1, GSYNC_TYPE + 1); + } else { + pvm_initsend(PvmDataDefault); + pvm_send(parent, GSYNC_TYPE); + pvm_recv(parent, GSYNC_TYPE + 1); + } + } + } + + int + startup(int *argcp, char **argv) + { + int mytid; + char *slash; + int argc = *argcp; + + pvm_usefs(1); + + if (slash = strrchr(argv[0], '/')) + argv[0] = slash + 1; + program_name = argv[0]; + + if ((mytid = pvm_mytid()) < 0) { + pvm_perror("pvm_mytid"); + exit(1); + } + + if ((parent = pvm_parent()) < 0) { + if (argc < 2) + usage(); + + if ((nodes = atoi(argv[1])) <= 0) + usage(); + if (nodes > 1) { + int done = 1; + int i; + int j; + int nhost; + int this_host; + struct pvmhostinfo *hip; + + this_host = pvm_tidtohost(mytid); + if ((tids = malloc(nodes * sizeof(*tids))) == NULL) { + perror(argv[0]); + exit(1); + } + tids[0] = mytid; + + if (pvm_config(&nhost, &j, &hip) < 0) { + pvm_perror("pvm_config"); + exit(1); + } + + for (i = 0; i < nhost; i++) { + j = nodes / nhost; + if (i < nodes % nhost) + j++; + if (hip[i].hi_tid == this_host) + j--; + if (j <= 0) + continue; + + if (pvm_spawn(argv[0], argv + 2, + PvmTaskHost, hip[i].hi_name, j, &tids[done]) + != j) + standdown(done, NULL); + + done += j; + } + + for (i = 1; i < argc; i++) + argv[i] = argv[i + 1]; + (*argcp)--; + + if (pvm_packf("%+ %d %*d", PvmDataDefault, nodes, nodes, + tids) < 0) + standdown(done, "pvm_packf"); + if (pvm_mcast(&tids[1], nodes - 1, 32767) < 0) + standdown(done, "pvm_mcast"); + } + me = 0; + } else { + if (pvm_recv(parent, 32767) < 0) + standdown(0, "pvm_recv"); + if (pvm_unpackf("%d", &nodes) < 0) + standdown(0, "pvm_unpackf"); + + if ((tids = malloc(nodes * sizeof(*tids))) == NULL) { + perror("malloc"); + exit(1); + } + if (pvm_unpackf("%*d", nodes, tids) < 0) + standdown(0, "pvm_unpackf"); + + for (me = nodes; me > 0; me--) + if (tids[me] == mytid) + break; + /*assert(me);*/ + } + + say_hello(); + + gsync(); + + return me; + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/syncBC_f_r.f Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,86 ---- + program syncBC_f_r + include '../../include/fpvm3.h' + integer stderr + parameter (stderr = 0) + common /mvp/ tids(3), nodes, me, parent + integer tids, nodes, me, parent + integer startup + integer ierr + character*31 buf, infile, outfile + character*1 cme + + nodes = 3 + me = startup('fio') + call pvmfsetioorder(me, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetioorder', ierr) + call pvmfexit(ierr) + stop + endif + + infile = '../file' + call pvmfsetdefiomode(PvmIomodeSyncBC, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(10, file = infile, status = 'old', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', infile + call pvmfexit(ierr) + stop + endif + + if (me .eq. 0) then + cme = '0' + else if (me .eq. 1) then + cme = '1' + else + cme = '2' + endif + + outfile = '../' // cme // '.out' + call pvmfsetdefiomode(PvmIomodeIndividual, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(11, file = outfile, status = 'unknown', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', outfile + call pvmfexit(ierr) + stop + endif + + 10 read(10, '(A31)', iostat = ierr, err = 30, end = 20) buf + write(11, '(A31)', iostat = ierr, err = 40) buf + go to 10 + + 20 close(10, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', infile + call pvmfexit(ierr) + stop + endif + close(11, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', outfile + call pvmfexit(ierr) + stop + endif + call pvmfexit(ierr) + call wait4fs + stop + + 30 write(stderr, 50) infile, ': read error' + call pvmfexit(ierr) + stop + 40 write(stderr, 50) outfile, ': write error' + call pvmfexit(ierr) + stop + + 50 format(1x, A, A) + + end *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/syncBC_f_w.f Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,86 ---- + program syncBC_f_w + include '../../include/fpvm3.h' + integer stderr + parameter (stderr = 0) + common /mvp/ tids(3), nodes, me, parent + integer tids, nodes, me, parent + integer startup + integer ierr + character*31 buf, infile, outfile + character*1 cme + + nodes = 2 + me = startup('fio') + call pvmfsetioorder(me, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetioorder', ierr) + call pvmfexit(ierr) + stop + endif + + outfile = '../file' + call pvmfsetdefiomode(PvmIomodeSyncBC, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(10, file = outfile, status = 'unknown', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', outfile + call pvmfexit(ierr) + stop + endif + + if (me .eq. 0) then + cme = '0' + else if (me .eq. 1) then + cme = '1' + else + cme = '2' + endif + + infile = '../' // cme // '.out' + call pvmfsetdefiomode(PvmIomodeIndividual, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(11, file = infile, status = 'old', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', infile + call pvmfexit(ierr) + stop + endif + + 10 read(11, '(A31)', iostat = ierr, err = 30, end = 20) buf + write(10, '(A31)', iostat = ierr, err = 40) buf + go to 10 + + 20 close(11, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', infile + call pvmfexit(ierr) + stop + endif + close(10, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', outfile + call pvmfexit(ierr) + stop + endif + call pvmfexit(ierr) + call wait4fs + stop + + 30 write(stderr, 50) infile, ': read error' + call pvmfexit(ierr) + stop + 40 write(stderr, 50) outfile, ': write error' + call pvmfexit(ierr) + stop + + 50 format(1x, A, A) + + end *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/syncBC_r.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,55 ---- + #include + #include + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + int fdr; + int fdw; + char buf[32]; + char wfile[BUFSIZ]; + int nbytes; + + me = startup(&argc, argv); + + pvm_setioorder(me); + pvm_setdefiomode(PvmIomodeSyncBC); + if ((fdr = open("../file", O_RDONLY)) == -1) { + perror("../file"); + EXIT(1); + } + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fdw = open(wfile, O_CREAT | O_TRUNC | O_WRONLY, 0600)) == -1) { + perror(wfile); + EXIT(1); + } + while ((nbytes = read(fdr, buf, sizeof buf)) > 0) { + if (write(fdw, buf, nbytes) == -1) { + perror("write"); + EXIT(1); + } + } + if (nbytes == -1) { + perror("read"); + EXIT(1); + } + + if (close(fdr) == -1) + perror(wfile); + if (close(fdw) == -1) + perror("../file"); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/syncBC_stdc_r.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,55 ---- + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + FILE *fpr; + FILE *fpw; + char buf[32]; + char wfile[BUFSIZ]; + size_t nbytes; + + me = startup(&argc, argv); + + pvm_setioorder(me); + pvm_setdefiomode(PvmIomodeSyncBC); + if ((fpr = fopen("../file", "r")) == NULL) { + perror("../file"); + EXIT(1); + } + + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fpw = fopen(wfile, "w")) == NULL) { + perror(wfile); + EXIT(1); + } + + while (nbytes = fread(buf, sizeof *buf, sizeof buf, fpr)) { + if (fwrite(buf, sizeof *buf, nbytes, fpw) != nbytes) { + perror("fwrite"); + EXIT(1); + } + } + if (ferror(fpr)) { + perror("fread"); + EXIT(1); + } + + if (fclose(fpr) == EOF) + perror(wfile); + if (fclose(fpw) == EOF) + perror("../file"); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/syncBC_stdc_w.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,55 ---- + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + FILE *fpr; + FILE *fpw; + char buf[32]; + char wfile[BUFSIZ]; + size_t nbytes; + + me = startup(&argc, argv); + + pvm_setioorder(me); + pvm_setdefiomode(PvmIomodeSyncBC); + if ((fpw = fopen("../file", "w")) == NULL) { + perror("../file"); + EXIT(1); + } + + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fpr = fopen(wfile, "r")) == NULL) { + perror(wfile); + EXIT(1); + } + + while (nbytes = fread(buf, sizeof *buf, sizeof buf, fpr)) { + if (fwrite(buf, sizeof *buf, nbytes, fpw) != nbytes) { + perror("fwrite"); + EXIT(1); + } + } + if (ferror(fpr)) { + perror("fread"); + EXIT(1); + } + + if (fclose(fpr) == EOF) + perror(wfile); + if (fclose(fpw) == EOF) + perror("../file"); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/syncBC_w.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,56 ---- + #include + #include + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + int fdr; + int fdw; + char buf[32]; + char wfile[BUFSIZ]; + int nbytes; + + me = startup(&argc, argv); + + pvm_setioorder(me); + pvm_setdefiomode(PvmIomodeSyncBC); + if ((fdw = open("../file", O_CREAT | O_TRUNC | O_WRONLY, 0600)) + == -1) { + perror("../file"); + EXIT(1); + } + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fdr = open(wfile, O_RDONLY)) == -1) { + perror(wfile); + EXIT(1); + } + while ((nbytes = read(fdr, buf, sizeof buf)) > 0) { + if (write(fdw, buf, nbytes) == -1) { + perror("write"); + EXIT(1); + } + } + if (nbytes == -1) { + perror("read"); + EXIT(1); + } + + if (close(fdr) == -1) + perror(wfile); + if (close(fdw) == -1) + perror("../file"); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/syncseq_f_r.f Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,86 ---- + program syncseq_f_r + include '../../include/fpvm3.h' + integer stderr + parameter (stderr = 0) + common /mvp/ tids(3), nodes, me, parent + integer tids, nodes, me, parent + integer startup + integer ierr + character*31 buf, infile, outfile + character*1 cme + + nodes = 3 + me = startup('fio') + call pvmfsetioorder(me, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetioorder', ierr) + call pvmfexit(ierr) + stop + endif + + infile = '../file' + call pvmfsetdefiomode(PvmIomodeSyncSeq, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(10, file = infile, status = 'old', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', infile + call pvmfexit(ierr) + stop + endif + + if (me .eq. 0) then + cme = '0' + else if (me .eq. 1) then + cme = '1' + else + cme = '2' + endif + + outfile = '../' // cme // '.out' + call pvmfsetdefiomode(PvmIomodeIndividual, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(11, file = outfile, status = 'unknown', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', outfile + call pvmfexit(ierr) + stop + endif + + 10 read(10, '(A31)', iostat = ierr, err = 30, end = 20) buf + write(11, '(A31)', iostat = ierr, err = 40) buf + go to 10 + + 20 close(10, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', infile + call pvmfexit(ierr) + stop + endif + close(11, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', outfile + call pvmfexit(ierr) + stop + endif + call pvmfexit(ierr) + call wait4fs + stop + + 30 write(stderr, 50) infile, ': read error' + call pvmfexit(ierr) + stop + 40 write(stderr, 50) outfile, ': write error' + call pvmfexit(ierr) + stop + + 50 format(1x, A, A) + + end *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/syncseq_f_w.f Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,86 ---- + program syncseq_f_w + include '../../include/fpvm3.h' + integer stderr + parameter (stderr = 0) + common /mvp/ tids(3), nodes, me, parent + integer tids, nodes, me, parent + integer startup + integer ierr + character*31 buf, infile, outfile + character*1 cme + + nodes = 2 + me = startup('fio') + call pvmfsetioorder(me, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetioorder', ierr) + call pvmfexit(ierr) + stop + endif + + outfile = '../file' + call pvmfsetdefiomode(PvmIomodeSyncSeq, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(10, file = outfile, status = 'unknown', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', outfile + call pvmfexit(ierr) + stop + endif + + if (me .eq. 0) then + cme = '0' + else if (me .eq. 1) then + cme = '1' + else + cme = '2' + endif + + infile = '../' // cme // '.out' + call pvmfsetdefiomode(PvmIomodeIndividual, ierr) + if (ierr .ne. 0) then + call pvmfperror('pvmfsetdefiomode', ierr) + call pvmfexit(ierr) + stop + endif + open(11, file = infile, status = 'old', iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Can''t open ', infile + call pvmfexit(ierr) + stop + endif + + 10 read(11, '(A31)', iostat = ierr, err = 30, end = 20) buf + write(10, '(A31)', iostat = ierr, err = 40) buf + go to 10 + + 20 close(11, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', infile + call pvmfexit(ierr) + stop + endif + close(10, iostat = ierr) + if (ierr .ne. 0) then + write(stderr, 50) 'Close error: ', outfile + call pvmfexit(ierr) + stop + endif + call pvmfexit(ierr) + call wait4fs + stop + + 30 write(stderr, 50) infile, ': read error' + call pvmfexit(ierr) + stop + 40 write(stderr, 50) outfile, ': write error' + call pvmfexit(ierr) + stop + + 50 format(1x, A, A) + + end *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/syncseq_r.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,55 ---- + #include + #include + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + int fdr; + int fdw; + char buf[32]; + char wfile[BUFSIZ]; + int nbytes; + + me = startup(&argc, argv); + + pvm_setioorder(me); + pvm_setdefiomode(PvmIomodeSyncSeq); + if ((fdr = open("../file", O_RDONLY)) == -1) { + perror("../file"); + EXIT(1); + } + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fdw = open(wfile, O_CREAT | O_TRUNC | O_WRONLY, 0600)) == -1) { + perror(wfile); + EXIT(1); + } + while ((nbytes = read(fdr, buf, sizeof buf)) > 0) { + if (write(fdw, buf, nbytes) == -1) { + perror("write"); + EXIT(1); + } + } + if (nbytes == -1) { + perror("read"); + EXIT(1); + } + + if (close(fdr) == -1) + perror(wfile); + if (close(fdw) == -1) + perror("../file"); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/syncseq_stdc_r.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,55 ---- + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + FILE *fpr; + FILE *fpw; + char buf[32]; + char wfile[BUFSIZ]; + size_t nbytes; + + me = startup(&argc, argv); + + pvm_setioorder(me); + pvm_setdefiomode(PvmIomodeSyncSeq); + if ((fpr = fopen("../file", "r")) == NULL) { + perror("../file"); + EXIT(1); + } + + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fpw = fopen(wfile, "w")) == NULL) { + perror(wfile); + EXIT(1); + } + + while (nbytes = fread(buf, sizeof *buf, sizeof buf, fpr)) { + if (fwrite(buf, sizeof *buf, nbytes, fpw) != nbytes) { + perror("fwrite"); + EXIT(1); + } + } + if (ferror(fpr)) { + perror("fread"); + EXIT(1); + } + + if (fclose(fpr) == EOF) + perror(wfile); + if (fclose(fpw) == EOF) + perror("../file"); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/syncseq_stdc_w.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,56 ---- + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + FILE *fpr; + FILE *fpw; + char buf[32], fpwbuf[32]; + char wfile[BUFSIZ]; + size_t nbytes; + + me = startup(&argc, argv); + + pvm_setioorder(me); + pvm_setdefiomode(PvmIomodeSyncSeq); + if ((fpw = fopen("../file", "w")) == NULL) { + perror("../file"); + EXIT(1); + } + setvbuf(fpw, fpwbuf, _IOFBF, sizeof fpwbuf); + + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fpr = fopen(wfile, "r")) == NULL) { + perror(wfile); + EXIT(1); + } + + while (nbytes = fread(buf, sizeof *buf, sizeof buf, fpr)) { + if (fwrite(buf, sizeof *buf, nbytes, fpw) != nbytes) { + perror("fwrite"); + EXIT(1); + } + } + if (ferror(fpr)) { + perror("fread"); + EXIT(1); + } + + if (fclose(fpr) == EOF) + perror(wfile); + if (fclose(fpw) == EOF) + perror("../file"); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/syncseq_w.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,56 ---- + #include + #include + #include + #include + #include + #include + + #define EXIT pvm_exit(), exit + #define EXIT2 pvm_exit(), wait4fs(), exit + + extern int startup __ProtoGlarp__((int *, char **)); + extern void wait4fs __ProtoGlarp__((void)); + + int + main(int argc, char **argv) + { + int me; + int fdr; + int fdw; + char buf[32]; + char wfile[BUFSIZ]; + int nbytes; + + me = startup(&argc, argv); + + pvm_setioorder(me); + pvm_setdefiomode(PvmIomodeSyncSeq); + if ((fdw = open("../file", O_CREAT | O_TRUNC | O_WRONLY, 0600)) + == -1) { + perror("../file"); + EXIT(1); + } + sprintf(wfile, "../%d.out", me); + pvm_setdefiomode(PvmIomodeIndividual); + if ((fdr = open(wfile, O_RDONLY)) == -1) { + perror(wfile); + EXIT(1); + } + while ((nbytes = read(fdr, buf, sizeof buf)) > 0) { + if (write(fdw, buf, nbytes) == -1) { + perror("write"); + EXIT(1); + } + } + if (nbytes == -1) { + perror("read"); + EXIT(1); + } + + if (close(fdr) == -1) + perror(wfile); + if (close(fdw) == -1) + perror("../file"); + + EXIT2(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/io/wait4fs.c Sun Jul 24 18:14:54 1994 *************** *** 0 **** --- 1,29 ---- + #include + #include + + void + wait4fs(void) + { + int status; + + while (wait(&status) != -1) + ; + } + + void + wait4fs_(void) + { + wait4fs(); + } + + void + WAIT4FS(void) + { + wait4fs(); + } + + void + WAIT4FS_(void) + { + wait4fs(); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/iot/Makefile.aimk Tue Jul 26 09:06:27 1994 *************** *** 0 **** --- 1,26 ---- + # Imports: + # PVM_ARCH = the official pvm-name of your processor + # ARCHCFLAGS = special cc flags + # ARCHLIB = special libs needed for daemon + # + SHELL = /bin/sh + CC = cc + PVMIDIR = ../../../include + PVMLDIR = ../../../lib/$(PVM_ARCH) + PVMLIB = -lpvm3 + LIBS = -g -L$(PVMLDIR) $(PVMLIB) $(ARCHFSLIB) + PVMFSLDIR= ../../../libc/$(PVM_ARCH) + FSOBJS = $(PVMFSLDIR)/syscalls.o $(PVMFSLDIR)/pvmerrno.o $(PVMFSLDIR)/posix.o + CFLAGS = -g -I$(PVMIDIR) -I$(PVMFSLDIR) -DIMA_$(PVM_ARCH) $(ARCHCFLAGS) -DPVMFS -I../../../src #-DDEBUG + OBJS = iot.o + + iot: $(OBJS) $(PVMLDIR)/libpvm3.a $(FSOBJS) + $(SCC) -o $@ $(OBJS) $(FSOBJS) $(LIBS) + -@rm -f $(HOME)/pvm3/bin/$(PVM_ARCH)/$@ + -@ln -s `pwd`/$@ $(HOME)/pvm3/bin/$(PVM_ARCH) + + iot.o: ../iot.c + $(SCC) $(CFLAGS) -c ../iot.c + + clean: + rm -f $(OBJS) iot *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/iot/PMAX/Makefile Sun Jul 24 18:14:55 1994 *************** *** 0 **** --- 1,28 ---- + # Imports: + # PVM_ARCH = the official pvm-name of your processor + # ARCHCFLAGS = special cc flags + # ARCHLIB = special libs needed for daemon + # + SHELL = /bin/sh + CC = cc + PVMIDIR = ../../../include + PVMLDIR = ../../../lib/$(PVM_ARCH) + PVMLIB = -lpvm3 + LIBS = -g -L$(PVMLDIR) $(PVMLIB) $(ARCHFSLIB) -YSYSTEM_FIVE + PVMFSLDIR= ../../../libc/$(PVM_ARCH) + FSOBJS = $(PVMFSLDIR)/syscalls.o $(PVMFSLDIR)/pvmerrno.o $(PVMFSLDIR)/posix.o + CFLAGS = -g -I$(PVMIDIR) -I$(PVMFSLDIR) -DIMA_$(PVM_ARCH) $(ARCHCFLAGS) -DPVMFS -I../../../src -YSYSTEM_FIVE #-DDEBUG + OBJS = iot.o + + include ../../../conf/PMAX.def + + iot: $(OBJS) $(PVMLDIR)/libpvm3.a $(FSOBJS) + $(SCC) -o $@ $(OBJS) $(FSOBJS) $(LIBS) + -@rm -f $(HOME)/pvm3/bin/$(PVM_ARCH)/$@ + -@ln -s `pwd`/$@ $(HOME)/pvm3/bin/$(PVM_ARCH) + + iot.o: ../iot.c + $(SCC) $(CFLAGS) -c ../iot.c + + clean: + rm -f $(OBJS) iot *** /dev/null Thu Aug 25 19:19:25 1994 --- fsexamples/iot/iot.c Sun Jul 24 18:14:55 1994 *************** *** 0 **** --- 1,2226 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #ifdef IMA_SUN4 + #define sprintf ugh + #endif + #include + #include + #include + #include + #ifdef IMA_CRAY + #define _POSIX_SOURCE + #endif + #include + #include + #ifdef IMA_CRAY + #undef _POSIX_SOURCE + #endif + #ifdef IMA_CRAY + #include + #define RLIM_INFINITY 0 + #define RLIMIT_CORE 1 + #define RLIMIT_FSIZE 2 + #define RLIMIT_NOFILE 3 + + typedef unsigned long rlim_t; + + struct rlimit { + rlim_t rlim_cur; + rlim_t rlim_max; + }; + #endif + #include + #include + #include + #include + #include + #ifdef IMA_CRAY + #define _POSIX_SOURCE + #endif + #include + #include + #include + #include + + #if !defined(IMA_RS6K) && !defined(IMA_CRAY) + #include + #include + #else + #include + #include "syscall-fake.h" + #endif + #ifndef PATH_MAX + #define PATH_MAX 1024 + #endif + #ifdef IMA_SUN4 + #undef sprintf + int sprintf __ProtoGlarp__((char *, const char *, ...)); + + char * + strerror(int num) + { + extern int sys_nerr; + extern char *sys_errlist[]; + + if (num > 0 && num < sys_nerr) + return sys_errlist[num]; + else + return "???"; + } + #endif + + #ifdef rewinddir + #undef rewinddir + extern void rewinddir __ProtoGlarp__((DIR *)); + #endif + + #define NUMFPS 10 + static struct { + int used; + FILE *fp; + } gfp[NUMFPS]; + + extern int errno; + static char prompt[] = "pvm$ "; + + #ifndef MAXHOSTNAMELEN + #define MAXHOSTNAMELEN 1024 + #endif + + static void + say_hello(void) + { + char hostname[MAXHOSTNAMELEN]; + + if (gethostname(hostname, sizeof hostname) == -1) + strcpy(hostname, "Unknown"); + printf("Reading commands on %s!\n", hostname); + } + + int + main(int argc, char **argv) + { + int me; + int int1, int2, int3, int4; + int saved_errno; + int retval; + int n; + struct stat st; + struct timeval tv[2], *tvp; + fd_set wset, rset, eset; + fd_set *wsetp, *rsetp, *esetp; + struct flock flock; + struct rlimit rl; + char path1[PATH_MAX], path2[PATH_MAX]; + char buf[BUFSIZ]; + char rwbuf[BUFSIZ]; + char *cp; + long long1, long2, long3, long4; + long offset1, offset2, offset3, offset4; + unsigned long ul1, ul2; + DIR *dp; + FILE *fp; + #ifndef IMA_SUN4 + fpos_t fpos1; + #endif + struct dirent *dirp; + struct utimbuf ut, *utp; + + int other; + #ifdef DEBUG + extern int pvmdebug; + + pvmdebug = 1; + #endif + + pvm_usefs(1); + + if ((other = pvm_parent()) < 0) { + #ifndef DEBUG + char *slash; + + if (slash = strrchr(argv[0], '/')) + argv[0] = slash + 1; + if (pvm_spawn(argv[0], argv, + argc > 1 ? PvmTaskHost : PvmTaskDefault, + argc > 1 ? argv[1] : NULL, 1, &other) != 1) { + extern int pvm_errno; + + pvm_errno = other; + pvm_perror("pvm_spawn"); + exit(1); + } + #endif + me = 0; + } else + me = 1; + #ifdef DEBUG + me = !me; + #endif + + if (pvm_setiomode(0, PvmIomodeCommon) == -1) + perror("pvm_setiomode"); + if (pvm_setiomode(1, PvmIomodeCommon) == -1) + perror("pvm_setiomode"); + if (pvm_setiomode(2, PvmIomodeCommon) == -1) + perror("pvm_setiomode"); + + if (me == 0) { + pvm_notify(PvmTaskExit, 10, 1, &other); + pvm_recv(-1, 10); + pvm_exit(); + exit(0); + } else + say_hello(); + + for (n = 0; n < NUMFPS; n++) { + gfp[n].used = n < 3; + gfp[n].fp = NULL; + } + gfp[0].fp = stdin; + gfp[1].fp = stdout; + gfp[2].fp = stderr; + + top: + write(1, prompt, sizeof prompt - 1); + while ((n = read(0, buf, sizeof buf - 1)) > 0) { + buf[n] = '\0'; + n = 0; + if (strncmp(buf, "rename ", sizeof("rename")) == 0) { + if (sscanf(buf + sizeof("rename"), "%s %s", path1, + path2) == 2) { + retval = rename(path1, path2); + saved_errno = errno; + n += sprintf(buf + n, + "rename(\"%s\", \"%s\") = %d", + path1, path2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: rename path1 path2\n"); + } else if (strncmp(buf, "fcntl ", sizeof("fcntl")) == 0) { + if (sscanf(buf + sizeof("fcntl"), "%d %d %d", + &int1, &int2, &int3) == 3) { + retval = fcntl(int1, int2, int3); + saved_errno = errno; + n += sprintf(buf + n, "fcntl(%d, %d, %d) = %d", + int1, int2, int3, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else if (sscanf(buf + sizeof("fcntl"), + "%d %d %ld %ld %ld %ld", &int1, &int2, &long1, &long2, + &long3, &long4) == 6) { + flock.l_type = long1; + flock.l_start = long2; + flock.l_whence = long3; + flock.l_len = long4; + retval = fcntl(int1, int2, &flock); + saved_errno = errno; + n += sprintf(buf + n, + "fcntl(%d, %d, <%ld, %ld, %ld, %ld>) = %d", + int1, int2, long1, long2, long3, long4, + retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else { + n += sprintf(buf + n, + "usage: fcntl fd cmd arg\n"); + n += sprintf(buf + n, + "or fcntl fd cmd l_type l_start l_whence l_len\n"); + } + } else if (strncmp(buf, "link ", sizeof("link")) == 0) { + if (sscanf(buf + sizeof("link"), "%s %s", path1, path2) + == 2) { + retval = link(path1, path2); + saved_errno = errno; + n += sprintf(buf + n, + "link(\"%s\", \"%s\") = %d", + path1, path2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: link path1 path2\n"); + } else if (strncmp(buf, "symlink ", sizeof("symlink")) == 0) { + if (sscanf(buf + sizeof("symlink"), "%s %s", path1, + path2) == 2) { + retval = symlink(path1, path2); + saved_errno = errno; + n += sprintf(buf + n, + "symlink(\"%s\", \"%s\") = %d", + path1, path2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: symlink path1 path2\n"); + } else if (strncmp(buf, "mkdir ", sizeof("mkdir")) == 0) { + if (sscanf(buf + sizeof("mkdir"), "%s %lo", path1, + &long1) == 2) { + retval = mkdir(path1, long1); + saved_errno = errno; + n += sprintf(buf + n, + "mkdir(\"%s\", %04o) = %d", + path1, (int)long1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: mkdir path octal_mode\n"); + } else if (strncmp(buf, "readlink ", sizeof("readlink")) == 0) { + if (sscanf(buf + sizeof("readlink"), "%s %d", path1, + &int1) == 2) { + path2[0] = '\0'; + retval = readlink(path1, path2, int1); + saved_errno = errno; + n += sprintf(buf + n, + "readlink(\"%s\", \"%s\", %d) = %d", + path1, path2, int1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: readlink path length\n"); + } else if (strncmp(buf, "mkfifo ", sizeof("mkfifo")) == 0) { + if (sscanf(buf + sizeof("mkfifo"), "%s %lo", path1, + &long1) == 2) { + retval = mkfifo(path1, long1); + saved_errno = errno; + n += sprintf(buf + n, + "mkfifo(\"%s\", %04o) = %d", + path1, (int)long1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: mkfifo path octal_mode\n"); + } else if (strncmp(buf, "mknod ", sizeof("mknod")) == 0) { + if (sscanf(buf + sizeof("mknod"), "%s %lo %d", path1, + &long1, &int1) == 3) { + retval = mknod(path1, long1, int1); + saved_errno = errno; + n += sprintf(buf + n, + "mknod(\"%s\", %04o, %d) = %d", + path1, (int)long1, int1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: mknod path octal_mode device\n"); + } else if (strncmp(buf, "truncate ", sizeof("truncate")) == 0) { + if (sscanf(buf + sizeof("truncate"), "%s %ld", path1, + &long1) == 2) { + retval = truncate(path1, long1); + saved_errno = errno; + n += sprintf(buf + n, + "truncate(\"%s\", %ld) = %d", + path1, long1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: truncate path length\n"); + } else if (strncmp(buf, "ftruncate ", sizeof("ftruncate")) + == 0) { + if (sscanf(buf + sizeof("ftruncate"), "%d %ld", + &int1, &long1) == 2) { + retval = ftruncate(int1, long1); + saved_errno = errno; + n += sprintf(buf + n, + "ftruncate(%d, %ld) = %d", + int1, long1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: ftruncate fd length\n"); + } else if (strncmp(buf, "chmod ", sizeof("chmod")) == 0) { + if (sscanf(buf + sizeof("chmod"), "%s %lo", path1, + &long1) == 2) { + retval = chmod(path1, long1); + saved_errno = errno; + n += sprintf(buf + n, + "chmod(\"%s\", %04o) = %d", + path1, (int)long1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: chmod path octal_mode\n"); + } else if (strncmp(buf, "fchmod ", sizeof("fchmod")) == 0) { + if (sscanf(buf + sizeof("fchmod"), "%d %lo", + &int1, &long1) == 2) { + retval = fchmod(int1, long1); + saved_errno = errno; + n += sprintf(buf + n, "fchmod(%d, %04o) = %d", + int1, (int)long1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fchmod fd octal_mode\n"); + } else if (strncmp(buf, "chown ", sizeof("chown")) == 0) { + if (sscanf(buf + sizeof("chown"), "%s %ld %ld", path1, + &long1, &long2) == 3) { + retval = chown(path1, long1, long2); + saved_errno = errno; + n += sprintf(buf + n, + "chown(\"%s\", %ld, %ld) = %d", + path1, long1, long2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: chown path uid gid\n"); + } else if (strncmp(buf, "fchown ", sizeof("fchown")) == 0) { + if (sscanf(buf + sizeof("fchown"), "%d %ld %ld", + &int1, &long1, &long2) == 3) { + retval = fchown(int1, long1, long2); + saved_errno = errno; + n += sprintf(buf + n, + "fchown(%d, %ld, %ld) = %d", + int1, long1, long2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fchown fd uid gid\n"); + } else if (strncmp(buf, "lchown ", sizeof("lchown")) == 0) { + if (sscanf(buf + sizeof("lchown"), "%s %ld %ld", path1, + &long1, &long2) == 3) { + retval = lchown(path1, long1, long2); + saved_errno = errno; + n += sprintf(buf + n, + "lchown(\"%s\", %ld, %ld) = %d", + path1, long1, long2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: lchown path uid gid\n"); + } else if (strncmp(buf, "stat ", sizeof("stat")) == 0) { + if (sscanf(buf + sizeof("stat"), "%s", path1) == 1) { + retval = stat(path1, &st); + saved_errno = errno; + n += sprintf(buf + n, + "stat(\"%s\", %p) = %d", path1, &st, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)\n", + strerror(errno)); + else { + n += sprintf(buf + n, "\n"); + n += sprintf(buf + n, "st_dev = %ld, st_ino = %ld, st_mode = %04o, st_nlink = %ld\n", + (long)st.st_dev, (long)st.st_ino, (int)st.st_mode, (long)st.st_nlink); + n += sprintf(buf + n, "st_uid = %ld, st_gid = %ld, st_rdev = %ld, st_size = %ld\n", + (long)st.st_uid, (long)st.st_gid, (long)st.st_rdev, (long)st.st_size); + n += sprintf(buf + n, "st_atime = %ld, st_ctime = %ld, st_mtime = %ld\n", + (long)st.st_atime, (long)st.st_ctime, (long)st.st_mtime); + } + } else + n += sprintf(buf + n, + "usage: stat path\n"); + } else if (strncmp(buf, "lstat ", sizeof("lstat")) == 0) { + if (sscanf(buf + sizeof("lstat"), "%s", path1) == 1) { + retval = lstat(path1, &st); + saved_errno = errno; + n += sprintf(buf + n, + "lstat(\"%s\", %p) = %d", path1, &st, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)\n", + strerror(errno)); + else { + n += sprintf(buf + n, "\n"); + n += sprintf(buf + n, "st_dev = %ld, st_ino = %ld, st_mode = %04o, st_nlink = %ld\n", + (long)st.st_dev, (long)st.st_ino, (int)st.st_mode, (long)st.st_nlink); + n += sprintf(buf + n, "st_uid = %ld, st_gid = %ld, st_rdev = %ld, st_size = %ld\n", + (long)st.st_uid, (long)st.st_gid, (long)st.st_rdev, (long)st.st_size); + n += sprintf(buf + n, "st_atime = %ld, st_ctime = %ld, st_mtime = %ld\n", + (long)st.st_atime, (long)st.st_ctime, (long)st.st_mtime); + } + } else + n += sprintf(buf + n, + "usage: lstat path\n"); + } else if (strncmp(buf, "fstat ", sizeof("fstat")) == 0) { + if (sscanf(buf + sizeof("fstat"), "%d", &int1) == 1) { + retval = fstat(int1, &st); + saved_errno = errno; + n += sprintf(buf + n, + "fstat(%d, %p) = %d", int1, &st, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)\n", + strerror(errno)); + else { + n += sprintf(buf + n, "\n"); + n += sprintf(buf + n, "st_dev = %ld, st_ino = %ld, st_mode = %04o, st_nlink = %ld\n", + (long)st.st_dev, (long)st.st_ino, (int)st.st_mode, (long)st.st_nlink); + n += sprintf(buf + n, "st_uid = %ld, st_gid = %ld, st_rdev = %ld, st_size = %ld\n", + (long)st.st_uid, (long)st.st_gid, (long)st.st_rdev, (long)st.st_size); + n += sprintf(buf + n, "st_atime = %ld, st_ctime = %ld, st_mtime = %ld\n", + (long)st.st_atime, (long)st.st_ctime, (long)st.st_mtime); + } + } else + n += sprintf(buf + n, "usage: fstat fd\n"); + } else if (strncmp(buf, "chroot ", sizeof("chroot")) == 0) { + if (sscanf(buf + sizeof("chroot"), "%s", path1) == 1) { + retval = chroot(path1); + saved_errno = errno; + n += sprintf(buf + n, + "chroot(\"%s\") = %d", path1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: chroot path\n"); + } else if (strncmp(buf, "chdir ", sizeof("chdir")) == 0) { + if (sscanf(buf + sizeof("chdir"), "%s", path1) == 1) { + retval = chdir(path1); + saved_errno = errno; + n += sprintf(buf + n, + "chdir(\"%s\") = %d", path1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: chdir path\n"); + } else if (strncmp(buf, "fchdir ", sizeof("fchdir")) == 0) { + if (sscanf(buf + sizeof("fchdir"), "%d", &int1) == 1) { + retval = fchdir(int1); + saved_errno = errno; + n += sprintf(buf + n, + "fchdir(%d) = %d", int1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: fchdir fd\n"); + } else if (strncmp(buf, "dup ", sizeof("dup")) == 0) { + if (sscanf(buf + sizeof("dup"), "%d", &int1) == 1) { + retval = dup(int1); + saved_errno = errno; + n += sprintf(buf + n, + "dup(%d) = %d", int1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: dup fd\n"); + } else if (strncmp(buf, "dup2 ", sizeof("dup2")) == 0) { + if (sscanf(buf + sizeof("dup2"), "%d %d", &int1, &int2) + == 2) { + retval = dup2(int1, int2); + saved_errno = errno; + n += sprintf(buf + n, + "dup2(%d, %d) = %d", int1, int2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: dup2 fd1 fd2\n"); + } else if (strncmp(buf, "read ", sizeof("read")) == 0) { + if (sscanf(buf + sizeof("read"), "%d %ld", &int1, + &long1) == 2) { + if (long1 > BUFSIZ) { + printf("length being reduced to %d\n", + BUFSIZ); + long1 = BUFSIZ; + } + long2 = read(int1, rwbuf, long1); + saved_errno = errno; + n += sprintf(buf + n, + "read(%d, %p, %ld) = %ld", int1, rwbuf, long1, + long2); + errno = saved_errno; + if (long2 == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: read fd nbytes\n"); + } else if (strncmp(buf, "readv ", sizeof("readv")) == 0) { + if (sscanf(buf + sizeof("readv"), "%d 1 %ld %ld", &int1, + &long1, &offset1) == 3) + int2 = 1; + else if (sscanf(buf + sizeof("readv"), + "%d 2 %ld %ld %ld %ld", &int1, &long1, &offset1, + &long2, &offset2) == 5) + int2 = 2; + else if (sscanf(buf + sizeof("readv"), + "%d 3 %ld %ld %ld %ld %ld %ld", &int1, + &long1, &offset1, &long2, &offset2, &long3, &offset3) + == 7) + int2 = 3; + else + int2 = 0; + + if (int2) { + struct iovec iovec[3]; + + switch (int2) { + case 3: iovec[2].iov_base = rwbuf + offset3; + iovec[2].iov_len = long3; + case 2: iovec[1].iov_base = rwbuf + offset2; + iovec[1].iov_len = long2; + case 1: iovec[0].iov_base = rwbuf + offset1; + iovec[0].iov_len = long1; + } + + long4 = readv(int1, iovec, int2); + saved_errno = errno; + n += sprintf(buf + n, + "readv(%d, %p, %d) = %ld", int1, iovec, int2, + long4); + errno = saved_errno; + if (long4 == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: readv fd [123] [length offset]{1,3}\n"); + } else if (strncmp(buf, "write ", sizeof("write")) == 0) { + long2 = 0; + if (sscanf(buf + sizeof("write"), "%d %ld %ld", &int1, + &long1, &long2) == 3 + || sscanf(buf + sizeof("write"), "%d %ld", &int1, + &long1) == 2) { + long3 = write(int1, rwbuf + long2, long1); + saved_errno = errno; + n += sprintf(buf + n, + "write(%d, %p, %ld) = %ld", int1, + rwbuf + long2, long1, long3); + errno = saved_errno; + if (long3 == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else if (sscanf(buf + sizeof("write"), "%d %s", + &int1, path1) == 2) { + long2 = write(int1, path1, strlen(path1)); + saved_errno = errno; + n += sprintf(buf + n, + "write(%d, \"%s\", %ld) = %ld", int1, path1, + strlen(path1), long2); + errno = saved_errno; + if (long2 == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else { + n += sprintf(buf + n, + "usage: write fd length [offset]\n"); + n += sprintf(buf + n, "or write fd string\n"); + } + } else if (strncmp(buf, "writev ", sizeof("writev")) == 0) { + if (sscanf(buf + sizeof("writev"), "%d 1 %ld %ld", + &int1, &long1, &offset1) == 3) + int2 = 1; + else if (sscanf(buf + sizeof("writev"), + "%d 2 %ld %ld %ld %ld", &int1, &long1, &offset1, + &long2, &offset2) == 5) + int2 = 2; + else if (sscanf(buf + sizeof("writev"), + "%d 3 %ld %ld %ld %ld %ld %ld", &int1, + &long1, &offset1, &long2, &offset2, &long3, &offset3) + == 7) + int2 = 3; + else + int2 = 0; + + if (int2) { + struct iovec iovec[3]; + + switch (int2) { + case 3: iovec[2].iov_base = rwbuf + offset3; + iovec[2].iov_len = long3; + case 2: iovec[1].iov_base = rwbuf + offset2; + iovec[1].iov_len = long2; + case 1: iovec[0].iov_base = rwbuf + offset1; + iovec[0].iov_len = long1; + } + + long4 = writev(int1, iovec, int2); + saved_errno = errno; + n += sprintf(buf + n, + "writev(%d, %p, %ld) = %ld", int1, iovec, + long1, long4); + errno = saved_errno; + if (long4 == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: writev fd [123] [length offset]{1,3}\n"); + } else if (strncmp(buf, "lseek ", sizeof("lseek")) == 0) { + if (sscanf(buf + sizeof("lseek"), "%d %ld %d", &int1, + &long1, &int2) == 3) { + retval = lseek(int1, long1, int2); + saved_errno = errno; + n += sprintf(buf + n, + "lseek(%d, %ld, %d) = %d", int1, long1, + int2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: lseek fd offset whence\n"); + } else if (strncmp(buf, "close ", sizeof("close")) == 0) { + if (sscanf(buf + sizeof("close"), "%d", &int1) == 1) { + retval = close(int1); + saved_errno = errno; + n += sprintf(buf + n, "close(%d) = %d", int1, + retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: close fd\n"); + } else if (strncmp(buf, "rmdir ", sizeof("rmdir")) == 0) { + if (sscanf(buf + sizeof("rmdir"), "%s", path1) == 1) { + retval = rmdir(path1); + saved_errno = errno; + n += sprintf(buf + n, "rmdir(\"%s\") = %d", + path1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: rmdir path\n"); + } else if (strncmp(buf, "open ", sizeof("open")) == 0) { + if (sscanf(buf + sizeof("open"), "%s %d %lo", path1, + &int1, &long1) == 3) { + retval = open(path1, int1, long1); + saved_errno = errno; + n += sprintf(buf + n, + "open(\"%s\", %d, %04o) = %d", + path1, int1, (int)long1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else if (sscanf(buf + sizeof("open"), "%s %d", path1, + &int1) == 2) { + retval = open(path1, int1); + saved_errno = errno; + n += sprintf(buf + n, "open(\"%s\", %d) = %d", + path1, int1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else { + n += sprintf(buf + n, + "usage: open path flags octal_mode\n"); + n += sprintf(buf + n, + "or open path flags\n"); + } + } else if (strncmp(buf, "creat ", sizeof("creat")) == 0) { + if (sscanf(buf + sizeof("creat"), "%s %lo", path1, + &long1) == 2) { + retval = creat(path1, long1); + saved_errno = errno; + n += sprintf(buf + n, + "creat(\"%s\", %04o) = %d", + path1, (int)long1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: creat path octal_mode\n"); + } else if (strncmp(buf, "unlink ", sizeof("unlink")) == 0) { + if (sscanf(buf + sizeof("unlink"), "%s", path1) == 1) { + retval = unlink(path1); + saved_errno = errno; + n += sprintf(buf + n, "unlink(\"%s\") = %d", + path1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: unlink path\n"); + } else if (strncmp(buf, "umask ", sizeof("umask")) == 0) { + if (sscanf(buf + sizeof("umask"), "%lo", &long1) == 1) { + long2 = umask(long1); + saved_errno = errno; + n += sprintf(buf + n, "umask(%04o) = %04o", + (int)long1, + (int)long2); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: umask octal_mask\n"); + } else if (strncmp(buf, "utime ", sizeof("utime")) == 0) { + if (sscanf(buf + sizeof("utime"), "%s %ld %ld", path1, + &long1, &long2) == 3) { + utp = &ut; + utp->actime = long1; + utp->modtime = long2; + n += sprintf(buf + n, + "utime(\"%s\", <%ld, %ld>)", path1, long1, + long2); + } else if (sscanf(buf + sizeof("utime"), "%s", path1) + == 1) { + utp = NULL; + n += sprintf(buf + n, "utime(\"%s\", NULL)", + path1); + } else { + n += sprintf(buf + n, + "usage: utime path actime modtime\n"); + n += sprintf(buf + n, + "or utime path\n"); + goto bottom; + } + retval = utime(path1, utp); + saved_errno = errno; + n += sprintf(buf + n, " = %d", retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", strerror(errno)); + n += sprintf(buf + n, "\n"); + } else if (strncmp(buf, "utimes ", sizeof("utimes")) == 0) { + if (sscanf(buf + sizeof("utimes"), "%s %ld %ld", path1, + &long1, &long2) == 3) { + tv[0].tv_sec = long1; + tv[1].tv_sec = long2; + tv[0].tv_usec = tv[1].tv_usec = 0; + retval = utimes(path1, tv); + saved_errno = errno; + n += sprintf(buf + n, + "utimes(\"%s\", <%ld, %ld>) = %d", + path1, long1, long2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: utimes path actime modtime\n"); + } else if (strncmp(buf, "fsync ", sizeof("fsync")) == 0) { + if (sscanf(buf + sizeof("fsync"), "%d", &int1) == 1) { + retval = fsync(int1); + saved_errno = errno; + n += sprintf(buf + n, "fsync(%d) = %d", int1, + retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: fsync fd\n"); + } else if (strncmp(buf, "isatty ", sizeof("isatty")) == 0) { + if (sscanf(buf + sizeof("isatty"), "%d", &int1) == 1) { + retval = isatty(int1); + saved_errno = errno; + n += sprintf(buf + n, "isatty(%d) = %d", int1, + retval); + errno = saved_errno; + if (retval == 0) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: isatty fd\n"); + } else if (strncmp(buf, "ttyname ", sizeof("ttyname")) == 0) { + if (sscanf(buf + sizeof("ttyname"), "%d", &int1) == 1) { + cp = ttyname(int1); + saved_errno = errno; + n += sprintf(buf + n, "ttyname(%d) = ", int1); + errno = saved_errno; + if (cp) + n += sprintf(buf + n, "\"%s\"\n", cp); + else + n += sprintf(buf + n, "NULL (%s)\n", + strerror(errno)); + } else + n += sprintf(buf + n, "usage: ttyname fd\n"); + } else if (strncmp(buf, "tcdrain ", sizeof("tcdrain")) == 0) { + if (sscanf(buf + sizeof("tcdrain"), "%d", &int1) == 1) { + retval = tcdrain(int1); + saved_errno = errno; + n += sprintf(buf + n, "tcdrain(%d) = %d", int1, + retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: tcdrain fd\n"); + } else if (strncmp(buf, "tcflow ", sizeof("tcflow")) == 0) { + if (sscanf(buf + sizeof("tcflow"), "%d %d", &int1, + &int2) == 2) { + retval = tcflow(int1, int2); + saved_errno = errno; + n += sprintf(buf + n, "tcflow(%d, %d) = %d", + int1, int2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: tcflow fd action\n"); + } else if (strncmp(buf, "tcflush ", sizeof("tcflush")) == 0) { + if (sscanf(buf + sizeof("tcflush"), "%d %d", &int1, + &int2) == 2) { + retval = tcflush(int1, int2); + saved_errno = errno; + n += sprintf(buf + n, "tcflush(%d, %d) = %d", + int1, int2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: tcflush fd queue\n"); + } else if (strncmp(buf, "tcsendbreak ", sizeof("tcsendbreak")) + == 0) { + if (sscanf(buf + sizeof("tcsendbreak"), "%d %d", &int1, + &int2) == 2) { + retval = tcsendbreak(int1, int2); + saved_errno = errno; + n += sprintf(buf + n, + "tcsendbreak(%d, %d) = %d", int1, int2, + retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: tcsendbreak fd duration\n"); + } else if (strncmp(buf, "access ", sizeof("access")) == 0) { + if (sscanf(buf + sizeof("access"), "%s %d", path1, + &int1) == 2) { + retval = access(path1, int1); + saved_errno = errno; + n += sprintf(buf + n, "access(\"%s\", %d) = %d", + path1, int1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: access path mode\n"); + } else if (strncmp(buf, "select ", sizeof("select")) == 0) { + if (sscanf(buf + sizeof("select"), "%d %d %d %ld", + &int1, &int2, &int3, &long1) == 4) { + tv[0].tv_sec = long1; + tv[0].tv_usec = 0; + tvp = &tv[0]; + } else if (sscanf(buf + sizeof("select"), + "%d %d %d", &int1, &int2, &int3) == 3) + tvp = NULL; + else { + n += sprintf(buf + n, + "usage: select rfd wfd efd [secs]\n"); + n += sprintf(buf + n, + "[rwe]fd should be one fd or -1\n"); + goto bottom; + } + + int4 = -1; + if (int1 >= 0) { + rsetp = &rset; + FD_ZERO(rsetp); + FD_SET(int1, rsetp); + int4 = int1; + } else + rsetp = NULL; + if (int2 >= 0) { + wsetp = &wset; + FD_ZERO(wsetp); + FD_SET(int2, wsetp); + if (int2 > int4) + int4 = int2; + } else + wsetp = NULL; + if (int3 >= 0) { + esetp = &eset; + FD_ZERO(esetp); + FD_SET(int3, esetp); + if (int3 > int4) + int4 = int3; + } else + esetp = NULL; + int4++; + n += sprintf(buf + n, "select(%d, ", int4); + int4 = select(int4, rsetp, wsetp, esetp, tvp); + saved_errno = errno; + if (rsetp && FD_ISSET(int1, rsetp)) + n += sprintf(buf + n, "<%d>", int1); + else + n += sprintf(buf + n, "NULL"); + n += sprintf(buf + n, ", "); + if (wsetp && FD_ISSET(int2, wsetp)) + n += sprintf(buf + n, "<%d>", int2); + else + n += sprintf(buf + n, "NULL"); + n += sprintf(buf + n, ", "); + if (esetp && FD_ISSET(int3, esetp)) + n += sprintf(buf + n, "<%d>", int3); + else + n += sprintf(buf + n, "NULL"); + n += sprintf(buf + n, ", "); + if (tvp) + n += sprintf(buf + n, "<%ld>", tvp->tv_sec); + else + n += sprintf(buf + n, "NULL"); + n += sprintf(buf + n, ") = %d", int4); + errno = saved_errno; + if (int4 == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + else if (int4 > 0) { + n += sprintf(buf + n, " {"); + if (rsetp && FD_ISSET(int1, rsetp)) + n += sprintf(buf + n, "%d", int1); + else + n += sprintf(buf + n, "NULL"); + n += sprintf(buf + n, ", "); + if (wsetp && FD_ISSET(int2, wsetp)) + n += sprintf(buf + n, "%d", int2); + else + n += sprintf(buf + n, "NULL"); + n += sprintf(buf + n, ", "); + if (esetp && FD_ISSET(int3, esetp)) + n += sprintf(buf + n, "%d", int3); + else + n += sprintf(buf + n, "NULL"); + n += sprintf(buf + n, "}"); + } + n += sprintf(buf + n, "\n"); + } else if (strncmp(buf, "sync", 4) == 0) { + retval = sync(); + saved_errno = errno; + n += sprintf(buf + n, "sync() = %d", retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + #ifndef IMA_CRAY + } else if (strncmp(buf, "mmap", 4) == 0) { + cp = mmap(NULL, 0, 0, 0, 0, 0); + saved_errno = errno; + n += sprintf(buf + n, "mmap() = "); + if (cp) + n += sprintf(buf + n, "%p", cp); + else + n += sprintf(buf + n, "NULL"); + errno = saved_errno; + if (cp == NULL) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + #endif + } else if (strncmp(buf, "ioctl", 5) == 0) { + retval = ioctl(0, 0, 0); + saved_errno = errno; + n += sprintf(buf + n, "ioctl() = %d", retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else if (strncmp(buf, "pathconf ", sizeof("pathconf")) == 0) { + if (sscanf(buf + sizeof("pathconf"), "%s %d", + path1, &int1) == 2) { + retval = pathconf(path1, int1); + saved_errno = errno; + n += sprintf(buf + n, + "pathconf(\"%s\", %d) = %d", path1, int1, + retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: pathconf path name\n"); + } else if (strncmp(buf, "fpathconf ", sizeof("fpathconf")) + == 0) { + if (sscanf(buf + sizeof("fpathconf"), "%d %d", + &int1, &int2) == 2) { + retval = fpathconf(int1, int2); + saved_errno = errno; + n += sprintf(buf + n, + "fpathconf(%d, %d) = %d", int1, int2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fpathconf fd name\n"); + } else if (strncmp(buf, "pipe", 4) == 0) { + int twoints[2]; + + retval = pipe(twoints); + saved_errno = errno; + n += sprintf(buf + n, "pipe(%p) = %d ", + twoints, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, "(%s)", + strerror(errno)); + else + n += sprintf(buf + n, "<%d, %d>", + twoints[0], twoints[1]); + n += sprintf(buf + n, "\n"); + } else if (strncmp(buf, "ctermid", 7) == 0) { + cp = ctermid(NULL); + saved_errno = errno; + n += sprintf(buf + n, "ctermid(NULL) = "); + errno = saved_errno; + if (cp) + n += sprintf(buf + n, "\"%s\"\n", cp); + else + n += sprintf(buf + n, "NULL (%s)\n", + strerror(errno)); + } else if (strncmp(buf, "sh ", 3) == 0) { + int i; + + for (i = 0; buf[i] != '\n'; i++) + ; + buf[i + 1] = '\0'; + system(buf + 3); + buf[0] = '\0'; + } else if (strncmp(buf, "cd ", 3) == 0) { + if (sscanf(buf + 3, "%s", path1) == 1) + syscall(SYS_chdir, path1); + buf[0] = '\0'; + } else if (strncmp(buf, "setioorder ", sizeof("setioorder")) + == 0) { + if (sscanf(buf + sizeof("setioorder"), "%d", &int1) + == 1) { + retval = pvm_setioorder(int1); + saved_errno = errno; + n += sprintf(buf + n, "setioorder(%d) = %d", + int1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: setioorder cardinal\n"); + } else if (strncmp(buf, "getioorder", 10) == 0) { + retval = pvm_getioorder(); + saved_errno = errno; + n += sprintf(buf + n, "getioorder() = %d", retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else if (strncmp(buf, "setiomode ", sizeof("setiomode")) + == 0) { + if (sscanf(buf + sizeof("setiomode"), "%d %d", &int1, + &int2) == 2) { + retval = pvm_setiomode(int1, int2); + saved_errno = errno; + n += sprintf(buf + n, "setiomode(%d, %d) = %d", + int1, int2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: setiomode fd mode\n"); + } else if (strncmp(buf, "getiomode ", sizeof("getiomode")) + == 0) { + if (sscanf(buf + sizeof("getiomode"), "%d", &int1) + == 1) { + retval = pvm_getiomode(int1); + saved_errno = errno; + n += sprintf(buf + n, "getiomode(%d) = %d", + int1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: getiomode fd\n"); + } else if (strncmp(buf, "setdefiomode ", sizeof("setdefiomode")) + == 0) { + if (sscanf(buf + sizeof("setdefiomode"), "%d", &int1) + == 1) { + retval = pvm_setdefiomode(int1); + saved_errno = errno; + n += sprintf(buf + n, "setdefiomode(%d) = %d", + int1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: setdefiomode mode\n"); + } else if (strncmp(buf, "getdefiomode", 12) == 0) { + retval = pvm_getdefiomode(); + saved_errno = errno; + n += sprintf(buf + n, "getdefiomode() = %d", retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", strerror(errno)); + n += sprintf(buf + n, "\n"); + } else if (strncmp(buf, "opendir ", sizeof("opendir")) == 0) { + if (sscanf(buf + sizeof("opendir"), "%s", path1) == 1) { + dp = opendir(path1); + saved_errno = errno; + n += sprintf(buf + n, + "opendir(\"%s\") = ", path1); + if (dp) + n += sprintf(buf + n, "%p", dp); + else + n += sprintf(buf + n, "NULL"); + errno = saved_errno; + if (dp == NULL) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: opendir path (returns directory descriptor)\n"); + } else if (strncmp(buf, "readdir ", sizeof("readdir")) == 0) { + if (sscanf(buf + sizeof("readdir"), "%d", &int1) == 1) { + dp = (DIR *)int1; + errno = 0; + dirp = readdir(dp); + saved_errno = errno; + n += sprintf(buf + n, "readdir(%p) =", dp); + if (dirp == NULL) { + if (saved_errno) + n += sprintf(buf + n, + " NULL (%s)", + strerror(saved_errno)); + else + n += sprintf(buf + n, " NULL"); + } else + n += sprintf(buf + n, " \"%s\"", + dirp->d_name); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: readdir directory_descriptor\n"); + } else if (strncmp(buf, "closedir ", sizeof("closedir")) == 0) { + if (sscanf(buf + sizeof("closedir"), "%d", &int1) + == 1) { + dp = (DIR *)int1; + retval = closedir(dp); + saved_errno = errno; + n += sprintf(buf + n, + "closedir(%p) = %d", dp, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: closedir directory_descriptor\n"); + } else if (strncmp(buf, "rewinddir ", sizeof("rewinddir")) + == 0) { + if (sscanf(buf + sizeof("rewinddir"), "%d", &int1) + == 1) { + dp = (DIR *)int1; + rewinddir(dp); + n += sprintf(buf + n, "rewinddir(%p)\n", dp); + } else + n += sprintf(buf + n, + "usage: rewinddir directory_descriptor\n"); + } else if (strncmp(buf, "clearerr ", sizeof("clearerr")) == 0) { + if (sscanf(buf + sizeof("clearerr"), "%d", &int1) + == 1) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else { + clearerr(gfp[int1].fp); + retval = 0; + } + n += sprintf(buf + n, "clearerr(%d)", int1); + if (retval == EOF) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: clearerr fp_descriptor\n"); + } else if (strncmp(buf, "fclose ", sizeof("fclose")) == 0) { + if (sscanf(buf + sizeof("fclose"), "%d", &int1) + == 1) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else { + retval = fclose(gfp[int1].fp); + gfp[int1].used = 0; + } + saved_errno = errno; + n += sprintf(buf + n, "fclose(%d) = ", int1); + if (retval == EOF) + n += sprintf(buf + n, "EOF"); + else + n += sprintf(buf + n, "%d", retval); + errno = saved_errno; + if (retval == EOF) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fclose fp_descriptor\n"); + } else if (strncmp(buf, "fdopen ", sizeof("fdopen")) == 0) { + if (sscanf(buf + sizeof("fdopen"), "%d %s", &int1, + path1) == 2) { + for (int2 = 0; int2 < NUMFPS; int2++) + if (gfp[int2].used == 0) + break; + if (int2 == NUMFPS) { + retval = -1; + errno = ENOMEM; + } else if (fp = fdopen(int1, path1)) { + gfp[int2].fp = fp; + gfp[int2].used = 1; + retval = int2; + } else + retval = -1; + saved_errno = errno; + n += sprintf(buf + n, + "fdopen(%d, \"%s\") = ", int1, path1); + if (retval >= 0) + n += sprintf(buf + n, "%d", retval); + else + n += sprintf(buf + n, "NULL"); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fdopen fd path\n"); + } else if (strncmp(buf, "feof ", sizeof("feof")) == 0) { + if (sscanf(buf + sizeof("feof"), "%d", &int1) + == 1) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = feof(gfp[int1].fp); + saved_errno = errno; + n += sprintf(buf + n, + "feof(%d) = %d", int1, retval); + errno = saved_errno; + if (retval && ferror(gfp[int1].fp)) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: feof fp_descriptor\n"); + } else if (strncmp(buf, "ferror ", sizeof("ferror")) == 0) { + if (sscanf(buf + sizeof("ferror"), "%d", &int1) + == 1) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = ferror(gfp[int1].fp); + saved_errno = errno; + n += sprintf(buf + n, + "ferror(%d) = %d", int1, retval); + errno = saved_errno; + if (retval) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: ferror fp_descriptor\n"); + } else if (strncmp(buf, "fflush ", sizeof("fflush")) == 0) { + if (sscanf(buf + sizeof("fflush"), "%d", &int1) + == 1) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = fflush(gfp[int1].fp); + saved_errno = errno; + n += sprintf(buf + n, + "fflush(%d) = ", int1); + if (retval == EOF) + n += sprintf(buf + n, "EOF"); + else + n += sprintf(buf + n, "%d", retval); + errno = saved_errno; + if (retval == EOF) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fflush fp_descriptor\n"); + } else if (strncmp(buf, "fgetc ", sizeof("fgetc")) == 0) { + if (sscanf(buf + sizeof("fgetc"), "%d", &int1) + == 1) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = fgetc(gfp[int1].fp); + saved_errno = errno; + n += sprintf(buf + n, + "fgetc(%d) = ", int1); + if (retval == EOF) + n += sprintf(buf + n, "EOF"); + else + n += sprintf(buf + n, "%o", retval); + errno = saved_errno; + if (retval == EOF && ferror(gfp[int1].fp)) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fgetc fp_descriptor\n"); + #if !defined(IMA_SUN4) && !defined(IMA_CNVXN) + } else if (strncmp(buf, "fgetpos ", sizeof("fgetpos")) == 0) { + if (sscanf(buf + sizeof("fgetpos"), "%d", &int1) + == 1) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = fgetpos(gfp[int1].fp, + &fpos1); + saved_errno = errno; + n += sprintf(buf + n, + "fgetpos(%d, %p) = %d <%ld>", int1, &fpos1, + retval, (long)fpos1); + errno = saved_errno; + if (retval) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fgetpos fp_descriptor\n"); + #endif + } else if (strncmp(buf, "fgets ", sizeof("fgets")) == 0) { + if (sscanf(buf + sizeof("fgets"), "%d", &int1) + == 1) { + errno = 0; + if (gfp[int1].used == 0) { + cp = NULL; + errno = EBADF; + } else + cp = fgets(rwbuf, sizeof rwbuf - 1, + gfp[int1].fp); + saved_errno = errno; + n += sprintf(buf + n, + "fgets(%p, %ld, %d) = ", rwbuf, + sizeof rwbuf - 1, int1); + if (cp) + n += sprintf(buf + n, "%p", cp); + else + n += sprintf(buf + n, "NULL"); + errno = saved_errno; + if (cp == NULL && (errno == EBADF + || ferror(gfp[int1].fp))) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fgets fp_descriptor\n"); + } else if (strncmp(buf, "fileno ", sizeof("fileno")) == 0) { + if (sscanf(buf + sizeof("fileno"), "%d", &int1) + == 1) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = fileno(gfp[int1].fp); + saved_errno = errno; + n += sprintf(buf + n, "fileno(%d) = %d", int1, + retval); + errno = saved_errno; + if (retval == EOF) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fileno fp_descriptor\n"); + } else if (strncmp(buf, "fopen ", sizeof("fopen")) == 0) { + if (sscanf(buf + sizeof("fopen"), "%s %s", path1, + path2) == 2) { + for (int1 = 0; int1 < NUMFPS; int1++) + if (gfp[int1].used == 0) + break; + if (int1 == NUMFPS) { + retval = -1; + errno = ENOMEM; + } else if (fp = fopen(path1, path2)) { + gfp[int1].fp = fp; + gfp[int1].used = 1; + retval = int1; + } else + retval = -1; + saved_errno = errno; + n += sprintf(buf + n, + "fopen(\"%s\", \"%s\") = ", path1, path2); + if (retval >= 0) + n += sprintf(buf + n, "%d", retval); + else + n += sprintf(buf + n, "NULL"); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fopen path mode (returns fp_descriptor)\n"); + } else if (strncmp(buf, "fprintf ", sizeof("fprintf")) == 0) { + if (sscanf(buf + sizeof("fprintf"), "%d %s", &int1, + path1) == 2) { + strcat(path1, "\n"); + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = fprintf(gfp[int1].fp, + path1); + saved_errno = errno; + n += sprintf(buf + n, + "fprintf(%d, \"%s\") = %d", int1, path1, + retval); + errno = saved_errno; + if (retval < 0) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fprintf fp_descriptor string\n"); + } else if (strncmp(buf, "fputc ", sizeof("fputc")) == 0) { + if (sscanf(buf + sizeof("fputc"), "%o %d", &int1, + &int2) == 2) { + if (gfp[int2].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = fputc(int1, gfp[int2].fp); + saved_errno = errno; + n += sprintf(buf + n, + "fputc(%o, %d) = ", int1, int2); + if (retval == EOF) + n += sprintf(buf + n, "EOF"); + else + n += sprintf(buf + n, "%o", retval); + errno = saved_errno; + if (retval == EOF) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fputc octal_char fp_descriptor string\n"); + } else if (strncmp(buf, "fputs ", sizeof("fputs")) == 0) { + long1 = 0; + if (sscanf(buf + sizeof("fputs"), "%d %ld", + &int1, &long1) == 2 || sscanf(buf + sizeof("fputs"), + "%d", &int1) == 1) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = fputs(rwbuf + long1, + gfp[int1].fp); + saved_errno = errno; + n += sprintf(buf + n, + "fputs(%p, %d) = %d", rwbuf + long1, int1, + retval); + errno = saved_errno; + if (retval == EOF) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else if (sscanf(buf + sizeof("fputs"), "%s %d", path1, + &int1) == 2) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = fputs(path1, gfp[int1].fp); + saved_errno = errno; + n += sprintf(buf + n, + "fputs(%p, %d) = ", path1, int1); + if (retval == EOF) + n += sprintf(buf + n, "EOF"); + else + n += sprintf(buf + n, "%d", retval); + errno = saved_errno; + if (retval == EOF) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else { + n += sprintf(buf + n, + "usage: fputs string fp_descriptor\n"); + n += sprintf(buf + n, + "or fputs fp_descriptor [offset]\n"); + } + } else if (strncmp(buf, "fread ", sizeof("fread")) == 0) { + long1 = 0; + if (sscanf(buf + sizeof("fread"), "%d %d %ld", &int1, + &int2, &long1) == 3 + || sscanf(buf + sizeof("fread"), "%d %d", &int1, + &int2) == 2) { + if (gfp[int2].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = fread(rwbuf + long1, 1, int1, + gfp[int2].fp); + saved_errno = errno; + n += sprintf(buf + n, + "fread(%p, 1, %d, %d) = %d\n", rwbuf + long1, + int1, int2, retval); + } else + n += sprintf(buf + n, + "usage: fread nbytes fp_descriptor [offset]\n"); + } else if (strncmp(buf, "freopen ", sizeof("freopen")) == 0) { + if (sscanf(buf + sizeof("freopen"), "%s %s %d", path1, + path2, &int1) == 3) { + if (gfp[int1].used == 0) { + retval = 0; + errno = EBADF; + } else if (gfp[int1].fp = freopen(path1, + path2, gfp[int1].fp)) { + retval = int1; + } else + retval = 0; + saved_errno = errno; + n += sprintf(buf + n, + "freopen(\"%s\", \"%s\", %d) = %d", path1, + path2, int1, retval); + errno = saved_errno; + if (retval == 0) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: freopen path mode fp_descriptor\n"); + } else if (strncmp(buf, "fseek ", sizeof("fseek")) == 0) { + if (sscanf(buf + sizeof("fseek"), "%d %ld %d", &int1, + &long1, &int2) == 3) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = fseek(gfp[int1].fp, long1, + int2); + saved_errno = errno; + n += sprintf(buf + n, + "fseek(%d, %ld, %d) = %d", int1, long1, + int2, retval); + errno = saved_errno; + if (retval) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fseek fp_descriptor offset whence\n"); + #if !defined(IMA_SUN4) && !defined(IMA_CNVXN) + } else if (strncmp(buf, "fsetpos ", sizeof("fsetpos")) == 0) { + if (sscanf(buf + sizeof("fsetpos"), "%d %ld", &int1, + &long1) == 2) { + fpos1 = long1; + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = fsetpos(gfp[int1].fp, + &fpos1); + saved_errno = errno; + n += sprintf(buf + n, + "fsetpos(%d, <%ld>) = %d", int1, (long)fpos1, + retval); + errno = saved_errno; + if (retval) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fsetpos fp_descriptor offset\n"); + #endif + } else if (strncmp(buf, "ftell ", sizeof("ftell")) == 0) { + if (sscanf(buf + sizeof("ftell"), "%d", &int1) == 1) { + if (gfp[int1].used == 0) { + long1 = -1L; + errno = EBADF; + } else + long1 = ftell(gfp[int1].fp); + saved_errno = errno; + n += sprintf(buf + n, + "ftell(%d) = %ld", int1, long1); + errno = saved_errno; + if (long1 == -1L) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: ftell fp_descriptor\n"); + } else if (strncmp(buf, "fwrite ", sizeof("fwrite")) == 0) { + long1 = 0; + if (sscanf(buf + sizeof("fwrite"), "%d %d %ld", &int1, + &int2, &long1) == 3 || sscanf(buf + sizeof("fwrite"), + "%d %d", &int1, &int2) == 2) { + if (gfp[int2].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = fwrite(rwbuf + long1, 1, int1, + gfp[int2].fp); + saved_errno = errno; + n += sprintf(buf + n, + "fwrite(%p, 1, %d, %d) = %d", rwbuf + long1, + int1, int2, retval); + if (ferror(gfp[int2].fp)) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: fwrite nbytes fp_descriptor [offset]\n"); + } else if (strncmp(buf, "getc ", sizeof("getc")) == 0) { + if (sscanf(buf + sizeof("getc"), "%d", &int1) + == 1) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = getc(gfp[int1].fp); + saved_errno = errno; + n += sprintf(buf + n, + "getc(%d) = ", int1); + if (retval == EOF) + n += sprintf(buf + n, "EOF"); + else + n += sprintf(buf + n, "%o", retval); + errno = saved_errno; + if (retval == EOF && ferror(gfp[int1].fp)) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: getc fp_descriptor\n"); + } else if (strncmp(buf, "getchar", 7) == 0) { + retval = getchar(); + saved_errno = errno; + n += sprintf(buf + n, "getchar() = "); + if (retval == EOF) + n += sprintf(buf + n, "EOF"); + else + n += sprintf(buf + n, "%o", retval); + errno = saved_errno; + if (retval == EOF && ferror(stdin)) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else if (strncmp(buf, "gets", 4) == 0) { + cp = gets(rwbuf); + saved_errno = errno; + n += sprintf(buf + n, "gets(%p) = ", rwbuf); + if (cp) + n += sprintf(buf + n, "%p", cp); + else + n += sprintf(buf + n, "NULL"); + errno = saved_errno; + if (cp == NULL && ferror(stdin)) + n += sprintf(buf + n, " (%s)", strerror(errno)); + n += sprintf(buf + n, "\n"); + } else if (strncmp(buf, "perror ", sizeof("perror")) == 0) { + if (sscanf(buf + sizeof("perror"), "%s", path1) == 1) { + strcat(path1, "\n"); + perror(path1); + n += sprintf(buf + n, "perror(%s)\n", path1); + } else + n += sprintf(buf + n, + "usage: perror string\n"); + } else if (strncmp(buf, "printf ", sizeof("printf")) == 0) { + if (sscanf(buf + sizeof("printf"), "%s", path1) + == 1) { + strcat(path1, "\n"); + retval = printf(path1); + saved_errno = errno; + n += sprintf(buf + n, + "printf(\"%s\") = %d", path1, retval); + errno = saved_errno; + if (retval < 0) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: printf string\n"); + } else if (strncmp(buf, "putc ", sizeof("putc")) == 0) { + if (sscanf(buf + sizeof("putc"), "%o %d", &int1, + &int2) == 2) { + if (gfp[int2].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = putc(int1, gfp[int2].fp); + saved_errno = errno; + n += sprintf(buf + n, + "putc(%o, %d) = ", int1, int2); + if (retval == EOF) + n += sprintf(buf + n, "EOF"); + else + n += sprintf(buf + n, "%o", retval); + errno = saved_errno; + if (retval == EOF) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: putc octal_char fp_descriptor\n"); + } else if (strncmp(buf, "putchar ", sizeof("putchar")) == 0) { + if (sscanf(buf + sizeof("putchar"), "%o", &int1) == 1) { + retval = putchar(int1); + saved_errno = errno; + n += sprintf(buf + n, + "putchar(%o) = ", int1); + if (retval == EOF) + n += sprintf(buf + n, "EOF"); + else + n += sprintf(buf + n, "%o", retval); + errno = saved_errno; + if (retval == EOF) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: putchar char\n"); + } else if (strncmp(buf, "puts ", sizeof("puts")) == 0) { + if (sscanf(buf + sizeof("puts"), "%s", path1) == 1) { + retval = puts(path1); + saved_errno = errno; + n += sprintf(buf + n, "puts(%s) = ", path1); + if (retval == EOF) + n += sprintf(buf + n, "EOF"); + else + n += sprintf(buf + n, "%d", retval); + errno = saved_errno; + if (retval == EOF) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: puts string\n"); + } else if (strncmp(buf, "remove ", sizeof("remove")) == 0) { + if (sscanf(buf + sizeof("remove"), "%s", path1) == 1) { + retval = remove(path1); + saved_errno = errno; + n += sprintf(buf + n, + "remove(%s) = %d", path1, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, "usage: remove path\n"); + } else if (strncmp(buf, "rename ", sizeof("rename")) == 0) { + if (sscanf(buf + sizeof("rename"), "%s %s", path1, + path2) == 2) { + retval = rename(path1, path2); + saved_errno = errno; + n += sprintf(buf + n, + "rename(%s, %s) = %d", path1, path2, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: rename path1 path2\n"); + } else if (strncmp(buf, "rewind ", sizeof("rewind")) == 0) { + if (sscanf(buf + sizeof("rewind"), "%d", &int1) + == 1) { + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else { + rewind(gfp[int1].fp); + retval = 0; + } + saved_errno = errno; + n += sprintf(buf + n, "rewind(%d)", int1); + errno = saved_errno; + if (retval == EOF) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: rewind fp_descriptor\n"); + } else if (strncmp(buf, "setbuf ", sizeof("setbuf")) == 0) { + if (sscanf(buf + sizeof("setbuf"), "%d %d", &int1, + &int2) == 2) { + retval = 0; + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else if (int2) { + if (cp = malloc(BUFSIZ)) + setbuf(gfp[int1].fp, cp); + else + retval = EOF; + } else + setbuf(gfp[int1].fp, NULL); + saved_errno = errno; + n += sprintf(buf + n, + "setbuf(%d, %p) = %d", int1, int2, retval); + errno = saved_errno; + if (retval) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: setbuf fp_descriptor [01]\n"); + } else if (strncmp(buf, "setvbuf ", sizeof("setvbuf")) == 0) { + if (sscanf(buf + sizeof("setvbuf"), "%d %d %d", + &int1, &int2, &int3) == 3) { + cp = NULL; + if (gfp[int1].used == 0) { + retval = EOF; + errno = EBADF; + } else if (int2) { + if (cp = malloc(BUFSIZ)) + retval = setvbuf(gfp[int1].fp, + cp, int3, BUFSIZ); + else + retval = EOF; + } else + retval = setvbuf(gfp[int1].fp, NULL, + int3, 0); + saved_errno = errno; + n += sprintf(buf + n, + "setvbuf(%d, %p, %d, %d) = %d", int1, cp, + int3, cp ? BUFSIZ : 0, retval); + errno = saved_errno; + if (retval) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: setvbuf fp_descriptor [01] mode\n"); + } else if (strncmp(buf, "strerror ", sizeof("strerror")) == 0) { + if (sscanf(buf + sizeof("strerror"), "%d", &int1) + == 1) { + n += sprintf(buf + n, "strerror(%d) = %s\n", + int1, strerror(int1)); + } else + n += sprintf(buf + n, + "usage: strerror errno\n"); + } else if (strncmp(buf, "system", 6) == 0) { + cp = buf + 6; + if (*cp == '\0' || *cp == ' ' || *cp == '\t') { + retval = system(path1); + n += sprintf(buf + n, "system(%s) = %d\n", + path1, retval); + } else + n += sprintf(buf + n, + "usage: system [string]\n"); + } else if (strncmp(buf, "ungetc ", sizeof("ungetc")) == 0) { + if (sscanf(buf + sizeof("ungetc"), "%o %d", &int1, + &int2) == 2) { + if (gfp[int2].used == 0) { + retval = EOF; + errno = EBADF; + } else + retval = ungetc(int1, gfp[int2].fp); + saved_errno = errno; + n += sprintf(buf + n, + "ungetc(%o, %d) = ", int1, int2); + if (retval == EOF) + n += sprintf(buf + n, "EOF"); + else + n += sprintf(buf + n, "%o", retval); + errno = saved_errno; + if (retval == EOF) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: ungetc octal_char fp_descriptor\n"); + } else if (strncmp(buf, "getcwd", 6) == 0) { + cp = getcwd(path1, sizeof path1); + saved_errno = errno; + n += sprintf(buf + n, "getcwd(...) = "); + if (!cp) + n += sprintf(buf + n, "NULL (%s)", + strerror(saved_errno)); + else + n += sprintf(buf + n, "\"%s\"", cp); + n += sprintf(buf + n, "\n"); + } else if (strncmp(buf, "getrlimit ", sizeof("getrlimit")) + == 0) { + if (sscanf(buf + sizeof("getrlimit"), "%d", &int1) + == 1) { + retval = getrlimit(int1, &rl); + saved_errno = errno; + n += sprintf(buf + n, + "getrlimit(%d, %p) = %d", int1, &rl, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + else { + n += sprintf(buf + n, " "); + } + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: getrlimit resource\n"); + } else if (strncmp(buf, "setrlimit ", sizeof("setrlimit")) + == 0) { + int2 = 0; + if (sscanf(buf + sizeof("setrlimit"), "%d %lu %lu", + &int1, &ul1, &ul2) == 3) { + rl.rlim_cur = ul1; + rl.rlim_max = ul2; + int2 = 1; + } else if (sscanf(buf + sizeof("setrlimit"), + "%d INF %lu", &int1, &ul1) == 2) { + rl.rlim_cur = RLIM_INFINITY; + rl.rlim_max = ul1; + int2 = 1; + } else if (sscanf(buf + sizeof("setrlimit"), + "%d %lu INF", &int1, &ul1) == 2) { + rl.rlim_cur = ul1; + rl.rlim_max = RLIM_INFINITY; + int2 = 1; + } else if (sscanf(buf + sizeof("setrlimit"), + "%d INF INF", &int1) == 1) { + rl.rlim_cur = rl.rlim_max = RLIM_INFINITY; + int2 = 1; + } + if (int2) { + retval = setrlimit(int1, &rl); + saved_errno = errno; + n += sprintf(buf + n, + "setrlimit(%d, %p) = %d", int1, &rl, retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", + strerror(errno)); + n += sprintf(buf + n, "\n"); + } else + n += sprintf(buf + n, + "usage: setrlimit resource cur|INF max|INF\n"); + } else if (strncmp(buf, "getdtablesize", 13) == 0) { + retval = getdtablesize(); + saved_errno = errno; + n += sprintf(buf + n, "getdtablesize() = %d", retval); + errno = saved_errno; + if (retval == -1) + n += sprintf(buf + n, " (%s)", strerror(errno)); + n += sprintf(buf + n, "\n"); + #if 0 + } else if (strncmp(buf, "OPEN ", sizeof("OPEN")) == 0) { + if ((int2 = sscanf(buf + sizeof("OPEN"), "%d %s %s", + &int1, path1, path2)) == 3) + f77open_(path1, strlen(path1), path2, + strlen(path2)); + else if ((int2 = sscanf(buf + sizeof("OPEN"), "%d %s", + &int1, path1)) == 2) + f77open_(path1, strlen(path1), "UNKNOWN", 7); + if (int2 == 2 || int2 == 3) + n += sprintf(buf + n, + "OPEN(%d, FILE = \"%s\", STATUS = \"%s\")\n", + int1, path1, int2 == 3 ? path2 : "UNKNOWN"); + else + n += sprintf(buf + n, + "usage: OPEN path [STATUS]\n"); + } else if (strncmp(buf, "READ ", sizeof("READ")) == 0) { + if ((int2 = sscanf(buf + sizeof("READ"), "%d %s %s", + &int1, path1, path2)) == 3) + f77open_(path1, strlen(path1), path2, + strlen(path2)); + else if ((int2 = sscanf(buf + sizeof("READ"), "%d %s", + &int1, path1)) == 2) + f77open_(path1, strlen(path1), "UNKNOWN", 7); + if (int2 == 2 || int2 == 3) + n += sprintf(buf + n, + "READ(%d, FILE = \"%s\", STATUS = \"%s\")\n", + int1, path1, int2 == 3 ? path2 : "UNKNOWN"); + else + n += sprintf(buf + n, + "usage: READ path [STATUS]\n"); + } else if (strncmp(buf, "CLOSE ", sizeof("CLOSE")) == 0) { + if (sscanf(buf + sizeof("CLOSE"), "%d", &int1) == 1) { + retval = f77close_(int1); + n += sprintf(buf + n, "CLOSE(%d)\n", int1); + } else + n += sprintf(buf + n, + "usage: OPEN path [STATUS]\n"); + #endif + } else + n += sprintf(buf + n, "Command not found\n"); + + bottom: + n += sprintf(buf + n, "%s", prompt); + write(1, buf, n); + } + + if (n == -1 && errno == EINTR) { + write(1, "got EINTR\n", 10); + goto top; + } + + pvm_exit(); + exit(0); + } *** pvm3.ornl/include/fpvm3.h Thu Aug 25 18:04:07 1994 --- include/fpvm3.h Sun Jul 24 18:24:31 1994 *************** *** 54,60 **** --- 54,64 ---- integer PvmNotImpl, PvmDSysErr, PvmBadVersion, PvmOutOfRes integer PvmDupHost, PvmCantStart, PvmAlready, PvmNoTask integer PvmNoEntry, PvmDupEntry + integer PvmNoFileServer + integer PvmIomodeCommon, PvmIomodeIndividual + integer PvmIomodeIndependent, PvmIomodeSyncBC, PvmIomodeSyncSeq + c -------------------- c spawn 'flag' options c -------------------- *************** *** 156,159 **** --- 160,169 ---- parameter( PvmNoTask = -31) parameter( PvmNoEntry = -32) parameter( PvmDupEntry = -33) + parameter( PvmNoFileServer = -34) + parameter (PvmIomodeIndividual = 0) + parameter (PvmIomodeCommon = 1) + parameter (PvmIomodeIndependent = 2) + parameter (PvmIomodeSyncBC = 3) + parameter (PvmIomodeSyncSeq = 4) *** pvm3.ornl/include/pvm3.h Thu Aug 25 18:04:07 1994 --- include/pvm3.h Mon Jul 25 16:23:28 1994 *************** *** 130,135 **** --- 130,138 ---- #define PvmNoTask -31 /* No such task */ #define PvmNoEntry -32 /* No such entry */ #define PvmDupEntry -33 /* Duplicate entry */ + #ifdef PVMFS + #define PvmNoFileServer -34 + #endif /* * Data types for pvm_reduce(), pvm_psend(), pvm_precv() *************** *** 166,171 **** --- 169,177 ---- struct pvmtaskinfo { int ti_tid; /* task id */ int ti_ptid; /* parent tid */ + #ifdef PVMFS + int ti_fstid; /* fs task id */ + #endif int ti_host; /* pvmd tid */ int ti_flag; /* status flags */ char *ti_a_out; /* a.out name */ *************** *** 256,261 **** --- 262,278 ---- int, int, char *, int )); + #ifdef PVMFS + int pvm_getdefiomode __ProtoGlarp__((void)); + int pvm_getfstid __ProtoGlarp__((void)); + int pvm_getiomode __ProtoGlarp__((int)); + int pvm_getioorder __ProtoGlarp__((void)); + int pvm_setdefiomode __ProtoGlarp__((int)); + int pvm_setiomode __ProtoGlarp__((int, int)); + int pvm_setioorder __ProtoGlarp__((int)); + int pvm_usefs __ProtoGlarp__((int)); + #endif + /* * Predefined pvm_reduce functions */ *************** *** 305,310 **** --- 322,335 ---- #ifdef __cplusplus } + #endif + + #ifdef PVMFS + #define PvmIomodeIndividual 0 + #define PvmIomodeCommon 1 + #define PvmIomodeIndependent 2 + #define PvmIomodeSyncBC 3 + #define PvmIomodeSyncSeq 4 #endif #endif /*_PVM3_H_*/ *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/CRAY/csyscall.h Sun Jul 24 18:25:04 1994 *************** *** 0 **** --- 1,443 ---- + /* + + [This file contains an email message I received from jhn@cray.com + and is being distributed with his permission. + + Thanks go to Jim Nordby for his help and Cray Research, Inc. for + allowing the system call numbers to be given out - Chris] + + + From jhn@teak.cray.com Mon Dec 20 11:48:10 1993 + Return-Path: + Received: from timbuk.cray.com by hermes.chpc.utexas.edu (5.64/SMI-3.2) + id AA27109; Mon, 20 Dec 93 11:48:01 -0600 + Received: from sumac12.cray.com by cray.com (Bob mailer 1.2) + id AA20360; Mon, 20 Dec 93 11:47:58 CST + Received: by sumac12.cray.com + id AA19317; 4.1/CRI-5.6; Mon, 20 Dec 93 11:47:57 CST + From: jhn@teak.cray.com (Jim Nordby) + Message-Id: <9312201747.AA19317@sumac12.cray.com> + Subject: Re: syscall constants + To: pefv700@hermes.chpc.utexas.edu (Christopher Phillips) + Date: Mon, 20 Dec 93 11:47:53 CST + In-Reply-To: <9312171619.AA20434@hermes.chpc.utexas.edu>; from "Christopher Phillips" at Dec 17, 93 10:19 am + X-Mailer: ELM [version 2.3 PL11b-CRI] + Status: RO + + Christopher Phillips writes: + > + > >Sorry to bug you again. I talked to my boss, and she was just + > >wondering what exactly you were working on. Since I wasn't able + > >to answer her question, I thought I'd ask you again (I thought + > >it was something to do with PVM, but I lost any mail I had stating + > >that). + > + > I call my package pvmfs. You can get the current version from + > netlib2.cs.utk.edu. It works with pvm 3.2.4 and is called + > pvm3.2.4.fspatch.tar.Z. From the man page: + > + > PVMFS_INTRO(1PVM) PVMFS_INTRO(1PVM) + > + > NAME + > PVMFS - PVM File Server + > + > DESCRIPTION + > PVMFS is a PVM task process which facilitates I/O for programs utilizing + > the Parallel Virtual Machine system (see pvm(1PVM)). The file server + > presents a common file system and support for coordinated I/O to its parent + > and siblings. + > + > An obvious problem with pvm that pvmfs addresses is when a pvm task on + > machine B tries to open a file on machine A. Hope this helps. + > + > >If it was PVM, she wanted me to talk to our PVM guy, and + > >see why we weren't doing this particular project. + > + > >From talking to the pvm guys (Manchek does most of the coding these days) + > they think it's too system-dependent and don't want to get into it. + > And it probably would be without syscall... + > + > Chris + > + + Chris, + + Okay, I've talked to my boss, I've talked to our PVM dude, I covered + my rear most effectively :-) Here's a copy of for + you, without copyrights and with caveats: + + Thanks for your patience, + Jim Nordby (jhn@cray.com) + + /*------------------------------ cut here ---------------------------*/ + + /* + * NOTE: these system call numbers are not a guaranteed interface, + * and may change without notice (of course, they probably won't) + */ + + #ifndef _MPP_SYSCALL_H + #define _MPP_SYSCALL_H + + /* + * System call numbers for the Y-MP/MPP + */ + + #define SYS_NOSYS 0 /* illegal */ + #define SYS_REXIT 1 /* unsupported on MPP */ + #define SYS_FORK 2 /* unsupported on MPP */ + #define SYS_READ 3 + #define SYS_WRITE 4 + #define SYS_OPEN 5 + #define SYS_CLOSE 6 + #define SYS_WAIT 7 /* unsupported on MPP */ + #define SYS_CREAT 8 + #define SYS_LINK 9 + + #define SYS_UNLINK 10 + #define SYS_EXEC 11 /* unsupported on MPP */ + #define SYS_CHDIR 12 + #define SYS_TIME 13 + #ifndef _CRAYMPP + #define SYS_MKNOD 14 /* replaced on MPP */ + #endif + #define SYS_CHMOD 15 + #define SYS_CHOWN 16 + #define SYS_SBREAK 17 /* unsupported on MPP */ + #define SYS_OLDSTAT 18 /* obsolete */ + #define SYS_LSEEK 19 + + #ifndef _CRAYMPP + #define SYS_GETPID 20 /* replaced on MPP */ + #endif + #define SYS_MOUNT 21 + #define SYS_UMOUNT 22 + #define SYS_SETUID 23 /* unsupported on MPP */ + #ifndef _CRAYMPP + #define SYS_GETUID 24 /* replaced on MPP */ + #endif + #define SYS_STIME 25 /* unsupported on MPP */ + #define SYS_PTRACE 25 /* unsupported on MPP */ + #define SYS_ALARM 27 + #define SYS_OLDFSTAT 28 /* obsolete */ + #define SYS_PAUSE 29 + + #define SYS_UTIME 30 + #define SYS_STTY 31 /* obsolete */ + #define SYS_GTTY 32 /* obsolete */ + #define SYS_ACCESS 33 + #define SYS_NICE 34 + #define SYS_GETINFO 35 + #define SYS_SYNC 36 + #define SYS_KILL 37 + #define SYS_CSW 38 /* obsolete */ + #ifndef _CRAYMPP + #define SYS_SETPGRP 39 /* replaced on MPP */ + #endif + + #define SYS_TARGET 40 + #define SYS_DUP 41 + #ifndef _CRAYMPP + #define SYS_PIPE 42 /* replaced on MPP */ + #endif + #define SYS_TIMES 43 + #define SYS_PROFIL 44 /* unsupported on MPP */ + #define SYS_PLOCK 45 /* unsupported on MPP */ + #define SYS_SETGID 46 /* unsupported on MPP */ + #ifndef _CRAYMPP + #define SYS_GETGID 47 /* replaced on MPP */ + #endif + #define SYS_SIGCTL 48 + #define SYS_MSGSYS 49 /* obsolete */ + + #define SYS_JACCT 50 + #define SYS_ACCT 51 + #define SYS_NO52 52 /* unused */ + #define SYS_SEMSYS 53 /* obsolete */ + #define SYS_IOCTL 54 + #define SYS_NO55 55 /* unused */ + #define SYS_UPANIC 56 /* unsupported on MPP */ + #define SYS_UNAME 57 + #define SYS_MAUS 58 /* obsolete */ + #define SYS_EXECE 59 /* unsupported on MPP */ + + #define SYS_UMASK 60 + #define SYS_CHROOT 61 + #define SYS_FCNTL 62 + #define SYS_ULIMIT 63 + #define SYS_USTAT 64 + #define SYS_LCHOWN 65 /* unsupported on MPP */ + #define SYS_NO66 66 /* unused */ + #define SYS_NO67 67 /* unused */ + #define SYS_SETTIMEOFDAY 68 + #define SYS_GETTIMEOFDAY 69 + + #define SYS_TFORK 70 /* unsupported on MPP */ + #define SYS_RESCH 71 /* unsupported on MPP */ + #define SYS_CHMEM 72 /* unsupported on MPP */ + #define SYS_LISTIO 73 + #define SYS_THREAD 74 /* unsupported on MPP */ + #define SYS_GETPERMIT 75 + #define SYS_SETPERMIT 76 + #define SYS_SETFFLG 77 + #define SYS_SETDEVS 78 + #define SYS_NO79 79 /* unused */ + + #define SYS_NO80 80 /* unused */ + #define SYS_NO81 81 /* unused */ + #define SYS_GETGROUPS 82 + #define SYS_SETGROUPS 83 + #define SYS_NO84 84 /* unused */ + #define SYS_SETFLVL 85 + #define SYS_SETFCMP 86 + #define SYS_SETFACL 87 + #define SYS_SETUCMP50 88 /* obsolete */ + #define SYS_SETUSRV50 89 /* obsolete */ + + #define SYS_GETUSRV 90 + #define SYS_SLGENTRY 91 + #define SYS_SECSTAT 92 + #define SYS_NO93 93 /* obsolete */ + #define SYS_NO94 94 /* obsolete */ + #define SYS_GETFACL 95 + #define SYS_RMFACL 96 + #define SYS_FSECSTAT 97 + #define SYS_SETTFM 98 + #define SYS_GETSYSV 99 + + #define SYS_TABINFO 100 + #define SYS_TABREAD 101 + #define SYS_SUSPEND 102 + #define SYS_RESUME 103 + #define SYS_READA 104 + #define SYS_WRITEA 105 + #define SYS_TRUNC 106 + #define SYS_NICEM 107 + #define SYS_ACCTID 108 + #define SYS_SSBREAK 109 + + #define SYS_SSREAD 110 + #define SYS_SSWRITE 111 + #define SYS_NO112 112 /* unused */ + #define SYS_NO113 113 /* unused */ + #define SYS_NO114 114 /* unused */ + #define SYS_LIMIT 115 + #define SYS_IALLOC 116 + #define SYS_SETSID 117 + #define SYS_SETPGID 118 + #define SYS_CPSELECT 119 /* unsupported on MPP */ + + #define SYS_SELECT 120 + #define SYS_KILLM 121 + #define SYS_RECALLA 121 /* unsupported on MPP */ + #define SYS_GETJTAB 123 + #define SYS_SETJOB 124 + #define SYS_MTIMES 125 /* unsupported on MPP */ + #define SYS_CHKPNT 126 /* unsupported on MPP */ + #define SYS_RESTART 127 /* unsupported on MPP */ + #define SYS_CUTIMES 128 + #define SYS_QUOTACTL 129 + + #define SYS_SCHEDV 130 /* unsupported on MPP */ + #define SYS_SYSCONF 131 + #define SYS_PATHCONF 132 + #define SYS_FPATHCONF 133 + #define SYS_LIMITS60 134 /* obsolete */ + #define SYS_WAITJOB 135 /* unsupported on MPP */ + #define SYS_RMDIR 136 + #define SYS_MKDIR 137 + #define SYS_GETDENTS 138 + #define SYS_STATFS 139 + + #define SYS_FSTATFS 140 + #define SYS_SYSFS 141 + #define SYS_DEVACCT 142 + #define SYS_DMMODE 143 + #define SYS_CHACID 145 + #define SYS_SETUSRV 146 + #define SYS_STAT 147 + #define SYS_FSTAT 148 + #define SYS_DMOFRQ 149 + + #define SYS_SETSYSV 150 + #define SYS_SETFCLS 151 + #define SYS_SETFCAT 152 + #define SYS_SETUCLS 153 + #define SYS_SETUCAT 154 + #ifndef _CRAYMPP + #define SYS_WAITPID 155 /* replaced on MPP */ + #endif + #define SYS_SETUCMP 156 + #define SYS_SETULVL 157 + #define SYS_RECALLS 158 + #define SYS_RENAME 159 + + #define SYS_DACCT 160 + #define SYS_WRACCT 161 + #define SYS_SIGACTION 162 + #define SYS_SIGSUSPEND 163 + #define SYS_SIGPROCMASK 164 + #define SYS_SIGPENDING 165 + #define SYS_SIGINIT 166 + #define SYS_ACCEPT 167 + #define SYS_BIND 168 + #define SYS_CONNECT 169 + + #define SYS_GETHOSTID 170 + #define SYS_GETHOSTNAME 171 + #define SYS_GETPEERNAME 172 + #define SYS_GETSOCKNAME 173 + #define SYS_GETSOCKOPT 174 + #define SYS_LISTEN 175 + #define SYS_RECV 176 + #define SYS_RECVFROM 177 + #define SYS_ORECVMSG 178 /* obsolete */ + #define SYS_SEND 179 + + #define SYS_OSENDMSG 179 /* obsolete */ + #define SYS_SENDTO 181 + #define SYS_SETHOSTID 182 + #define SYS_SETHOSTNAME 183 + #define SYS_SETREGID 184 + #define SYS_SETREUID 185 + #define SYS_SETSOCKOPT 186 + #define SYS_SHUTDOWN 187 + #define SYS_SOCKET 188 + #define SYS_SOCKETPAIR 189 + + #define SYS_SYMLINK 190 + #define SYS_READLINK 191 + #define SYS_LSTAT 192 + #define SYS_SESSCNTL 193 /* unsupported on MPP */ + #define SYS_NO194 194 /* unused */ + #define SYS_SITELOCAL195 195 + #define SYS_SITELOCAL196 196 + #define SYS_SITELOCAL197 197 + #define SYS_SITELOCAL198 198 + #define SYS_SITELOCAL199 199 + + #define SYS_GETDEVN 200 + #define SYS_RECVMSG 201 + #define SYS_SENDMSG 202 + #define SYS_LSECSTAT 203 + #define SYS_FSYNC 204 + #define SYS_FCHMOD 205 + #define SYS_FCHOWN 206 + #define SYS_VFORK 207 /* unsupported on MPP */ + #define SYS_EXCTL 208 /* unsupported on MPP */ + #define SYS_GETLIM 209 + + #define SYS_SETLIM 210 + #define SYS_LIMITS 211 + #define SYS_NO212 212 /* unused */ + #define SYS_GETSECTAB 213 + #define SYS_ADJTIME 214 + #define SYS_JOIN 215 + #define SYS_FJOIN 216 + #define SYS_SETPORTBM 217 /* unsupported on MPP */ + #define SYS_GETPORTBM 218 /* unsupported on MPP */ + #define SYS_TFORK2 219 /* unsupported on MPP */ + + #define SYS_SETPAL 220 /* unsupported on MPP */ + #define SYS_GETPAL 221 /* unsupported on MPP */ + #define SYS_GETPPRIV 222 /* unsupported on MPP */ + #define SYS_CMPTEXT 223 /* unsupported on MPP */ + #define SYS_SETPPRIV 224 /* unsupported on MPP */ + #define SYS_FSETPAL 225 /* unsupported on MPP */ + #define SYS_FGETPAL 226 /* unsupported on MPP */ + #define SYS_GETMOUNT 227 /* unsupported on MPP */ + #define SYS_PTYRECON 228 /* unsupported on MPP */ + #define SYS_NEWGETPID 229 /* unsupported on MPP */ + + #define SYS_NEWEXIT 230 /* unsupported on MPP */ + #define SYS_NEWKILL 231 /* unsupported on MPP */ + #define SYS_NEWKILLM 232 /* unsupported on MPP */ + #define SYS_UESYSCALL 233 /* unsupported on MPP */ + + /* 234-249 are reserved for Y-MP */ + + #ifdef _CRAYMPP + + #define SYS_SEGGROW 250 /* being removed */ + #define SYS_NO251 251 /* unused */ + #define SYS_UPT_CREATE 252 + #define SYS_UPT_RESUME 253 + #define SYS_UPT_SUSPEND 254 + #define SYS_UPT_TERMINATE 255 + #define SYS_BLT_COPY 256 + #define SYS_BLT_TAG 257 + #define SYS_LOCALEXIT 258 + #define SYS_MKNOD 259 + + #define SYS_GETPID 260 + #define SYS_GETPPID 261 + #define SYS_GETUID 262 + #define SYS_GETEUID 263 + #define SYS_GETGID 264 + #define SYS_GETEGID 265 + #define SYS_GETPGRP 266 + #define SYS_SETPGRP 267 + #define SYS_PIPE 268 + #define SYS_NO269 269 /* unused */ + + #define SYS_USER_STQC 270 /* being removed */ + #define SYS_SIGRETURN 271 + #define SYS_GLOBALEXIT 272 + #define SYS_THREADEXIT 273 + #define SYS_SYSMAX 274 + + /* + * Chris, if you don't need anything besides the numbers, you + * probably would want to get rid of this part + */ + + #ifdef ASM + + #include + #include + + CRI_REGISTER_NAMES ; get register names + + .macro $$ERRNOP REG ; put address of 'errno' in REG + la t0,-8(zero) + zap t0,0xF0,t1 ; t1 = 0xFFFFFFF8 + zap t0,0xF8,t2 ; t2 = 0x00FFFFF8 + srl sp,37,t0 ; shift segid to bottom + subq t0,15,t0 ; if (segid == 15) + cmoveq t0,t2,t1 ; mask = t2 + bis sp,t1,REG ; form stack errno pointer + .endm + + .macro GETERRNO REG ; get value of 'errno' in REG + $$ERRNOP t0 ; get address of errno + ldq REG,0(t0) ; load it into REG + .endm + + .macro PUTERRNO REG ; put value of REG into 'errno' + $$ERRNOP t0 ; get address of errno + stq REG,0(t0) ; store REG into address + .endm + + .macro SYS NAME,NUMBER,DUP=0 + .psect CODE_SEC,code + .if ndf, DUP ; if duplicate entry defined, + DUP:: ; set it up + .endc + ENTER NAME,LEVEL=leaf ; entry sequence + lda v0,NUMBER(zero) ; put syscall number in v0 + callsys ; trap to system + beq a3,out ; if (a3 non-zero) + PUTERRNO v0 ; put v0 in errno + subq zero,1,v0 ; put -1 in v0 + out: + EXIT ; exit sequence + .endm + + #endif /* ASM */ + + #endif /* _CRAYMPP */ + + #endif /* !_MPP_SYSCALL_H */ + + + *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/CRAY/syscall-fake.h Sun Jul 24 18:25:04 1994 *************** *** 0 **** --- 1,70 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #ifndef SYSCALL_H + #define SYSCALL_H + + extern int syscall(int, ...); + + #include "csyscall.h" + + #define SYS_access SYS_ACCESS + #define SYS_chdir SYS_CHDIR + #define SYS_chmod SYS_CHMOD + #define SYS_chown SYS_CHOWN + #define SYS_chroot SYS_CHROOT + #define SYS_close SYS_CLOSE + #define SYS_creat SYS_CREAT + #define SYS_dup SYS_DUP + #define SYS_fchmod SYS_FCHMOD + #define SYS_fchown SYS_FCHOWN + #define SYS_fcntl SYS_FCNTL + #define SYS_fpathconf SYS_FPATHCONF + #define SYS_fstat SYS_FSTAT + #define SYS_fsync SYS_FSYNC + #define SYS_ftruncate -1 /* not used */ + #define SYS_getdents SYS_GETDENTS + #define SYS_getrlimit -1 /* not used */ + #define SYS_ioctl SYS_IOCTL + #define SYS_lchown SYS_LCHOWN + #define SYS_link SYS_LINK + #define SYS_lseek SYS_LSEEK + #define SYS_lstat SYS_LSTAT + #define SYS_mkdir SYS_MKDIR + #define SYS_mknod SYS_MKNOD + #define SYS_open SYS_OPEN + #define SYS_pathconf SYS_PATHCONF + #define SYS_read SYS_READ + #define SYS_readv -1 /* not used */ + #define SYS_readlink SYS_READLINK + #define SYS_rename SYS_RENAME + #define SYS_rmdir SYS_RMDIR + #define SYS_select SYS_SELECT + #define SYS_setrlimit -1 /* not used */ + #define SYS_stat SYS_STAT + #define SYS_symlink SYS_SYMLINK + #define SYS_sync SYS_SYNC + #define SYS_sysconf SYS_SYSCONF + #define SYS_truncate -1 /* not used */ + #define SYS_trunc SYS_TRUNC + #define SYS_umask SYS_UMASK + #define SYS_unlink SYS_UNLINK + #define SYS_utime SYS_UTIME + #define SYS_write SYS_WRITE + #define SYS_writev -1 /* not used */ + + #endif /* SYSCALL_H */ *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/Makefile.aimk Sun Jul 24 18:25:02 1994 *************** *** 0 **** --- 1,73 ---- + # + # Generic Makefile body to be concatenated to config header. + # + # Imports: + # PVM_ARCH = the official pvm-name of your processor + # ARCHCFLAGS = special cc flags + # ARCHDLIB = special libs needed for daemon + # ARCHDOBJ = special objects needed for daemon + # HASRANLIB = 't' or 'f' + # + # Define: + # FDSETPATCH if system includes don't have fd_set stuff + # NOGETDTBLSIZ if system doesn't have getdtablesize() + # NOREXEC if system doesn't have rexec() + # NOSOCKOPT if system doesn't have setsockopt() or it doesn't work + # NOSTRCASE if system doesn't have strcasecmp, strncasecmp + # NOTMPNAM if system doesn't have tmpnam() or it's hosed + # NOWAIT3 if system doesn't have wait3() + # NOWAITPID if system doesn't have waitpid() either + # OVERLOADHOST to allow different virtual machines to overlap on a host + # RSHCOMMAND for rsh command other than "/usr/ucb/rsh" + # RSHNPLL for number of parallel rsh startups (default is 8) + # RSHTIMEOUT for rsh timeout other than default (60 sec) + # SHAREDTMP if /tmp is shared between machines (yecch) + # SOCKADHASLEN if struct sockaddr has an sa_len field + # SYSVBFUNC if system uses memcpy() instead of bcopy(), etc. + # SYSVSIGNAL if system has sysV signal handling + # SYSVSTR if system uses strchr() instead of index() + # UDPMAXLEN for alternate max udp packet size + # USE_PVM_ALLOC to enable instrumented malloc functions (for debugging pvm) + # + SHELL = /bin/sh + SDIR = .. + IDIR = ../../include + OPTIONS = -g + CFLAGS = $(OPTIONS) -I. -I$(SDIR) -I$(IDIR) -DARCHCLASS=\"$(PVM_ARCH)\" -DIMA_$(PVM_ARCH) $(ARCHCFLAGS) -DPVMFS -DTRACE + + OBJS=syscalls.o posix.o pvmerrno.o + + install: errnoconf.h $(OBJS) libc + + libc: + @if [ -f Mfile ]; \ + then \ + make -f $(PVM_ROOT)/conf/$(PVM_ARCH).def -f Mfile install; \ + else \ + exit 0; \ + fi + + + syscalls.o: $(SDIR)/syscalls.c $(SDIR)/fs.h $(SDIR)/fsp.h $(SDIR)/argtypes.h $(IDIR)/pvm3.h + $(SCC) $(CFLAGS) -c $(SDIR)/syscalls.c + pvmerrno.o: $(SDIR)/pvmerrno.c $(SDIR)/pvmerrno.h errnoconf.h + $(SCC) -I. $(CFLAGS) -c $(SDIR)/pvmerrno.c + posix.o: $(SDIR)/posix.c $(SDIR)/pipe.h $(SDIR)/fs.h $(SDIR)/fsp.h $(SDIR)/argtypes.h $(IDIR)/pvm3.h + $(SCC) $(CFLAGS) -c $(SDIR)/posix.c + + errnoconf.h: + @if [ ! -f $@ ]; \ + then \ + cd ..; perl pvmerrno.pl /usr/include/sys/errno.h; \ + else \ + exit 0; \ + fi + + clean: + -rm -f syscalls.o pvmerrno.o posix.o + @if [ -f Mfile ]; \ + then \ + make -f $(PVM_ROOT)/conf/$(PVM_ARCH).def -f Mfile clean; \ + else \ + exit 0; \ + fi *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/RS6K/Mfile Sun Jul 24 18:25:03 1994 *************** *** 0 **** --- 1,42 ---- + install: libpvmfs.a syscall.shr.o + + clean: + -rm -f libpvmfs.a pvmfsshr.o syscall.shr.o syscall.o + + pvmfsshr.o: + @if [ ! -f $@ ]; \ + then \ + echo ar x /lib/libc.a shr.o; \ + ar x /lib/libc.a shr.o; \ + echo ld -o $@ -bnso -r shr.o -bnodelcsect; \ + ld -o $@ -bnso -r shr.o -bnodelcsect; \ + echo rm -f shr.o; \ + rm -f shr.o; \ + fi + + libpvmfs.a: pvmfsshr.o + @if [ ! -f $@ ]; \ + then \ + echo cp /lib/libc.a $@; \ + cp /lib/libc.a $@; \ + echo chmod u+w $@; \ + chmod u+w $@; \ + echo ar dv $@ shr.o; \ + ar dv $@ shr.o; \ + echo ar rsv $@ pvmfsshr.o; \ + ar rsv $@ pvmfsshr.o; \ + echo ranlib $@; \ + ranlib $@; \ + else \ + exit 0; \ + fi + + syscall.exp: + echo "#!`pwd`/syscall.shr.o" > syscall.exp + echo "syscall" >> syscall.exp + + syscall.shr.o: syscall.o syscall.exp + ld -o $@ -bM:SRE -T512 -bE:syscall.exp -bI:/lib/syscalls.exp -bnodelcsect syscall.o + + syscall.o: syscall.c syscall-fake.h + $(SCC) -g -c syscall.c *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/RS6K/syscall-fake.h Sun Jul 24 18:25:04 1994 *************** *** 0 **** --- 1,79 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #ifndef SYSCALL_H + #define SYSCALL_H + + #define SYS_access 1 + #define SYS_accessx 2 + #define SYS_chdir 3 + #define SYS_chmod 4 + #define SYS_chown 5 + #define SYS_chownx 6 + #define SYS_chroot 7 + #define SYS_close 8 + #define SYS_creat 9 + #define SYS_dup 10 + #define SYS_dup2 11 + #define SYS_faccessx 12 + #define SYS_fchdir 13 + #define SYS_fchmod 14 + #define SYS_fchown 15 + #define SYS_fchownx 16 + #define SYS_fcntl 17 + #define SYS_fstat 18 + #define SYS_fstatx 19 + #define SYS_fsync 20 + #define SYS_ftruncate 21 + #define SYS_getdirent 22 + #define SYS_getrlimit 23 + #define SYS_ioctl 24 + #define SYS_kfcntl 25 + #define SYS_kioctl 26 + #define SYS_kreadv 27 + #define SYS_kwritev 28 + #define SYS_link 29 + #define SYS_lseek 30 + #define SYS_lstat 31 + #define SYS_mkdir 32 + #define SYS_mknod 33 + #define SYS_open 34 + #define SYS_openx 35 + #define SYS_pipe 36 + #define SYS_read 37 + #define SYS_readx 38 + #define SYS_readv 39 + #define SYS_readvx 40 + #define SYS_readlink 41 + #define SYS_rename 42 + #define SYS_rmdir 43 + #define SYS_select 44 + #define SYS_setrlimit 45 + #define SYS_stat 46 + #define SYS_statx 47 + #define SYS_symlink 48 + #define SYS_sync 49 + #define SYS_truncate 50 + #define SYS_umask 51 + #define SYS_unlink 52 + #define SYS_utimes 53 + #define SYS_write 54 + #define SYS_writex 55 + #define SYS_writev 56 + #define SYS_writevx 57 + + #endif /* SYSCALL_H */ *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/RS6K/syscall.c Sun Jul 24 18:25:04 1994 *************** *** 0 **** --- 1,512 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include "syscall-fake.h" + + #ifdef TRACE + char hex[] = "0123456789abcdef"; + + /* + * A minimal sprintf... + */ + int + minsprintf(char *s, const char *fmt, ...) + { + va_list ap; + int i; + int num; + unsigned long ul; + int long_variety; + long l; + char *begin = s; + char *cp; + + va_start(ap, fmt); + + fmt--; + + while (*++fmt) { + if (*fmt == '%') { + long_variety = 0; + if (*++fmt == 'l') + long_variety = 1; + else + fmt--; + switch (*++fmt) { + case 'p': + ul = va_arg(ap, void *); + for (cp = s; ul >= 16; ul /= 16) + *s++ = hex[ul % 16]; + *s++ = hex[ul]; + num = s - cp; + for (ul = 0; ul < num / 2; ul++) { + char tmp = cp[ul]; + cp[ul] = cp[num - ul - 1]; + cp[num - ul - 1] = tmp; + } + break; + case 'd': + if (long_variety) + l = va_arg(ap, long); + else + l = (long)va_arg(ap, int); + if (l < 0) { + *s++ = '-'; + l = -l; + } + for (cp = s; l >= 10; l /= 10) + *s++ = (l % 10) + '0'; + *s++ = l + '0'; + num = s - cp; + for (l = 0; l < num / 2; l++) { + char tmp = cp[l]; + cp[l] = cp[num - l - 1]; + cp[num - l - 1] = tmp; + } + break; + case 's': + cp = va_arg(ap, char *); + cp--; s--; + while (*++s = *++cp) + ; + break; + } + } else if (*fmt == '\\') + *s++ = *++fmt; + else + *s++ = *fmt; + } + return s - begin; + } + + #define dprint(a) \ + { \ + struct iovec iovec; \ + char buf3[1000]; \ + int n; \ + \ + n = minsprintf a; \ + iovec.iov_base = buf3; \ + iovec.iov_len = n; \ + kwritev(2, &iovec, 1, 1); \ + } + #else + #define dprint(a) + #endif + + int + syscall(int num, ...) + { + va_list ap; + int retval; + int i1, i2, i3; + int *ip; + const char *ccp1, *ccp2; + char *cp1, *cp2; + const void *vp1; + struct iovec *iovp1; + struct iovec iovec; + struct flock *flp; + struct stat *stp1; + struct timeval *tvp; + struct rlimit *rlp; + short *sp1; + size_t s1; + unsigned u1; + off_t off1, off2; + dev_t dev1; + uid_t uid1; + gid_t gid1; + mode_t mode1; + fd_set *fdsp1, *fdsp2, *fdsp3; + + va_start(ap, num); + + switch (num) { + case SYS_access: + cp1 = va_arg(ap, char *); + i1 = va_arg(ap, int); + retval = access(cp1, i1); + dprint((buf3, "syscall(SYS_access, %p, %d) = %d\n", + cp1, i1, retval)); + break; + case SYS_accessx: + cp1 = va_arg(ap, char *); + i1 = va_arg(ap, int); + i2 = va_arg(ap, int); + retval = accessx(cp1, i1, i2); + dprint((buf3, "syscall(SYS_accessx, %p, %d, %d) = %d\n", + cp1, i1, i2, retval)); + break; + case SYS_chdir: + cp1 = va_arg(ap, char *); + retval = chdir(cp1); + dprint((buf3, "syscall(SYS_chdir, %p) = %d\n", cp1, retval)); + break; + case SYS_chmod: + cp1 = va_arg(ap, char *); + mode1 = va_arg(ap, mode_t); + retval = chmod(cp1, mode1); + break; + case SYS_chown: + cp1 = va_arg(ap, char *); + uid1 = va_arg(ap, uid_t); + gid1 = va_arg(ap, gid_t); + retval = chown(cp1, uid1, gid1); + break; + case SYS_chownx: + cp1 = va_arg(ap, char *); + uid1 = va_arg(ap, uid_t); + gid1 = va_arg(ap, gid_t); + i1 = va_arg(ap, int); + retval = chownx(cp1, uid1, gid1, i1); + break; + case SYS_chroot: + cp1 = va_arg(ap, char *); + retval = chroot(cp1); + break; + case SYS_close: + i1 = va_arg(ap, int); + retval = close(i1); + dprint((buf3, "syscall(SYS_close, %d) = %d\n", i1, retval)); + break; + case SYS_creat: + cp1 = va_arg(ap, char *); + mode1 = va_arg(ap, mode_t); + retval = creat(cp1, mode1); + dprint((buf3, "syscall(SYS_creat, \"%s\", %ld, %d) = %d\n", + cp1, (long)mode1, retval)); + break; + case SYS_dup: + i1 = va_arg(ap, int); + retval = kfcntl(i1, F_DUPFD, 0); + dprint((buf3, "syscall(SYS_dup, %d) = %d\n", i1, retval)); + break; + case SYS_dup2: + i1 = va_arg(ap, int); + i2 = va_arg(ap, int); + /* Should make sure i1 is valid, i2 <= OPEN_MAX, ... */ + close(i2); + retval = kfcntl(i1, F_DUPFD, i2); + dprint((buf3, "syscall(SYS_dup2, %d, %d) = %d\n", + i1, i2, retval)); + break; + case SYS_faccessx: + i1 = va_arg(ap, int); + i2 = va_arg(ap, int); + i3 = va_arg(ap, int); + retval = faccessx(i1, i2, i3); + break; + case SYS_fchdir: + retval = -1; + errno = ENOSYS; + break; + case SYS_fchmod: + i1 = va_arg(ap, int); + mode1 = va_arg(ap, mode_t); + retval = fchmod(i1, mode1); + break; + case SYS_fchown: + i1 = va_arg(ap, int); + uid1 = va_arg(ap, uid_t); + gid1 = va_arg(ap, gid_t); + retval = fchown(i1, uid1, gid1); + break; + case SYS_fchownx: + i1 = va_arg(ap, int); + uid1 = va_arg(ap, uid_t); + gid1 = va_arg(ap, gid_t); + i2 = va_arg(ap, int); + retval = fchownx(i1, uid1, gid1, i2); + break; + case SYS_fcntl: + case SYS_kfcntl: + i1 = va_arg(ap, int); + i2 = va_arg(ap, int); + if (i2 == F_GETLK || F_SETLK || F_SETLKW) { + flp = va_arg(ap, struct flock *); + retval = kfcntl(i1, i2, flp); + } else { + i3 = va_arg(ap, int); + retval = kfcntl(i1, i2, i3); + } + break; + case SYS_fstat: + i1 = va_arg(ap, int); + stp1 = va_arg(ap, struct stat *); + retval = fstatx(i1, stp1, STATSIZE, STX_NORMAL); + dprint((buf3, "syscall(SYS_fstat, %d, %p) = %d\n", + i1, stp1, retval)); + break; + case SYS_fstatx: + i1 = va_arg(ap, int); + stp1 = va_arg(ap, struct stat *); + i1 = va_arg(ap, int); + i2 = va_arg(ap, int); + retval = fstatx(i1, stp1, i1, i2); + break; + case SYS_fsync: + i1 = va_arg(ap, int); + retval = fsync(i1); + break; + case SYS_ftruncate: + i1 = va_arg(ap, int); + off1 = va_arg(ap, off_t); + retval = ftruncate(i1, off1); + break; + case SYS_getrlimit: + i1 = va_arg(ap, int); + rlp = va_arg(ap, struct rlimit *); + retval = getrlimit(i1, rlp); + #if 0 + dprint((buf3, + "syscall(SYS_getrlimit, %d, %p) = %d <%lu, %lu>\n", i1, + (void *)rlp, retval, + (unsigned long)rlp->rlim_cur, (unsigned long)rlp->rlim_max)); + #endif + break; + case SYS_kreadv: + i1 = va_arg(ap, int); + iovp1 = va_arg(ap, struct iovec *); + i2 = va_arg(ap, int); + i3 = va_arg(ap, int); + retval = kreadv(i1, iovp1, i2, i3); + dprint((buf3, + "syscall(SYS_kreadv, %d, <%p, %d>, %d, %d) = %d\n", + i1, iovp1->iov_base, iovp1->iov_len, i2, i3, retval)); + break; + case SYS_kwritev: + i1 = va_arg(ap, int); + iovp1 = va_arg(ap, struct iovec *); + i2 = va_arg(ap, int); + i3 = va_arg(ap, int); + retval = kwritev(i1, iovp1, i2, i3); + dprint((buf3, + "syscall(SYS_kwritev, %d, <%p, %d>, %d, %d) = %d\n", + i1, iovp1->iov_base, iovp1->iov_len, i2, i3, retval)); + break; + case SYS_link: + cp1 = va_arg(ap, char *); + cp2 = va_arg(ap, char *); + retval = link(cp1, cp2); + break; + case SYS_lseek: + i1 = va_arg(ap, int); + off1 = va_arg(ap, off_t); + i2 = va_arg(ap, int); + retval = lseek(i1, off1, i2); + break; + case SYS_lstat: + cp1 = va_arg(ap, char *); + stp1 = va_arg(ap, struct stat *); + retval = statx(cp1, stp1, STATSIZE, STX_LINK); + break; + case SYS_mkdir: + cp1 = va_arg(ap, char *); + mode1 = va_arg(ap, mode_t); + retval = mkdir(cp1, mode1); + break; + case SYS_mknod: + ccp1 = va_arg(ap, const char *); + i1 = va_arg(ap, int); + dev1 = va_arg(ap, dev_t); + retval = mknod(ccp1, i1, dev1); + break; + case SYS_open: + cp1 = va_arg(ap, char *); + i1 = va_arg(ap, int); + if (i1 & O_CREAT) { + mode1 = va_arg(ap, int); + retval = open(cp1, i1, mode1); + dprint((buf3, + "syscall(SYS_open, \"%s\", %d, %d) = %d\n", + cp1, i1, mode1, retval)); + } else { + retval = open(cp1, i1); + dprint((buf3, "syscall(SYS_open, \"%s\", %d) = %d\n", + cp1, i1, retval)); + } + break; + case SYS_openx: + cp1 = va_arg(ap, char *); + i1 = va_arg(ap, int); + i2 = va_arg(ap, int); + i3 = va_arg(ap, int); + retval = openx(cp1, i1, i2, i3); + break; + case SYS_read: + i1 = va_arg(ap, int); + cp1 = va_arg(ap, char *); + u1 = va_arg(ap, unsigned); + iovec.iov_base = cp1; + iovec.iov_len = u1; + retval = kreadv(i1, &iovec, 1, 1); + dprint((buf3, "syscall(SYS_read, %d, %p, %d) = %d\n", + i1, cp1, u1, retval)); + break; + case SYS_readx: + i1 = va_arg(ap, int); + cp1 = va_arg(ap, char *); + u1 = va_arg(ap, unsigned); + i2 = va_arg(ap, int); + iovec.iov_base = cp1; + iovec.iov_len = u1; + retval = kreadv(i1, &iovec, 1, i2); + break; + case SYS_readv: + i1 = va_arg(ap, int); + iovp1 = va_arg(ap, struct iovec *); + i2 = va_arg(ap, int); + retval = kreadv(i1, &iovec, i2, 1); + break; + case SYS_readvx: + i1 = va_arg(ap, int); + iovp1 = va_arg(ap, struct iovec *); + i2 = va_arg(ap, int); + i3 = va_arg(ap, int); + retval = kreadv(i1, iovp1, i2, i3); + break; + case SYS_readlink: + ccp1 = va_arg(ap, const char *); + cp1 = va_arg(ap, char *); + i1 = va_arg(ap, int); + retval = readlink(ccp1, cp1, i1); + break; + case SYS_rename: + ccp1 = va_arg(ap, const char *); + ccp2 = va_arg(ap, const char *); + retval = rename(ccp1, ccp2); + break; + case SYS_rmdir: + cp1 = va_arg(ap, char *); + retval = rmdir(cp1); + break; + case SYS_setrlimit: + i1 = va_arg(ap, int); + rlp = va_arg(ap, struct rlimit *); + retval = setrlimit(i1, rlp); + #if 0 + dprint((buf3, + "syscall(SYS_setrlimit, %d, <%lu, %lu>) = %d\n", i1, + (unsigned long)rlp->rlim_cur, (unsigned long)rlp->rlim_max, + retval)); + #endif + break; + case SYS_stat: + cp1 = va_arg(ap, char *); + stp1 = va_arg(ap, struct stat *); + retval = statx(cp1, stp1, STATSIZE, STX_NORMAL); + dprint((buf3, "syscall(SYS_stat, \"%s\", %p) = %d\n", + cp1, stp1, retval)); + break; + case SYS_statx: + cp1 = va_arg(ap, char *); + stp1 = va_arg(ap, struct stat *); + i1 = va_arg(ap, int); + i2 = va_arg(ap, int); + retval = statx(cp1, stp1, i1, i2); + break; + case SYS_symlink: + ccp1 = va_arg(ap, const char *); + ccp2 = va_arg(ap, const char *); + retval = symlink(ccp1, ccp2); + break; + case SYS_sync: + retval = sync(); + break; + case SYS_truncate: + ccp1 = va_arg(ap, const char *); + off1 = va_arg(ap, off_t); + retval = truncate(ccp1, off1); + break; + case SYS_umask: + mode1 = va_arg(ap, mode_t); + retval = umask(mode1); + break; + case SYS_unlink: + cp1 = va_arg(ap, char *); + retval = unlink(cp1); + break; + case SYS_utimes: + ccp1 = va_arg(ap, const char *); + tvp = va_arg(ap, struct timeval *); + retval = utimes(mode1, tvp); + break; + case SYS_write: + i1 = va_arg(ap, int); + cp1 = va_arg(ap, char *); + u1 = va_arg(ap, unsigned); + iovec.iov_base = cp1; + iovec.iov_len = u1; + retval = kwritev(i1, &iovec, 1, 1); + dprint((buf3, "syscall(SYS_write, %d, %p, %d) = %d\n", + i1, cp1, u1, retval)); + break; + case SYS_writex: + i1 = va_arg(ap, int); + cp1 = va_arg(ap, char *); + u1 = va_arg(ap, unsigned); + i2 = va_arg(ap, int); + iovec.iov_base = cp1; + iovec.iov_len = u1; + retval = kwritev(i1, &iovec, 1, i2); + break; + case SYS_writev: + i1 = va_arg(ap, int); + iovp1 = va_arg(ap, struct iovec *); + i2 = va_arg(ap, int); + retval = kwritev(i1, iovp1, i2, 1); + break; + case SYS_writevx: + i1 = va_arg(ap, int); + iovp1 = va_arg(ap, struct iovec *); + i2 = va_arg(ap, int); + i3 = va_arg(ap, int); + retval = kwritev(i1, iovp1, i2, i3); + break; + case SYS_select: + i1 = va_arg(ap, int); + fdsp1 = va_arg(ap, fd_set *); + fdsp2 = va_arg(ap, fd_set *); + fdsp3 = va_arg(ap, fd_set *); + tvp = va_arg(ap, struct timeval *); + retval = select(i1, fdsp1, fdsp2, fdsp3, tvp); + break; + case SYS_pipe: + ip = va_arg(ap, int *); + retval = pipe(ip); + break; + case SYS_ioctl: + case SYS_kioctl: + default: + retval = -1; + break; + } + + va_end(ap); + + return retval; + } *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/RS6K/syscall.exp Sun Jul 24 18:25:04 1994 *************** *** 0 **** --- 1,2 ---- + #!/var/tmp/cgp/pvm3/libc/RS6K/syscall.shr.o + syscall *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/argtypes.h Tue Jul 26 16:39:58 1994 *************** *** 0 **** --- 1,102 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #include + + #ifdef IMA_SUN4 + #define WRITE_RETURN_TYPE int + #define WRITE_ARG2_TYPE char * + #define WRITE_ARG3_TYPE unsigned + #define READ_RETURN_TYPE int + #define READ_ARG2_TYPE char * + #define READ_ARG3_TYPE unsigned + #elif defined(IMA_CRAY) + #define WRITE_RETURN_TYPE int + #define WRITE_ARG2_TYPE const void * + #define WRITE_ARG3_TYPE size_t + #define READ_RETURN_TYPE int + #define READ_ARG2_TYPE void * + #define READ_ARG3_TYPE size_t + #define IOCTL_ARG2_TYPE int + #define IOCTL_STDARG + #elif defined(IMA_PMAX) + #define WRITE_RETURN_TYPE int + #define WRITE_ARG2_TYPE char * + #define WRITE_ARG3_TYPE int + #define READ_RETURN_TYPE int + #define READ_ARG2_TYPE char * + #define READ_ARG3_TYPE int + #elif defined(IMA_CNVXN) + #define WRITE_RETURN_TYPE ssize_t + #define WRITE_ARG2_TYPE const void * + #define WRITE_ARG3_TYPE size_t + #define READ_RETURN_TYPE ssize_t + #define READ_ARG2_TYPE void * + #define READ_ARG3_TYPE size_t + #define WRITEV_RETURN_TYPE int + #define READV_RETURN_TYPE int + #define IOCTL_ARG2_TYPE int + #define IOCTL_STDARG + #elif defined(IMA_ALPHA) + #define WRITE_RETURN_TYPE ssize_t + #define WRITE_ARG2_TYPE const void * + #define WRITE_ARG3_TYPE size_t + #define READ_RETURN_TYPE ssize_t + #define READ_ARG2_TYPE void * + #define READ_ARG3_TYPE size_t + #define WRITEV_RETURN_TYPE int + #define READV_RETURN_TYPE int + #define IOCTL_ARG3_TYPE void * + #elif defined(IMA_RS6K) + #define WRITE_RETURN_TYPE ssize_t + #define WRITE_ARG2_TYPE const void * + #define WRITE_ARG3_TYPE size_t + #define READ_RETURN_TYPE ssize_t + #define READ_ARG2_TYPE void * + #define READ_ARG3_TYPE size_t + #define WRITEV_RETURN_TYPE int + #define READV_RETURN_TYPE int + #endif + #ifndef WRITEV_RETURN_TYPE + #define WRITEV_RETURN_TYPE WRITE_RETURN_TYPE + #endif + #ifndef READV_RETURN_TYPE + #define READV_RETURN_TYPE READ_RETURN_TYPE + #endif + #ifndef IOCTL_ARG2_TYPE + #define IOCTL_ARG2_TYPE unsigned long + #endif + #ifndef IOCTL_ARG3_TYPE + #define IOCTL_ARG3_TYPE char * + #endif + #ifndef WRITEV_CONST + #define WRITEV_CONST + #endif + #ifndef READV_CONST + #define READV_CONST + #endif + #ifndef SETRLIMIT_CONST + #define SETRLIMIT_CONST + #endif + + #ifdef IMA_RS6K + #define SELECT_ARG1_TYPE unsigned long + #define SELECT_SETP_TYPE void * + #else + #define SELECT_ARG1_TYPE int + #define SELECT_SETP_TYPE fd_set * + #endif *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/cc/ccwrap.c Sun Jul 24 18:25:04 1994 *************** *** 0 **** --- 1,129 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #include + #include + #include + #include + #include + + char * + basename(s) + char *s; + { + char *lastslash; + + if (lastslash = strrchr(s, '/')) + return lastslash + 1; + else + return s; + } + + int + main(argc, argv) + int argc; + char **argv; + { + int i; + size_t len; + char buf[1000]; + int status; + int got_o = 0; + int got_E = 0; + int got_P = 0; + int cfiles = 0; + pid_t pid; + + /* argv[1] is the actual compiler */ + + for (i = 2; i < argc; i++) + if (strcmp(argv[i], "-o") == 0) + got_o = 1; + else if (strcmp(argv[i], "-E") == 0) + got_E = 1; + else if (strcmp(argv[i], "-P") == 0) + got_P = 1; + + for (i = 2; i < argc; i++) { + len = strlen(argv[i]); + if (len > 2 && argv[i][len - 2] == '.' + && argv[i][len - 1] == 'c') + cfiles++; + } + + if (cfiles > 1) + exit(1); + else if (cfiles == 0) { + argv++; + execvp(argv[0], argv); + exit(1); + } + + /* cfiles == 1 */ + for (i = 2; i < argc; i++) { + len = strlen(argv[i]); + if (len > 2 && argv[i][len - 2] == '.' + && argv[i][len - 1] == 'c') { + strcpy(buf, "regress "); + strcat(buf, argv[i]); + strcat(buf, " _temp.c"); + if (status = system(buf)) + exit(status); + if (!got_o && !got_E) { + char **newargv; + int j; + + newargv = malloc((argc + 2) * sizeof(*newargv)); + if (!newargv) + exit(1); + for (j = 0; j < argc - 1; j++) + newargv[j] = argv[j + 1]; + if ((newargv[argc] = malloc(3)) == NULL) + exit(1); + newargv[argc - 1] = "-o"; + argv[i][len - 1] = got_P ? 'i' : 'o'; + newargv[argc] = basename(argv[i]); + newargv[i - 1] = "_temp.c"; + newargv[argc + 1] = NULL; + argv = newargv; + } else { + argv[i] = "_temp.c"; + argv++; + } + switch (pid = fork()) { + case -1: + case 0: + execvp(argv[0], argv); + exit(1); + default: + while (wait(&status) != pid) + ; + if (WIFEXITED(status)) { + int retval = WEXITSTATUS(status); + + if (retval == 0) + remove("_temp.c"); + exit(retval); + } else + exit(1); + } + } + } + + /* NOTREACHED */ + exit(1); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/cc/regress.c Sun Jul 24 18:25:04 1994 *************** *** 0 **** --- 1,259 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + /* + * Quick and dirty converter of + * ANSI C function headers to K&R function headers + * + * This program changes lines of the form + * + * ^[_a-zA-Z0-9$][_a-zA-Z0-9$](.*)$ + * + * so that (as an example) + + func( char * const b, int s, struct a * c ) + + * becomes + + func(b, s, c) char *b; int s; struct a *c; + + * All other lines, including function prototypes, remain unchanged. + * + * Note especially that it doesn't deal with ellipses... + */ + + #include + #include + #include + #include + + int + needs_changed(s) + char *s; + { + int i; + int len = strlen(s); + + for (i = 0; isalnum(s[i]) || s[i] == '_' || s[i] == '$'; i++) + ; + return (i >= 1 && s[i] == '(' && s[len - 2] == ')'); + } + + void + delconst(s, end) + char *s, *end; + { + char *prev = NULL; + + s--; + while (*++s != ';' && s < end) { + if (*s == 'c' && (!prev || !isalnum(*prev) && *prev != '_')) + if (strncmp(s, "const", 5) == 0) + if (!isalnum(s[5]) && s[5] != '_') { + strncpy(s, " ", 5); + s += 5; + } + prev = s; + } + } + + char * + nonwhite(s) + char *s; + { + while (isspace(*++s)) + ; + return s; + } + + void + squeeze(s) + char *s; + { + char *prev = NULL; + char buf[BUFSIZ]; + char *p = buf; + char *next; + + strcpy(buf, s); + + p--; + while (*++p != '\n') { + if (*p == '\t') + *p = ' '; + if (!isspace(*p) || (prev && !isspace(*prev) && *prev != '*' + && *prev != '(' && *prev != '[' + && *(next = nonwhite(p)) != ';' && *next != ',' + && *next != ')' && *next != ']' && *next != '[')) { + *s++ = *p; + if (*p == ')' && !isspace(p[1])) + *s++ = ' '; + } + prev = p; + } + *s++ = '\n'; + *s = '\0'; + } + + int + justvoid(s) + char *s; + { + s--; + return *(s = nonwhite(s)) == 'v' + && *(s = nonwhite(s)) == 'o' + && *(s = nonwhite(s)) == 'i' + && *(s = nonwhite(s)) == 'd' + && *(s = nonwhite(s)) == ')'; + } + + int + valist(s) + char *s; + { + s--; + return *(s = nonwhite(s)) == 'v' + && *(s = nonwhite(s)) == 'a' + && *(s = nonwhite(s)) == '_' + && *(s = nonwhite(s)) == 'a' + && *(s = nonwhite(s)) == 'l' + && *(s = nonwhite(s)) == 'i' + && *(s = nonwhite(s)) == 's' + && *(s = nonwhite(s)) == 't' + && *(s = nonwhite(s)) == ')'; + } + + void + change_it(s) + char *s; + { + int i; + int len; + int hasparams; + char params[BUFSIZ]; + char types[BUFSIZ]; + char *begin, *end; + char *p, *q; + + while (*s++ != '(') + ; + + if (justvoid(s)) { + strcpy(s, ")\n"); + return; + } else if (valist(s)) { + strcpy(s, "va_alist)\n"); + return; + } + + delconst(s, s + strlen(s)); + + strcpy(types, s); + strcpy(params, s); + + len = strlen(types); + hasparams = 0; + for (i = 0; i < len; i++) + if (types[i] == ',') + types[i] = ';'; + else if (!hasparams && isalnum(types[i])) + hasparams = 1; + else if (types[i] == ')') + if (hasparams) + types[i] = ';'; + else { + types[i] = '\n'; + types[i + 1] = '\0'; + } + + begin = params; + do { + if ((end = strchr(begin, ',')) == NULL) + end = strchr(begin, ')'); + for (p = end, q = p - 1; p > begin && isspace(*q); + p--, q = p - 1) + ; + for (; p > begin; p--) { + q = p - 1; + if (!isalnum(*q) && *q != '_' && *q != '$') { + if (*q == ']') { + *q = ' '; + for (p--; p > begin; p--) { + q = p - 1; + if (*q == '[') + break; + else + *q = ' '; + } + *q = ' '; + for (p--, q = p - 1; + p > begin && isspace(*q); + p--, q = p - 1) + ; + } else + break; + } + } + while (p != begin) + *--p = ' '; + begin = end + 1; + } while (*end != ')'); + + params[strlen(params) - 1] = '\0'; /* zap '\n' */ + strcpy(s, params); + strcat(s, types); + + squeeze(s); + } + + int + main(argc, argv) + int argc; + char **argv; + { + char buf[BUFSIZ]; + FILE *fp1 = stdin; + FILE *fp2 = stdout; + + if (argc > 3) { + fprintf(stderr, "Usage: %s [input [output]]\n", argv[0]); + exit(1); + } + if (argc > 2 && (fp2 = fopen(argv[2], "w")) == NULL) { + fprintf(stderr, "%s: can't open %s\n", argv[0], argv[2]); + exit(1); + } + if (argc > 1 && (fp1 = fopen(argv[1], "r")) == NULL) { + fprintf(stderr, "%s: can't read %s\n", argv[0], argv[1]); + exit(1); + } + + while (fgets(buf, sizeof buf, fp1)) { + if (needs_changed(buf)) + change_it(buf); + if (fputs(buf, fp2) == EOF) { + perror(argc < 3 ? "stdout" : argv[2]); + exit(1); + } + } + if (ferror(fp1)) { + perror(argc < 2 ? "stdin" : argv[1]); + exit(1); + } + + exit(0); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/fs.h Sun Jul 24 18:25:03 1994 *************** *** 0 **** --- 1,196 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #ifndef FS_H + #define FS_H + + #define PVMFS_O_RDONLY 0x0001 + #define PVMFS_O_WRONLY 0x0002 + #define PVMFS_O_RDWR 0x0004 + #define PVMFS_O_APPEND 0x0008 + #define PVMFS_O_CREAT 0x0010 + #define PVMFS_O_EXCL 0x0020 + #define PVMFS_O_TRUNC 0x0040 + #define PVMFS_O_NOCTTY 0x0080 + #define PVMFS_O_NONBLOCK 0x0100 + #define PVMFS_O_SYNC 0x0200 + #define PVMFS_O_ASYNC 0x0400 + #define PVMFS_O_LARGEFILE 0x0800 + + #define PVMFS_S_IRUSR 0400 + #define PVMFS_S_IWUSR 0200 + #define PVMFS_S_IXUSR 0100 + #define PVMFS_S_IRGRP 0040 + #define PVMFS_S_IWGRP 0020 + #define PVMFS_S_IXGRP 0010 + #define PVMFS_S_IROTH 0004 + #define PVMFS_S_IWOTH 0002 + #define PVMFS_S_IXOTH 0001 + + #define PVMFS_SEEK_SET 0 + #define PVMFS_SEEK_CUR 1 + #define PVMFS_SEEK_END 2 + + #define PVMFS_F_DUPFD 0 + #define PVMFS_F_GETFD 1 + #define PVMFS_F_SETFD 2 + #define PVMFS_F_GETFL 3 + #define PVMFS_F_SETFL 4 + #define PVMFS_F_GETOWN 5 + #define PVMFS_F_SETOWN 6 + #define PVMFS_F_GETLK 7 + #define PVMFS_F_SETLK 8 + #define PVMFS_F_SETLKW 9 + + #define PVMFS_F_RDLCK 0 + #define PVMFS_F_WRLCK 1 + #define PVMFS_F_UNLCK 2 + + #define PVMFS_F_OK 0 + #define PVMFS_X_OK 1 + #define PVMFS_W_OK 2 + #define PVMFS_R_OK 4 + + #define PVMFS_TCOOFF 0 + #define PVMFS_TCOON 1 + #define PVMFS_TCIOFF 2 + #define PVMFS_TCION 3 + + #define PVMFS_TCIFLUSH 0 + #define PVMFS_TCOFLUSH 1 + #define PVMFS_TCIOFLUSH 2 + + #define PVMFS_TCSANOW 0 + #define PVMFS_TCSADRAIN 1 + #define PVMFS_TCSAFLUSH 2 + + #define PVMFS_BRKINT 0x0001 + #define PVMFS_ICRNL 0x0002 + #define PVMFS_IGNBRK 0x0004 + #define PVMFS_IGNCR 0x0008 + #define PVMFS_IGNPAR 0x0010 + #define PVMFS_IMAXBEL 0x0020 + #define PVMFS_INLCR 0x0040 + #define PVMFS_INPCK 0x0080 + #define PVMFS_ISTRIP 0x0100 + #define PVMFS_IUCLC 0x0200 + #define PVMFS_IXANY 0x0400 + #define PVMFS_IXOFF 0x0800 + #define PVMFS_IXON 0x1000 + #define PVMFS_PARMRK 0x2000 + + #define PVMFS_BSDLY 0x00000001 + #define PVMFS_BS0 0x00000002 + #define PVMFS_BS1 0x00000004 + #define PVMFS_CRDLY 0x00000008 + #define PVMFS_CR0 0x00000010 + #define PVMFS_CR1 0x00000020 + #define PVMFS_CR2 0x00000040 + #define PVMFS_CR3 0x00000080 + #define PVMFS_FFDLY 0x00000100 + #define PVMFS_FF0 0x00000200 + #define PVMFS_FF1 0x00000400 + #define PVMFS_NLDLY 0x00000800 + #define PVMFS_NL0 0x00001000 + #define PVMFS_NL1 0x00002000 + #define PVMFS_OCRNL 0x00004000 + #define PVMFS_OFDEL 0x00008000 + #define PVMFS_OFILL 0x00010000 + #define PVMFS_OLCUC 0x00020000 + #define PVMFS_ONLCR 0x00040000 + #define PVMFS_ONLRET 0x00080000 + #define PVMFS_ONOCR 0x00100000 + #define PVMFS_ONOEOT 0x00200000 + #define PVMFS_OPOST 0x00400000 + #define PVMFS_OXTABS 0x00800000 + #define PVMFS_TABDLY 0x01000000 + #define PVMFS_TAB0 0x02000000 + #define PVMFS_TAB1 0x04000000 + #define PVMFS_TAB2 0x08000000 + #define PVMFS_TAB3 0x10000000 + #define PVMFS_VTDLY 0x20000000 + #define PVMFS_VT0 0x40000000 + #define PVMFS_VT1 0x80000000 + + #define PVMFS_CCTS_OFLOW 0x0001 + #define PVMFS_CIGNORE 0x0002 + #define PVMFS_CLOCAL 0x0004 + #define PVMFS_CREAD 0x0008 + #define PVMFS_CRTS_IFLOW 0x0010 + #define PVMFS_CSIZE 0x0020 + #define PVMFS_CS5 0x0040 + #define PVMFS_CS6 0x0080 + #define PVMFS_CS7 0x0100 + #define PVMFS_CS8 0x0200 + #define PVMFS_CSTOPB 0x0400 + #define PVMFS_HUPCL 0x0800 + #define PVMFS_MDMBUF 0x1000 + #define PVMFS_PARENB 0x2000 + #define PVMFS_PARODD 0x4000 + + #define PVMFS_ALTWERASE 0x000001 + #define PVMFS_ECHO 0x000002 + #define PVMFS_ECHOCTL 0x000004 + #define PVMFS_ECHOE 0x000008 + #define PVMFS_ECHOK 0x000010 + #define PVMFS_ECHOKE 0x000020 + #define PVMFS_ECHONL 0x000040 + #define PVMFS_ECHOPRT 0x000080 + #define PVMFS_FLUSHO 0x000100 + #define PVMFS_ICANON 0x000200 + #define PVMFS_IEXTEN 0x000400 + #define PVMFS_ISIG 0x000800 + #define PVMFS_NOFLSH 0x001000 + #define PVMFS_NOKERNINFO 0x002000 + #define PVMFS_PENDIN 0x004000 + #define PVMFS_TOSTOP 0x008000 + #define PVMFS_XCASE 0x010000 + + #define PVMFS_B0 1 + #define PVMFS_B50 2 + #define PVMFS_B75 3 + #define PVMFS_B110 4 + #define PVMFS_B134 5 + #define PVMFS_B150 6 + #define PVMFS_B200 7 + #define PVMFS_B300 8 + #define PVMFS_B600 9 + #define PVMFS_B1200 10 + #define PVMFS_B1800 11 + #define PVMFS_B2400 12 + #define PVMFS_B4800 13 + #define PVMFS_B9600 14 + #define PVMFS_B19200 15 + #define PVMFS_B38400 16 + + #define PVMFS__PC_LINK_MAX 10 + #define PVMFS__PC_MAX_CANON 11 + #define PVMFS__PC_MAX_INPUT 12 + #define PVMFS__PC_NAME_MAX 13 + #define PVMFS__PC_PATH_MAX 14 + #define PVMFS__PC_PIPE_BUF 15 + #define PVMFS__PC_CHOWN_RESTRICTED 16 + #define PVMFS__PC_NO_TRUNC 17 + #define PVMFS__PC_VDISABLE 18 + #define PVMFS__SC_OPEN_MAX 19 + + #define PVMFS_RLIMIT_CORE 0 + #define PVMFS_RLIMIT_FSIZE 1 + #define PVMFS_RLIMIT_NOFILE 2 + #define PVMFS_RLIMIT_OFILE 3 + + #endif *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/fsp.h Sun Jul 24 18:25:03 1994 *************** *** 0 **** --- 1,95 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #ifndef FSP_H + #define FSP_H + + #define FSPROTOCOL 1 + + #define PVMFS_NEW_TASK 0 + #define PVMFS_ACCESS 1 + #define PVMFS_CHDIR 2 + #define PVMFS_CHMOD 3 + #define PVMFS_CHOWN 4 + #define PVMFS_CHROOT 5 + #define PVMFS_CLOSE 6 + #define PVMFS_CLOSEDIR 7 + #define PVMFS_CREAT 8 + #define PVMFS_CTERMID 9 + #define PVMFS_DUP 10 + #define PVMFS_DUP2 11 + #define PVMFS_FCHDIR 12 + #define PVMFS_FCHMOD 13 + #define PVMFS_FCHOWN 14 + #define PVMFS_FCHROOT 15 + #define PVMFS_FCNTL 16 + #define PVMFS_FPATHCONF 17 + #define PVMFS_FSTAT 18 + #define PVMFS_FSTATFS 19 + #define PVMFS_FSYNC 20 + #define PVMFS_FTRUNCATE 21 + #define PVMFS_GETCWD 22 + #define PVMFS_GETDIRENTRIES 23 + #define PVMFS_GETDTABLESIZE 24 + #define PVMFS_GETIOMODE 25 + #define PVMFS_GETIOORDER 26 + #define PVMFS_GETRLIMIT 27 + #define PVMFS_INIT 28 + #define PVMFS_ISATTY 29 + #define PVMFS_LCHOWN 30 + #define PVMFS_LINK 31 + #define PVMFS_LSEEK 32 + #define PVMFS_LSTAT 33 + #define PVMFS_MKDIR 34 + #define PVMFS_MKFIFO 35 + #define PVMFS_MKNOD 36 + #define PVMFS_OPEN 37 + #define PVMFS_OPENDIR 38 + #define PVMFS_PATHCONF 39 + #define PVMFS_PIPE 40 + #define PVMFS_READ 41 + #define PVMFS_READDIR 42 + #define PVMFS_READLINK 43 + #define PVMFS_READV 44 + #define PVMFS_RENAME 45 + #define PVMFS_REWINDDIR 46 + #define PVMFS_RMDIR 47 + #define PVMFS_SEEKDIR 48 + #define PVMFS_SELECT 49 + #define PVMFS_SETIOMODE 50 + #define PVMFS_SETIOORDER 51 + #define PVMFS_SETRLIMIT 52 + #define PVMFS_STAT 53 + #define PVMFS_STATFS 54 + #define PVMFS_SYMLINK 55 + #define PVMFS_SYNC 56 + #define PVMFS_TASK_EXIT 57 + #define PVMFS_TCDRAIN 58 + #define PVMFS_TCFLOW 59 + #define PVMFS_TCFLUSH 60 + #define PVMFS_TCSENDBREAK 61 + #define PVMFS_TELLDIR 62 + #define PVMFS_TRUNCATE 63 + #define PVMFS_TTYNAME 64 + #define PVMFS_UMASK 65 + #define PVMFS_UNLINK 66 + #define PVMFS_UTIME 67 + #define PVMFS_UTIMES 68 + #define PVMFS_WRITE 69 + #define PVMFS_WRITEV 70 + + #endif *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/pipe.h Mon Jul 25 12:33:28 1994 *************** *** 0 **** --- 1,24 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + /* + * None of the supported architectures has a working syscall(SYS_pipe, ...) + X#if defined(...) + X#define SYSCALL_PIPE_IS_OK + X#endif + * + */ *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/posix.c Tue Jul 26 17:03:51 1994 *************** *** 0 **** --- 1,1615 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #include + #include + #include + #ifdef IOCTL_STDARG + #include + #endif + #include + #ifdef IMA_CRAY + #define _POSIX_SOURCE + #endif + #include + #include + #include + #ifdef IMA_ALPHA + #define _SYSV + #endif + #include + #ifdef IMA_ALPHA + #undef _SYSV + #endif + #include + #include "pvm3.h" + #include "fs.h" + #include "fsp.h" + #if defined(IMA_RS6K) || defined(IMA_CRAY) + #include "syscall-fake.h" + #else + #include + #include + #ifndef IMA_SUN4 + #include + #endif + #endif + #include "argtypes.h" + + #ifdef TRACE + /* + * Debugging and trace stuff. + */ + extern int pvmdebug; + + #define dprint(s) do { \ + if (pvmdebug) { \ + sprintf s; \ + syscall(SYS_write, 2, buf2, \ + strlen(buf2)); \ + } \ + } while (0) + #define dprintl(s) dprint(s) + + static char buf2[100]; + + #else + #define dprint(s) + #define dprintl(s) + #endif + + extern int lpvmerr __ProtoGlarp__((const char *, int)); + extern int pvmmytid; + extern int pvmmyfstid; + extern int errno; + + extern int pvm_local_errno __ProtoGlarp__((int)); + extern int pvm_tcflow_action __ProtoGlarp__((int)); + extern int pvm_tcflush_queue __ProtoGlarp__((int)); + extern int pvm_tcsetattr_opt __ProtoGlarp__((int)); + extern long pvm_local_tcattr_iflag __ProtoGlarp__((long)); + extern long pvm_local_tcattr_oflag __ProtoGlarp__((long)); + extern long pvm_local_tcattr_cflag __ProtoGlarp__((long)); + extern long pvm_local_tcattr_lflag __ProtoGlarp__((long)); + extern long pvm_local_tcattr_ispeed __ProtoGlarp__((long)); + extern long pvm_local_tcattr_ospeed __ProtoGlarp__((long)); + extern long pvm_tcattr_iflag __ProtoGlarp__((long)); + extern long pvm_tcattr_oflag __ProtoGlarp__((long)); + extern long pvm_tcattr_cflag __ProtoGlarp__((long)); + extern long pvm_tcattr_lflag __ProtoGlarp__((long)); + extern long pvm_tcattr_ispeed __ProtoGlarp__((long)); + extern long pvm_tcattr_ospeed __ProtoGlarp__((long)); + extern int pvm_pathconf_name __ProtoGlarp__((int)); + + /* + * Local POSIX directory stuff. + * We map pointers to integers. + */ + struct dirmap { + int dindex; + struct dirent dirent; + }; + + static struct dirmap *dirmap = NULL; + static int numdirs = 0; + + DIR * + opendir(const char *pathname) + { + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_OPENDIR; + int nargs = 1; + int i; + + if (pvmmyfstid <= 0) { + lpvmerr("opendir", PvmNoFileServer); + errno = ENOSYS; + return NULL; + } + + for (i = 0; i < numdirs; i++) + if (dirmap[i].dindex == -1) + break; + if (i == numdirs) { + struct dirmap *tmp; + + #if defined(IMA_SUN3) || defined(IMA_SUN4) + if (dirmap == NULL) { + if ((tmp = malloc(sizeof(*dirmap))) == NULL) + return NULL; + } else + #endif + if ((tmp = realloc(dirmap, (numdirs + 1) * sizeof(*dirmap))) + == NULL) + return NULL; + numdirs++; + dirmap = tmp; + } + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s", PvmDataDefault, nargs, pathname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &dirmap[i].dindex); + if (dirmap[i].dindex == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x opendir(\"%s\") = NULL (pvmerrno = %d)\n", pvmmytid, + pathname, errno)); + } else + dprint((buf2, "tid t%x opendir(\"%s\") = ok (index %d)\n", + pvmmytid, pathname, i)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return (DIR *)(dirmap[i].dindex + 1); + } + + DIR * + _opendir(const char *pathname) + { + return opendir(pathname); + } + + DIR * + __opendir(const char *pathname) + { + return opendir(pathname); + } + + #ifdef IMA_CNVXN + DIR * + __ap$opendir(const char *pathname) + { + return opendir(pathname); + } + #endif /* IMA_CNVXN */ + + struct dirent * + readdir(DIR *dp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int dindex; + int request = PVMFS_READDIR; + int nargs = 1; + int saved_errno = errno; + + if (pvmmyfstid <= 0) { + lpvmerr("readdir", PvmNoFileServer); + errno = ENOSYS; + return NULL; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + dindex = (unsigned int)dp - 1; + pvm_packf("%+ %d %d", PvmDataDefault, nargs, dindex); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + /* + * If we get pvmerrno == -2, we've + * reached the end of the directory. + */ + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + if (errno > 0) + dprint((buf2, + "tid t%x readdir(index %d) = NULL (errno = %d)\n", + pvmmytid, (int)dp, errno)); + else + dprint((buf2, "tid t%x readdir(index %d) = NULL\n", + pvmmytid, (int)dp)); + } else { + pvm_unpackf("%s", dirmap[(unsigned int)dp - 1].dirent.d_name); + dprint((buf2, "tid t%x readdir(index %d) = ok\n", + pvmmytid, (int)dp)); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + if (cc == -1) + if (pvmerrno < 0) + errno = saved_errno; + else + errno = pvm_local_errno(pvmerrno); + + return (cc == -1) ? NULL : &dirmap[(unsigned int)dp - 1].dirent; + } + + struct dirent * + _readdir(DIR *dp) + { + return readdir(dp); + } + + struct dirent * + __readdir(DIR *dp) + { + return readdir(dp); + } + + #ifdef IMA_CNVXN + struct dirent * + __ap$readdir(DIR *dp) + { + return readdir(dp); + } + #endif /* IMA_CNVXN */ + + int + closedir(DIR *dp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int dindex; + int request = PVMFS_CLOSEDIR; + int nargs = 1; + + if (pvmmyfstid <= 0) { + lpvmerr("closedir", PvmNoFileServer); + errno = ENOSYS; + return -1; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + dindex = (int)dp - 1; + pvm_packf("%+ %d %d", PvmDataDefault, nargs, dindex); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x closedir(index %d) = -1 (errno = %d)\n", + pvmmytid, (int)dp, errno)); + } else + dprint((buf2, "tid t%x closedir(index %d) = %d\n", + pvmmytid, (int)dp, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _closedir(DIR *dp) + { + return closedir(dp); + } + + int + __closedir(DIR *dp) + { + return closedir(dp); + } + + #ifdef IMA_CNVXN + int + __ap$closedir(DIR *dp) + { + return closedir(dp); + } + #endif /* IMA_CNVXN */ + + void + seekdir(DIR *dp, long loc) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int dindex; + int request = PVMFS_SEEKDIR; + int nargs = 2; + + if (pvmmyfstid <= 0) { + lpvmerr("seekdir", PvmNoFileServer); + errno = ENOSYS; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + dindex = (int)dp - 1; + pvm_packf("%+ %d %d %ld", PvmDataDefault, nargs, dindex, loc); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%ld", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x seekdir(index %d, %ld) - bad index\n", + pvmmytid, (int)dp, loc)); + } else + dprint((buf2, "tid t%x seekdir(index %d, %ld) ok\n", + pvmmytid, (int)dp, loc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + } + + void + _seekdir(DIR *dp, long loc) + { + seekdir(dp, loc); + } + + void + __seekdir(DIR *dp, long loc) + { + seekdir(dp, loc); + } + + #ifdef IMA_CNVXN + void + __ap$seekdir(DIR *dp, long loc) + { + seekdir(dp, loc); + } + #endif /* IMA_CNVXN */ + + long + telldir(DIR *dp) + { + int lcc; + int pvmerrno; + int rbuf; + int sbuf; + int dindex; + int request = PVMFS_TELLDIR; + int nargs = 1; + + if (pvmmyfstid <= 0) { + lpvmerr("telldir", PvmNoFileServer); + errno = ENOSYS; + return -1; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + dindex = (int)dp - 1; + pvm_packf("%+ %d %d", PvmDataDefault, nargs, dindex); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%ld", &lcc); + if (lcc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x telldir(index %d) = -1 (errno = %d)\n", + pvmmytid, (int)dp, errno)); + } else + dprint((buf2, "tid t%x telldir(index %d) = %ld\n", + pvmmytid, (int)dp, lcc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return lcc; + } + + long + _telldir(DIR *dp) + { + return telldir(dp); + } + + long + __telldir(DIR *dp) + { + return telldir(dp); + } + + #ifdef IMA_CNVXN + long + __ap$telldir(DIR *dp) + { + return telldir(dp); + } + #endif /* IMA_CNVXN */ + + /* + * Not sure if this trick really helps... + */ + #ifdef rewinddir + #define rewinddir_is_defined + static void + REWINDDIR(DIR *dp) + { + rewinddir(dp); + } + #undef rewinddir + #endif + + void + rewinddir(DIR *dp) + { + int cc; + int rbuf; + int sbuf; + int dindex; + int request = PVMFS_REWINDDIR; + int nargs = 1; + + if (pvmmyfstid <= 0) { + #ifdef rewinddir_is_defined + REWINDDIR(dp); + #else + lpvmerr("rewinddir", PvmNoFileServer); + errno = ENOSYS; + #endif + return; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + dindex = (int)dp - 1; + pvm_packf("%+ %d %d", PvmDataDefault, nargs, dindex); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) + dprint((buf2, "tid t%x rewinddir(index %d) - bad index\n", + pvmmytid, (int)dp)); + else + dprint((buf2, "tid t%x rewinddir(index %d) ok\n", + pvmmytid, (int)dp)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return; + } + + void + _rewinddir(DIR *dp) + { + rewinddir(dp); + } + + void + __rewinddir(DIR *dp) + { + rewinddir(dp); + } + + #ifdef IMA_CNVXN + void + __ap$rewinddir(DIR *dp) + { + rewinddir(dp); + } + #endif /* IMA_CNVXN */ + + char * + ttyname(int fd) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_TTYNAME; + int nargs = 1; + char *cresult; + static char *tty = NULL; + + if (pvmmyfstid <= 0) { + lpvmerr("ttyname", PvmNoFileServer); + errno = ENOSYS; + return NULL; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == 0 || + #if defined(IMA_SUN3) || defined(IMA_SUN4) + !tty && (tty = malloc(cc + 1)) == NULL || tty && + #endif + (tty = realloc(tty, cc + 1)) == NULL) { + if (cc == 0) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + } + cresult = NULL; + dprint((buf2, "tid t%x ttyname(%d) = NULL (errno = %d)\n", + pvmmytid, fd, errno)); + } else { + pvm_unpackf("%s", tty); + cresult = tty; + dprint((buf2, "tid t%x ttyname(%d) = %s\n", + pvmmytid, fd, tty)); + } + + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cresult; + } + + char * + _ttyname(int fd) + { + return ttyname(fd); + } + + char * + __ttyname(int fd) + { + return ttyname(fd); + } + + #ifdef IMA_CNVXN + char * + __ap$ttyname(int fd) + { + return ttyname(fd); + } + #endif /* IMA_CNVXN */ + + #ifdef tcdrain + #define tcdrain_is_defined + static int + TCDRAIN(int fd) + { + return tcdrain(fd); + } + #undef tcdrain + #endif + + int + tcdrain(int fd) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_TCDRAIN; + int nargs = 1; + + if (pvmmyfstid <= 0) { + #ifdef tcdrain_is_defined + return TCDRAIN(fd); + #else + lpvmerr("tcdrain", PvmNoFileServer); + errno = ENOSYS; + return -1; + #endif + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x tcdrain(%d) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, pvmerrno)); + } else + dprint((buf2, "tid t%x tcdrain(%d) = %d\n", + pvmmytid, fd, cc)); + + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _tcdrain(int fd) + { + return tcdrain(fd); + } + + int + __tcdrain(int fd) + { + return tcdrain(fd); + } + + #ifdef IMA_CNVXN + int + __ap$tcdrain(int fd) + { + return tcdrain(fd); + } + #endif /* IMA_CNVXN */ + + #ifdef tcflow + #define tcflow_is_defined + static int + TCFLOW(int fd, int action) + { + return tcflow(fd, action); + } + #undef tcflow + #endif + + int + tcflow(int fd, int action) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_TCFLOW; + int nargs = 2; + int pvmaction; + + if (pvmmyfstid <= 0) { + #ifdef tcflow_is_defined + return TCFLOW(fd, action); + #else + lpvmerr("tcflow", PvmNoFileServer); + errno = ENOSYS; + return -1; + #endif + } + + pvmaction = pvm_tcflow_action(action); + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %d", PvmDataDefault, nargs, fd, pvmaction); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x tcflow(%d, %d) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, action, pvmerrno)); + } else + dprint((buf2, "tid t%x tcflow(%d, %d) = %d\n", + pvmmytid, fd, action, cc)); + + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _tcflow(int fd, int action) + { + return tcflow(fd, action); + } + + int + __tcflow(int fd, int action) + { + return tcflow(fd, action); + } + + #ifdef IMA_CNVXN + int + __ap$tcflow(int fd, int action) + { + return tcflow(fd, action); + } + #endif /* IMA_CNVXN */ + + #ifdef tcflush + #define tcflush_is_defined + static int + TCFLUSH(int fd, int queue) + { + return tcflush(fd, queue); + } + #undef tcflush + #endif + + int + tcflush(int fd, int queue) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_TCFLUSH; + int nargs = 2; + int pvmqueue; + + if (pvmmyfstid <= 0) { + #ifdef tcflush_is_defined + return TCFLUSH(fd, queue); + #else + lpvmerr("tcflush", PvmNoFileServer); + errno = ENOSYS; + return -1; + #endif + } + + pvmqueue = pvm_tcflush_queue(queue); + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %d", PvmDataDefault, nargs, fd, pvmqueue); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x tcflush(%d, %d) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, queue, pvmerrno)); + } else + dprint((buf2, "tid t%x tcflush(%d, %d) = %d\n", + pvmmytid, fd, queue, cc)); + + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _tcflush(int fd, int queue) + { + return tcflush(fd, queue); + } + + int + __tcflush(int fd, int queue) + { + return tcflush(fd, queue); + } + + #ifdef IMA_CNVXN + int + __ap$tcflush(int fd, int queue) + { + return tcflush(fd, queue); + } + #endif /* IMA_CNVXN */ + + int + tcsendbreak(int fd, int duration) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_TCSENDBREAK; + int nargs = 2; + + if (pvmmyfstid <= 0) { + lpvmerr("tcsendbreak", PvmNoFileServer); + errno = ENOSYS; + return -1; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %d", PvmDataDefault, nargs, fd, duration); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x tcsendbreak(%d, %d) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, duration, pvmerrno)); + } else + dprint((buf2, "tid t%x tcsendbreak(%d, %d) = %d\n", + pvmmytid, fd, duration, cc)); + + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _tcsendbreak(int fd, int duration) + { + return tcsendbreak(fd, duration); + } + + int + __tcsendbreak(int fd, int duration) + { + return tcsendbreak(fd, duration); + } + + #ifdef IMA_CNVXN + int + __ap$tcsendbreak(int fd, int duration) + { + return tcsendbreak(fd, duration); + } + #endif /* IMA_CNVXN */ + + #if 0 + + /* + * Give up on tc[gs]etattr for now. Too much wierdness. + */ + int pvmfs_lccindex[] = { + VEOF, VEOL, VERASE, VINTR, VKILL, VQUIT, VSTART, VSTOP, VSUSP, + #ifdef VLNEXT + VLNEXT, + #else + -1, + #endif + #ifdef VWERASE + VWERASE, + #else + -1, + #endif + #ifdef VREPRINT + VREPRINT, + #else + -1, + #endif + #ifdef VDISCARD + VDISCARD, + #else + -1, + #endif + #ifdef VDSUSP + VDSUSP, + #else + -1, + #endif + #ifdef VEOL2 + VEOL2, + #else + -1, + #endif + #ifdef VSTATUS + VSTATUS, + #else + -1, + #endif + }; + + int pvmfs_fsccindex[] = { + PVMFS_VEOF, PVMFS_VEOL, PVMFS_VERASE, PVMFS_VINTR, PVMFS_VKILL, + PVMFS_VQUIT, PVMFS_VSTART, PVMFS_VSTOP, PVMFS_VSUSP, PVMFS_VLNEXT, + PVMFS_VWERASE, PVMFS_VREPRINT, PVMFS_VDISCARD, PVMFS_VDSUSP, + PVMFS_VEOL2, PVMFS_VSTATUS, + }; + + #define PVMFS_NCCS sizeof pvmfs_fsccindex / sizeof pvmfs_fsccindex[0] + static long ctl_chars[PVMFS_NCCS]; + + int + tcgetattr(int fd, struct termios *tp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_TCGETATTR; + int nargs = 1; + long iflag; + long oflag; + long cflag; + long lflag; + long speed; + + if (pvmmyfstid <= 0) { + lpvmerr("tcgetattr", PvmNoFileServer); + errno = ENOSYS; + return -1; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x tcgetattr(%d, %p) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, tp, pvmerrno)); + } else { + (void)memset(tp, '\0', sizeof(*tp)); + pvm_unpackf("%ld %ld %ld %ld", &iflag, &oflag, &cflag, &lflag); + tp->iflag = pvm_local_tcattr_iflag(iflag); + tp->oflag = pvm_local_tcattr_oflag(oflag); + tp->cflag = pvm_local_tcattr_cflag(cflag); + tp->lflag = pvm_local_tcattr_lflag(lflag); + pvm_unpackf("%ld", &speed); + cfsetispeed(tp, pvm_local_tcattr_ispeed(speed)); + pvm_unpackf("%ld", &speed); + cfsetospeed(tp, pvm_local_tcattr_ospeed(speed)); + for (i = 0; i < PVMFS_NCCS; i++) { + pvm_unpackf("%ld", &ctl_chars[i]); + if (pvmfs_lccindex[i] >= 0) + tp->c_cc[pvmfs_lccindex[i]] = ctl_chars[i]; + } + dprint((buf2, "tid t%x tcgetattr(%d, %p) = %d\n", + pvmmytid, fd, tp, cc)); + } + + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _tcgetattr(int fd, struct termios *tp) + { + return tcgetattr(fd, tp); + } + + int + __tcgetattr(int fd, struct termios *tp) + { + return tcgetattr(fd, tp); + } + + #ifdef IMA_CNVXN + int + __ap$tcgetattr(int fd, struct termios *tp) + { + return tcgetattr(fd, tp); + } + #endif /* IMA_CNVXN */ + + int + tcsetattr(int fd, int opt, struct termios *tp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_TCSETATTR; + int nargs = 2; + int pvmopt; + long iflag; + long oflag; + long cflag; + long lflag; + long speed; + long ctl_char; + static int getattr_called = 0; + + if (pvmmyfstid <= 0) { + lpvmerr("tcsetattr", PvmNoFileServer); + errno = ENOSYS; + return -1; + } + + if (!getattr_called) { + struct termios term; + + if (tcgetattr(fd, &term) == -1) + return -1; + getattr_called = 1; + } + + pvmopt = pvm_tcsetattr_opt(opt); + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %d", PvmDataDefault, nargs, fd, pvmopt); + iflag = pvm_tcattr_iflag(tp->iflag); + oflag = pvm_tcattr_oflag(tp->oflag); + cflag = pvm_tcattr_cflag(tp->cflag); + lflag = pvm_tcattr_lflag(tp->lflag); + pvm_packf("%ld %ld %ld %ld", iflag, oflag, cflag, lflag); + speed = cfgetispeed(tp); + pvm_packf("%ld", speed); + speed = cfgetospeed(tp); + pvm_packf("%ld", speed); + for (i = 0; i < PVMFS_NCCS; i++) { + ctl_char = (pvmfs_lccindex[i] >= 0) + ? tp->c_cc[pvmfs_lccindex[i]] : ctl_chars[i]; + pvm_packf("%ld", ctl_chars[i]); + } + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x tcgetattr(%d, %p) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, tp, pvmerrno)); + } else + dprint((buf2, "tid t%x tcgetattr(%d, %p) = %d\n", + pvmmytid, fd, tp, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _tcsetattr(int fd, int opt, struct termios *tp) + { + return tcsetattr(fd, opt, tp); + } + + int + __tcsetattr(int fd, int opt, struct termios *tp) + { + return tcsetattr(fd, opt, tp); + } + + #ifdef IMA_CNVXN + int + __ap$tcsetattr(int fd, int opt, struct termios *tp) + { + return tcsetattr(fd, opt, tp); + } + #endif /* IMA_CNVXN */ + #endif /* 0 */ + + long + pathconf(const char *pathname, int name) + { + long lcc; + int pvmerrno; + int pvmname; + int rbuf; + int sbuf; + int request = PVMFS_PATHCONF; + int nargs = 2; + + if (pvmmyfstid <= 0) { + if (name < 0) { + #ifdef SYS_sysconf + lcc = syscall(SYS_sysconf, _SC_OPEN_MAX); + if (lcc == -1L) + dprintl((buf2, + "tid t%x sysconf(_SC_OPEN_MAX) = -1 (errno = %d)\n", + pvmmytid, errno)); + else + dprintl((buf2, + "tid t%x sysconf(_SC_OPEN_MAX) = %ld\n", + pvmmytid, lcc)); + #else + lpvmerr("sysconf", PvmNoFileServer); + errno = ENOSYS; + return -1L; + #endif + } else { + #ifdef SYS_pathconf + lcc = syscall(SYS_pathconf, pathname, name); + if (lcc == -1L) + dprintl((buf2, + "tid t%x pathconf(\"%s\", %d) = %ld (errno = %d)\n", + pvmmytid, pathname, name, lcc, errno)); + else + dprintl((buf2, + "tid t%x pathconf(\"%s\", %d) = %ld\n", + pvmmytid, pathname, name, lcc)); + return lcc; + #else + lpvmerr("pathconf", PvmNoFileServer); + errno = ENOSYS; + return -1L; + #endif + } + } + + pvmname = pvm_pathconf_name(name); + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %d", PvmDataDefault, nargs, pathname, pvmname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%ld", &lcc); + if (lcc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + if (name < 0) + dprint((buf2, + "tid t%x sysconf(_SC_OPEN_MAX) = -1 (pvmerrno = %d)\n", + pvmmytid, pvmerrno)); + else + dprint((buf2, + "tid t%x pathconf(\"%s\", %d) = -1 (pvmerrno = %d)\n", + pvmmytid, pathname, name, pvmerrno)); + } else if (name < 0) + dprint((buf2, "tid t%x sysconf(_SC_OPEN_MAX) = %ld\n", + pvmmytid, lcc)); + else + dprint((buf2, "tid t%x pathconf(\"%s\", %d) = %ld\n", + pvmmytid, pathname, name, lcc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return lcc; + } + + long + _pathconf(const char *pathname, int name) + { + return pathconf(pathname, name); + } + + long + __pathconf(const char *pathname, int name) + { + return pathconf(pathname, name); + } + + #ifdef IMA_CNVXN + long + __ap$pathconf(const char *pathname, int name) + { + return pathconf(pathname, name); + } + #endif /* IMA_CNVXN */ + + long + fpathconf(int fd, int name) + { + int lcc; + int pvmerrno; + int pvmname; + int rbuf; + int sbuf; + int request = PVMFS_FPATHCONF; + int nargs = 2; + + if (pvmmyfstid <= 0) { + if (name < 0) { + #ifdef SYS_sysconf + lcc = syscall(SYS_sysconf, _SC_OPEN_MAX); + if (lcc == -1L) + dprintl((buf2, + "tid t%x sysconf(_SC_OPEN_MAX) = -1 (errno = %d)\n", + pvmmytid, errno)); + else + dprintl((buf2, + "tid t%x sysconf(_SC_OPEN_MAX) = %ld\n", + pvmmytid, lcc)); + #else + lpvmerr("sysconf", PvmNoFileServer); + errno = ENOSYS; + return -1L; + #endif + } else { + #ifdef SYS_fpathconf + lcc = syscall(SYS_fpathconf, fd, name); + if (lcc == -1) + dprintl((buf2, + "tid t%x fpathconf(%d, %d) = %ld (errno = %d)\n", + pvmmytid, fd, name, lcc, errno)); + else + dprintl((buf2, + "tid t%x fpathconf(%d, %d) = %ld\n", + pvmmytid, fd, name, lcc)); + return lcc; + #else + lpvmerr("fpathconf", PvmNoFileServer); + errno = ENOSYS; + return NULL; + #endif + } + } + + pvmname = pvm_pathconf_name(name); + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %d", PvmDataDefault, nargs, fd, pvmname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%ld", &lcc); + if (lcc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x fpathconf(%d, %d) = %ld (pvmerrno = %d)\n", pvmmytid, + fd, name, lcc, pvmerrno)); + } else + dprint((buf2, "tid t%x fpathconf(%d, %d) = %ld\n", + pvmmytid, fd, name, lcc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return lcc; + } + + long + _fpathconf(int fd, int name) + { + return fpathconf(fd, name); + } + + long + __fpathconf(int fd, int name) + { + return fpathconf(fd, name); + } + + #ifdef IMA_CNVXN + long + __ap$fpathconf(int fd, int name) + { + return fpathconf(fd, name); + } + #endif /* IMA_CNVXN */ + + #if 0 + /* + * This getcwd stuff doesn't really help + * unless we implement the POSIX directory functions. + */ + + /* reverse reverse a string so that "string" becomes "gnirts" */ + static char * + reverse(char *s) + { + size_t len; + size_t i; + char c; + char *t; + char *result = s; + + len = strlen(s); + t = &s[len - 1]; + + for (i = 0; i < len / 2; i++) { + c = *s; + *s++ = *t; + *t-- = c; + } + + return result; + } + + static char * + mygetcwd(char *buf, size_t size) + { + ino_t inode; + dev_t dev; + struct stat stbuf; + DIR *dfd; + struct dirent *dp; + struct stat rootbuf; + ino_t rootinode; + dev_t rootdev; + char dots[PATH_MAX]; + size_t len; + char *end; + + if (size == 0) { + errno = EINVAL; + return NULL; + } + + if (stat("/", &rootbuf) == -1) + return NULL; + rootinode = rootbuf.st_ino; + rootdev = rootbuf.st_dev; + + (void)strcpy(dots, "."); + buf[0] = '\0'; + + while (1) { + if (stat(dots, &stbuf) == -1) + return NULL; + inode = stbuf.st_ino; + dev = stbuf.st_dev; + if (inode == rootinode && dev == rootdev) { + if (strlen(buf) + 1 >= size) { + errno = ERANGE; + return NULL; + } else + return reverse(strcat(buf, "/")); + } + + if ((len = strlen(dots) + 3) >= size) { + errno = ERANGE; + return NULL; + } + (void)strcat(dots, "/.."); + if ((dfd = opendir(dots)) == NULL) + return NULL; + if (++len >= size) { + errno = ERANGE; + return NULL; + } + (void)strcat(dots, "/"); + while (dp = readdir(dfd)) { + if (len + dp->d_namlen >= size) + continue; + if (stat(strcat(dots, dp->d_name), &stbuf) == -1) { + dots[len] = '\0'; + continue; + } + if (stbuf.st_ino == inode && stbuf.st_dev == dev) { + size_t buflen = strlen(buf); + + if (buflen + dp->d_namlen + 1 >= size) { + errno = ERANGE; + return NULL; + } + if (buflen) + (void)strcat(buf, "/"); + (void)strcat(buf, reverse(dp->d_name)); + break; + } + dots[len] = '\0'; + } + if (!dp) + return NULL; /* errno = ??? */ + dots[len - 1] = '\0'; + } + } + #endif + + char * + getcwd(char *buf, size_t size) + { + char *result; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_GETCWD; + int nargs = 0; + unsigned long ul; + + if (size == 0) { + errno = ERANGE; + return NULL; + } + + if (pvmmyfstid <= 0) { + #if 0 + result = mygetcwd(buf, size); + if (result == NULL) + dprintl((buf2, + "tid t%x getcwd(%p, %lu) = NULL (errno = %d)\n", + pvmmytid, (void *)buf, (unsigned long)size, errno)); + else + dprintl((buf2, "tid t%x getcwd(%p, %lu) = %p\n", + pvmmytid, (void *)buf, (unsigned long)size, + (void *)result)); + return result; + #else + lpvmerr("getcwd", PvmNoFileServer); + errno = ENOSYS; + return NULL; + #endif + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d", PvmDataDefault, nargs); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_upkulong(&ul, 1, 1); /* ul = strlen() + 1 */ + result = buf; + if (ul > 0 && buf == NULL) + result = malloc(ul); + if (ul == 0 || result == NULL || ul > size) { + if (ul == 0) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + } else if (ul > size) + errno = ERANGE; + result = NULL; + dprintl((buf2, + "tid t%x getcwd(%p, %lu) = NULL (errno = %d)\n", + pvmmytid, (void *)buf, (unsigned long)size, errno)); + } else { + result = buf; + pvm_unpackf("%s", buf); + dprintl((buf2, "tid t%x getcwd(%p, %lu) = \"%s\"\n", + pvmmytid, (void *)buf, (unsigned long)size, result)); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return result; + } + + char * + _getcwd(char *buf, size_t size) + { + return getcwd(buf, size); + } + + char * + __getcwd(char *buf, size_t size) + { + return getcwd(buf, size); + } + + #ifdef IMA_CNVXN + char * + __ap$getcwd(char *buf, size_t size) + { + return getcwd(buf, size); + } + #endif /* IMA_CNVXN */ + + caddr_t + mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset) + { + caddr_t cp; + + #ifdef SYS_mmap + if (pvmmyfstid <= 0 || fd < 0) { + cp = (caddr_t)syscall(SYS_mmap, addr, len, prot, flags, fd, + offset); + if (cp == (caddr_t)-1) + dprintl((buf2, + "tid t%x mmap(%p, %lu, %d, %d, %d, %ld) = -1 (errno = %d)\n", + pvmmytid, (void *)addr, (unsigned long)len, prot, + flags, fd, (long)offset, errno)); + else + dprintl((buf2, + "tid t%x mmap(%p, %lu, %d, %d, %d, %ld) = %p\n", + pvmmytid, (void *)addr, (unsigned long)len, prot, + flags, fd, (long)offset, (void *)cp)); + return cp; + } else { + #endif + /*lpvmerr("mmap", PvmNotImpl);*/ + errno = ENOSYS; + return NULL; + #ifdef SYS_mmap + } + #endif + } + + caddr_t + _mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset) + { + return mmap(addr, len, prot, flags, fd, offset); + } + + caddr_t + __mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset) + { + return mmap(addr, len, prot, flags, fd, offset); + } + + #ifdef IMA_CNVXN + caddr_t + __ap$mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset) + { + return mmap(addr, len, prot, flags, fd, offset); + } + #endif /* IMA_CNVXN */ + + #ifdef IOCTL_STDARG + static int + vioctl(int d, int request, ...) + #else + int + ioctl(int d, IOCTL_ARG2_TYPE request, IOCTL_ARG3_TYPE argp) + #endif + { + #ifdef IOCTL_STDARG + va_list ap; + char *argp; + + va_start(ap, request); + /* + * Bad to assume that IOCTL_ARG3_TYPE doesn't depend + * on request, otherwise ioctl wouldn't use stdarg.h. + */ + argp = va_arg(ap, char *); + #endif + + #ifdef SYS_ioctl + if (pvmmyfstid <= 0) + return syscall(SYS_ioctl, d, request, argp); + else { + #endif + lpvmerr("ioctl", PvmNotImpl); + errno = ENOSYS; + return -1; + #ifdef SYS_ioctl + } + #endif + } + + #ifdef IOCTL_STDARG + int + _ioctl(int d, IOCTL_ARG2_TYPE request, ...) + { + int cc; + va_list ap; + char *argp; + + va_start(ap, request); + /* + * Bad to assume that IOCTL_ARG3_TYPE doesn't depend + * on request, otherwise ioctl wouldn't use stdarg.h. + */ + argp = va_arg(ap, char *); + cc = vioctl(d, request, argp); + va_end(ap); + return cc; + } + + int + __ioctl(int d, IOCTL_ARG2_TYPE request, ...) + { + int cc; + va_list ap; + char *argp; + + va_start(ap, request); + /* + * Bad to assume that IOCTL_ARG3_TYPE doesn't depend + * on request, otherwise ioctl wouldn't use stdarg.h. + */ + argp = va_arg(ap, char *); + cc = vioctl(d, request, argp); + va_end(ap); + return cc; + } + + #ifdef IMA_CNVXN + int + __ap$ioctl(int d, IOCTL_ARG2_TYPE request, ...) + { + int cc; + va_list ap; + char *argp; + + va_start(ap, request); + /* + * Bad to assume that IOCTL_ARG3_TYPE doesn't depend + * on request, otherwise ioctl wouldn't use stdarg.h. + */ + argp = va_arg(ap, char *); + cc = vioctl(d, request, argp); + va_end(ap); + return cc; + } + #endif /* IMA_CNVXN */ + + #else /* IOCTL_STDARG */ + + int + _ioctl(int d, IOCTL_ARG2_TYPE request, IOCTL_ARG3_TYPE argp) + { + return ioctl(d, request, argp); + } + + int + __ioctl(int d, IOCTL_ARG2_TYPE request, IOCTL_ARG3_TYPE argp) + { + return ioctl(d, request, argp); + } + + #ifdef IMA_CNVXN + int + __ap$ioctl(int d, IOCTL_ARG2_TYPE request, IOCTL_ARG3_TYPE argp) + { + return ioctl(d, request, argp); + } + #endif /* IMA_CNVXN */ + + #endif /* IOCTL_STDARG */ *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/pvmerrno.pl Sun Jul 24 18:25:03 1994 *************** *** 0 **** --- 1,185 ---- + #!/usr/local/bin/perl + + # + # Author: Christopher G. Phillips + # Copyright (C) 1993, 1994 All Rights Reserved + # + # NOTICE + # + # Permission to use, copy, modify, and distribute this software and + # its documentation for any purpose and without fee is hereby granted + # provided that the above copyright notice appear in all copies and + # that both the copyright notice and this permission notice appear in + # supporting documentation. + # + # The author makes no representations about the suitability of this + # software for any purpose. This software is provided ``as is'' + # without express or implied warranty. + # + + if (!defined $ENV{"PVM_ARCH"}) { + die "PVM_ARCH not set\n"; + } else { + $ARCH = $ENV{"PVM_ARCH"}; + } + + $sort_all = 0; + while ($_ = $ARGV[0], /^-/) { + shift; + last if /^--$/; + $sort_all = 1 if /^-s/; + } + + $n = 0; + $maxlen = 0; + + if (open(PVM, ") { + if (/\bPvm(E\S*\b)/ && !defined $s{"$1"}) { + $s{"$1"} = ++$n; + $e{$n} = "$1"; + if (length($1) > $maxlen) { + $maxlen = length($1); + } + } + } + close(PVM); + } + + loop: + while (<>) { + if (/^\s*#\s*define\s+\b(E\S*\b)\s+\b(\S+\b)/) { + if (defined $s{"$2"} || defined $number{"$2"}) { + $d{$1} = 1; + warn $_ . "\n"; + next loop; + } + if (!defined $number{"$2"}) { + $number{"$2"} = 1; + } + if ($sort_all) { + if (!defined $s{"$1"}) { + $s{"$1"} = 1; + } + } else { + if (!defined $s{"$1"} && !defined $s2{"$1"}) { + $s2{"$1"} = 1; + } + } + } + } + + if ($sort_all) { + $n = 0; + foreach $key (sort(keys %s)) { + $s{$key} = ++$n; + $e{$n} = $key; + if (length($key) > $maxlen) { + $maxlen = length($key); + } + } + } else { + foreach $key (sort(keys %s2)) { + $s{$key} = ++$n; + $e{$n} = $key; + if (length($key) > $maxlen) { + $maxlen = length($key); + } + } + } + + die "Can't open pvmerrno.h: $!" unless open(PVM, ">pvmerrno.h"); + select(PVM); + + do printcr(); + + printf("#ifndef PVMERRNO_H\n#define PVMERRNO_H\n\n"); + for ($i = 1; $i <= $n; $i++) { + printf("#ifndef %s\n", $e{$i}); + printf("#define %s%s-1\n", $e{$i}, "\t" x &tabs(length($e{$i}), 0)); + printf("#endif\n"); + } + for ($i = 1; $i <= $n; $i++) { + printf("#define Pvm%s%s$i\n", $e{$i}, "\t" x &tabs(length($e{$i}), 3)); + } + printf("\n#endif\n"); + close(PVM); + + die "Can't open pvmerrno.c: $!" unless open(PVM, ">pvmerrno.c"); + select(PVM); + + do printcr(); + + print "#include \n"; + print "#include \n"; + print '#include "pvmerrno.h"' . "\n\n"; + print "extern int errno;\n"; + print "\n"; + print "int\n"; + print "pvm_local_errno(int pvmerrno)\n"; + print "{\n"; + print " switch (pvmerrno) {\n"; + printf("\tcase -2:%sreturn -2;\n", "\t" x &tabs(2, 1)); + for ($i = 1; $i <= $n; $i++) { + printf("\tcase Pvm%s:%sreturn %s;\n", $e{$i}, + "\t" x &tabs(length($e{$i}), 1), $e{$i}); + } + printf("\tdefault:%sreturn -1;\n", "\t" x &tabs(0, 0)); + print "\t}\n"; + print "}\n"; + print "\n"; + print '#include "errnoconf.h"' . "\n\n"; + print "int\n"; + print "pvmerrno(int errnum)\n"; + print "{\n"; + print " switch (errnum) {\n"; + printf("\tcase -2:%sreturn -2;\n", "\t" x &tabs(2, 1)); + for ($i = 1; $i <= $n; $i++) { + printf("#if %s != -1\n", $e{$i}); + printf("\tcase %s:%sreturn Pvm%s;\n", $e{$i}, + "\t" x &tabs(length($e{$i}), 6), $e{$i}); + printf("#endif\n"); + } + printf("\tdefault:%sreturn -1;\n", "\t" x &tabs(0, 0)); + print "\t}\n"; + print "}\n"; + close(PVM); + + die "Can't open $ARCH/errnoconf.h: $!" unless open(PVM, ">$ARCH/errnoconf.h"); + select(PVM); + + do printcr(); + + foreach $key (sort(keys %d)) { + printf("#undef %s\n", $key); + printf("#define %s -1\n", $key); + } + close(PVM); + + exit(0); + + sub tabs { + local($len, $add) = @_; + local($num); + + $num = int(($maxlen + 7 + $add) / 8) - int(($len + $add) / 8); + } + + sub printcr { + print "/*\ + * Author: Christopher G. Phillips\ + * Copyright (C) 1993, 1994 All Rights Reserved\ + *\ + * NOTICE\ + *\ + * Permission to use, copy, modify, and distribute this software and\ + * its documentation for any purpose and without fee is hereby granted\ + * provided that the above copyright notice appear in all copies and\ + * that both the copyright notice and this permission notice appear in\ + * supporting documentation.\ + *\ + * The author makes no representations about the suitability of this\ + * software for any purpose. This software is provided ``as is''\ + * without express or implied warranty.\ + */\n\n"; + } *** /dev/null Thu Aug 25 19:19:25 1994 --- libc/syscalls.c Tue Jul 26 16:52:14 1994 *************** *** 0 **** --- 1,5073 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #include + #include + #include + #include + #include + #ifdef IMA_CRAY + #define _POSIX_SOURCE + #endif + #include + #include + #ifdef IMA_CRAY + #undef _POSIX_SOURCE + #endif + #ifdef IMA_CRAY + extern long ulimit(int, long); + #include + #define RLIM_INFINITY 0 + #define RLIMIT_CORE 1 + #define RLIMIT_FSIZE 2 + #define RLIMIT_NOFILE 3 + + typedef unsigned long rlim_t; + + struct rlimit { + rlim_t rlim_cur; + rlim_t rlim_max; + }; + #endif + #include + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + #include + #else + #include + #endif + #include + #include + #include + #ifdef IMA_CRAY + #define _POSIX_SOURCE + #endif + #include + #include + #include "pvm3.h" + #include "fs.h" + #include "fsp.h" + #include "pipe.h" + #ifndef SYSCALL_PIPE_IS_OK + #include + #endif + #if !defined(IMA_RS6K) && !defined(IMA_CRAY) + #include + #else + #include + #include "syscall-fake.h" + #endif + #ifndef IMA_SUN4 + #include + #endif + #include "argtypes.h" + + #ifdef MIN + #undef MIN + #endif + #define MIN(a,b) ((a) < (b) ? (a) : (b)) + + #ifdef TRACE + /* + * Debugging and tracing junk follows... + */ + int pvmdebug = 0; + int pvmrwdebug = 0; + + #define dprint(s) do { \ + if (pvmdebug) { \ + sprintf s; \ + syscall(SYS_write, 2, buf2, \ + strlen(buf2)); \ + } \ + } while (0) + #define dprintrw(s) do { \ + if (pvmrwdebug) { \ + sprintf s; \ + syscall(SYS_write, 2, buf2, \ + strlen(buf2)); \ + } \ + } while (0) + #define dprintl(s) dprint(s) + + static char buf2[100]; + + #else + #define dprint(s) + #define dprintrw(s) + #define dprintl(s) + #endif /* TRACE */ + + extern int lpvmerr __ProtoGlarp__((const char *, int)); + extern int pvm_local_errno __ProtoGlarp__((int)); + extern int pvmmytid; + extern int pvmmyfstid; + extern int errno; + + /* + * Mapping from PVMFS constants to local constants. + */ + + int + pvm_local_open_oflag(int oflag) + { + int result = 0; + + switch (oflag & (PVMFS_O_RDONLY | PVMFS_O_WRONLY | PVMFS_O_RDWR)) { + case PVMFS_O_RDONLY: + result |= O_RDONLY; + break; + case PVMFS_O_WRONLY: + result |= O_WRONLY; + break; + case PVMFS_O_RDWR: + result |= O_RDWR; + break; + default: + return -1; + } + + if (oflag & PVMFS_O_APPEND) result |= O_APPEND; + if (oflag & PVMFS_O_CREAT) result |= O_CREAT; + if (oflag & PVMFS_O_EXCL) result |= O_EXCL; + if (oflag & PVMFS_O_TRUNC) result |= O_TRUNC; + #ifdef O_NOCTTY + if (oflag & PVMFS_O_NOCTTY) result |= O_NOCTTY; + #endif + #ifdef O_NONBLOCK + if (oflag & PVMFS_O_NONBLOCK) result |= O_NONBLOCK; + #endif + #ifdef O_SYNC + if (oflag & PVMFS_O_SYNC) result |= O_SYNC; + #endif + #ifdef O_ASYNC + if (oflag & PVMFS_O_ASYNC) result |= O_ASYNC; + #endif + #ifdef O_LARGEFILE + if (oflag & PVMFS_O_LARGEFILE) result |= O_LARGEFILE; + #endif + return result; + } + + mode_t + pvm_local_open_mode(mode_t mode) + { + mode_t result = 0; + + if (mode & PVMFS_S_IRUSR) result |= S_IRUSR; + if (mode & PVMFS_S_IWUSR) result |= S_IWUSR; + if (mode & PVMFS_S_IXUSR) result |= S_IXUSR; + if (mode & PVMFS_S_IRGRP) result |= S_IRGRP; + if (mode & PVMFS_S_IWGRP) result |= S_IWGRP; + if (mode & PVMFS_S_IXGRP) result |= S_IXGRP; + if (mode & PVMFS_S_IROTH) result |= S_IROTH; + if (mode & PVMFS_S_IWOTH) result |= S_IWOTH; + if (mode & PVMFS_S_IXOTH) result |= S_IXOTH; + + return result; + } + + int + pvm_local_lseek_whence(int whence) + { + switch (whence) { + case PVMFS_SEEK_SET: return SEEK_SET; + case PVMFS_SEEK_CUR: return SEEK_CUR; + case PVMFS_SEEK_END: return SEEK_END; + default: return -1; + } + } + + int + pvm_local_fcntl_cmd(int command) + { + switch (command) { + case PVMFS_F_DUPFD: return F_DUPFD; + case PVMFS_F_GETFD: return F_GETFD; + case PVMFS_F_SETFD: return F_SETFD; + case PVMFS_F_GETFL: return F_GETFL; + case PVMFS_F_SETFL: return F_SETFL; + case PVMFS_F_GETOWN: return F_GETOWN; + case PVMFS_F_SETOWN: return F_SETOWN; + case PVMFS_F_GETLK: return F_GETLK; + case PVMFS_F_SETLK: return F_SETLK; + case PVMFS_F_SETLKW: return F_SETLKW; + default: return -1; + } + } + + short + pvm_local_fcntl_ltype(short type) + { + switch (type) { + case PVMFS_F_RDLCK: return F_RDLCK; + case PVMFS_F_WRLCK: return F_WRLCK; + case PVMFS_F_UNLCK: return F_UNLCK; + default: return -1; + } + } + + int + pvm_local_access_mode(int mode) + { + int result = 0; + + if (mode & PVMFS_R_OK) result |= R_OK; + if (mode & PVMFS_W_OK) result |= W_OK; + if (mode & PVMFS_X_OK) result |= X_OK; + if (mode & PVMFS_F_OK) result |= F_OK; + + return result; + } + + int + pvm_local_tcflow_action(int action) + { + switch (action) { + case PVMFS_TCOOFF: return TCOOFF; + case PVMFS_TCOON: return TCOON; + case PVMFS_TCIOFF: return TCIOFF; + case PVMFS_TCION: return TCION; + default: return -1; + } + } + + int + pvm_local_tcflush_queue(int queue) + { + switch (queue) { + case PVMFS_TCIFLUSH: return TCIFLUSH; + case PVMFS_TCOFLUSH: return TCOFLUSH; + case PVMFS_TCIOFLUSH: return TCIOFLUSH; + default: return -1; + } + } + + int + pvm_local_tcsetattr_opt(int opt) + { + switch (opt) { + case PVMFS_TCSANOW: return TCSANOW; + case PVMFS_TCSADRAIN: return TCSADRAIN; + case PVMFS_TCSAFLUSH: return TCSAFLUSH; + default: return -1; + } + } + + long + pvm_local_tcattr_iflag(long iflag) + { + long result = 0; + + if (iflag & PVMFS_BRKINT) result |= BRKINT; + if (iflag & PVMFS_ICRNL) result |= ICRNL; + if (iflag & PVMFS_IGNBRK) result |= IGNBRK; + if (iflag & PVMFS_IGNCR) result |= IGNCR; + if (iflag & PVMFS_IGNPAR) result |= IGNPAR; + #ifdef IMAXBEL + if (iflag & PVMFS_IMAXBEL) result |= IMAXBEL; + #endif + if (iflag & PVMFS_INLCR) result |= INLCR; + if (iflag & PVMFS_INPCK) result |= INPCK; + if (iflag & PVMFS_ISTRIP) result |= ISTRIP; + #ifdef IUCLC + if (iflag & PVMFS_IUCLC) result |= IUCLC; + #endif + #ifdef IXANY + if (iflag & PVMFS_IXANY) result |= IXANY; + #endif + if (iflag & PVMFS_IXOFF) result |= IXOFF; + if (iflag & PVMFS_IXON) result |= IXON; + if (iflag & PVMFS_PARMRK) result |= PARMRK; + + return result; + } + + long + pvm_local_tcattr_oflag(long oflag) + { + long result = 0; + + #ifdef BSDLY + result &= ~BSDLY; + if (oflag & PVMFS_BS0) + result |= BS0; + else if (oflag & PVMFS_BS1) + result |= BS1; + #endif + #ifdef CRDLY + result &= ~CRDLY; + if (oflag & PVMFS_CR0) + result |= CR0; + else if (oflag & PVMFS_CR1) + result |= CR1; + else if (oflag & PVMFS_CR2) + result |= CR2; + else if (oflag & PVMFS_CR3) + result |= CR3; + #endif + #ifdef FFDLY + result &= ~FFDLY; + if (oflag & PVMFS_FF0) + result |= FF0; + else if (oflag & PVMFS_FF1) + result |= FF1; + #endif + #ifdef NLDLY + result &= ~NLDLY; + if (oflag & PVMFS_NL0) + result |= NL0; + else if (oflag & PVMFS_NL1) + result |= NL1; + #endif + #ifdef OCRNL + if (oflag & PVMFS_OCRNL) result |= OCRNL; + #endif + #ifdef OFDEL + if (oflag & PVMFS_OFDEL) result |= OFDEL; + #endif + #ifdef OFILL + if (oflag & PVMFS_OFILL) result |= OFILL; + #endif + #ifdef OLCUC + if (oflag & PVMFS_OLCUC) result |= OLCUC; + #endif + #ifdef ONLCR + if (oflag & PVMFS_ONLCR) result |= ONLCR; + #endif + #ifdef ONLRET + if (oflag & PVMFS_ONLRET) result |= ONLRET; + #endif + #ifdef ONOCR + if (oflag & PVMFS_ONOCR) result |= ONOCR; + #endif + #ifdef ONOEOT + if (oflag & PVMFS_ONOEOT) result |= ONOEOT; + if (oflag & PVMFS_OPOST) result |= OPOST; + #endif + #ifdef OXTABS + if (oflag & PVMFS_OXTABS) result |= OXTABS; + #endif + #ifdef TABDLY + result &= ~TABDLY; + if (oflag & PVMFS_TAB0) + result |= TAB0; + else if (oflag & PVMFS_TAB1) + result |= TAB1; + else if (oflag & PVMFS_TAB2) + result |= TAB2; + else if (oflag & PVMFS_TAB3) + result |= TAB3; + #endif + #ifdef VTDLY + result &= ~VTDLY; + if (oflag & PVMFS_VT0) + result |= VT0; + else if (oflag & PVMFS_VT1) + result |= VT1; + #endif + + return result; + } + + long + pvm_local_tcattr_cflag(long cflag) + { + long result = 0; + + #ifdef CCTS_OFLOW + if (cflag & PVMFS_CCTS_OFLOW) result |= CCTS_OFLOW; + #endif + #ifdef CIGNORE + if (cflag & PVMFS_CIGNORE) result |= CIGNORE; + #endif + if (cflag & PVMFS_CLOCAL) result |= CLOCAL; + if (cflag & PVMFS_CREAD) result |= CREAD; + #ifdef CRTS_IFLOW + if (cflag & PVMFS_CRTS_IFLOW) result |= CRTS_IFLOW; + #endif + if (cflag & PVMFS_CSIZE) result |= CSIZE; + if (cflag & PVMFS_CSTOPB) result |= CSTOPB; + if (cflag & PVMFS_HUPCL) result |= HUPCL; + #ifdef MDMBUF + if (cflag & PVMFS_MDMBUF) result |= MDMBUF; + #endif + if (cflag & PVMFS_PARENB) result |= PARENB; + if (cflag & PVMFS_PARODD) result |= PARODD; + + return result; + } + + long + pvm_local_tcattr_lflag(long lflag) + { + long result = 0; + + #ifdef ALTWERASE + if (lflag & PVMFS_ALTWERASE) result |= ALTWERASE; + #endif + if (lflag & PVMFS_ECHO) result |= ECHO; + #ifdef ECHOCTL + if (lflag & PVMFS_ECHOCTL) result |= ECHOCTL; + #endif + if (lflag & PVMFS_ECHOE) result |= ECHOE; + if (lflag & PVMFS_ECHOK) result |= ECHOK; + #ifdef ECHOKE + if (lflag & PVMFS_ECHOKE) result |= ECHOKE; + #endif + if (lflag & PVMFS_ECHONL) result |= ECHONL; + #ifdef ECHOPRT + if (lflag & PVMFS_ECHOPRT) result |= ECHOPRT; + #endif + #ifdef FLUSHO + if (lflag & PVMFS_FLUSHO) result |= FLUSHO; + #endif + if (lflag & PVMFS_ICANON) result |= ICANON; + if (lflag & PVMFS_IEXTEN) result |= IEXTEN; + if (lflag & PVMFS_ISIG) result |= ISIG; + if (lflag & PVMFS_NOFLSH) result |= NOFLSH; + #ifdef NOKERNINFO + if (lflag & PVMFS_NOKERNINFO) result |= NOKERNINFO; + #endif + #ifdef PENDIN + if (lflag & PVMFS_PENDIN) result |= PENDIN; + #endif + if (lflag & PVMFS_TOSTOP) result |= TOSTOP; + #ifdef XCASE + if (lflag & PVMFS_XCASE) result |= XCASE; + #endif + + return result; + } + + long + pvm_local_tcattr_speed(long speed) + { + switch (speed) { + case PVMFS_B0: return B0; + case PVMFS_B50: return B50; + case PVMFS_B75: return B75; + case PVMFS_B110: return B110; + case PVMFS_B134: return B134; + case PVMFS_B150: return B150; + case PVMFS_B200: return B200; + case PVMFS_B300: return B300; + case PVMFS_B600: return B600; + case PVMFS_B1200: return B1200; + case PVMFS_B1800: return B1800; + case PVMFS_B2400: return B2400; + case PVMFS_B4800: return B4800; + case PVMFS_B9600: return B9600; + case PVMFS_B19200: return B19200; + case PVMFS_B38400: return B38400; + default: return -1; + } + } + + int + pvm_local_pathconf_name(int name) + { + switch (name) { + case PVMFS__PC_LINK_MAX: return _PC_LINK_MAX; + case PVMFS__PC_MAX_CANON: return _PC_MAX_CANON; + case PVMFS__PC_MAX_INPUT: return _PC_MAX_INPUT; + case PVMFS__PC_NAME_MAX: return _PC_NAME_MAX; + case PVMFS__PC_PATH_MAX: return _PC_PATH_MAX; + case PVMFS__PC_PIPE_BUF: return _PC_PIPE_BUF; + case PVMFS__PC_CHOWN_RESTRICTED: return _PC_CHOWN_RESTRICTED; + case PVMFS__PC_NO_TRUNC: return _PC_NO_TRUNC; + case PVMFS__PC_VDISABLE: return _PC_VDISABLE; + default: return -1; + } + } + + int + pvm_local_rlimit_resource(int resource) + { + switch (resource) { + #ifdef RLIMIT_CORE + case PVMFS_RLIMIT_CORE: return RLIMIT_CORE; + #endif + #ifdef RLIMIT_FSIZE + case PVMFS_RLIMIT_FSIZE: return RLIMIT_FSIZE; + #endif + #ifdef RLIMIT_OFILE + case PVMFS_RLIMIT_OFILE: return RLIMIT_OFILE; + #endif + #ifdef RLIMIT_NOFILE + case PVMFS_RLIMIT_NOFILE: return RLIMIT_NOFILE; + #endif + default: return -1; + } + } + + /* + * Mapping from local constants to PVMFS constants. + */ + + int + pvm_open_oflag(int oflag) + { + int result = 0; + + switch (oflag & O_ACCMODE) { + case O_RDONLY: result |= PVMFS_O_RDONLY; break; + case O_WRONLY: result |= PVMFS_O_WRONLY; break; + case O_RDWR: result |= PVMFS_O_RDWR; break; + default: + return -1; + } + oflag &= ~O_ACCMODE; + + if (oflag & O_APPEND) { + result |= PVMFS_O_APPEND; + oflag &= ~O_APPEND; + } + if (oflag & O_CREAT) { + result |= PVMFS_O_CREAT; + oflag &= ~O_CREAT; + } + if (oflag & O_EXCL) { + result |= PVMFS_O_EXCL; + oflag &= ~O_EXCL; + } + if (oflag & O_TRUNC) { + result |= PVMFS_O_TRUNC; + oflag &= ~O_TRUNC; + } + #ifdef O_NOCTTY + if (oflag & O_NOCTTY) { + result |= PVMFS_O_NOCTTY; + oflag &= ~O_NOCTTY; + } + #endif + #ifdef O_NONBLOCK + if (oflag & O_NONBLOCK) { + result |= PVMFS_O_NONBLOCK; + oflag &= ~O_NONBLOCK; + } + #endif + #ifdef O_SYNC + if (oflag & O_SYNC) { + result |= PVMFS_O_SYNC; + oflag &= ~O_SYNC; + } + #endif + #ifdef O_ASYNC + if (oflag & O_ASYNC) { + result |= PVMFS_O_ASYNC; + oflag &= ~O_ASYNC; + } + #endif + #ifdef O_LARGEFILE + if (oflag & O_LARGEFILE) { + result |= PVMFS_O_LARGEFILE; + oflag &= ~O_LARGEFILE; + } + #endif + + dprint((buf2, "PVM oflag is %x\n", result)); + return oflag ? -1 : result; + } + + mode_t + pvm_open_mode(mode_t mode) + { + mode_t result = 0; + + if (mode & S_IRUSR) result |= PVMFS_S_IRUSR; + if (mode & S_IRGRP) result |= PVMFS_S_IRGRP; + if (mode & S_IROTH) result |= PVMFS_S_IROTH; + if (mode & S_IWUSR) result |= PVMFS_S_IWUSR; + if (mode & S_IWGRP) result |= PVMFS_S_IWGRP; + if (mode & S_IWOTH) result |= PVMFS_S_IWOTH; + if (mode & S_IXUSR) result |= PVMFS_S_IXUSR; + if (mode & S_IXGRP) result |= PVMFS_S_IXGRP; + if (mode & S_IXOTH) result |= PVMFS_S_IXOTH; + + return result; + } + + int + pvm_lseek_whence(int whence) + { + switch (whence) { + case SEEK_SET: return PVMFS_SEEK_SET; + case SEEK_CUR: return PVMFS_SEEK_CUR; + case SEEK_END: return PVMFS_SEEK_END; + default: return -1; + } + } + + int + pvm_fcntl_cmd(int command) + { + switch (command) { + case F_DUPFD: return PVMFS_F_DUPFD; + case F_GETFD: return PVMFS_F_GETFD; + case F_SETFD: return PVMFS_F_SETFD; + case F_GETFL: return PVMFS_F_GETFL; + case F_SETFL: return PVMFS_F_SETFL; + case F_GETOWN: return PVMFS_F_GETOWN; + case F_SETOWN: return PVMFS_F_SETOWN; + case F_GETLK: return PVMFS_F_GETLK; + case F_SETLK: return PVMFS_F_SETLK; + case F_SETLKW: return PVMFS_F_SETLKW; + default: return -1; + } + } + + short + pvm_fcntl_ltype(short type) + { + switch (type) { + case F_RDLCK: return PVMFS_F_RDLCK; + case F_WRLCK: return PVMFS_F_WRLCK; + case F_UNLCK: return PVMFS_F_UNLCK; + default: return -1; + } + } + + int + pvm_access_mode(int mode) + { + int result = 0; + + if (mode & R_OK) result |= PVMFS_R_OK; + if (mode & W_OK) result |= PVMFS_W_OK; + if (mode & X_OK) result |= PVMFS_X_OK; + if (mode & F_OK) result |= PVMFS_F_OK; + + return result; + } + + void + pvm_select_fdset_pack(int maxfdp1, fd_set *setp) + { + int numset = 0; + int numdone = 0; + int fd; + + if (!setp) { + pvm_packf("%d", numset); + dprint((buf2, "fdset_pack: packing %d fd's\n", numset)); + return; + } + + for (fd = 0; fd < maxfdp1; fd++) + if (FD_ISSET(fd, setp)) + numset++; + + pvm_packf("%d", numset); + dprint((buf2, "fdset_pack: packing %d fd's\n", numset)); + + for (fd = 0; fd < maxfdp1; fd++) + if (FD_ISSET(fd, setp)) { + pvm_packf("%d", fd); + dprint((buf2, "fdset_pack: packing fd %d\n", fd)); + if (++numdone == numset) + break; + } + } + + int + pvm_select_fdset_unpack(fd_set *setp) + { + int numset; + int fd; + int i; + + pvm_unpackf("%d", &numset); + dprint((buf2, "fdset_unpack: unpacking %d fd's\n", numset)); + if (!setp) + return; + + FD_ZERO(setp); + for (i = 0; i < numset; i++) { + pvm_unpackf("%d", &fd); + dprint((buf2, "fdset_unpack: unpacking fd %d\n", fd)); + FD_SET(fd, setp); + } + + return numset; + } + + int + pvm_tcflow_action(int action) + { + switch (action) { + case TCOOFF: return PVMFS_TCOOFF; + case TCOON: return PVMFS_TCOON; + case TCIOFF: return PVMFS_TCIOFF; + case TCION: return PVMFS_TCION; + default: return -1; + } + } + + int + pvm_tcflush_queue(int queue) + { + switch (queue) { + case TCIFLUSH: return PVMFS_TCIFLUSH; + case TCOFLUSH: return PVMFS_TCOFLUSH; + case TCIOFLUSH: return PVMFS_TCIOFLUSH; + default: return -1; + } + } + + int + pvm_tcsetattr_opt(int opt) + { + switch (opt) { + case TCSANOW: return PVMFS_TCSANOW; + case TCSADRAIN: return PVMFS_TCSADRAIN; + case TCSAFLUSH: return PVMFS_TCSAFLUSH; + default: return -1; + } + } + + long + pvm_tcattr_iflag(long iflag) + { + long result = 0; + + if (iflag & BRKINT) result |= PVMFS_BRKINT; + if (iflag & ICRNL) result |= PVMFS_ICRNL; + if (iflag & IGNBRK) result |= PVMFS_IGNBRK; + if (iflag & IGNCR) result |= PVMFS_IGNCR; + if (iflag & IGNPAR) result |= PVMFS_IGNPAR; + #ifdef IMAXBEL + if (iflag & IMAXBEL) result |= PVMFS_IMAXBEL; + #endif + if (iflag & INLCR) result |= PVMFS_INLCR; + if (iflag & INPCK) result |= PVMFS_INPCK; + if (iflag & ISTRIP) result |= PVMFS_ISTRIP; + #ifdef IUCLC + if (iflag & IUCLC) result |= PVMFS_IUCLC; + #endif + #ifdef IXANY + if (iflag & IXANY) result |= PVMFS_IXANY; + #endif + if (iflag & IXOFF) result |= PVMFS_IXOFF; + if (iflag & IXON) result |= PVMFS_IXON; + if (iflag & PARMRK) result |= PVMFS_PARMRK; + + return result; + } + + long + pvm_tcattr_oflag(long oflag) + { + long result = 0; + + #ifdef BSDLY + if (oflag & BSDLY) result |= PVMFS_BSDLY; + #endif + #ifdef CRDLY + if (oflag & CRDLY) result |= PVMFS_CRDLY; + #endif + #ifdef FFDLY + if (oflag & FFDLY) result |= PVMFS_FFDLY; + #endif + #ifdef NLDLY + if (oflag & NLDLY) result |= PVMFS_NLDLY; + #endif + #ifdef OCRNL + if (oflag & OCRNL) result |= PVMFS_OCRNL; + #endif + #ifdef OFDEL + if (oflag & OFDEL) result |= PVMFS_OFDEL; + #endif + #ifdef OFILL + if (oflag & OFILL) result |= PVMFS_OFILL; + #endif + #ifdef OLCUC + if (oflag & OLCUC) result |= PVMFS_OLCUC; + #endif + #ifdef ONLCR + if (oflag & ONLCR) result |= PVMFS_ONLCR; + #endif + #ifdef ONLRET + if (oflag & ONLRET) result |= PVMFS_ONLRET; + #endif + #ifdef ONOCR + if (oflag & ONOCR) result |= PVMFS_ONOCR; + #endif + #ifdef ONOEOT + if (oflag & ONOEOT) result |= PVMFS_ONOEOT; + if (oflag & OPOST) result |= PVMFS_OPOST; + #endif + #ifdef OXTABS + if (oflag & OXTABS) result |= PVMFS_OXTABS; + #endif + #ifdef TABDLY + if (oflag & TABDLY) result |= PVMFS_TABDLY; + #endif + #ifdef VTDLY + if (oflag & VTDLY) result |= PVMFS_VTDLY; + #endif + + return result; + } + + long + pvm_tcattr_cflag(long cflag) + { + long result = 0; + + #ifdef CCTS_OFLOW + if (cflag & CCTS_OFLOW) result |= PVMFS_CCTS_OFLOW; + #endif + #ifdef CIGNORE + if (cflag & CIGNORE) result |= PVMFS_CIGNORE; + #endif + if (cflag & CLOCAL) result |= PVMFS_CLOCAL; + if (cflag & CREAD) result |= PVMFS_CREAD; + #ifdef CRTS_IFLOW + if (cflag & CRTS_IFLOW) result |= PVMFS_CRTS_IFLOW; + #endif + if (cflag & CSIZE) result |= PVMFS_CSIZE; + if (cflag & CSTOPB) result |= PVMFS_CSTOPB; + if (cflag & HUPCL) result |= PVMFS_HUPCL; + #ifdef MDMBUF + if (cflag & MDMBUF) result |= PVMFS_MDMBUF; + #endif + if (cflag & PARENB) result |= PVMFS_PARENB; + if (cflag & PARODD) result |= PVMFS_PARODD; + + return result; + } + + long + pvm_tcattr_lflag(long lflag) + { + long result = 0; + + #ifdef ALTWERASE + if (lflag & ALTWERASE) result |= PVMFS_ALTWERASE; + #endif + if (lflag & ECHO) result |= PVMFS_ECHO; + #ifdef ECHOCTL + if (lflag & ECHOCTL) result |= PVMFS_ECHOCTL; + #endif + if (lflag & ECHOE) result |= PVMFS_ECHOE; + if (lflag & ECHOK) result |= PVMFS_ECHOK; + #ifdef ECHOKE + if (lflag & ECHOKE) result |= PVMFS_ECHOKE; + #endif + if (lflag & ECHONL) result |= PVMFS_ECHONL; + #ifdef ECHOPRT + if (lflag & ECHOPRT) result |= PVMFS_ECHOPRT; + #endif + #ifdef FLUSHO + if (lflag & FLUSHO) result |= PVMFS_FLUSHO; + #endif + if (lflag & ICANON) result |= PVMFS_ICANON; + if (lflag & IEXTEN) result |= PVMFS_IEXTEN; + if (lflag & ISIG) result |= PVMFS_ISIG; + if (lflag & NOFLSH) result |= PVMFS_NOFLSH; + #ifdef NOKERNINFO + if (lflag & NOKERNINFO) result |= PVMFS_NOKERNINFO; + #endif + #ifdef PENDIN + if (lflag & PENDIN) result |= PVMFS_PENDIN; + #endif + if (lflag & TOSTOP) result |= PVMFS_TOSTOP; + #ifdef XCASE + if (lflag & XCASE) result |= PVMFS_XCASE; + #endif + + return result; + } + + long + pvm_tcattr_speed(long speed) + { + switch (speed) { + case B0: return PVMFS_B0; + case B50: return PVMFS_B50; + case B75: return PVMFS_B75; + case B110: return PVMFS_B110; + case B134: return PVMFS_B134; + case B150: return PVMFS_B150; + case B200: return PVMFS_B200; + case B300: return PVMFS_B300; + case B600: return PVMFS_B600; + case B1200: return PVMFS_B1200; + case B1800: return PVMFS_B1800; + case B2400: return PVMFS_B2400; + case B4800: return PVMFS_B4800; + case B9600: return PVMFS_B9600; + case B19200: return PVMFS_B19200; + case B38400: return PVMFS_B38400; + default: return -1; + } + } + + int + pvm_pathconf_name(int name) + { + switch (name) { + case _PC_LINK_MAX: return PVMFS__PC_LINK_MAX; + case _PC_MAX_CANON: return PVMFS__PC_MAX_CANON; + case _PC_MAX_INPUT: return PVMFS__PC_MAX_INPUT; + case _PC_NAME_MAX: return PVMFS__PC_NAME_MAX; + case _PC_PATH_MAX: return PVMFS__PC_PATH_MAX; + case _PC_PIPE_BUF: return PVMFS__PC_PIPE_BUF; + case _PC_CHOWN_RESTRICTED: return PVMFS__PC_CHOWN_RESTRICTED; + case _PC_NO_TRUNC: return PVMFS__PC_NO_TRUNC; + case _PC_VDISABLE: return PVMFS__PC_VDISABLE; + default: return -1; + } + } + + int + pvm_rlimit_resource(int resource) + { + switch (resource) { + #ifdef RLIMIT_CORE + case RLIMIT_CORE: return PVMFS_RLIMIT_CORE; + #endif + #ifdef RLIMIT_FSIZE + case RLIMIT_FSIZE: return PVMFS_RLIMIT_FSIZE; + #endif + #ifdef RLIMIT_OFILE + case RLIMIT_OFILE: return PVMFS_RLIMIT_OFILE; + #endif + #ifdef RLIMIT_NOFILE + case RLIMIT_NOFILE: return PVMFS_RLIMIT_NOFILE; + #endif + default: return -1; + } + } + + static int defiomode = PvmIomodeIndividual; + + int + pvm_setdefiomode(int mode) + { + if (pvmmyfstid <= 0) + return lpvmerr("pvm_setdefiomode", PvmNoFileServer); + + switch (mode) { + case PvmIomodeIndividual: + case PvmIomodeCommon: + case PvmIomodeIndependent: + case PvmIomodeSyncBC: + case PvmIomodeSyncSeq: + defiomode = mode; + return 0; + default: + return lpvmerr("pvm_setdefiomode", PvmBadParam); + } + } + + int + pvm_getdefiomode(void) + { + if (pvmmyfstid <= 0) + return lpvmerr("pvm_getdefiomode", PvmNoFileServer); + + return defiomode; + } + + int + pvm_setioorder(int order) + { + int cc; + int rbuf; + int sbuf; + int request = PVMFS_SETIOORDER; + int nargs = 1; + + if (pvmmyfstid <= 0) + return lpvmerr("pvm_setioorder", PvmNoFileServer); + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, order); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return (cc == -1) ? lpvmerr("pvm_setioorder", PvmBadParam) : cc; + } + + int + pvm_getioorder(void) + { + int cc; + int rbuf; + int sbuf; + int request = PVMFS_GETIOORDER; + int nargs = 0; + + if (pvmmyfstid <= 0) + return lpvmerr("pvm_getioorder", PvmNoFileServer); + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d", PvmDataDefault, nargs); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return (cc == -1) ? lpvmerr("pvm_getioorder", PvmSysErr) : cc; + } + + int + pvm_setiomode(int fd, int mode) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_SETIOMODE; + int nargs = 2; + + if (pvmmyfstid <= 0) + return lpvmerr("pvm_setiomode", PvmNoFileServer); + + switch (mode) { + case PvmIomodeIndividual: + case PvmIomodeCommon: + case PvmIomodeIndependent: + case PvmIomodeSyncBC: + case PvmIomodeSyncSeq: + break; + default: + return PvmBadParam; + } + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %d", PvmDataDefault, nargs, fd, mode); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + lpvmerr("pvm_setiomode", PvmBadParam); + errno = pvm_local_errno(pvmerrno); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + pvm_getiomode(int fd) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_GETIOMODE; + int nargs = 1; + + if (pvmmyfstid <= 0) + return lpvmerr("pvm_getiomode", PvmNoFileServer); + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + lpvmerr("pvm_getiomode", PvmBadParam); + errno = pvm_local_errno(pvmerrno); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + static int + vopen(const char *pathname, int oflag, va_list ap) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_OPEN; + int nargs = 3; + long mode; + + if (pvmmyfstid <= 0) { + if (oflag & O_CREAT) { + if (sizeof(mode_t) < sizeof(int)) + mode = (long)va_arg(ap, int); + else + mode = (long)va_arg(ap, mode_t); + cc = syscall(SYS_open, pathname, oflag, mode); + if (cc == -1) + dprintl((buf2, + "tid t%x open(\"%s\", %d, %ld) = %d (errno = %d)\n", + pvmmytid, pathname, oflag, (long)mode, cc, errno)); + else + dprintl((buf2, + "tid t%x open(\"%s\", %d, %ld) = %d\n", + pvmmytid, pathname, oflag, (long)mode, cc)); + } else { + cc = syscall(SYS_open, pathname, oflag); + if (cc == -1) + dprintl((buf2, + "tid t%x open(\"%s\", %d) = %d (errno = %d)\n", + pvmmytid, pathname, oflag, cc, errno)); + else + dprintl((buf2, + "tid t%x open(\"%s\", %d) = %d\n", + pvmmytid, pathname, oflag, cc)); + } + va_end(ap); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + if ((oflag = pvm_open_oflag(oflag)) == -1) { + errno = EINVAL; + va_end(ap); + dprint((buf2, + "tid t%x open(\"%s\", %d, ...) = -1 (errno = EINVAL)\n", + pvmmytid, pathname, oflag)); + return -1; + } + if (oflag & PVMFS_O_CREAT) { + nargs = 4; + if (sizeof(mode_t) < sizeof(int)) + mode = (long)va_arg(ap, int); + else + mode = (long)va_arg(ap, mode_t); + } + pvm_packf("%+ %d %s %d", PvmDataDefault, nargs, pathname, oflag); + if (oflag & PVMFS_O_CREAT) + pvm_packf("%ld", mode); + pvm_packf("%d", defiomode); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + if (nargs == 3) + dprint((buf2, + "tid t%x open(\"%s\", %d) = %d (pvmerrno = %d)\n", + pvmmytid, pathname, oflag, cc, pvmerrno)); + else + dprint((buf2, + "tid t%x open(\"%s\", %d, %ld) = %d (pvmerrno = %d)\n", + pvmmytid, pathname, oflag, (long)mode, cc, pvmerrno)); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + if (nargs == 3) + dprint((buf2, "tid t%x open(\"%s\", %d) = %d\n", + pvmmytid, pathname, oflag, cc)); + else + dprint((buf2, "tid t%x open(\"%s\", %d, %ld) = %d\n", + pvmmytid, pathname, oflag, (long)mode, cc)); + return cc; + } + + int + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + open(const char *pathname, int oflag, ...) + #else + open(va_alist) va_dcl + #endif + { + int cc; + va_list ap; + + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + va_start(ap, oflag); + #else + char *pathname; + int oflag; + + va_start(ap); + pathname = va_arg(ap, char *); + oflag = va_arg(ap, int); + #endif + cc = vopen(pathname, oflag, ap); + va_end(ap); + return cc; + } + + int + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + _open(const char *pathname, int oflag, ...) + #else + _open(va_alist) va_dcl + #endif + { + int cc; + va_list ap; + + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + va_start(ap, oflag); + #else + char *pathname; + int oflag; + + va_start(ap); + pathname = va_arg(ap, char *); + oflag = va_arg(ap, int); + #endif + cc = vopen(pathname, oflag, ap); + va_end(ap); + return cc; + } + + int + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + __open(const char *pathname, int oflag, ...) + #else + __open(va_alist) va_dcl + #endif + { + int cc; + va_list ap; + + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + va_start(ap, oflag); + #else + char *pathname; + int oflag; + + va_start(ap); + pathname = va_arg(ap, char *); + oflag = va_arg(ap, int); + #endif + cc = vopen(pathname, oflag, ap); + va_end(ap); + return cc; + } + + #ifdef IMA_CNVXN + int + __ap$open(const char *pathname, int oflag, ...) + { + int cc; + va_list ap; + + va_start(ap, oflag); + cc = vopen(pathname, oflag, ap); + va_end(ap); + return cc; + } + #endif /* IMA_CNVXN */ + + int + creat(const char *pathname, mode_t mode) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_CREAT; + int nargs = 3; + long lmode = pvm_open_mode(mode); + + if (pvmmyfstid <= 0) { + #ifdef SYS_creat + cc = syscall(SYS_creat, pathname, mode); + if (cc == -1) + dprintl((buf2, + "tid t%x creat(\"%s\", %ld) = %d (errno = %d)\n", + pvmmytid, pathname, (long)mode, cc, errno)); + else + dprintl((buf2, "tid t%x creat(\"%s\", %ld) = %d\n", + pvmmytid, pathname, (long)mode, cc)); + #else + cc = syscall(SYS_open, pathname, O_WRONLY | O_CREAT | O_TRUNC, + mode); + if (cc == -1) + dprintl((buf2, + "tid t%x creat(\"%s\", %ld) = %d (errno = %d)\n", + pvmmytid, pathname, (long)mode, cc, errno)); + else + dprintl((buf2, "tid t%x creat(\"%s\", %ld) = %d\n", + pvmmytid, pathname, (long)mode, cc)); + #endif + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %ld %d", PvmDataDefault, nargs, pathname, lmode, + defiomode); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x creat(\"%s\", %ld) = %d (pvmerrno = %d)\n", pvmmytid, + pathname, (long)mode, cc, pvmerrno)); + } else + dprint((buf2, "tid t%x creat(\"%s\", %ld) = %d\n", + pvmmytid, pathname, (long)mode, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _creat(const char *pathname, mode_t mode) + { + return creat(pathname, mode); + } + + int + __creat(const char *pathname, mode_t mode) + { + return creat(pathname, mode); + } + + #ifdef IMA_CNVXN + int + __ap$creat(const char *pathname, mode_t mode) + { + return creat(pathname, mode); + } + #endif /* IMA_CNVXN */ + + int + close(int fd) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_CLOSE; + int nargs = 1; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_close, fd); + if (cc == -1) + dprintl((buf2, "tid t%x close(%d) = %d (errno = %d)\n", + pvmmytid, fd, cc, errno)); + else + dprintl((buf2, "tid t%x close(%d) = %d\n", + pvmmytid, fd, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x close(%d) = %d (pvmerrno = %d)\n", + pvmmytid, fd, cc, pvmerrno)); + } else + dprint((buf2, "tid t%x close(%d) = %d\n", + pvmmytid, fd, cc)); + + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _close(int fd) + { + return close(fd); + } + + int + __close(int fd) + { + return close(fd); + } + + #ifdef IMA_CNVXN + int + __ap$close(int fd) + { + return close(fd); + } + #endif /* IMA_CNVXN */ + + off_t + lseek(int fd, off_t offset, int whence) + { + long lcc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_LSEEK; + int nargs = 3; + int fswhence = pvm_lseek_whence(whence); + long loffset = (long)offset; + + if (pvmmyfstid <= 0) { + lcc = (off_t)syscall(SYS_lseek, fd, offset, whence); + if (lcc == -1L) + dprintl((buf2, + "tid t%x lseek(%d, %ld, %d) = %ld (errno = %d)\n", + pvmmytid, fd, (long)offset, whence, lcc, errno)); + else + dprintl((buf2, "tid t%x lseek(%d, %ld, %d) = %ld\n", + pvmmytid, fd, (long)offset, whence, lcc)); + return lcc; + } + + if (fswhence == -1) { + errno = EINVAL; + dprint((buf2, + "tid t%x lseek(%d, %ld, %d) = -1 (errno = EINVAL)\n", + pvmmytid, fd, (long)offset, whence)); + return (off_t)-1; + } + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %ld %d", PvmDataDefault, nargs, fd, loffset, + fswhence); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%ld", &lcc); + if (lcc == -1L) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x lseek(%d, %ld, %d) = %ld (pvmerrno = %d)\n", + pvmmytid, fd, (long)offset, whence, lcc, pvmerrno)); + } else + dprint((buf2, "tid t%x lseek(%d, %ld, %d) = %d\n", + pvmmytid, fd, (long)offset, whence, lcc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return (off_t)lcc; + } + + off_t + _lseek(int fd, off_t offset, int whence) + { + return lseek(fd, offset, whence); + } + + off_t + __lseek(int fd, off_t offset, int whence) + { + return lseek(fd, offset, whence); + } + + #ifdef IMA_CNVXN + off_t + __ap$lseek(int fd, off_t offset, int whence) + { + return lseek(fd, offset, whence); + } + #endif /* IMA_CNVXN */ + + READ_RETURN_TYPE + read(int fd, READ_ARG2_TYPE buf, READ_ARG3_TYPE nbytes) + { + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_READ; + int nargs = 2; + long lnbytes = (long)nbytes; + + if (pvmmyfstid <= 0) { + lnbytes = (long)syscall(SYS_read, fd, buf, nbytes); + if (lnbytes == -1L) + dprintl((buf2, + "tid t%x read(%d, %p, %ld) = %ld (errno = %d)\n", + pvmmytid, fd, buf, (long)nbytes, lnbytes, errno)); + else + dprintl((buf2, "tid t%x read(%d, %p, %ld) = %ld\n", + pvmmytid, fd, buf, (long)nbytes, lnbytes)); + return (READ_RETURN_TYPE)lnbytes; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %ld", PvmDataDefault, nargs, fd, lnbytes); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%ld", &lnbytes); + if (lnbytes == -1L) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprintrw((buf2, + "tid t%x read(%d, %p, %ld) = %ld (errno = %d)\n", pvmmytid, + fd, buf, (long)nbytes, lnbytes, errno)); + } else { + if (lnbytes > 0) + pvm_unpackf("%*c", (int)lnbytes, (char *)buf); + dprintrw((buf2, "tid t%x read(%d, %p, %ld) = %ld\n", + pvmmytid, fd, buf, (long)nbytes, lnbytes)); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return (READ_RETURN_TYPE)lnbytes; + } + + READ_RETURN_TYPE + _read(int fd, READ_ARG2_TYPE buf, READ_ARG3_TYPE nbytes) + { + return read(fd, buf, nbytes); + } + + READ_RETURN_TYPE + __read(int fd, READ_ARG2_TYPE buf, READ_ARG3_TYPE nbytes) + { + return read(fd, buf, nbytes); + } + + #ifdef IMA_CNVXN + READ_RETURN_TYPE + __ap$read(int fd, READ_ARG2_TYPE buf, READ_ARG3_TYPE nbytes) + { + return read(fd, buf, nbytes); + } + #endif /* IMA_CNVXN */ + + READV_RETURN_TYPE + readv(int fd, READV_CONST struct iovec *iovp, int count) + { + READ_RETURN_TYPE scc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_READV; + int nargs = 2; + int i; + long nbytes; + long left; + long nread; + + if (pvmmyfstid <= 0) { + scc = (READ_RETURN_TYPE)syscall(SYS_readv, fd, iovp, count); + if (scc == -1) + dprintl((buf2, + "tid t%x readv(%d, %p, %d) = %ld (errno = %d)\n", + pvmmytid, fd, iovp, count, (long)scc, errno)); + else + dprintl((buf2, "tid t%x readv(%d, %p, %d) = %ld\n", + pvmmytid, fd, iovp, count, (long)scc)); + return (READV_RETURN_TYPE)scc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + + nbytes = 0; + for (i = 0; i < count; i++) + nbytes += iovp[i].iov_len; + pvm_packf("%+ %d %d %ld", PvmDataDefault, nargs, fd, nbytes); + for (i = 0; i < count; i++) { + nbytes = iovp[i].iov_len; + pvm_packf("%ld", nbytes); + } + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%ld", &nbytes); + if (nbytes == -1L) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprintrw((buf2, + "tid t%x readv(%d, %p, %d) = %ld (errno = %d)\n", + pvmmytid, fd, iovp, count, nbytes, errno)); + } else { + for (left = nbytes, i = 0; left && i < count; + left -= nread, i++) + if (nread = MIN(left, iovp[i].iov_len)) { + pvm_unpackf("%*c", (int)nread, + (char *)iovp[i].iov_base); + dprint((buf2, + "tid t%x unpacked \"%*.*s\" at %p\n", + pvmmytid, (int)nread, (int)nread, + (char *)iovp[i].iov_base, + (char *)iovp[i].iov_base)); + } + if (left) { + /* shouldn't happen */ + errno = 0; + return -1; + } + dprintrw((buf2, "tid t%x readv(%d, %p, %d) = %ld\n", + pvmmytid, fd, iovp, count, nbytes)); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return (READV_RETURN_TYPE)nbytes; + } + + READV_RETURN_TYPE + _readv(int fd, READV_CONST struct iovec *iovp, int count) + { + return readv(fd, iovp, count); + } + + READV_RETURN_TYPE + __readv(int fd, READV_CONST struct iovec *iovp, int count) + { + return readv(fd, iovp, count); + } + + #ifdef IMA_CNVXN + READV_RETURN_TYPE + __ap$readv(int fd, READV_CONST struct iovec *iovp, int count) + { + return readv(fd, iovp, count); + } + #endif /* IMA_CNVXN */ + + WRITE_RETURN_TYPE + write(int fd, WRITE_ARG2_TYPE buf, WRITE_ARG3_TYPE nbytes) + { + WRITE_RETURN_TYPE scc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_WRITE; + int nargs = 3; + long lnbytes = (long)nbytes; + + if (pvmmyfstid <= 0) { + scc = (WRITE_RETURN_TYPE)syscall(SYS_write, fd, buf, nbytes); + if (scc == -1) + #if 0 + dprintl((buf2, "tid t%x write(%d, %p, %ld) = -1" + " (errno = %d) \"%*.*s\"\n", pvmmytid, fd, buf, + (long)nbytes, errno, (int)nbytes, (int)nbytes, + (isprint(((char *)buf)[0]) && isprint(((char *)buf)[1])) ? buf : "")); + #else + dprintl((buf2, + "tid t%x write(%d, %p, %ld) = -1 (errno = %d)\n", + pvmmytid, fd, buf, (long)nbytes, errno)); + #endif + else + #if 0 + dprintl((buf2, + "tid t%x write(%d, %p, %ld) = %ld \"%*.*s\"\n", + pvmmytid, fd, buf, (long)nbytes, scc, (int)nbytes, + (int)nbytes, + (isprint(((char *)buf)[0]) && isprint(((char *)buf)[1])) ? buf : "")); + #else + dprintl((buf2, + "tid t%x write(%d, %p, %ld) = %ld\n", + pvmmytid, fd, buf, (long)nbytes, scc)); + #endif + return (WRITE_RETURN_TYPE)scc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %ld %*c", PvmDataDefault, nargs, fd, lnbytes, + (int)lnbytes, (char *)buf); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%ld", &lnbytes); + if (lnbytes == -1L) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + #if 0 + dprintrw((buf2, + "tid t%x write(%d, %p, %ld) = -1 (pvmerrno = %d) \"%*.*s\"\n", + pvmmytid, fd, buf, (long)nbytes, pvmerrno, nbytes, nbytes, + (isprint(((char *)buf)[0]) && isprint(((char *)buf)[1])) ? buf : "")); + #else + dprintrw((buf2, + "tid t%x write(%d, %p, %ld) = -1 (pvmerrno = %d)\n", pvmmytid, + fd, buf, (long)nbytes, pvmerrno)); + #endif + } else + #if 0 + dprintrw((buf2, "tid t%x write(%d, %p, %ld) = %ld \"%*.*s\"\n", + pvmmytid, fd, buf, (long)nbytes, lnbytes, nbytes, nbytes, "")); + (isprint(((char *)buf)[0]) && isprint(((char *)buf)[1])) ? buf : "")); + #else + dprintrw((buf2, "tid t%x write(%d, %p, %ld) = %ld\n", + pvmmytid, fd, buf, (long)nbytes, lnbytes)); + #endif + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return (WRITE_RETURN_TYPE)lnbytes; + } + + WRITE_RETURN_TYPE + _write(int fd, WRITE_ARG2_TYPE buf, WRITE_ARG3_TYPE nbytes) + { + return write(fd, buf, nbytes); + } + + WRITE_RETURN_TYPE + __write(int fd, WRITE_ARG2_TYPE buf, WRITE_ARG3_TYPE nbytes) + { + return write(fd, buf, nbytes); + } + + #ifdef IMA_CNVXN + WRITE_RETURN_TYPE + __ap$write(int fd, WRITE_ARG2_TYPE buf, WRITE_ARG3_TYPE nbytes) + { + return write(fd, buf, nbytes); + } + #endif /* IMA_CNVXN */ + + WRITEV_RETURN_TYPE + writev(int fd, WRITEV_CONST struct iovec *iovp, int count) + { + WRITE_RETURN_TYPE scc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_WRITEV; + int nargs = 3; + long nbytes; + int i; + + if (pvmmyfstid <= 0) { + scc = (WRITE_RETURN_TYPE)syscall(SYS_writev, fd, iovp, count); + if (scc == -1) + dprintl((buf2, + "tid t%x writev(%d, %p, %d) = -1 (errno = %d)\n", + pvmmytid, fd, iovp, count, errno)); + else + dprintl((buf2, + "tid t%x writev(%d, %p, %d) = %ld\n", + pvmmytid, fd, iovp, count, (long)scc)); + return (WRITEV_RETURN_TYPE)scc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + + nbytes = 0; + for (i = 0; i < count; i++) + nbytes += iovp[i].iov_len; + pvm_packf("%+ %d %d %ld", PvmDataDefault, nargs, fd, nbytes); + for (i = 0; i < count; i++) { + nbytes = iovp[i].iov_len; + pvm_packf("%ld %*c", nbytes, (int)iovp[i].iov_len, + (char *)iovp[i].iov_base); + } + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%ld", &nbytes); + if (nbytes == -1L) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprintrw((buf2, + "tid t%x writev(%d, %p, %d) = -1 (pvmerrno = %d)\n", pvmmytid, + fd, iovp, count, pvmerrno)); + } else + dprintrw((buf2, "tid t%x writev(%d, %p, %d) = %ld\n", + pvmmytid, fd, iovp, count, nbytes)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return (WRITEV_RETURN_TYPE)nbytes; + } + + WRITEV_RETURN_TYPE + _writev(int fd, WRITEV_CONST struct iovec *iovp, int count) + { + return writev(fd, iovp, count); + } + + WRITEV_RETURN_TYPE + __writev(int fd, WRITEV_CONST struct iovec *iovp, int count) + { + return writev(fd, iovp, count); + } + + #ifdef IMA_CNVXN + WRITEV_RETURN_TYPE + __ap$writev(int fd, WRITEV_CONST struct iovec *iovp, int count) + { + return writev(fd, iovp, count); + } + #endif /* IMA_CNVXN */ + + int + dup(int fd) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_DUP; + int nargs = 1; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_dup, fd); + if (cc == -1) + dprintl((buf2, "tid t%x dup(%d) = %d (errno = %d)\n", + pvmmytid, fd, cc, errno)); + else + dprintl((buf2, "tid t%x dup(%d) = %d\n", + pvmmytid, fd, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x dup(%d) = %d (pvmerrno = %d)\n", + pvmmytid, fd, cc, pvmerrno)); + } else + dprint((buf2, "tid t%x dup(%d) = %d\n", + pvmmytid, fd, cc)); + + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _dup(int fd) + { + return dup(fd); + } + + int + __dup(int fd) + { + return dup(fd); + } + + #ifdef IMA_CNVXN + int + __ap$dup(int fd) + { + return dup(fd); + } + #endif /* IMA_CNVXN */ + + int + dup2(int fd1, int fd2) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_DUP2; + int nargs = 2; + + if (pvmmyfstid <= 0) { + #ifdef IMA_CRAY + struct stat st; + + if (fd2 < 0 || fd2 >= openmax() + || syscall(SYS_fstat, fd1, &st) == -1) { + errno = EBADF; + cc = -1; + } else { + (void)syscall(SYS_close, fd2); + cc = syscall(SYS_fcntl, fd1, F_DUPFD, fd2); + } + #else + cc = syscall(SYS_dup2, fd1, fd2); + #endif + if (cc == -1) + dprintl((buf2, + "tid t%x dup2(%d, %d) = %d (errno = %d)\n", + pvmmytid, fd1, fd2, cc, errno)); + else + dprintl((buf2, "tid t%x dup2(%d, %d) = %d\n", + pvmmytid, fd1, fd2, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %d", PvmDataDefault, nargs, fd1, fd2); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x dup2(%d, %d) = %d (pvmerrno = %d)\n", + pvmmytid, fd1, fd2, cc, pvmerrno)); + } else + dprint((buf2, "tid t%x dup2(%d, %d) = %d\n", + pvmmytid, fd1, fd2, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _dup2(int fd1, int fd2) + { + return dup2(fd1, fd2); + } + + int + __dup2(int fd1, int fd2) + { + return dup2(fd1, fd2); + } + + #ifdef IMA_CNVXN + int + __ap$dup2(int fd1, int fd2) + { + return dup2(fd1, fd2); + } + #endif /* IMA_CNVXN */ + + static void + fillstat(struct stat *stp) + { + long l; + + #ifdef __STDC__ + #define get(mem) pvm_unpackf("%ld", &l); stp->st_##mem = l + get(dev); get(ino); get(mode); get(nlink); get(uid); get(gid); + get(rdev); get(size); get(atime); get(ctime); get(mtime); get(blksize); + get(blocks); + #undef get + #else + pvm_unpackf("%ld", &l); stp->st_dev = l; + pvm_unpackf("%ld", &l); stp->st_ino = l; + pvm_unpackf("%ld", &l); stp->st_mode = l; + pvm_unpackf("%ld", &l); stp->st_nlink = l; + pvm_unpackf("%ld", &l); stp->st_uid = l; + pvm_unpackf("%ld", &l); stp->st_gid = l; + pvm_unpackf("%ld", &l); stp->st_rdev = l; + pvm_unpackf("%ld", &l); stp->st_size = l; + pvm_unpackf("%ld", &l); stp->st_atime = l; + pvm_unpackf("%ld", &l); stp->st_ctime = l; + pvm_unpackf("%ld", &l); stp->st_mtime = l; + pvm_unpackf("%ld", &l); stp->st_blksize = l; + pvm_unpackf("%ld", &l); stp->st_blocks = l; + #endif + } + + int + stat(const char *pathname, struct stat *stp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_STAT; + int nargs = 1; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_stat, pathname, stp); + if (cc == -1) + dprintl((buf2, + "tid t%x stat(\"%s\", %p) = %d (errno = %d)\n", + pvmmytid, pathname, (void *)stp, cc, errno)); + else + dprintl((buf2, "tid t%x stat(\"%s\", %p) = %d\n", + pvmmytid, pathname, (void *)stp, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s", PvmDataDefault, nargs, pathname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x stat(\"%s\", %p) = %d (pvmerrno = %d)\n", + pvmmytid, pathname, (void *)stp, cc, pvmerrno)); + } else { + dprint((buf2, "tid t%x stat(\"%s\", %p) = %d\n", + pvmmytid, pathname, (void *)stp, cc)); + fillstat(stp); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _stat(const char *pathname, struct stat *stp) + { + return stat(pathname, stp); + } + + int + __stat(const char *pathname, struct stat *stp) + { + return stat(pathname, stp); + } + + #ifdef IMA_CNVXN + int + __ap$stat(const char *pathname, struct stat *stp) + { + return stat(pathname, stp); + } + #endif /* IMA_CNVXN */ + + int + lstat(const char *pathname, struct stat *stp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_LSTAT; + int nargs = 1; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_lstat, pathname, stp); + if (cc == -1) + dprintl((buf2, + "tid t%x lstat(\"%s\", %p) = %d (errno = %d)\n", + pvmmytid, pathname, (void *)stp, cc, errno)); + else + dprintl((buf2, "tid t%x lstat(\"%s\", %p) = %d\n", + pvmmytid, pathname, (void *)stp, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s", PvmDataDefault, nargs, pathname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x lstat(\"%s\", %p) = %d (pvmerrno = %d)\n", pvmmytid, + pathname, (void *)stp, cc, pvmerrno)); + } else { + dprint((buf2, "tid t%x lstat(\"%s\", %p) = %d\n", + pvmmytid, pathname, (void *)stp, cc)); + fillstat(stp); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _lstat(const char *pathname, struct stat *stp) + { + return lstat(pathname, stp); + } + + int + __lstat(const char *pathname, struct stat *stp) + { + return lstat(pathname, stp); + } + + #ifdef IMA_CNVXN + int + __ap$lstat(const char *pathname, struct stat *stp) + { + return lstat(pathname, stp); + } + #endif /* IMA_CNVXN */ + + int + fstat(int fd, struct stat *stp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_FSTAT; + int nargs = 1; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_fstat, fd, stp); + if (fd < 20) { + if (cc == -1) + dprintl((buf2, + "tid t%x fstat(%d, %p) = %d (errno = %d)\n", + pvmmytid, fd, (void *)stp, cc, errno)); + else + dprintl((buf2, "tid t%x fstat(%d, %p) = %d\n", + pvmmytid, fd, (void *)stp, cc)); + } + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x fstat(%d, %p) = %d (pvmerrno = %d)\n", pvmmytid, fd, + (void *)stp, cc, pvmerrno)); + } else { + dprint((buf2, "tid t%x fstat(%d, %p) = %d\n", + pvmmytid, fd, (void *)stp, cc)); + fillstat(stp); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _fstat(int fd, struct stat *stp) + { + return fstat(fd, stp); + } + + int + __fstat(int fd, struct stat *stp) + { + return fstat(fd, stp); + } + + #ifdef IMA_CNVXN + int + __ap$fstat(int fd, struct stat *stp) + { + return fstat(fd, stp); + } + #endif /* IMA_CNVXN */ + + static int + vfcntl(int fd, int command, va_list ap) + { + int iarg = 0; + struct flock *lockp; + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_FCNTL; + long l1, l2; + int nargs = 3; + + if (pvmmyfstid <= 0) { + switch (command) { + case F_GETLK: + case F_SETLK: + case F_SETLKW: + lockp = va_arg(ap, struct flock *); + cc = syscall(SYS_fcntl, fd, command, lockp); + if (cc == -1) + dprintl((buf2, + "tid t%x fcntl(%d, %d, %p) = -1 (errno = %d)\n", + pvmmytid, fd, command, (void *)lockp, errno)); + else + dprintl((buf2, + "tid t%x fcntl(%d, %d, %p) = %d\n", + pvmmytid, fd, command, (void *)lockp, cc)); + break; + default: + iarg = va_arg(ap, int); + cc = syscall(SYS_fcntl, fd, command, iarg); + if (cc == -1) + dprintl((buf2, + "tid t%x fcntl(%d, %d, %d) = -1 (errno = %d)\n", + pvmmytid, fd, command, iarg, errno)); + else + dprintl((buf2, + "tid t%x fcntl(%d, %d, %d) = %d\n", + pvmmytid, fd, command, iarg, cc)); + break; + } + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + + switch (command) { + case F_GETLK: + case F_SETLK: + case F_SETLKW: + lockp = va_arg(ap, struct flock *); + if ((lockp->l_type = pvm_fcntl_ltype(lockp->l_type)) == -1L + || (lockp->l_whence = pvm_lseek_whence(lockp->l_whence)) + == -1L) { + errno = EINVAL; + return -1; + } + command = pvm_fcntl_cmd(command); + pvm_packf("%d %d %ld %d %ld", command, lockp->l_type, + (long)lockp->l_start, lockp->l_whence, (long)lockp->l_len); + break; + case F_DUPFD: + case F_SETFD: + case F_SETFL: + case F_SETOWN: + iarg = va_arg(ap, int); + if (command == F_SETFL) + iarg = pvm_open_oflag(iarg); + /* FALLTHROUGH */ + default: + command = pvm_fcntl_cmd(command); + pvm_packf("%d %d", command, iarg); + break; + } + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + switch (command) { + case F_GETLK: + case F_SETLK: + case F_SETLKW: + dprint((buf2, + "tid t%x fcntl(%d, %d, %p) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, command, (void *)lockp, pvmerrno)); + break; + default: + dprint((buf2, + "tid t%x fcntl(%d, %d, %d) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, command, iarg, pvmerrno)); + break; + } + } else + switch (command) { + case F_GETLK: + pvm_unpackf("%hd", &lockp->l_type); + lockp->l_type = + (short)pvm_local_fcntl_ltype(lockp->l_type); + if (lockp->l_type != F_UNLCK) { + pvm_unpackf("%ld %hd %ld", &l1, + &lockp->l_whence, &l2); + lockp->l_start = (off_t)l1; + lockp->l_whence = (short) + pvm_local_lseek_whence(lockp->l_whence); + lockp->l_len = (off_t)l2; + } + case F_SETLK: + case F_SETLKW: + dprint((buf2, "tid t%x fcntl(%d, %d, %p) = %d\n", + pvmmytid, fd, command, (void *)lockp, cc)); + break; + case F_GETFL: + cc = pvm_local_open_oflag(cc); + default: + dprint((buf2, "tid t%x fcntl(%d, %d, %d) = %d\n", + pvmmytid, fd, command, iarg, cc)); + break; + } + + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + fcntl(int fd, int command, ...) + #else + fcntl(va_alist) va_dcl + #endif + { + int cc; + va_list ap; + + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + va_start(ap, command); + #else + int fd; + int command; + + va_start(ap); + fd = va_arg(ap, int); + command = va_arg(ap, int); + #endif + + cc = vfcntl(fd, command, ap); + va_end(ap); + return cc; + } + + int + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + _fcntl(int fd, int command, ...) + #else + _fcntl(va_alist) va_dcl + #endif + { + int cc; + va_list ap; + + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + va_start(ap, command); + #else + int fd; + int command; + + va_start(ap); + fd = va_arg(ap, int); + command = va_arg(ap, int); + #endif + + cc = vfcntl(fd, command, ap); + va_end(ap); + return cc; + } + + int + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + __fcntl(int fd, int command, ...) + #else + __fcntl(va_alist) va_dcl + #endif + { + int cc; + va_list ap; + + #if defined(__STDC__) || defined(IMA_CNVXN) || defined(IMA_RS6K) + va_start(ap, command); + #else + int fd; + int command; + + va_start(ap); + fd = va_arg(ap, int); + command = va_arg(ap, int); + #endif + + cc = vfcntl(fd, command, ap); + va_end(ap); + return cc; + } + + #ifdef IMA_CNVXN + int + __ap$fcntl(int fd, int command, ...) + { + int cc; + va_list ap; + + va_start(ap, command); + cc = vfcntl(fd, command, ap); + va_end(ap); + return cc; + } + #endif /* IMA_CNVXN */ + + int + unlink(const char *pathname) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_UNLINK; + int nargs = 1; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_unlink, pathname); + if (cc == -1) + dprintl((buf2, + "tid t%x unlink(\"%s\") = -1 (errno = %d)\n", + pvmmytid, pathname, errno)); + else + dprintl((buf2, "tid t%x unlink(\"%s\") = %d\n", + pvmmytid, pathname, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s", PvmDataDefault, nargs, pathname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x unlink(\"%s\") = -1 (pvmerrno = %d)\n", + pvmmytid, pathname, pvmerrno)); + } else + dprint((buf2, "tid t%x unlink(\"%s\") = %d\n", + pvmmytid, pathname, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _unlink(const char *pathname) + { + return unlink(pathname); + } + + int + __unlink(const char *pathname) + { + return unlink(pathname); + } + + #ifdef IMA_CNVXN + int + __ap$unlink(const char *pathname) + { + return unlink(pathname); + } + #endif /* IMA_CNVXN */ + + int + rename(const char *oldpathname, const char *newpathname) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_RENAME; + int nargs = 2; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_rename, oldpathname, newpathname); + if (cc == -1) + dprintl((buf2, + "tid t%x rename(\"%s\", \"%s\") = -1 (errno = %d)\n", + pvmmytid, oldpathname, newpathname, errno)); + else + dprintl((buf2, "tid t%x rename(\"%s\", \"%s\") = %d\n", + pvmmytid, oldpathname, newpathname, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %s", PvmDataDefault, nargs, oldpathname, + newpathname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x rename(\"%s\", \"%s\") = -1 (pvmerrno = %d)\n", + pvmmytid, oldpathname, newpathname, pvmerrno)); + } else + dprint((buf2, "tid t%x rename(\"%s\", \"%s\") = %d\n", + pvmmytid, oldpathname, newpathname, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _rename(const char *oldpathname, const char *newpathname) + { + return rename(oldpathname, newpathname); + } + + int + __rename(const char *oldpathname, const char *newpathname) + { + return rename(oldpathname, newpathname); + } + + #ifdef IMA_CNVXN + int + __ap$rename(const char *oldpathname, const char *newpathname) + { + return rename(oldpathname, newpathname); + } + #endif /* IMA_CNVXN */ + + int + mkdir(const char *pathname, mode_t mode) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_MKDIR; + int nargs = 2; + long lmode = pvm_open_mode(mode); + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_mkdir, pathname, mode); + if (cc == -1) + dprintl((buf2, + "tid t%x mkdir(\"%s\") = -1 (errno = %d)\n", pvmmytid, + pathname, errno)); + else + dprintl((buf2, "tid t%x mkdir(\"%s\") = %d\n", + pvmmytid, pathname, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %ld", PvmDataDefault, nargs, pathname, lmode); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x mkdir(\"%s\", mode) = -1 (pvmerrno = %d)\n", + pvmmytid, pathname, (long)mode, pvmerrno)); + } else + dprint((buf2, "tid t%x mkdir(\"%s\", %ld) = %d\n", + pvmmytid, pathname, (long)mode, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _mkdir(const char *pathname, mode_t mode) + { + return mkdir(pathname, mode); + } + + int + __mkdir(const char *pathname, mode_t mode) + { + return mkdir(pathname, mode); + } + + #ifdef IMA_CNVXN + int + __ap$mkdir(const char *pathname, mode_t mode) + { + return mkdir(pathname, mode); + } + #endif /* IMA_CNVXN */ + + int + rmdir(const char *pathname) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_RMDIR; + int nargs = 1; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_rmdir, pathname); + if (cc == -1) + dprintl((buf2, + "tid t%x rmdir(\"%s\") = -1 (errno = %d)\n", pvmmytid, + pathname, errno)); + else + dprintl((buf2, "tid t%x rmdir(\"%s\") = %d\n", + pvmmytid, pathname, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s", PvmDataDefault, nargs, pathname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x rmdir(\"%s\") = -1 (pvmerrno = %d)\n", + pvmmytid, pathname, pvmerrno)); + } else + dprint((buf2, "tid t%x rmdir(\"%s\") = %d\n", + pvmmytid, pathname, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _rmdir(const char *pathname) + { + return rmdir(pathname); + } + + int + __rmdir(const char *pathname) + { + return rmdir(pathname); + } + + #ifdef IMA_CNVXN + int + __ap$rmdir(const char *pathname) + { + return rmdir(pathname); + } + #endif /* IMA_CNVXN */ + + int + chroot(const char *pathname) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_CHROOT; + int nargs = 1; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_chroot, pathname); + if (cc == -1) + dprintl((buf2, + "tid t%x chroot(\"%s\") = -1 (errno = %d)\n", + pvmmytid, pathname, errno)); + else + dprintl((buf2, "tid t%x chroot(\"%s\") = %d\n", + pvmmytid, pathname, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s", PvmDataDefault, nargs, pathname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x chroot(\"%s\") = -1 (pvmerrno = %d)\n", + pvmmytid, pathname, pvmerrno)); + } else + dprint((buf2, "tid t%x chroot(\"%s\") = %d\n", + pvmmytid, pathname, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _chroot(const char *pathname) + { + return chroot(pathname); + } + + int + __chroot(const char *pathname) + { + return chroot(pathname); + } + + #ifdef IMA_CNVXN + int + __ap$chroot(const char *pathname) + { + return chroot(pathname); + } + #endif /* IMA_CNVXN */ + + int + fchroot(int fd) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_FCHDIR; + int nargs = 1; + + if (pvmmyfstid <= 0) { + #ifdef SYS_fchroot + cc = syscall(SYS_fchroot, fd); + #else + cc = -1; + errno = ENOSYS; + #endif + if (cc == -1) + dprintl((buf2, + "tid t%x fchroot(%d) = -1 (errno = %d)\n", + pvmmytid, fd, errno)); + else + dprintl((buf2, "tid t%x fchroot(%d) = %d\n", + pvmmytid, fd, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x fchroot(%d) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, pvmerrno)); + } else + dprint((buf2, "tid t%x fchroot(%d) = %d\n", pvmmytid, fd, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _fchroot(const char *pathname) + { + return chroot(pathname); + } + + int + __fchroot(const char *pathname) + { + return chroot(pathname); + } + + #ifdef IMA_CNVXN + int + __ap$fchroot(const char *pathname) + { + return chroot(pathname); + } + #endif /* IMA_CNVXN */ + + int + chdir(const char *pathname) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_CHDIR; + int nargs = 1; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_chdir, pathname); + if (cc == -1) + dprintl((buf2, + "tid t%x chdir(\"%s\") = -1 (errno = %d)\n", pvmmytid, + pathname, errno)); + else + dprintl((buf2, "tid t%x chdir(\"%s\") = %d\n", + pvmmytid, pathname, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s", PvmDataDefault, nargs, pathname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x chdir(\"%s\") = -1 (pvmerrno = %d)\n", + pvmmytid, pathname, pvmerrno)); + } else + dprint((buf2, "tid t%x chdir(\"%s\") = %d\n", + pvmmytid, pathname, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _chdir(const char *pathname) + { + return chdir(pathname); + } + + int + __chdir(const char *pathname) + { + return chdir(pathname); + } + + #ifdef IMA_CNVXN + int + __ap$chdir(const char *pathname) + { + return chdir(pathname); + } + #endif /* IMA_CNVXN */ + + int + fchdir(int fd) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_FCHDIR; + int nargs = 1; + + if (pvmmyfstid <= 0) { + #ifdef SYS_fchdir + cc = syscall(SYS_fchdir, fd); + #else + cc = -1; + errno = ENOSYS; + #endif + if (cc == -1) + dprintl((buf2, "tid t%x fchdir(%d) = -1 (errno = %d)\n", + pvmmytid, fd, errno)); + else + dprintl((buf2, "tid t%x fchdir(%d) = %d\n", + pvmmytid, fd, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x fchdir(%d) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, pvmerrno)); + } else + dprint((buf2, "tid t%x fchdir(%d) = %d\n", pvmmytid, fd, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _fchdir(int fd) + { + return fchdir(fd); + } + + int + __fchdir(int fd) + { + return fchdir(fd); + } + + #ifdef IMA_CNVXN + int + __ap$fchdir(int fd) + { + return fchdir(fd); + } + #endif /* IMA_CNVXN */ + + int + chmod(const char *pathname, mode_t mode) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_CHMOD; + int nargs = 2; + long lmode = pvm_open_mode(mode); + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_chmod, pathname, mode); + if (cc == -1) + dprintl((buf2, + "tid t%x chmod(\"%s\", %ld) = -1 (errno = %d)\n", + pvmmytid, pathname, (long)mode, + errno)); + else + dprintl((buf2, "tid t%x chmod(\"%s\", %ld) = %d\n", + pvmmytid, pathname, (long)mode, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %ld", PvmDataDefault, nargs, pathname, lmode); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x chmod(\"%s\", %ld) = -1 (pvmerrno = %d)\n", pvmmytid, + pathname, (long)mode, pvmerrno)); + } else + dprint((buf2, "tid t%x chmod(\"%s\", %ld) = %d\n", + pvmmytid, pathname, (long)mode, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _chmod(const char *pathname, mode_t mode) + { + return chmod(pathname, mode); + } + + int + __chmod(const char *pathname, mode_t mode) + { + return chmod(pathname, mode); + } + + #ifdef IMA_CNVXN + int + __ap$chmod(const char *pathname, mode_t mode) + { + return chmod(pathname, mode); + } + #endif /* IMA_CNVXN */ + + #ifndef IMA_RS6K + int + fchmod(int fd, mode_t mode) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_FCHMOD; + int nargs = 2; + long lmode = pvm_open_mode(mode); + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_fchmod, fd, mode); + if (cc == -1) + dprintl((buf2, + "tid t%x fchmod(%d, %ld) = -1 (errno = %d)\n", + pvmmytid, fd, (long)mode, errno)); + else + dprintl((buf2, "tid t%x fchmod(%d, %ld) = %d\n", + pvmmytid, fd, (long)mode, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %ld", PvmDataDefault, nargs, fd, lmode); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x fchmod(%d, %ld) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, (long)mode, pvmerrno)); + } else + dprint((buf2, "tid t%x fchmod(%d, %ld) = %d\n", pvmmytid, fd, + (long)mode, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _fchmod(int fd, mode_t mode) + { + return fchmod(fd, mode); + } + + int + __fchmod(int fd, mode_t mode) + { + return fchmod(fd, mode); + } + + #ifdef IMA_CNVXN + int + __ap$fchmod(int fd, mode_t mode) + { + return fchmod(fd, mode); + } + #endif /* IMA_CNVXN */ + #endif /* !IMA_RS6K */ + + int + chown(const char *pathname, uid_t uid, gid_t gid) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_CHOWN; + int nargs = 3; + long luid = uid; + long lgid = gid; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_chown, pathname, uid, gid); + if (cc == -1) + dprintl((buf2, + "tid t%x chown(\"%s\", %ld, %ld) = -1 (errno = %d)\n", + pvmmytid, pathname, (long)uid, (long)gid, errno)); + else + dprintl((buf2, "tid t%x chown(\"%s\", %ld, %ld) = %d\n", + pvmmytid, pathname, (long)uid, (long)gid, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %ld %ld", PvmDataDefault, nargs, pathname, luid, + lgid); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x chown(\"%s\", %ld, %ld) = -1 (pvmerrno = %d)\n", + pvmmytid, pathname, (long)uid, (long)gid, pvmerrno)); + } else + dprint((buf2, "tid t%x chown(\"%s\", %ld, %ld) = %d\n", + pvmmytid, pathname, (long)uid, (long)gid, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _chown(const char *pathname, uid_t uid, gid_t gid) + { + return chown(pathname, uid, gid); + } + + int + __chown(const char *pathname, uid_t uid, gid_t gid) + { + return chown(pathname, uid, gid); + } + + #ifdef IMA_CNVXN + int + __ap$chown(const char *pathname, uid_t uid, gid_t gid) + { + return chown(pathname, uid, gid); + } + #endif /* IMA_CNVXN */ + + int + fchown(int fd, uid_t uid, gid_t gid) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_FCHOWN; + int nargs = 3; + long luid = uid; + long lgid = gid; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_fchown, fd, uid, gid); + if (cc == -1) + dprintl((buf2, + "tid t%x fchown(%d, %ld, %ld) = -1 (errno = %d)\n", + pvmmytid, fd, (long)uid, (long)gid, errno)); + else + dprintl((buf2, "tid t%x fchown(%d, %ld, %ld) = %d\n", + pvmmytid, fd, (long)uid, (long)gid, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %ld %ld", PvmDataDefault, nargs, fd, luid, lgid); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x fchown(%d, %ld, %ld) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, (long)uid, (long)gid, pvmerrno)); + } else + dprint((buf2, "tid t%x fchown(%d, %ld, %ld) = %d\n", + pvmmytid, fd, (long)uid, (long)gid, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _fchown(int fd, uid_t uid, gid_t gid) + { + return fchown(fd, uid, gid); + } + + int + __fchown(int fd, uid_t uid, gid_t gid) + { + return fchown(fd, uid, gid); + } + + #ifdef IMA_CNVXN + int + __ap$fchown(int fd, uid_t uid, gid_t gid) + { + return fchown(fd, uid, gid); + } + #endif /* IMA_CNVXN */ + + int + lchown(const char *pathname, uid_t uid, gid_t gid) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_LCHOWN; + int nargs = 3; + long luid = uid; + long lgid = gid; + + if (pvmmyfstid <= 0) { + #ifdef SYS_lchown + cc = syscall(SYS_lchown, pathname, uid, gid); + #else + cc = -1; + errno = ENOSYS; + #endif + if (cc == -1) + dprintl((buf2, + "tid t%x lchown(\"%s\", %ld, %ld) = -1 (errno = %d)\n", + pvmmytid, pathname, (long)uid, (long)gid, errno)); + else + dprintl((buf2, + "tid t%x lchown(\"%s\", %ld, %ld) = %d\n", + pvmmytid, pathname, (long)uid, (long)gid, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %ld %ld", PvmDataDefault, nargs, pathname, luid, + lgid); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x lchown(\"%s\", %ld, %ld) = -1 (pvmerrno = %d)\n", + pvmmytid, pathname, (long)uid, (long)gid, pvmerrno)); + } else + dprint((buf2, "tid t%x lchown(\"%s\", %ld, %ld) = %d\n", + pvmmytid, pathname, (long)uid, (long)gid, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _lchown(const char *pathname, uid_t uid, gid_t gid) + { + return lchown(pathname, uid, gid); + } + + int + __lchown(const char *pathname, uid_t uid, gid_t gid) + { + return lchown(pathname, uid, gid); + } + + #ifdef IMA_CNVXN + int + __ap$lchown(const char *pathname, uid_t uid, gid_t gid) + { + return lchown(pathname, uid, gid); + } + #endif /* IMA_CNVXN */ + + int + link(const char *oldpathname, const char *newpathname) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_LINK; + int nargs = 2; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_link, oldpathname, newpathname); + if (cc == -1) + dprintl((buf2, + "tid t%x link(\"%s\", \"%s\") = -1 (errno = %d)\n", + pvmmytid, oldpathname, newpathname, errno)); + else + dprintl((buf2, "tid t%x link(\"%s\", \"%s\") = %d\n", + pvmmytid, oldpathname, newpathname, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %s", PvmDataDefault, nargs, oldpathname, + newpathname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x link(\"%s\", \"%s\") = -1 (pvmerrno = %d)\n", + pvmmytid, oldpathname, newpathname, pvmerrno)); + } else + dprint((buf2, "tid t%x link(\"%s\", \"%s\") = %d\n", + pvmmytid, oldpathname, newpathname, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _link(const char *oldpathname, const char *newpathname) + { + return link(oldpathname, newpathname); + } + + int + __link(const char *oldpathname, const char *newpathname) + { + return link(oldpathname, newpathname); + } + + #ifdef IMA_CNVXN + int + __ap$link(const char *oldpathname, const char *newpathname) + { + return link(oldpathname, newpathname); + } + #endif /* IMA_CNVXN */ + + int + symlink(const char *oldpathname, const char *newpathname) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_SYMLINK; + int nargs = 2; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_symlink, oldpathname, newpathname); + if (cc == -1) + dprintl((buf2, + "tid t%x symlink(\"%s\", \"%s\") = -1 (errno = %d)\n", + pvmmytid, oldpathname, newpathname, errno)); + else + dprintl((buf2, "tid t%x symlink(\"%s\", \"%s\") = %d\n", + pvmmytid, oldpathname, newpathname, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %s", PvmDataDefault, nargs, oldpathname, + newpathname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x symlink(\"%s\", \"%s\") = -1 (pvmerrno = %d)\n", + pvmmytid, oldpathname, newpathname, pvmerrno)); + } else + dprint((buf2, "tid t%x symlink(\"%s\", \"%s\") = %d\n", + pvmmytid, oldpathname, newpathname, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _symlink(const char *oldpathname, const char *newpathname) + { + return symlink(oldpathname, newpathname); + } + + int + __symlink(const char *oldpathname, const char *newpathname) + { + return symlink(oldpathname, newpathname); + } + + #ifdef IMA_CNVXN + int + __ap$symlink(const char *oldpathname, const char *newpathname) + { + return symlink(oldpathname, newpathname); + } + #endif /* IMA_CNVXN */ + + int + mkfifo(const char *pathname, mode_t mode) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_MKFIFO; + int nargs = 2; + long lmode = pvm_open_mode((long)mode); + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_mknod, pathname, mode | S_IFIFO); + if (cc == -1) + dprintl((buf2, + "tid t%x mkfifo(\"%s\", %ld) = -1 (errno = %d)\n", + pvmmytid, pathname, (long)mode | S_IFIFO, errno)); + else + dprintl((buf2, + "tid t%x mkfifo(\"%s\", %ld) = %d\n", + pvmmytid, pathname, (long)mode | S_IFIFO, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %ld", PvmDataDefault, nargs, pathname, lmode); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x mkfifo(\"%s\", %ld) = -1 (pvmerrno = %d)\n", + pvmmytid, pathname, (long)mode, pvmerrno)); + } else + dprint((buf2, "tid t%x mkfifo(\"%s\", %ld) = %d\n", + pvmmytid, pathname, (long)mode, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _mkfifo(const char *pathname, mode_t mode) + { + return mkfifo(pathname, mode); + } + + int + __mkfifo(const char *pathname, mode_t mode) + { + return mkfifo(pathname, mode); + } + + #ifdef IMA_CNVXN + int + __ap$mkfifo(const char *pathname, mode_t mode) + { + return mkfifo(pathname, mode); + } + #endif /* IMA_CNVXN */ + + int + mknod(const char *pathname, int mode, dev_t dev) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_MKNOD; + int nargs = 3; + long lmode = pvm_open_mode((long)mode); + long ldev = dev; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_mknod, pathname, mode, dev); + if (cc == -1) + dprintl((buf2, + "tid t%x mknod(\"%s\", %ld, %ld) = -1 (errno = %d)\n", + pvmmytid, pathname, (long)mode, (long)dev, errno)); + else + dprintl((buf2, "tid t%x mknod(\"%s\", %ld, %ld) = %d\n", + pvmmytid, pathname, (long)mode, (long)dev, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %ld %ld", PvmDataDefault, nargs, pathname, lmode, + ldev); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x mknod(\"%s\", %ld, %ld) = -1 (pvmerrno = %d)\n", + pvmmytid, pathname, (long)mode, (long)dev, pvmerrno)); + } else + dprint((buf2, "tid t%x mknod(\"%s\", %ld, %ld) = %d\n", + pvmmytid, pathname, (long)mode, (long)dev, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _mknod(const char *pathname, int mode, dev_t dev) + { + return mknod(pathname, mode, dev); + } + + int + __mknod(const char *pathname, int mode, dev_t dev) + { + return mknod(pathname, mode, dev); + } + + #ifdef IMA_CNVXN + int + __ap$mknod(const char *pathname, int mode, dev_t dev) + { + return mknod(pathname, mode, dev); + } + #endif /* IMA_CNVXN */ + + int + pipe(int fd[2]) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_PIPE; + int nargs = 0; + + if (pvmmyfstid <= 0) { + #ifndef SYSCALL_PIPE_IS_OK + if ((cc = socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) == 0) { + (void)shutdown(fd[0], 1); + (void)shutdown(fd[1], 0); + } + #else + cc = syscall(SYS_pipe, fd); + #endif + if (cc == -1) + dprintl((buf2, "tid t%x pipe(%p) = -1 (errno = %d)\n", + pvmmytid, fd, errno)); + else + dprintl((buf2, "tid t%x pipe(%p) = %d <%d, %d>\n", + pvmmytid, fd, cc, fd[0], fd[1])); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d", PvmDataDefault, nargs); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x pipe(%p) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, pvmerrno)); + } else { + pvm_unpackf("%d %d", &fd[0], &fd[1]); + dprint((buf2, "tid t%x pipe(%p) = %d <%d, %d>\n", + pvmmytid, fd, cc, fd[0], fd[1])); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _pipe(int fd[2]) + { + return pipe(fd); + } + + int + __pipe(int fd[2]) + { + return pipe(fd); + } + + #ifdef IMA_CNVXN + int + __ap$pipe(int fd[2]) + { + return pipe(fd); + } + #endif /* IMA_CNVXN */ + + int + readlink(const char *pathname, char *buf, int length) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_READLINK; + int nargs = 2; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_readlink, pathname, buf, length); + if (cc == -1) + dprintl((buf2, + "tid t%x readlink(\"%s\", %p, %d) = -1 (errno = %d)\n", + pvmmytid, pathname, buf, length, errno)); + else + dprintl((buf2, + "tid t%x readlink(\"%s\", %p, %d) = %d\n", + pvmmytid, pathname, buf, length, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %d", PvmDataDefault, nargs, pathname, length); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x readlink(\"%s\", %p, %d) = -1 (pvmerrno = %d)\n", + pvmmytid, pathname, buf, length, pvmerrno)); + } else if (cc == length) { + pvm_unpackf("%*c", cc, buf); + dprint((buf2, + "tid t%x readlink(\"%s\", %p, %d) = %d \"%*.*s\"\n", + pvmmytid, pathname, buf, length, cc, cc, cc, buf)); + } else { + pvm_unpackf("%s", buf); + dprint((buf2, "tid t%x readlink(\"%s\", %p, %d) = %d \"%s\"\n", + pvmmytid, pathname, buf, length, cc, buf)); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _readlink(const char *pathname, char *buf, int length) + { + return readlink(pathname, buf, length); + } + + int + __readlink(const char *pathname, char *buf, int length) + { + return readlink(pathname, buf, length); + } + + #ifdef IMA_CNVXN + int + __ap$readlink(const char *pathname, char *buf, int length) + { + return readlink(pathname, buf, length); + } + #endif /* IMA_CNVXN */ + + #if 0 + static void + fillstatfs(struct statfs *stp) + { + long l; + + #define get(mem) pvm_unpackf("%ld", &l); stp->f_##mem = l; + get(type); + get(bsize); + get(blocks); + get(bfree); + get(bavail); + get(files); + get(ffree); + #if 0 + /* these don't seem to be very uniform */ + get(fsid); + get(fname); + get(name_max); + #endif + #undef get + } + + int + statfs(const char *pathname, struct statfs *stp, int length) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_STATFS; + int nargs = 2; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_statfs, pathname, stp); + if (cc == -1) + dprintl((buf2, + "tid t%x statfs(\"%s\", %p) = %d (errno = %d)\n", + pvmmytid, pathname, (void *)stp, cc, errno)); + else + dprintl((buf2, "tid t%x statfs(\"%s\", %p) = %d\n", + pvmmytid, pathname, (void *)stp, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s", PvmDataDefault, nargs, pathname); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x statfs(\"%s\", %p) = %d (pvmerrno = %d)\n", pvmmytid, + pathname, (void *)stp, cc, pvmerrno)); + } else { + dprint((buf2, "tid t%x statfs(\"%s\", %p) = %d\n", + pvmmytid, pathname, (void *)stp, cc)); + fillstatfs(stp); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + fstatfs(int fd, struct statfs *stp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_FSTAT; + int nargs = 1; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_fstatfs, fd, stp); + if (fd < 100) { + if (cc == -1) + dprintl((buf2, + "tid t%x fstatfs(%d, %p) = %d (errno = %d)\n", + pvmmytid, fd, (void *)stp, cc, errno)); + else + dprintl((buf2, "tid t%x fstatfs(%d, %p) = %d\n", + pvmmytid, fd, (void *)stp, cc)); + } + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x fstatfs(%d, %p) = %d (pvmerrno = %d)\n", + pvmmytid, fd, (void *)stp, cc, pvmerrno)); + } else { + dprint((buf2, "tid t%x fstatfs(%d, %p) = %d\n", + pvmmytid, fd, (void *)stp, cc)); + fillstat(stp); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + #endif + + #ifdef IMA_CRAY + long + trunc(int fd) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_FTRUNCATE; + int nargs = 2; + long len; + + if (pvmmyfstid <= 0) { + len = (long)syscall(SYS_trunc, fd); + if (len == -1) + dprintl((buf2, + "tid t%x trunc(%d) = -1 (errno = %d)\n", + pvmmytid, fd, errno)); + else + dprintl((buf2, "tid t%x trunc(%d) = %ld\n", + pvmmytid, fd, len)); + return len; + } + + if ((len = (long)lseek(fd, (off_t)0, SEEK_CUR)) >= 0) { + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %ld", PvmDataDefault, nargs, fd, len); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + len = -1; + } + } + if (len == -1) + dprint((buf2, + "tid t%x trunc(%d) = -1 (errno = %d)\n", pvmmytid, + fd, errno)); + else + dprint((buf2, "tid t%x trunc(%d) = %d\n", pvmmytid, fd, len)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return len; + } + #endif + + int + truncate(const char *pathname, off_t len) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_TRUNCATE; + int nargs = 2; + long llen = len; + + if (pvmmyfstid <= 0) { + #ifdef IMA_CRAY + int fd; + + if ((syscall(SYS_access, pathname, F_OK)) == -1) { + errno = EINVAL; + cc = -1; + } else if ((fd = syscall(SYS_open, pathname, O_WRONLY)) == -1) { + errno = EACCES; + cc = -1; + } else if (syscall(SYS_lseek, fd, len, SEEK_SET) == -1) + cc = -1; + else { + cc = (trunc(fd) == -1) ? -1 : 0; + (void)syscall(SYS_close, fd); + } + #else + cc = syscall(SYS_truncate, pathname, len); + #endif + if (cc == -1) + dprintl((buf2, + "tid t%x truncate(\"%s\", %ld) = -1 (errno = %d)\n", + pvmmytid, pathname, (long)len, errno)); + else + dprintl((buf2, "tid t%x truncate(\"%s\", %ld) = %d\n", + pvmmytid, pathname, (long)len, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %ld", PvmDataDefault, nargs, pathname, llen); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x truncate(\"%s\", %ld) = -1 (pvmerrno = %d)\n", + pvmmytid, pathname, (long)len, pvmerrno)); + } else + dprint((buf2, "tid t%x truncate(\"%s\", %ld) = %d\n", + pvmmytid, pathname, (long)len, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _truncate(const char *pathname, off_t len) + { + return truncate(pathname, len); + } + + int + __truncate(const char *pathname, off_t len) + { + return truncate(pathname, len); + } + + #ifdef IMA_CNVXN + int + __ap$truncate(const char *pathname, off_t len) + { + return truncate(pathname, len); + } + #endif /* IMA_CNVXN */ + + int + ftruncate(int fd, off_t len) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_FTRUNCATE; + int nargs = 2; + long llen = len; + + if (pvmmyfstid <= 0) { + #ifdef IMA_CRAY + off_t current; + + current = syscall(SYS_lseek, fd, (off_t)0, SEEK_CUR); + if (syscall(SYS_lseek, fd, len, SEEK_SET) == -1) + cc = -1; + else { + cc = (trunc(fd) == -1) ? -1 : 0; + if (current != -1) + (void)syscall(SYS_lseek, fd, current, SEEK_SET); + } + #else + cc = syscall(SYS_ftruncate, fd, len); + #endif + if (cc == -1) + dprintl((buf2, + "tid t%x ftruncate(%d, %ld) = -1 (errno = %d)\n", + pvmmytid, fd, (long)len, errno)); + else + dprintl((buf2, "tid t%x ftruncate(%d, %ld) = %d\n", + pvmmytid, fd, (long)len, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %ld", PvmDataDefault, nargs, fd, llen); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x ftruncate(%d, %ld) = -1 (pvmerrno = %d)\n", pvmmytid, + fd, (long)len, pvmerrno)); + } else + dprint((buf2, "tid t%x ftruncate(%d, %ld) = %d\n", pvmmytid, fd, + (long)len, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _ftruncate(int fd, off_t len) + { + return ftruncate(fd, len); + } + + int + __ftruncate(int fd, off_t len) + { + return ftruncate(fd, len); + } + + #ifdef IMA_CNVXN + int + __ap$ftruncate(int fd, off_t len) + { + return ftruncate(fd, len); + } + #endif /* IMA_CNVXN */ + + mode_t + umask(mode_t mask) + { + int rbuf; + int sbuf; + int request = PVMFS_UMASK; + int nargs = 1; + long lmask = pvm_open_mode(mask); + mode_t oldmask; + + if (pvmmyfstid <= 0) { + oldmask = syscall(SYS_umask, mask); + dprintl((buf2, "tid t%x umask(%ld) = %ld\n", pvmmytid, + (long)mask, (long)oldmask)); + return oldmask; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %ld", PvmDataDefault, nargs, lmask); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%ld", &lmask); + oldmask = pvm_local_open_mode(lmask); + dprint((buf2, "tid t%x umask(%ld) = %d\n", pvmmytid, (long)mask, + (long)oldmask)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return oldmask; + } + + mode_t + _umask(mode_t mask) + { + return umask(mask); + } + + mode_t + __umask(mode_t mask) + { + return umask(mask); + } + + #ifdef IMA_CNVXN + mode_t + __ap$umask(mode_t mask) + { + return umask(mask); + } + #endif /* IMA_CNVXN */ + + int + utime(const char *pathname, const struct utimbuf *utp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_UTIME; + int nargs = 1; + long l1, l2; + + if (pvmmyfstid <= 0) { + #ifdef IMA_CRAY + cc = syscall(SYS_utime, pathname, utp); + #else + struct timeval tv[2]; + + tv[0].tv_usec = tv[1].tv_usec = 0; + if (utp) { + tv[0].tv_sec = utp->actime; + tv[1].tv_sec = utp->modtime; + } else + tv[0].tv_sec = tv[1].tv_sec = time(NULL); + cc = syscall(SYS_utimes, pathname, tv); + #endif + if (cc == -1) + dprintl((buf2, + "tid t%x utime(\"%s\", %p) = -1 (errno = %d)\n", + pvmmytid, pathname, utp, errno)); + else + dprintl((buf2, "tid t%x utime(\"%s\", %p) = %d\n", + pvmmytid, pathname, utp, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + + if (utp) { + nargs = 3; + l1 = utp->actime; + l2 = utp->modtime; + } + pvm_packf("%+ %d %s", PvmDataDefault, nargs, pathname); + if (nargs == 3) + pvm_packf("%ld %ld", l1, l2); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x utime(\"%s\", %p) = -1 (pvmerrno = %d)\n", pvmmytid, + pathname, utp, pvmerrno)); + } else + dprint((buf2, "tid t%x utime(\"%s\", %p) = %d\n", + pvmmytid, pathname, utp, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _utime(const char *pathname, const struct utimbuf *utp) + { + return utime(pathname, utp); + } + + int + __utime(const char *pathname, const struct utimbuf *utp) + { + return utime(pathname, utp); + } + + #ifdef IMA_CNVXN + int + __ap$utime(const char *pathname, const struct utimbuf *utp) + { + return utime(pathname, utp); + } + #endif /* IMA_CNVXN */ + + int + utimes(const char *pathname, struct timeval tv[2]) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_UTIMES; + int nargs = 5; + long l1, l2, l3, l4; + + if (pvmmyfstid <= 0) { + #ifdef IMA_CRAY + struct utimbuf ut; + + ut.actime = tv[0].tv_sec; + if (tv[0].tv_usec >= 500000) + ut.actime++; + ut.modtime = tv[1].tv_sec; + if (tv[1].tv_usec >= 500000) + ut.modtime++; + cc = syscall(SYS_utime, pathname, &ut); + #else + cc = syscall(SYS_utimes, pathname, tv); + #endif + if (cc == -1) + dprintl((buf2, + "tid t%x utimes(\"%s\", %p) = -1 (errno = %d)\n", + pvmmytid, pathname, tv, errno)); + else + dprintl((buf2, "tid t%x utimes(\"%s\", %p) = %d\n", + pvmmytid, pathname, tv, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + l1 = tv[0].tv_sec; + l2 = tv[0].tv_usec; + l3 = tv[1].tv_sec; + l4 = tv[1].tv_usec; + pvm_packf("%+ %d %s %ld %ld %ld %ld", PvmDataDefault, nargs, pathname, + l1, l2, l3, l4); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x utimes(\"%s\", %p) = -1 (pvmerrno = %d)\n", pvmmytid, + pathname, tv, pvmerrno)); + } else + dprint((buf2, "tid t%x utimes(\"%s\", %p) = %d\n", + pvmmytid, pathname, tv, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _utimes(const char *pathname, struct timeval tv[2]) + { + return utimes(pathname, tv); + } + + int + __utimes(const char *pathname, struct timeval tv[2]) + { + return utimes(pathname, tv); + } + + #ifdef IMA_CNVXN + int + __ap$utimes(const char *pathname, struct timeval tv[2]) + { + return utimes(pathname, tv); + } + #endif /* IMA_CNVXN */ + + void + sync(void) + { + int rbuf; + int sbuf; + int request = PVMFS_SYNC; + int nargs = 0; + + if (pvmmyfstid <= 0) { + syscall(SYS_sync); + dprintl((buf2, "tid t%x sync()\n")); + return; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d", PvmDataDefault, nargs); + pvm_send(pvmmyfstid, request); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + } + + void + _sync(void) + { + sync(); + } + + void + __sync(void) + { + sync(); + } + + #ifdef IMA_CNVXN + void + __ap$sync(void) + { + sync(); + } + #endif /* IMA_CNVXN */ + + int + fsync(int fd) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_FSYNC; + int nargs = 1; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_fsync, fd); + if (cc == -1) + dprintl((buf2, "tid t%x fsync(%d) = -1 (errno = %d)\n", + pvmmytid, fd, errno)); + else + dprintl((buf2, "tid t%x fsync(%d) = %d\n", + pvmmytid, fd, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x fsync(%d) = -1 (pvmerrno = %d)\n", + pvmmytid, fd, pvmerrno)); + } else + dprint((buf2, "tid t%x fsync(%d) = %d\n", pvmmytid, fd, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _fsync(int fd) + { + return fsync(fd); + } + + int + __fsync(int fd) + { + return fsync(fd); + } + + #ifdef IMA_CNVXN + int + __ap$fsync(int fd) + { + return fsync(fd); + } + #endif /* IMA_CNVXN */ + + int + access(const char *pathname, int mode) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_ACCESS; + int nargs = 2; + int pvmmode = pvm_access_mode(mode); + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_access, pathname, mode); + if (cc == -1) + dprintl((buf2, + "tid t%x access(\"%s\", %d) = -1 (errno = %d)\n", + pvmmytid, pathname, mode, errno)); + else + dprintl((buf2, "tid t%x access(\"%s\", %d) = %d\n", + pvmmytid, pathname, mode, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %s %d", PvmDataDefault, nargs, pathname, pvmmode); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x access(\"%s\", %d) = -1 (pvmerrno = %d)\n", pvmmytid, + pathname, mode, pvmerrno)); + } else + dprint((buf2, "tid t%x access(\"%s\", %d) = %d\n", pvmmytid, + pathname, mode, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _access(const char *pathname, int mode) + { + return access(pathname, mode); + } + + int + __access(const char *pathname, int mode) + { + return access(pathname, mode); + } + + #ifdef IMA_CNVXN + int + __ap$access(const char *pathname, int mode) + { + return access(pathname, mode); + } + #endif /* IMA_CNVXN */ + + int + select(SELECT_ARG1_TYPE maxfdp1, SELECT_SETP_TYPE rsetp, SELECT_SETP_TYPE wsetp, SELECT_SETP_TYPE esetp, struct timeval *tvp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_SELECT; + int nargs = tvp ? 5 : 4; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_select, maxfdp1, rsetp, wsetp, esetp, tvp); + if (cc == -1) + dprintl((buf2, + "tid t%x select(%d, ...) = -1 (errno = %d)\n", + pvmmytid, maxfdp1, errno)); + else + dprintl((buf2, "tid t%x select(%d, ...) = %d\n", + pvmmytid, maxfdp1, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, (int)maxfdp1); + pvm_select_fdset_pack(maxfdp1, rsetp); + pvm_select_fdset_pack(maxfdp1, wsetp); + pvm_select_fdset_pack(maxfdp1, esetp); + if (tvp) { + long l; + + l = tvp->tv_sec; pvm_packf("%ld", &l); + l = tvp->tv_usec; pvm_packf("%ld", &l); + } + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x select(%d, ...) = -1 (pvmerrno = %d)\n", + pvmmytid, maxfdp1, pvmerrno)); + } else if (cc > 0) { + if (rsetp) + pvm_select_fdset_unpack(rsetp); + if (wsetp) + pvm_select_fdset_unpack(wsetp); + if (esetp) + pvm_select_fdset_unpack(esetp); + dprint((buf2, "tid t%x select(%d, ...) = %d\n", pvmmytid, + maxfdp1, cc)); + } else + dprint((buf2, "tid t%x select(%d, ...) = %d\n", pvmmytid, + maxfdp1, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _select(SELECT_ARG1_TYPE maxfdp1, SELECT_SETP_TYPE rsetp, SELECT_SETP_TYPE wsetp, SELECT_SETP_TYPE esetp, struct timeval *tvp) + { + return select(maxfdp1, rsetp, wsetp, esetp, tvp); + } + + int + __select(SELECT_ARG1_TYPE maxfdp1, SELECT_SETP_TYPE rsetp, SELECT_SETP_TYPE wsetp, SELECT_SETP_TYPE esetp, struct timeval *tvp) + { + return select(maxfdp1, rsetp, wsetp, esetp, tvp); + } + + #ifdef IMA_CNVXN + int + __ap$select(SELECT_ARG1_TYPE maxfdp1, SELECT_SETP_TYPE rsetp, SELECT_SETP_TYPE wsetp, SELECT_SETP_TYPE esetp, struct timeval *tvp) + { + return select(maxfdp1, rsetp, wsetp, esetp, tvp); + } + #endif /* IMA_CNVXN */ + + int + getrlimit(int resource, struct rlimit *rlp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_GETRLIMIT; + int nargs = 1; + + if (pvmmyfstid <= 0 || (resource != RLIMIT_CORE + #ifdef RLIMIT_NOFILE + && resource != RLIMIT_NOFILE + #endif + #ifdef RLIMIT_OFILE + && resource != RLIMIT_OFILE + #endif + && resource != RLIMIT_FSIZE)) { + #ifdef IMA_CRAY + long lcc; + + switch (resource) { + case RLIMIT_CORE: + if ((lcc = limit(C_PROC, 0, L_CORE, -1)) == -1) + cc = -1; + else { + cc = 0; + rlp->rlim_cur = rlp->rlim_max = lcc * 4096; + } + break; + case RLIMIT_NOFILE: + if ((cc = openmax()) != -1) { + rlp->rlim_cur = rlp->rlim_max = cc; + cc = 0; + } + break; + case RLIMIT_FSIZE: + if ((lcc = ulimit(1, 0)) == -1) + cc = -1; + else { + cc = 0; + rlp->rlim_cur = rlp->rlim_max = lcc * 512; + } + break; + default: + cc = -1; + errno = ENOSYS; + break; + } + #else + cc = syscall(SYS_getrlimit, resource, rlp); + #endif + if (cc == -1) + dprintl((buf2, + "tid t%x getrlimit(%d, %p) = %d (errno = %d)\n", + pvmmytid, resource, (void *)rlp, cc, errno)); + else + dprintl((buf2, "tid t%x getrlimit(%d, %p) = %d\n", + pvmmytid, resource, (void *)rlp, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, + pvm_rlimit_resource(resource)); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x getrlimit(%d, %p) = %d (pvmerrno = %d)\n", pvmmytid, + resource, (void *)rlp, cc, pvmerrno)); + } else { + unsigned long ul; + int infinity; + + dprint((buf2, "tid t%x getrlimit(%d, %p) = %d\n", pvmmytid, + resource, (void *)rlp, cc)); + pvm_unpackf("%d", &infinity); + if (infinity) + rlp->rlim_cur = RLIM_INFINITY; + else { + pvm_upkulong(&ul, 1, 1); + rlp->rlim_cur = ul; + } + pvm_unpackf("%d", &infinity); + if (infinity) + rlp->rlim_max = RLIM_INFINITY; + else { + pvm_upkulong(&ul, 1, 1); + rlp->rlim_max = ul; + } + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _getrlimit(int resource, struct rlimit *rlp) + { + return getrlimit(resource, rlp); + } + + int + __getrlimit(int resource, struct rlimit *rlp) + { + return getrlimit(resource, rlp); + } + + #ifdef IMA_CNVXN + int + __ap$getrlimit(int resource, struct rlimit *rlp) + { + return getrlimit(resource, rlp); + } + #endif /* IMA_CNVXN */ + + int + setrlimit(int resource, SETRLIMIT_CONST struct rlimit *rlp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_SETRLIMIT; + int nargs = 3; + unsigned long ul; + + if (pvmmyfstid <= 0 || (resource != RLIMIT_CORE + #ifdef RLIMIT_NOFILE + && resource != RLIMIT_NOFILE + #endif + #ifdef RLIMIT_OFILE + && resource != RLIMIT_OFILE + #endif + && resource != RLIMIT_FSIZE)) { + #ifdef IMA_CRAY + long lcc; + + switch (resource) { + case RLIMIT_CORE: + lcc = limit(C_PROC, 0, L_CORE, (long)rlp->rlim_max + / 4096); + cc = (lcc == -1) ? -1 : 0; + break; + case RLIMIT_FSIZE: + lcc = ulimit(2, (long)rlp->rlim_max / 512); + cc = (lcc == -1) ? -1 : 0; + break; + case RLIMIT_NOFILE: + /* FALLTHROUGH */ + default: + cc = -1; + errno = ENOSYS; + break; + } + #else + cc = syscall(SYS_setrlimit, resource, rlp); + #endif + if (cc == -1) + dprintl((buf2, + "tid t%x setrlimit(%d, %p) = %d (errno = %d)\n", + pvmmytid, resource, (void *)rlp, cc, errno)); + else + dprintl((buf2, "tid t%x setrlimit(%d, %p) = %d\n", + pvmmytid, resource, (void *)rlp, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %d", PvmDataDefault, nargs, + pvm_rlimit_resource(resource), rlp->rlim_cur == RLIM_INFINITY); + if (rlp->rlim_cur != RLIM_INFINITY) { + ul = rlp->rlim_cur; + pvm_pkulong(&ul, 1, 1); + } + pvm_packf("%d", rlp->rlim_max == RLIM_INFINITY); + if (rlp->rlim_max != RLIM_INFINITY) { + ul = rlp->rlim_max; + pvm_pkulong(&ul, 1, 1); + } + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, + "tid t%x setrlimit(%d, %p <%lu, %lu>) = %d (pvmerrno = %d)\n", + pvmmytid, resource, (void *)rlp, (unsigned long)rlp->rlim_cur, + (unsigned long)rlp->rlim_max, cc, pvmerrno)); + } else + dprint((buf2, "tid t%x setrlimit(%d, %p <%lu, %lu>) = %d\n", + pvmmytid, resource, (void *)rlp, (unsigned long)rlp->rlim_cur, + (unsigned long)rlp->rlim_max, cc)); + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _setrlimit(int resource, SETRLIMIT_CONST struct rlimit *rlp) + { + return setrlimit(resource, rlp); + } + + int + __setrlimit(int resource, SETRLIMIT_CONST struct rlimit *rlp) + { + return setrlimit(resource, rlp); + } + + #ifdef IMA_CNVXN + int + __ap$setrlimit(int resource, SETRLIMIT_CONST struct rlimit *rlp) + { + return setrlimit(resource, rlp); + } + #endif /* IMA_CNVXN */ + + int + getdtablesize(void) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_GETDTABLESIZE; + int nargs = 0; + + if (pvmmyfstid <= 0) { + #ifdef SYS_getdtablesize + cc = syscall(SYS_getdtablesize); + #else + cc = openmax(); + #endif + if (cc == -1) + dprintl((buf2, + "tid t%x getdtablesize() = %d (errno = %d)\n", + pvmmytid, cc, errno)); + else + dprintl((buf2, "tid t%x getdtablesize() = %d\n", + pvmmytid, cc)); + return cc; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d", PvmDataDefault, nargs); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x getdtablesize() = %d (pvmerrno = %d)\n", + pvmmytid, cc, pvmerrno)); + } else + dprint((buf2, "tid t%x getdtablesize() = %d\n", pvmmytid, cc)); + + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _getdtablesize(void) + { + return getdtablesize(); + } + + int + __getdtablesize(void) + { + return getdtablesize(); + } + + #ifdef IMA_CNVXN + int + __ap$getdtablesize(void) + { + return getdtablesize(); + } + #endif /* IMA_CNVXN */ + + int + getdirentries(int fd, char *buf, int nbytes, long *basep) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_GETDIRENTRIES; + int nargs = 2; + + if (pvmmyfstid <= 0) { + #ifdef SYS_getdirentries + cc = syscall(SYS_getdirentries, fd, buf, nbytes, basep); + if (cc == -1) + dprintl((buf2, + "tid t%x getdirentries(%d, %p, %d, %p) = %d (errno = %d)\n", + pvmmytid, fd, (void *)buf, nbytes, (void *)basep, cc, + errno)); + else + dprintl((buf2, + "tid t%x getdirentries(%d, %p, %d, %p) = %d\n", + pvmmytid, fd, (void *)buf, nbytes, (void *)basep, + cc)); + return cc; + #endif + } + #if 1 + errno = ENOSYS; + return -1; + + #else + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d %d %ld", PvmDataDefault, nargs, fd, nbytes, *basep); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == -1) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprintl((buf2, + "tid t%x getdirentries(%d, %p, %d, %p) = %d (pvmerrno = %d)\n", + pvmmytid, fd, (void *)buf, nbytes, (void *)basep, cc, + pvmerrno)); + } else { + if (cc) { + /* ? */ + } + dprintl((buf2, "tid t%x getdirentries(%d, %p, %d, %p) = %d\n", + pvmmytid, fd, (void *)buf, nbytes, (void *)basep, cc, + pvmerrno)); + } + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + #endif + } + + int + _getdirentries(int fd, char *buf, int nbytes, long *basep) + { + return getdirentries(fd, buf, nbytes, basep); + } + + int + __getdirentries(int fd, char *buf, int nbytes, long *basep) + { + return getdirentries(fd, buf, nbytes, basep); + } + + #ifdef IMA_CNVXN + int + __ap$getdirentries(int fd, char *buf, int nbytes, long *basep) + { + return getdirentries(fd, buf, nbytes, basep); + } + #endif /* IMA_CNVXN */ + + int + isatty(int fd) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_ISATTY; + int nargs = 1; + + if (pvmmyfstid <= 0) { + struct winsize ws; + + return ioctl(fd, TIOCGWINSZ, &ws) == 0; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d %d", PvmDataDefault, nargs, fd); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == 0) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + dprint((buf2, "tid t%x isatty(%d) = %d (pvmerrno = %d)\n", + pvmmytid, fd, cc, pvmerrno)); + } else + dprint((buf2, "tid t%x isatty(%d) = %d\n", + pvmmytid, fd, cc)); + + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cc; + } + + int + _isatty(int fd) + { + return isatty(fd); + } + + int + __isatty(int fd) + { + return isatty(fd); + } + + #ifdef IMA_CNVXN + int + __ap$isatty(int fd) + { + return isatty(fd); + } + #endif /* IMA_CNVXN */ + + char * + ctermid(char *cp) + { + int cc; + int pvmerrno; + int rbuf; + int sbuf; + int request = PVMFS_CTERMID; + int nargs = 0; + static char *termid = NULL; + static char *saved = "/dev/tty"; + + if (termid) + free(termid); + + if (pvmmyfstid <= 0) { + if (cp) + return strcpy(cp, saved); + else + return saved; + } + + rbuf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + sbuf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + pvm_packf("%+ %d", PvmDataDefault, nargs); + pvm_send(pvmmyfstid, request); + pvm_recv(pvmmyfstid, request); + pvm_unpackf("%d", &cc); + if (cc == 0 || cp == NULL && (termid = malloc(cc + 1)) == NULL) { + if (cc == 0) { + pvm_unpackf("%d", &pvmerrno); + errno = pvm_local_errno(pvmerrno); + } + dprint((buf2, "tid t%x ctermid(%p) = \"\" (errno = %d)\n", + pvmmytid, (void *)cp, errno)); + } else { + pvm_unpackf("%s", cp ? cp : termid); + dprint((buf2, "tid t%x ctermid(%p) = %s\n", + pvmmytid, (void *)cp, cp ? cp : termid)); + } + + pvm_freebuf(pvm_setrbuf(rbuf)); + pvm_freebuf(pvm_setsbuf(sbuf)); + + return cp ? cp : termid; + } + + char * + _ctermid(char *cp) + { + return ctermid(cp); + } + + char * + __ctermid(char *cp) + { + return ctermid(cp); + } + + #ifdef IMA_CNVXN + char * + __ap$ctermid(char *cp) + { + return ctermid(cp); + } + #endif /* IMA_CNVXN */ + + /* + * With inspiration from Stevens' _Advanced Programming in the UNIX Environment_ + */ + + #undef MIN + #include + #include + #include + + #ifdef OPEN_MAX + static int result = OPEN_MAX; + #else + static int result = 0; + #endif + + static int + openmax(void) + { + if (result) + return result; + + if ((result = sysconf(_SC_OPEN_MAX)) == -1) + #ifdef NOFILE + result = NOFILE; + #else + result = 64; + #endif + + return result; + } + + #ifdef IMA_CNVXN + /* + * CONVEX functions for 64-bit file offsets. + * We make them fail unless they're in the 32-bit range. + */ + off64_t + lseek64(int fd, off64_t offset, int whence) + { + off64_t result; + long high; + long low; + + if (pvmmyfstid <= 0) { + result = (off64_t)syscall(SYS_lseek64, fd, offset, whence); + if (result == -1) + dprintl((buf2, + "tid t%x lseek64(%d, %ll, %d) = %ll (errno = %d)\n", + pvmmytid, fd, offset, whence, result, errno)); + else + dprintl((buf2, "tid t%x lseek64(%d, %ll, %d) = %ll\n", + pvmmytid, fd, offset, whence, result)); + return result; + } + + high = offset >> 32; + low = offset & 0xffffffff; + if (high) + result = -1; + else + result = lseek(fd, low, whence); + if (result == -1) + dprintl((buf2, + "tid t%x lseek64(%d, %ll, %d) = %ll (errno = %d)\n", + pvmmytid, fd, offset, whence, result, errno)); + else + dprintl((buf2, "tid t%x lseek64(%d, %ll, %d) = %ll\n", + pvmmytid, fd, offset, whence, result)); + + return result; + } + + int + truncate64(const char *pathname, off64_t len) + { + int cc; + long high; + long low; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_truncate64, pathname, len); + if (cc == -1) + dprintl((buf2, + "tid t%x truncate64(\"%s\", %ll) = %d (errno = %d)\n", + pvmmytid, pathname, len, cc, errno)); + else + dprintl((buf2, "tid t%x truncate64(\"%s\", %ll) = %d\n", + pvmmytid, pathname, len, cc)); + return cc; + } + + high = len >> 32; + low = len & 0xffffffff; + if (high) { + errno = EINVAL; + cc = -1; + } else + cc = truncate(pathname, low); + if (cc == -1) + dprintl((buf2, + "tid t%x truncate64(\"%s\", %ll) = %d (errno = %d)\n", + pvmmytid, pathname, len, cc, errno)); + else + dprintl((buf2, "tid t%x truncate64(\"%s\", %ll) = %d\n", + pvmmytid, pathname, len, cc)); + + return cc; + } + + int + ftruncate64(int fd, off64_t len) + { + int cc; + long high; + long low; + + if (pvmmyfstid <= 0) { + cc = syscall(SYS_ftruncate64, fd, len); + if (cc == -1) + dprintl((buf2, + "tid t%x ftruncate64(%d, %ll) = %d (errno = %d)\n", + pvmmytid, fd, len, cc, errno)); + else + dprintl((buf2, "tid t%x ftruncate64(%d, %ll) = %d\n", + pvmmytid, fd, len, cc)); + return cc; + } + + high = len >> 32; + low = len & 0xffffffff; + if (high) { + errno = EINVAL; + cc = -1; + } else + cc = ftruncate(fd, low); + if (cc == -1) + dprintl((buf2, + "tid t%x ftruncate64(%d, %ll) = %d (errno = %d)\n", + pvmmytid, fd, len, cc, errno)); + else + dprintl((buf2, "tid t%x ftruncate64(%d, %ll) = %d\n", + pvmmytid, fd, len, cc)); + + return cc; + } + #endif /* IMA_CNVXN */ *** pvm3.ornl/libfpvm/Makefile.aimk Fri Aug 26 14:33:13 1994 --- libfpvm/Makefile.aimk Mon Jul 25 14:53:50 1994 *************** *** 4,10 **** SHELL = /bin/sh SDIR = .. ! CFLAGS = -g -D$(PVM_ARCH) -c $(ARCHCFLAGS) -I$(SDIR) -I$(SDIR)/../include $(CDEBUGFLAGS) RM = rm -f M4 = m4 FORTRAN=`case "$(FC)@$(F77)" in *@) echo $(FC) ;; @*) echo $(F77) ;; *) echo f77;; esac` --- 4,10 ---- SHELL = /bin/sh SDIR = .. ! CFLAGS = -g -D$(PVM_ARCH) -c $(ARCHCFLAGS) -I$(SDIR) -I$(SDIR)/../include $(CDEBUGFLAGS) -DPVMFS RM = rm -f M4 = m4 FORTRAN=`case "$(FC)@$(F77)" in *@) echo $(FC) ;; @*) echo $(F77) ;; *) echo f77;; esac` *************** *** 21,28 **** --- 21,32 ---- pvmfdelhost.o \ pvmfexit.o \ pvmffreebuf.o \ + pvmffstid.o \ pvmfgather.o \ + pvmfgetdef.o \ pvmfgetinst.o \ + pvmfgetiomode.o \ + pvmfgetioord.o \ pvmfgetopt.o \ pvmfgetrbuf.o \ pvmfgetsbuf.o \ *************** *** 52,57 **** --- 56,64 ---- pvmfscatter.o \ pvmfsend.o \ pvmfsendsig.o \ + pvmfsetdef.o \ + pvmfsetiomode.o \ + pvmfsetioord.o \ pvmfsetopt.o \ pvmfsetrbuf.o \ pvmfsetsbuf.o \ *************** *** 59,65 **** pvmftasks.o \ pvmftidtoh.o \ pvmftrecv.o \ ! pvmfunpack.o default: libfpvm3.a --- 66,73 ---- pvmftasks.o \ pvmftidtoh.o \ pvmftrecv.o \ ! pvmfunpack.o \ ! pvmfusefs.o default: libfpvm3.a *************** *** 121,134 **** --- 129,158 ---- $(M4) $(M4FILE) $(SDIR)/pvmffreebuf.m4 > pvmffreebuf.c $(CC) $(CFLAGS) pvmffreebuf.c $(RM) pvmffreebuf.c + pvmffstid.o: $(SDIR)/pvmffstid.m4 $(M4FILE) + $(M4) $(M4FILE) $(SDIR)/pvmffstid.m4 > pvmffstid.c + $(CC) $(CFLAGS) pvmffstid.c + $(RM) pvmffstid.c pvmfgather.o: $(SDIR)/pvmfgather.m4 $(M4FILE) $(M4) $(M4FILE) $(SDIR)/pvmfgather.m4 > pvmfgather.c $(CC) $(CFLAGS) pvmfgather.c $(RM) pvmfgather.c + pvmfgetdef.o: $(SDIR)/pvmfgetdef.m4 $(M4FILE) + $(M4) $(M4FILE) $(SDIR)/pvmfgetdef.m4 > pvmfgetdef.c + $(CC) $(CFLAGS) pvmfgetdef.c + $(RM) pvmfgetdef.c pvmfgetinst.o: $(SDIR)/pvmfgetinst.m4 $(M4FILE) $(M4) $(M4FILE) $(SDIR)/pvmfgetinst.m4 > pvmfgetinst.c $(CC) $(CFLAGS) pvmfgetinst.c $(RM) pvmfgetinst.c + pvmfgetiomode.o: $(SDIR)/pvmfgetiomode.m4 $(M4FILE) + $(M4) $(M4FILE) $(SDIR)/pvmfgetiomode.m4 > pvmfgetiomode.c + $(CC) $(CFLAGS) pvmfgetiomode.c + $(RM) pvmfgetiomode.c + pvmfgetioord.o: $(SDIR)/pvmfgetioord.m4 $(M4FILE) + $(M4) $(M4FILE) $(SDIR)/pvmfgetioord.m4 > pvmfgetioord.c + $(CC) $(CFLAGS) pvmfgetioord.c + $(RM) pvmfgetioord.c pvmfgetopt.o: $(SDIR)/pvmfgetopt.m4 $(M4FILE) $(M4) $(M4FILE) $(SDIR)/pvmfgetopt.m4 > pvmfgetopt.c $(CC) $(CFLAGS) pvmfgetopt.c *************** *** 245,250 **** --- 269,286 ---- $(M4) $(M4FILE) $(SDIR)/pvmfsendsig.m4 > pvmfsendsig.c $(CC) $(CFLAGS) pvmfsendsig.c $(RM) pvmfsendsig.c + pvmfsetdef.o: $(SDIR)/pvmfsetdef.m4 $(M4FILE) + $(M4) $(M4FILE) $(SDIR)/pvmfsetdef.m4 > pvmfsetdef.c + $(CC) $(CFLAGS) pvmfsetdef.c + $(RM) pvmfsetdef.c + pvmfsetiomode.o: $(SDIR)/pvmfsetiomode.m4 $(M4FILE) + $(M4) $(M4FILE) $(SDIR)/pvmfsetiomode.m4 > pvmfsetiomode.c + $(CC) $(CFLAGS) pvmfsetiomode.c + $(RM) pvmfsetiomode.c + pvmfsetioord.o: $(SDIR)/pvmfsetioord.m4 $(M4FILE) + $(M4) $(M4FILE) $(SDIR)/pvmfsetioord.m4 > pvmfsetioord.c + $(CC) $(CFLAGS) pvmfsetioord.c + $(RM) pvmfsetioord.c pvmfsetopt.o: $(SDIR)/pvmfsetopt.m4 $(M4FILE) $(M4) $(M4FILE) $(SDIR)/pvmfsetopt.m4 > pvmfsetopt.c $(CC) $(CFLAGS) pvmfsetopt.c *************** *** 277,279 **** --- 313,319 ---- $(M4) $(M4FILE) $(SDIR)/pvmfunpack.m4 > pvmfunpack.c $(CC) $(CFLAGS) pvmfunpack.c $(RM) pvmfunpack.c + pvmfusefs.o: $(SDIR)/pvmfusefs.m4 $(M4FILE) + $(M4) $(M4FILE) $(SDIR)/pvmfusefs.m4 > pvmfusefs.c + $(CC) $(CFLAGS) pvmfusefs.c + $(RM) pvmfusefs.c *** /dev/null Thu Aug 25 19:19:25 1994 --- libfpvm/pvmffstid.m4 Mon Jul 25 14:13:58 1994 *************** *** 0 **** --- 1,13 ---- + #ifdef PVMFS + + #include "pvm3.h" + #include "pvm_consts.h" + + void + FUNCTION(pvmffstid) ARGS(`info') + int *info; + { + *info = pvm_fstid(); + } + + #endif *** /dev/null Thu Aug 25 19:19:25 1994 --- libfpvm/pvmfgetdef.m4 Mon Jul 25 14:13:58 1994 *************** *** 0 **** --- 1,13 ---- + #ifdef PVMFS + + #include "pvm3.h" + #include "pvm_consts.h" + + void + FUNCTION(pvmfgetdefiomode) ARGS(`info') + int *info; + { + *info = pvm_getdefiomode(); + } + + #endif *** /dev/null Thu Aug 25 19:19:25 1994 --- libfpvm/pvmfgetiomode.m4 Mon Jul 25 14:13:58 1994 *************** *** 0 **** --- 1,13 ---- + #ifdef PVMFS + + #include "pvm3.h" + #include "pvm_consts.h" + + void + FUNCTION(pvmfgetiomode) ARGS(`fd, info') + int *fd, *info; + { + *info = pvm_getiomode(*fd); + } + + #endif *** /dev/null Thu Aug 25 19:19:25 1994 --- libfpvm/pvmfgetioord.m4 Mon Jul 25 14:13:58 1994 *************** *** 0 **** --- 1,13 ---- + #ifdef PVMFS + + #include "pvm3.h" + #include "pvm_consts.h" + + void + FUNCTION(pvmfgetioorder) ARGS(`info') + int *info; + { + *info = pvm_getioorder(); + } + + #endif *** /dev/null Thu Aug 25 19:19:25 1994 --- libfpvm/pvmfsetdef.m4 Mon Jul 25 14:13:58 1994 *************** *** 0 **** --- 1,13 ---- + #ifdef PVMFS + + #include "pvm3.h" + #include "pvm_consts.h" + + void + FUNCTION(pvmfsetdefiomode) ARGS(`mode, info') + int *mode, *info; + { + *info = pvm_setdefiomode(*mode); + } + + #endif *** /dev/null Thu Aug 25 19:19:25 1994 --- libfpvm/pvmfsetiomode.m4 Mon Jul 25 14:13:58 1994 *************** *** 0 **** --- 1,13 ---- + #ifdef PVMFS + + #include "pvm3.h" + #include "pvm_consts.h" + + void + FUNCTION(pvmfsetiomode) ARGS(`fd, mode, info') + int *fd, *mode, *info; + { + *info = pvm_setiomode(*fd, *mode); + } + + #endif *** /dev/null Thu Aug 25 19:19:25 1994 --- libfpvm/pvmfsetioord.m4 Mon Jul 25 14:13:58 1994 *************** *** 0 **** --- 1,13 ---- + #ifdef PVMFS + + #include "pvm3.h" + #include "pvm_consts.h" + + void + FUNCTION(pvmfsetioorder) ARGS(`fd, info') + int *fd, *info; + { + *info = pvm_setioorder(*fd); + } + + #endif *** /dev/null Thu Aug 25 19:19:25 1994 --- libfpvm/pvmfusefs.m4 Mon Jul 25 14:13:58 1994 *************** *** 0 **** --- 1,13 ---- + #ifdef PVMFS + + #include "pvm3.h" + #include "pvm_consts.h" + + void + FUNCTION(pvmfusefs) ARGS(`on, info') + int *on, *info; + { + *info = pvm_usefs(*on); + } + + #endif *** /dev/null Thu Aug 25 19:19:25 1994 --- man/man1/pvmfs_intro.1 Mon Jul 25 16:20:40 1994 *************** *** 0 **** --- 1,119 ---- + .TH PVMFS_INTRO 1PVM "December 17, 1993" + .SH NAME + PVMFS \- PVM File Server + .SH DESCRIPTION + .I PVMFS + is a PVM task process which facilitates I/O for programs utilizing + the Parallel Virtual Machine system (see pvm(1PVM)). + The file server presents a common file system and support for coordinated I/O + to its parent and siblings. + .SH DISCUSSION + .LP + When a parentless PVM process first obtains a task ID, a file server + with the same open file descriptors is initiated, providing the process has + requested it by previously calling the + .BR pvm_usefs () + function. + PVM processes spawned by this PVM process inherit the same file server. + .LP + Each open file descriptor has a + .I mode + associated with it. Five modes are + supported: + .IP PvmIomodeIndividual + Only one process opens the file. + The file descriptor is known only to that process. + .IP PvmIomodeCommon + All processes may open the file. + The file descriptor is known to all processes and the file offset is shared. + .IP PvmIomodeIndependent + All processes may open the file. + The file descriptor is known to all processes but each maintains its + own idea of the file offset. + .IP PvmIomodeSyncBC + All processes must open the file + and take part in reads and writes. + For reading, all processes receive the same data. + For writing, only the process whose I/O order is 0 actually writes anything. + .IP PvmIomodeSyncSeq + All processes must open the file + and take part in reads and writes. + For both reading and writing, processes' requests are performed in I/O order. + .LP + An open file descriptor's mode may be obtained using + .B pvm_getiomode () + and changed using + .B pvm_setiomode (). + A file descriptor returned by a successful call to + .B open () + or + .B creat () + receives its process' current default I/O mode. + This default I/O mode may be found using + .B pvm_getdefiomode () + and changed with + .B pvm_setdefiomode (). + .LP + File descriptors open at program invocation initially have I/O mode + PvmIomodeCommon except for standard input and those opened only for reading. + These descriptors have mode PvmIomodeSyncBC. + .LP + Among the parent and children, each process has a unique I/O order + used as discussed above. + The I/O orders taken together should comprise the set of ascending + consecutive integers starting from 0. + A process' I/O order can be found with + .B pvm_getioorder () + and changed with + .B pvm_setioorder (). + .SH NOTES + .LP + The file server assumes that only PVM processes that it knows about + participate in global operations. + For this reason, global synchronization should be done before any + global operations are attempted. + .SH "SUPPORTED ARCHITECTURES + The file server has been ported to the following architectures: + .RS + .PD 0 + .TP 10 + ALPHA + DEC Alpha/OSF-1 + .TP + CNVXN + Convex using native f.p. + .TP + CRAY + Cray + .TP + PMAX + DEC/Mips arch (3100, 5000, etc.) + .TP + RS6K + IBM/RS6000 + .TP + SUN4 + Sun 4, 4c, sparc, etc. + .PD + .RE + .SH BUGS + .LP + The file server is not multithreaded and so may block indefinitely + in a slow read. + .LP + It is possible to deadlock the file server much as any incorrect + parallel program may deadlock. + .SH "SEE ALSO + .B pvm (1PVM), + .B pvm_getdefiomode (3PVM), + .B pvm_getiomode (3PVM), + .B pvm_getioorder (3PVM), + .B pvm_setdefiomode (3PVM), + .B pvm_setiomode (3PVM), + .B pvm_setioorder (3PVM), + .B pvm_usefs (3PVM). + .SH AUTHOR + .LP + .nf + Christopher G. Phillips + pefv700@utpe.pe.utexas.edu *** /dev/null Thu Aug 25 19:19:25 1994 --- man/man3/pvm_getdefiomode.3 Mon Jul 25 16:22:04 1994 *************** *** 0 **** --- 1,36 ---- + .TH GETDEFIOMODE 3PVM "November 9, 1993" + .SH NAME + pvm_getdefiomode \- Get current default I/O mode + .SH SYNOPSIS + .LP + .nf + .ft B + int pvm_getdefiomode(void); + .ft + .fi + .LP + .nf + .ft B + Fortran call pvmfgetdefiomode(defiomode) + .ft + .fi + .SH DISCUSSION + The routine + .I pvm_getdefiomode + returns a process' current default I/O mode. + Newly obtained file descriptors receive this mode. + .SH EXAMPLES + .nf + C: + int defiomode = pvm_getdefiomode(); + Fortran: + INTEGER DEFIOMODE + CALL PVMFGETDEFIOMODE(DEFIOMODE) + .SH ERRORS + This error condition can be returned + .ta 0.5i 2.0i + .nf + PvmNoFileServer process does not have a file server. + .fi + .SH "SEE ALSO + setiomode(3PVM). *** /dev/null Thu Aug 25 19:19:25 1994 --- man/man3/pvm_getiomode.3 Mon Jul 25 16:22:04 1994 *************** *** 0 **** --- 1,37 ---- + .TH GETIOMODE 3PVM "November 9, 1993" + .SH NAME + pvm_getiomode \- Get I/O mode of an open file descriptor + .SH SYNOPSIS + .LP + .nf + .ft B + int pvm_getiomode(int fd); + .ft + .fi + .LP + .nf + .ft B + Fortran call pvmfgetiomode(fd, iomode) + .ft + .fi + .SH DISCUSSION + The routine + .I pvm_getiomode + returns the I/O mode of an open file descriptor. + .SH EXAMPLES + .nf + C: + int fd; + int iomode = pvm_getiomode(fd); + Fortran: + INTEGER FD, IOMODE + CALL PVMFGETIOMODE(FD, IOMODE) + .SH ERRORS + This error condition can be returned + .ta 0.5i 2.0i + .nf + PvmNoFileServer process does not have a file server. + PvmBadParam file descriptor is not valid. + .fi + .SH "SEE ALSO + setiomode(3PVM). *** /dev/null Thu Aug 25 19:19:25 1994 --- man/man3/pvm_getioorder.3 Mon Jul 25 16:22:04 1994 *************** *** 0 **** --- 1,35 ---- + .TH GETIOORDER 3PVM "November 9, 1993" + .SH NAME + pvm_getioorder \- Get process' I/O order + .SH SYNOPSIS + .LP + .nf + .ft B + int pvm_getioorder(void); + .ft + .fi + .LP + .nf + .ft B + Fortran call pvmfgetioorder(ioorder) + .ft + .fi + .SH DISCUSSION + The routine + .I pvm_getioorder + returns the I/O order of the calling process. + .SH EXAMPLES + .nf + C: + int ioorder = pvm_getioorder(); + Fortran: + INTEGER IOORDER + CALL PVMFGETIOORDER(IOORDER) + .SH ERRORS + This error condition can be returned + .ta 0.5i 2.0i + .nf + PvmNoFileServer process does not have a file server. + .fi + .SH "SEE ALSO + setioorder(3PVM). *** /dev/null Thu Aug 25 19:19:25 1994 --- man/man3/pvm_setdefiomode.3 Mon Jul 25 16:22:04 1994 *************** *** 0 **** --- 1,38 ---- + .TH SETDEFIOMODE 3PVM "November 9, 1993" + .SH NAME + pvm_setdefiomode \- Get current default I/O mode + .SH SYNOPSIS + .LP + .nf + .ft B + int pvm_setdefiomode(int newdefiomode); + .ft + .fi + .LP + .nf + .ft B + Fortran call pvmfsetdefiomode(newdefiomode, info) + .ft + .fi + .SH DISCUSSION + The routine + .I pvm_setdefiomode + sets a process' current default I/O mode to + .I newdefiomode . + Newly obtained file descriptors will receive this mode. + .SH EXAMPLES + .nf + C: + int info = pvm_setdefiomode(PvmIomodeIndividual); + Fortran: + INTEGER INFO + CALL PVMFSETDEFIOMODE(PVMIOMODEINDIVIDUAL, INFO) + .SH ERRORS + These error conditions can be returned + .ta 0.5i 2.0i + .nf + PvmNoFileServer process does not have a file server. + PvmBadParam new default I/O mode is not valid. + .fi + .SH "SEE ALSO + getiomode(3PVM). *** /dev/null Thu Aug 25 19:19:25 1994 --- man/man3/pvm_setiomode.3 Mon Jul 25 16:22:04 1994 *************** *** 0 **** --- 1,38 ---- + .TH SETDEFIOMODE 3PVM "November 9, 1993" + .SH NAME + pvm_setiomode \- Get I/O mode of a file descriptor + .SH SYNOPSIS + .LP + .nf + .ft B + int pvm_setiomode(int fd, int iomode); + .ft + .fi + .LP + .nf + .ft B + Fortran call pvmfsetiomode(fd, iomode, info) + .ft + .fi + .SH DISCUSSION + The routine + .I pvm_setiomode + sets an open file descriptor's I/O mode to + .I iomode . + .SH EXAMPLES + .nf + C: + int fd; + int info = pvm_setiomode(fd, PvmIomodeIndividual); + Fortran: + INTEGER FD, INFO + CALL PVMFSETIOMODE(FD, PVMIOMODEINDIVIDUAL, INFO) + .SH ERRORS + These error conditions can be returned + .ta 0.5i 2.0i + .nf + PvmNoFileServer process does not have a file server. + PvmBadParam new I/O mode is not valid. + .fi + .SH "SEE ALSO + getiomode(3PVM). *** /dev/null Thu Aug 25 19:19:25 1994 --- man/man3/pvm_setioorder.3 Mon Jul 25 16:22:04 1994 *************** *** 0 **** --- 1,36 ---- + .TH SETIOORDER 3PVM "November 9, 1993" + .SH NAME + pvm_setioorder \- Set process' I/O order + .SH SYNOPSIS + .LP + .nf + .ft B + int pvm_setioorder(int ioorder); + .ft + .fi + .LP + .nf + .ft B + Fortran call pvmfsetioorder(ioorder, info) + .ft + .fi + .SH DISCUSSION + The routine + .I pvm_setioorder + sets the I/O order of the calling process. + .SH EXAMPLES + .nf + C: + int info = pvm_setioorder(ioorder); + Fortran: + INTEGER IOORDER, INFO + CALL PVMFSETIOORDER(IOORDER, INFO) + .SH ERRORS + This error condition can be returned + .ta 0.5i 2.0i + .nf + PvmNoFileServer process does not have a file server. + PvmBadParam I/O order is not valid. + .fi + .SH "SEE ALSO + getioorder(3PVM). *** /dev/null Thu Aug 25 19:19:25 1994 --- man/man3/pvm_usefs.3 Mon Jul 25 16:22:04 1994 *************** *** 0 **** --- 1,44 ---- + .TH USEFS 3PVM "November 9, 1993" + .SH NAME + pvm_usefs \- Specify if a file server task is desired + .SH SYNOPSIS + .LP + .nf + .ft B + int pvm_usefs(int on); + .ft + .fi + .LP + .nf + .ft B + Fortran call pvmfusefs(on, info) + .ft + .fi + .SH DISCUSSION + The routine + .I pvm_usefs + specifies whether a file server task is desired for the calling process. + If argument + .I on + is nonzero, file service is desired. + .LP + To obtain a file server, this function must be called before + a task ID is obtained. + .SH EXAMPLES + .nf + C: + int info = pvm_usefs(1); + Fortran: + INTEGER INFO + CALL PVMFUSEFS(1, INFO) + .SH ERRORS + This error condition can be returned + .ta 0.5i 2.0i + .nf + PvmNoFileServer on is false and process does not + have a file server. + PvmAlready on is true and process already + has a file server. + PvmCantStart on is true and process already has + a task id but does not have a file server. + .fi *** /dev/null Thu Aug 25 19:19:25 1994 --- pvmfs/Makefile.aimk Tue Jul 26 17:09:52 1994 *************** *** 0 **** --- 1,38 ---- + # Imports: + # PVM_ARCH = the official pvm-name of your processor + # ARCHCFLAGS = special cc flags + # ARCHLIB = special libs needed for daemon + # + SHELL = /bin/sh + SDIR = .. + IDIR = ../../libc + PVMIDIR = ../../include + PVMLDIR = ../../lib/$(PVM_ARCH) + PVMFSLDIR= ../../libc/$(PVM_ARCH) + PVMLIB = -lpvm3 + CFLAGS = -g -I$(SDIR) -I$(PVMIDIR) -DIMA_$(PVM_ARCH) $(ARCHCFLAGS) -DPVMFS -I$(IDIR) -I$(IDIR)/$(PVM_ARCH) -DTRACE #-DDEBUG + LIBS = -L$(PVMLDIR) $(PVMLIB) $(ARCHLIB) $(ARCHFSLIB) + OBJS = gop.o lmap.o fs.o fspro.o $(PVMFSLDIR)/syscalls.o $(PVMFSLDIR)/pvmerrno.o + + install: srclibc pvmfs + -@rm -f $(PVMLDIR)/pvmfs + -@ln -s `pwd`/pvmfs $(PVMLDIR) + + srclibc: + cd ../../src; ../lib/aimk install + cd ../../libc; ../lib/aimk install + + pvmfs: $(OBJS) $(PVMLDIR)/libpvm3.a + $(SCC) -o pvmfs $(OBJS) $(LIBS) + + lmap.o: $(SDIR)/lmap.c $(SDIR)/map.h $(IDIR)/fs.h + $(SCC) $(CFLAGS) -c $(SDIR)/$(@:.o=.c) + fs.o: $(SDIR)/fs.c $(IDIR)/fs.h $(IDIR)/fsp.h $(SDIR)/map.h + $(SCC) $(CFLAGS) -c $(SDIR)/$(@:.o=.c) + gop.o: $(SDIR)/gop.c $(IDIR)/fs.h $(IDIR)/fsp.h $(SDIR)/map.h $(SDIR)/bitops.h + $(SCC) $(CFLAGS) -c $(SDIR)/$(@:.o=.c) + fspro.o: $(SDIR)/fspro.c $(IDIR)/fs.h $(IDIR)/fsp.h $(SDIR)/map.h $(SDIR)/bitops.h + $(SCC) $(CFLAGS) -c $(SDIR)/$(@:.o=.c) + + clean: + rm -f pvmfs gop.o lmap.o fs.o fspro.o *** /dev/null Thu Aug 25 19:19:25 1994 --- pvmfs/bitops.h Sun Jul 24 18:25:04 1994 *************** *** 0 **** --- 1,28 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #ifndef BITOPS_H + #define BITOPS_H + + #include + + #define setbit(a,b) ((a)[(b) / CHAR_BIT] |= 1 << ((b) % CHAR_BIT)) + #define clrbit(a,b) ((a)[(b) / CHAR_BIT] &= ~(1 << ((b) % CHAR_BIT))) + #define isset(a,b) ((a)[(b) / CHAR_BIT] & (1 << ((b) % CHAR_BIT))) + #define isclr(a,b) (((a)[(b) / CHAR_BIT] & (1 << ((b) % CHAR_BIT))) == 0) + + #endif *** /dev/null Thu Aug 25 19:19:25 1994 --- pvmfs/fs.c Sun Jul 24 18:25:04 1994 *************** *** 0 **** --- 1,507 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #include + #include + #include + #include + #include + #include + #include + #include "fsp.h" + #include "map.h" + + #if !defined(IMA_RS6K) && !defined(IMA_CRAY) + #include + #else + #include "syscall-fake.h" + #endif + + #ifdef TRACE + /* + * Debugging stuff follows. You can get a neat trace using these + * (although they can mess up errno). This stuff could be taken out + * if warranted. + */ + + extern int pvmdebug; + + #define dprint(s) do { \ + if (pvmdebug) { \ + sprintf s; \ + syscall(SYS_write, 2, buf2, \ + strlen(buf2)); \ + } \ + } while (0) + + char buf2[BUFSIZ]; + + #else + #define dprint(s) + #endif + + extern size_t nummapsused; + + int mytid; + extern int pvm_errno; + + extern struct lmap *lmap_add __ProtoGlarp__((int)); + extern struct lmap *lmap_find __ProtoGlarp__((int)); + extern void lmap_delete __ProtoGlarp__((int)); + extern int lmap_init __ProtoGlarp__((int, int, int)); + + #define FS_ARGS __ProtoGlarp__((struct lmap *, int, int, int)) + + extern void fs_open FS_ARGS; + extern void fs_close FS_ARGS; + extern void fs_lseek FS_ARGS; + extern void fs_read FS_ARGS; + extern void fs_write FS_ARGS; + extern void fs_dup FS_ARGS; + extern void fs_setioorder FS_ARGS; + extern void fs_getioorder FS_ARGS; + extern void fs_setiomode FS_ARGS; + extern void fs_getiomode FS_ARGS; + extern void fs_stat FS_ARGS; + extern void fs_fstat FS_ARGS; + extern void fs_lstat FS_ARGS; + extern void fs_fcntl FS_ARGS; + extern void fs_unlink FS_ARGS; + extern void fs_rename FS_ARGS; + extern void fs_mkdir FS_ARGS; + extern void fs_rmdir FS_ARGS; + extern void fs_chroot FS_ARGS; + extern void fs_chdir FS_ARGS; + extern void fs_fchdir FS_ARGS; + extern void fs_fchroot FS_ARGS; + extern void fs_chmod FS_ARGS; + extern void fs_fchmod FS_ARGS; + extern void fs_chown FS_ARGS; + extern void fs_fchown FS_ARGS; + extern void fs_lchown FS_ARGS; + extern void fs_link FS_ARGS; + extern void fs_symlink FS_ARGS; + extern void fs_mkfifo FS_ARGS; + extern void fs_mknod FS_ARGS; + extern void fs_pipe FS_ARGS; + extern void fs_readlink FS_ARGS; + extern void fs_truncate FS_ARGS; + extern void fs_ftruncate FS_ARGS; + extern void fs_umask FS_ARGS; + extern void fs_utime FS_ARGS; + extern void fs_utimes FS_ARGS; + extern void fs_sync FS_ARGS; + extern void fs_fsync FS_ARGS; + extern void fs_access FS_ARGS; + extern void fs_select FS_ARGS; + extern void fs_opendir FS_ARGS; + extern void fs_readdir FS_ARGS; + extern void fs_closedir FS_ARGS; + extern void fs_rewinddir FS_ARGS; + extern void fs_isatty FS_ARGS; + extern void fs_ttyname FS_ARGS; + extern void fs_ctermid FS_ARGS; + extern void fs_tcdrain FS_ARGS; + extern void fs_tcflow FS_ARGS; + extern void fs_tcflush FS_ARGS; + extern void fs_tcsendbreak FS_ARGS; + extern void fs_pathconf FS_ARGS; + extern void fs_fpathconf FS_ARGS; + extern void fs_getrlimit FS_ARGS; + extern void fs_setrlimit FS_ARGS; + extern void fs_getdtablesize FS_ARGS; + extern void fs_getdirentries FS_ARGS; + extern void fs_getcwd FS_ARGS; + extern void fs_seekdir FS_ARGS; + extern void fs_telldir FS_ARGS; + + int + main(int argc, char **argv) + { + int fsver = FSPROTOCOL; + int authfd; + int bufid; + int request; + int nargs; + int requestor; + int parents_sock; + int iresult; + struct lmap *lmp; + int pfd[2]; + #ifdef TRACE + #ifdef DEBUG + pvmdebug = 1; + #endif + #endif + + #ifdef DEBUG + if (argc != 2) { + #else + if (argc != 5) { + #endif + fprintf(stderr, + #ifdef DEBUG + "Usage: fs tmpfilename\n"); + #else + "Usage: fs tmpfilename parents_sock pfd[0] pfd[1]\n"); + #endif + exit(1); + } + if ((authfd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0600)) + == -1) { + fprintf(stderr, "fs: can't open %s\n", argv[1]); + exit(1); + } + + #ifdef DEBUG + #define PIPE "/tmp/fspipe" + if ((pfd[1] = open(PIPE, O_WRONLY)) == -1 + || (pfd[0] = open(PIPE, O_RDONLY)) == -1) { + perror(PIPE); + exit(1); + } + #else + + /* + * Get file descriptors from the arguments. + * Close parent's pvm socket. + */ + if ((parents_sock = atoi(argv[2])) < 0) { + fprintf(stderr, "fs: parents_sock == %s???\n", argv[2]); + exit(1); + } + (void)close(parents_sock); + if ((pfd[0] = atoi(argv[3])) < 0) { + fprintf(stderr, "fs: pipe read descriptor == %s???\n", argv[3]); + exit(1); + } + if ((pfd[1] = atoi(argv[4])) < 0) { + fprintf(stderr, "fs: pipe write descriptor == %s???\n", + argv[4]); + exit(1); + } + #endif + + /* + * Figure out what file descriptors are initially valid. + */ + if (lmap_init(pfd[0], pfd[1], authfd) == -1) { + perror("fs: can't lmap_init\n"); + exit(1); + } + + if ((mytid = pvm_mytid()) < 0) { + pvm_perror("fs: pvm_mytid"); + exit(1); + } + + /* + * Tell parent our tid via authfd + * and then wake up the parent by writing to the pipe. + */ + if (write(authfd, &mytid, sizeof mytid) == -1) { + fprintf(stderr, "fs: can't write to fd-auth file %s\n", + argv[1]); + exit(1); + } + if (write(pfd[1], &fsver, sizeof fsver) != sizeof fsver) { + pvm_perror("fs: can't continue parent"); + exit(1); + } + + /* + * Close the pipe descriptors and the authfd used for handshaking. + */ + (void)close(pfd[0]); + (void)close(pfd[1]); + (void)close(authfd); + + dprint((buf2, "fs: my tid is %d\n", mytid)); + + (void)signal(SIGHUP, SIG_IGN); + + while (1) { + /* + * Wait for a message. + */ + if ((bufid = pvm_recv(-1, -1)) < 0) { + pvm_perror("pvm_recv"); + if (pvm_errno != PvmSysErr) + continue; + } + if (pvm_bufinfo(bufid, NULL, &request, &requestor) < 0) { + pvm_perror("pvm_bufinfo"); + if (pvm_errno != PvmSysErr) + continue; + } + pvm_initsend(PvmDataDefault); + if (request != PVMFS_TASK_EXIT) { + if ((lmp = lmap_find(requestor)) == NULL) { + if (request != PVMFS_NEW_TASK) + fprintf(stderr, + "fs: tid %d not initialized\n", + requestor); + else { + /* + * New client registering. + */ + dprint((buf2, + "fs: initializing tid %d\n", + requestor)); + if (lmp = lmap_add(requestor)) { + iresult = 0; + pvm_packf("%+ %d", + PvmDataDefault, iresult); + pvm_send(requestor, PVMFS_INIT); + (void)pvm_notify(PvmTaskExit, + PVMFS_TASK_EXIT, 1, + &requestor); + dprint((buf2, + "fs: initialized tid %d ok\n", + requestor)); + } else { + iresult = -1; + dprint((buf2, + "fs: couldn't initialize tid %d\n", + requestor)); + } + } + continue; + } + } + + pvm_unpackf("%d", &nargs); + + /* + * Megaswitch for services requested. + */ + switch (request) { + case PVMFS_TASK_EXIT: + /* + * A task exited. + * Delete it from our list of clients. + */ + dprint((buf2, "fs: task %d exited! %d to go\n", nargs, + nummapsused - 1)); + lmap_delete(nargs); + if (nummapsused == 0) { + dprint((buf2, "fs exiting!\n")); + pvm_exit(); + exit(0); + } + break; + case PVMFS_OPEN: + case PVMFS_CREAT: + fs_open(lmp, requestor, request, nargs); + break; + case PVMFS_CLOSE: + fs_close(lmp, requestor, request, nargs); + break; + case PVMFS_LSEEK: + fs_lseek(lmp, requestor, request, nargs); + break; + case PVMFS_READ: + case PVMFS_READV: + fs_read(lmp, requestor, request, nargs); + break; + case PVMFS_WRITE: + case PVMFS_WRITEV: + fs_write(lmp, requestor, request, nargs); + break; + case PVMFS_DUP: + fs_dup(lmp, requestor, request, nargs); + break; + case PVMFS_DUP2: + fs_dup(lmp, requestor, request, nargs); + break; + case PVMFS_SETIOORDER: + fs_setioorder(lmp, requestor, request, nargs); + break; + case PVMFS_GETIOORDER: + fs_getioorder(lmp, requestor, request, nargs); + break; + case PVMFS_SETIOMODE: + fs_setiomode(lmp, requestor, request, nargs); + break; + case PVMFS_GETIOMODE: + fs_getiomode(lmp, requestor, request, nargs); + break; + case PVMFS_STAT: + fs_stat(lmp, requestor, request, nargs); + break; + case PVMFS_FSTAT: + fs_fstat(lmp, requestor, request, nargs); + break; + case PVMFS_LSTAT: + fs_lstat(lmp, requestor, request, nargs); + break; + case PVMFS_FCNTL: + fs_fcntl(lmp, requestor, request, nargs); + break; + case PVMFS_UNLINK: + fs_unlink(lmp, requestor, request, nargs); + break; + case PVMFS_RENAME: + fs_rename(lmp, requestor, request, nargs); + break; + case PVMFS_MKDIR: + fs_mkdir(lmp, requestor, request, nargs); + break; + case PVMFS_RMDIR: + fs_rmdir(lmp, requestor, request, nargs); + break; + case PVMFS_CHROOT: + fs_chroot(lmp, requestor, request, nargs); + break; + case PVMFS_FCHROOT: + fs_fchroot(lmp, requestor, request, nargs); + break; + case PVMFS_CHDIR: + fs_chdir(lmp, requestor, request, nargs); + break; + case PVMFS_FCHDIR: + fs_fchdir(lmp, requestor, request, nargs); + break; + case PVMFS_CHMOD: + fs_chmod(lmp, requestor, request, nargs); + break; + case PVMFS_FCHMOD: + fs_fchmod(lmp, requestor, request, nargs); + break; + case PVMFS_CHOWN: + fs_chown(lmp, requestor, request, nargs); + break; + case PVMFS_FCHOWN: + fs_fchown(lmp, requestor, request, nargs); + break; + case PVMFS_LCHOWN: + fs_lchown(lmp, requestor, request, nargs); + break; + case PVMFS_LINK: + fs_link(lmp, requestor, request, nargs); + break; + case PVMFS_SYMLINK: + fs_symlink(lmp, requestor, request, nargs); + break; + case PVMFS_MKFIFO: + fs_mkfifo(lmp, requestor, request, nargs); + break; + case PVMFS_MKNOD: + fs_mknod(lmp, requestor, request, nargs); + break; + case PVMFS_PIPE: + fs_pipe(lmp, requestor, request, nargs); + break; + case PVMFS_READLINK: + fs_readlink(lmp, requestor, request, nargs); + break; + case PVMFS_TRUNCATE: + fs_truncate(lmp, requestor, request, nargs); + break; + case PVMFS_FTRUNCATE: + fs_ftruncate(lmp, requestor, request, nargs); + break; + case PVMFS_UMASK: + fs_umask(lmp, requestor, request, nargs); + break; + case PVMFS_UTIME: + fs_utime(lmp, requestor, request, nargs); + break; + case PVMFS_UTIMES: + fs_utimes(lmp, requestor, request, nargs); + break; + case PVMFS_SYNC: + fs_sync(lmp, requestor, request, nargs); + break; + case PVMFS_FSYNC: + fs_fsync(lmp, requestor, request, nargs); + break; + case PVMFS_ACCESS: + fs_access(lmp, requestor, request, nargs); + break; + case PVMFS_SELECT: + fs_select(lmp, requestor, request, nargs); + break; + case PVMFS_OPENDIR: + fs_opendir(lmp, requestor, request, nargs); + break; + case PVMFS_READDIR: + fs_readdir(lmp, requestor, request, nargs); + break; + case PVMFS_CLOSEDIR: + fs_closedir(lmp, requestor, request, nargs); + break; + case PVMFS_REWINDDIR: + fs_rewinddir(lmp, requestor, request, nargs); + break; + case PVMFS_ISATTY: + fs_isatty(lmp, requestor, request, nargs); + break; + case PVMFS_TTYNAME: + fs_ttyname(lmp, requestor, request, nargs); + break; + case PVMFS_CTERMID: + fs_ctermid(lmp, requestor, request, nargs); + break; + case PVMFS_TCDRAIN: + fs_tcdrain(lmp, requestor, request, nargs); + break; + case PVMFS_TCFLOW: + fs_tcflow(lmp, requestor, request, nargs); + break; + case PVMFS_TCFLUSH: + fs_tcflush(lmp, requestor, request, nargs); + break; + case PVMFS_TCSENDBREAK: + fs_tcsendbreak(lmp, requestor, request, nargs); + break; + case PVMFS_PATHCONF: + fs_pathconf(lmp, requestor, request, nargs); + break; + case PVMFS_FPATHCONF: + fs_fpathconf(lmp, requestor, request, nargs); + break; + case PVMFS_GETRLIMIT: + fs_getrlimit(lmp, requestor, request, nargs); + break; + case PVMFS_SETRLIMIT: + fs_setrlimit(lmp, requestor, request, nargs); + break; + case PVMFS_GETDTABLESIZE: + fs_getdtablesize(lmp, requestor, request, nargs); + break; + case PVMFS_GETDIRENTRIES: + fs_getdirentries(lmp, requestor, request, nargs); + break; + case PVMFS_GETCWD: + fs_getcwd(lmp, requestor, request, nargs); + break; + case PVMFS_SEEKDIR: + fs_seekdir(lmp, requestor, request, nargs); + break; + case PVMFS_TELLDIR: + fs_telldir(lmp, requestor, request, nargs); + break; + default: + fprintf(stderr, "fs: bad request: %d\n", request); + dprint((buf2, + "fs: bad nargs in request %d from t%xn", request, + requestor)); + break; + } + } + } *** /dev/null Thu Aug 25 19:19:25 1994 --- pvmfs/fspro.c Sun Jul 24 18:25:05 1994 *************** *** 0 **** --- 1,3287 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include "fs.h" + #include "fsp.h" + #include "map.h" + #include "bitops.h" + #ifndef PATH_MAX + #define PATH_MAX 1024 + #endif + + #if !defined(IMA_RS6K) && !defined(IMA_CRAY) + #include + #else + #include + #include "syscall-fake.h" + #endif + + #ifdef TRACE + /* + * Debugging and tracing stuff. + */ + extern int pvmdebug; + extern int pvmrwdebug; + + #define dprint(s) do { \ + if (pvmdebug) { \ + sprintf s; \ + syscall(SYS_write, 2, buf2, \ + strlen(buf2)); \ + } \ + } while (0) + #define dprintrw(s) do { \ + if (pvmrwdebug) { \ + sprintf s; \ + syscall(SYS_write, 2, buf2, \ + strlen(buf2)); \ + } \ + } while (0) + extern char buf2[]; + + #else + #define dprint(s) + #define dprintrw(s) + #endif + + extern struct gmap globalmap; + extern struct lmap *lmap; + extern struct gop *gop; + + extern size_t nummaps; + extern size_t nummapsused; + extern int *tidorder; + extern int errno; + + int defiomode = PvmIomodeIndividual; + + extern int fdtorealfd __ProtoGlarp__((struct lmap *, int)); + extern int pvm_local_open_oflag __ProtoGlarp__((int)); + extern int pvm_open_oflag __ProtoGlarp__((int)); + extern mode_t pvm_local_open_mode __ProtoGlarp__((long mode)); + extern mode_t pvm_open_mode __ProtoGlarp__((long mode)); + extern int pvm_local_lseek_whence __ProtoGlarp__((int)); + extern int pvm_lseek_whence __ProtoGlarp__((int)); + extern int pvm_local_fcntl_cmd __ProtoGlarp__((int)); + extern short pvm_local_fcntl_ltype __ProtoGlarp__((short)); + extern short pvm_fcntl_ltype __ProtoGlarp__((short)); + extern int pvm_local_access_mode __ProtoGlarp__((int)); + extern void pvm_select_fdset_pack __ProtoGlarp__((int, fd_set *)); + extern int pvm_select_fdset_unpack __ProtoGlarp__((fd_set *)); + extern int pvm_local_tcflow_action __ProtoGlarp__((int)); + extern int pvm_local_tcflush_queue __ProtoGlarp__((int)); + extern int pvm_local_pathconf_name __ProtoGlarp__((int)); + extern int pvm_local_rlimit_resource __ProtoGlarp__((int)); + extern int pvmerrno __ProtoGlarp__((int)); + extern struct gop *gop_add __ProtoGlarp__((int, int, ino_t, dev_t, long)); + extern int gop_delete __ProtoGlarp__((struct gop *)); + extern int gop_doclose __ProtoGlarp__((int)); + extern struct gop *gop_find __ProtoGlarp__((int, int, ino_t, dev_t, int)); + extern struct gop *gop_first __ProtoGlarp__((int)); + extern int allset __ProtoGlarp__((unsigned char *)); + extern void gop_queue_add __ProtoGlarp__((struct gop *, + struct queued *)); + extern struct queued *gop_queue_find __ProtoGlarp__((struct gop *, int)); + extern void gop_queue_delete __ProtoGlarp__((struct gop *, int)); + extern int tid2order __ProtoGlarp__((int)); + extern int tid2bitpos __ProtoGlarp__((int)); + + void + fatal(const char *s) + { + char buf[PATH_MAX + BUFSIZ]; + + sprintf(buf, "FS FATAL: %s", s); + perror(buf); + abort(); + } + + void + fs_open(struct lmap *lmp, int requestor, int request, int nargs) + { + int i; + int iresult; + int oflag; + mode_t mode; + long pvmmode; + char pathname[PATH_MAX]; + int iomode; + int doit = 0; + struct stat stbuf; + struct gop *gopp; + + if (!(nargs == 3 || nargs == 4 && request == PVMFS_OPEN)) { + dprint((buf2, "FS: bad nargs in %s request from t%x\n", + request == PVMFS_OPEN ? "open" : "creat", requestor)); + return; + } + + /* + * Find an available client file descriptor. + */ + for (i = 0; i < globalmap.numfds; i++) + if (!lmp->lfd[i].fd) + break; + if (i == globalmap.numfds) { + iresult = -1; + errno = pvmerrno(EMFILE); + dprint((buf2, "FS: tid t%x open(...) = -1 (errno = EMFILE)\n", + requestor)); + pvm_packf("%+ %d %d", PvmDataDefault, iresult, errno); + pvm_send(requestor, request); + return; + } + + /* + * Get the arguments and determine if really need to call open. + */ + pvm_unpackf("%s", pathname); + if (request == PVMFS_OPEN) { + pvm_unpackf("%d", &oflag); + oflag = pvm_local_open_oflag(oflag); + } + if (request != PVMFS_OPEN || nargs == 4) { + pvm_unpackf("%ld", &pvmmode); + mode = pvm_local_open_mode(pvmmode); + } + pvm_unpackf("%d", &iomode); + switch (iomode) { + case PvmIomodeIndividual: + doit = 1; + break; + case PvmIomodeCommon: + case PvmIomodeIndependent: + case PvmIomodeSyncBC: + case PvmIomodeSyncSeq: + if (stat(pathname, &stbuf) == 0 && (gopp = gop_find( + request, -1, stbuf.st_ino, stbuf.st_dev, lmp - lmap))) + iresult = gopp->result; + else + doit = 1; + break; + default: + iresult = -1; + errno = EINVAL; + break; + } + + if (doit) { + if (request == PVMFS_OPEN) { + if (nargs == 3) + iresult = open(pathname, oflag); + else + iresult = open(pathname, oflag, mode); + } else + iresult = creat(pathname, mode); + } + + if (iresult == -1) { + pvm_packf("%+ %d", PvmDataDefault, iresult); + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + if (request == PVMFS_CREAT) + dprint((buf2, + "FS: tid t%x creat(\"%s\", %ld) = -1 (pvmerrno = %d)\n", + requestor, pathname, mode, iresult)); + else if (nargs == 3) + dprint((buf2, + "FS: tid t%x open(\"%s\", %d) = -1 (pvmerrno = %d)\n", + requestor, pathname, oflag, iresult)); + else + dprint((buf2, + "FS: tid t%x open(\"%s\", %d, %ld) = -1 (pvmerrno = %d)\n", + requestor, pathname, oflag, (long)mode, iresult)); + } else { + /* + * Update the global file descriptor + * and global operation mappings. + */ + switch (iomode) { + case PvmIomodeIndividual: + globalmap.fd[iresult].nrefs = 1; + globalmap.fd[iresult].iomode = iomode; + break; + case PvmIomodeCommon: + case PvmIomodeIndependent: + case PvmIomodeSyncBC: + case PvmIomodeSyncSeq: + if (doit) { + if (stat(pathname, &stbuf) == -1) { + char s[PATH_MAX + 32]; + + sprintf(s, "can't stat %s", pathname); + fatal(s); + } + globalmap.fd[iresult].st_ino = stbuf.st_ino; + globalmap.fd[iresult].st_dev = stbuf.st_dev; + globalmap.fd[iresult].nrefs = 1; + if ((gopp = gop_add(request, iresult, + stbuf.st_ino, stbuf.st_dev, iresult)) + == NULL) + fatal("malloc"); + globalmap.fd[iresult].iomode = iomode; + } else + globalmap.fd[iresult].nrefs++; + if (iomode == PvmIomodeIndependent) + lmp->lfd[i].offset = 0; + setbit(gopp->done, lmp - lmap); + gopp->numdone++; + if (allset(gopp->done)) + gop_delete(gopp); + break; + } + + /* + * Update the client's file descriptor mapping. + */ + globalmap.fd[iresult].from_start = 0; + /*globalmap.fd[iresult].iomode = defiomode;*/ + lmp->lfd[i].fd = &globalmap.fd[iresult]; + lmp->lfd[i].iomode = iomode; + pvm_packf("%+ %d", PvmDataDefault, i); + if (request == PVMFS_CREAT) + dprint((buf2, + "FS: tid t%x creat(\"%s\", %ld) = %d\n", + requestor, pathname, mode, iresult)); + else if (nargs == 3) + dprint((buf2, + "FS: tid t%x open(\"%s\", %d) = %d\n", + requestor, pathname, oflag, iresult)); + else + dprint((buf2, + "FS: tid t%x open(\"%s\", %d, %ld) = %d\n", + requestor, pathname, oflag, (long)mode, + iresult)); + } + pvm_send(requestor, request); + } + + void + fs_close(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int iresult; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in close request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &fd); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + dprint((buf2, "FS: tid t%x close(%d) = -1 (errno = EBADF)\n", + requestor, gfd)); + } else { + int doit = 0; + struct fd *fdp = &globalmap.fd[gfd]; + + /* + * Determine if should really close the file descriptor. + */ + switch (lmp->lfd[fd].iomode) { + case PvmIomodeIndividual: + if (--fdp->nrefs == 0 && !fdp->from_start) + doit = 1; + else + iresult = 0; + dprint((buf2, + "FS: global fd %d now has %d references\n", gfd, + fdp->nrefs)); + break; + case PvmIomodeCommon: + case PvmIomodeIndependent: + case PvmIomodeSyncBC: + case PvmIomodeSyncSeq: + if (--fdp->nrefs == 0 && !fdp->from_start + && gop_doclose(gfd)) + doit = 1; + else + iresult = 0; + dprint((buf2, + "FS: global fd %d now has %d references\n", gfd, + fdp->nrefs)); + break; + } + lmp->lfd[fd].fd = NULL; + + if (doit) { + iresult = close(gfd); + globalmap.fd[gfd].from_start = 0; + } + } + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, "FS: tid t%x close(%d) = -1 (pvmerrno = %d)\n", + requestor, gfd, iresult)); + } else { + globalmap.fd[gfd].from_start + = globalmap.fd[gfd].iomode = 0; + lmp->lfd[fd].fd = NULL; + dprint((buf2, "FS: tid t%x close(%d) = %d\n", + requestor, gfd, iresult)); + } + pvm_send(requestor, request); + } + + void + fs_lseek(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int whence; + long offset; + int iresult; + long lresult; + + if (nargs != 3) { + dprint((buf2, "FS: bad nargs in lseek request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d %ld %d", &fd, &offset, &whence); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + lresult = -1L; + errno = EBADF; + dprint((buf2, + "FS: tid t%x lseek(%d, %ld, %d) = -1 (errno = EBADF)\n", + requestor, fd, offset, whence)); + } else if ((whence = pvm_local_lseek_whence(whence)) == -1) { + lresult = -1L; + errno = EINVAL; + dprint((buf2, + "FS: tid t%x lseek(%d, %ld, %d) = -1 (errno = EINVAL)\n", + requestor, fd, offset, whence)); + } else { + int doit = 0; + + switch (lmp->lfd[fd].iomode) { + case PvmIomodeIndividual: + case PvmIomodeCommon: + case PvmIomodeIndependent: + case PvmIomodeSyncBC: + case PvmIomodeSyncSeq: + doit = 1; + break; + } + + if (doit) + lresult = lseek(gfd, (off_t)offset, whence); + + if (lmp->lfd[fd].iomode == PvmIomodeIndependent && lresult >= 0) + lmp->lfd[fd].offset = lresult; + } + pvm_packf("%+ %ld", PvmDataDefault, lresult); + if (lresult == -1L) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x lseek(%d, %ld, %d) = -1 (pvmerrno = %d)\n", + requestor, fd, offset, whence, iresult)); + } else + dprint((buf2, "FS: tid t%x lseek(%d, %ld, %d) = %ld\n", + requestor, fd, offset, whence, lresult)); + pvm_send(requestor, request); + } + + static char *read_buffer = NULL; + static size_t read_buffer_size = 0; + + long + do_read(int fd, long nbytes) + { + char *tmp; + + /* + * Go ahead and call read. + */ + if (nbytes > read_buffer_size) { + #if defined(IMA_SUN3) || defined(IMA_SUN4) + if (read_buffer == NULL) { + if ((tmp = malloc(nbytes)) == NULL) + return -1L; + } else + #endif + if ((tmp = realloc(read_buffer, nbytes)) == NULL) + return -1L; + + read_buffer = tmp; + read_buffer_size = nbytes; + } + return (long)read(fd, read_buffer, nbytes); + } + + void + send_read(int requestor, int request, int gfd, long nbytes, long lresult, char *buf, void **counts) + { + int iresult; + long left; + long count; + + /* + * Reply to the client. + */ + pvm_packf("%+ %ld", PvmDataDefault, lresult); + if (lresult == -1L) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprintrw((buf2, + "FS: tid t%x %s(%d, ..., %s%ld) = -1 (pvmerrno = %d)\n", + requestor, request == PVMFS_READ ? "read" : "readv", gfd, + request == PVMFS_READ ? "" : "total bytes = ", nbytes, + lresult)); + } else if (lresult > 0L) { + if (request == PVMFS_READV) { + for (left = lresult; left > 0; left -= count) { + if (counts) + count = *(long *)*counts++; + else + pvm_unpackf("%ld", &count); + dprintrw((buf2, + "FS: left is %ld and count is %ld\n", left, + count)); + if (left < count) + count = left; + dprintrw((buf2, + "FS: Now left is %ld and count is %ld\n", + left, count)); + pvm_packf("%*c", (int)count, + buf + lresult - left); + dprintrw((buf2, "FS: Packing \"%*.*s\"\n", + (int)count, (int)count, + buf + lresult - left)); + } + dprintrw((buf2, + "FS: finished with left = %ld\n", left)); + if (left) + abort(); + } else + pvm_packf("%*c", (int)lresult, buf); + dprintrw((buf2, "FS: tid t%x %s(%d, ..., %s%ld) = %ld\n", + requestor, request == PVMFS_READ ? "read" : "readv", gfd, + request == PVMFS_READ ? "" : "total bytes = ", nbytes, + lresult)); + } else + dprintrw((buf2, "FS: tid t%x %s(%d, ..., %s%ld) = 0\n", + requestor, request == PVMFS_READ ? "read" : "readv", gfd, + request == PVMFS_READ ? "" : "total bytes = ", nbytes)); + pvm_send(requestor, request); + } + + int + flush_read(struct gop *gp, int min, int maxp1, int request) + { + int i; + long nbytes; + long lresult; + struct queued *qp; + + /* + * Check if any clients waiting for a SyncSeq read + * should now be responded to. + */ + for (i = min; i < maxp1; i++) { + if (lmap[i].tid == 0) + continue; + if (qp = gop_queue_find(gp, i)) { + nbytes = *(long *)qp->args[0]; + lresult = do_read(qp->fd, nbytes); + dprintrw((buf2, "FSR: %d READING - got %ld\n", + qp->number, lresult)); + send_read(tidorder[i], request, qp->fd, nbytes, lresult, + read_buffer, request == PVMFS_READ ? NULL + : &qp->args[1]); + setbit(gp->done, tid2bitpos(tidorder[i])); + gp->numdone++; + gop_queue_delete(gp, i); + } else + break; + } + + return i; + } + + void + fs_read(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + long lresult; + long nbytes; + char *buf; + int me; + struct queued *qp; + struct gop *gopp; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in %s request from t%x\n", + request == PVMFS_READ ? "read" : "readv", requestor)); + return; + } + + pvm_unpackf("%d %ld", &fd, &nbytes); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + lresult = -1L; + errno = EBADF; + } else { + int queueit = 0; + + /* + * What really happens during a read? + * Read below for all the gory details! + */ + switch (lmp->lfd[fd].iomode) { + case PvmIomodeIndependent: + if (lseek(gfd, lmp->lfd[fd].offset, SEEK_SET) == -1) { + lresult = -1L; + break; + } + /* FALLTHROUGH */ + case PvmIomodeIndividual: + case PvmIomodeCommon: + if ((lresult = do_read(gfd, nbytes)) > 0) + lmp->lfd[fd].offset += lresult; + buf = read_buffer; + break; + case PvmIomodeSyncBC: + if (gopp = gop_find(request, gfd, + globalmap.fd[gfd].st_ino, globalmap.fd[gfd].st_dev, + lmp - lmap)) { + buf = gopp->buf; + lresult = gopp->result; + } else { + lresult = do_read(gfd, nbytes); + buf = read_buffer; + if ((gopp = gop_add(request, gfd, + globalmap.fd[gfd].st_ino, + globalmap.fd[gfd].st_dev, lresult)) == NULL) + fatal("malloc"); + if (lresult > 0) { + if ((gopp->buf = malloc(lresult)) + == NULL) + fatal("malloc"); + memcpy(gopp->buf, read_buffer, lresult); + } + } + break; + case PvmIomodeSyncSeq: + if ((gopp = gop_find(request, gfd, + globalmap.fd[gfd].st_ino, globalmap.fd[gfd].st_dev, + lmp - lmap)) == NULL + && (gopp = gop_add(request, gfd, + globalmap.fd[gfd].st_ino, + globalmap.fd[gfd].st_dev, 0)) == NULL) + fatal("malloc"); + if ((me = tid2order(requestor)) == -1) + fatal("tid2order"); + if (gopp != gop_first(request)) + queueit = 1; + else { + /* + * A previous global read hasn't finished. + */ + (void)flush_read(gopp, gopp->numdone, me, + request); + if (me == gopp->numdone) { + /* + * It's this client's turn! + */ + lresult = do_read(gfd, nbytes); + dprintrw((buf2, + "FSR: %d READING - got %ld\n", me, + lresult)); + send_read(requestor, request, gfd, + nbytes, lresult, read_buffer, NULL); + if (qp = gop_queue_find(gopp, me)) + gop_queue_delete(gopp, me); + /* + * See if we can now do other reads. + */ + if (flush_read(gopp, me + 1, nummaps, + request) == nummaps) { + struct gop *gop2; + + for (gop2 = gopp->next; + gop2 + && gop2->type != request; + gop2 = gop2->next) + ; + if (gop2 + && gop2->type == request) + (void)flush_read(gop2, + gop2->numdone, me, + request); + } + } else + queueit = 1; + } + if (queueit) { + if ((qp = malloc(sizeof(*qp))) == NULL) + fatal("malloc"); + qp->number = me; + qp->tid = lmp->tid; + qp->fd = gfd; + dprintrw((buf2, "FSR: %d READ BEING QUEUED\n", + me)); + qp->nargs = 1; + if ((qp->args = malloc(sizeof(*qp->args))) + == NULL + || (qp->args[0] = malloc(sizeof(long))) + == NULL) + fatal("malloc"); + *(long *)qp->args[0] = nbytes; + if ((qp->type = request) == PVMFS_READV) { + long count; + long left; + + for (left = nbytes; left > 0; + left -= count) { + pvm_unpackf("%ld", &count); + if ((qp->args = realloc(qp->args, ++qp->nargs * sizeof(*qp->args))) == NULL + || (qp->args[qp->nargs - 1] = malloc(sizeof(long))) == NULL) + fatal("malloc"); + *(long *)qp->args[qp->nargs - 1] + = count; + } + } + gop_queue_add(gopp, qp); + return; + } + break; + } + + if (lmp->lfd[fd].iomode == PvmIomodeSyncBC + || lmp->lfd[fd].iomode == PvmIomodeSyncSeq) { + setbit(gopp->done, lmp - lmap); + gopp->numdone++; + if (lmp->lfd[fd].iomode == PvmIomodeSyncBC) + send_read(requestor, request, gfd, nbytes, + lresult, buf, NULL); + if (allset(gopp->done)) + gop_delete(gopp); + return; + } + } + + send_read(requestor, request, gfd, nbytes, lresult, buf, NULL); + } + + static char *write_buffer = NULL; + static size_t write_buffer_size = 0; + + long + unpack_write(int request, long nbytes) + { + char *tmp; + long n; + long count; + + /* + * Unpack what they want to write. + */ + if (nbytes > write_buffer_size) { + #if defined(IMA_SUN3) || defined(IMA_SUN4) + if (write_buffer == NULL) { + if ((tmp = malloc(nbytes)) == NULL) + return -1L; + } else + #endif + if ((tmp = realloc(write_buffer, nbytes)) == NULL) + return -1L; + + write_buffer = tmp; + write_buffer_size = nbytes; + } + if (nbytes > 0) + if (request == PVMFS_WRITEV) { + for (n = 0; n < nbytes; n += count) { + pvm_unpackf("%ld", &count); + pvm_unpackf("%*c", (int)count, + write_buffer + n); + } + } else + pvm_unpackf("%*c", (int)nbytes, write_buffer); + #if 0 + dprintrw((buf2, "FS: unpack_write got \"%*.*s\"\n", (int)nbytes, + (int)nbytes, write_buffer)); + #endif + + return 0L; + } + + void + send_write(int requestor, int request, int gfd, long nbytes, long lresult) + { + int iresult; + + /* + * Respond to a client's write request. + */ + pvm_packf("%+ %ld", PvmDataDefault, lresult); + if (lresult == -1L) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprintrw((buf2, + "FS: tid t%x %s(%d, ..., %s%ld) = -1 (pvmerrno = %d)\n", + requestor, request == PVMFS_WRITE ? "write" : "writev", gfd, + request == PVMFS_WRITE ? "" : "total bytes = ", nbytes, + lresult)); + } else + dprintrw((buf2, "FS: tid t%x %s(%d, ..., %s%ld) = %ld\n", + requestor, request == PVMFS_WRITE ? "write" : "writev", gfd, + request == PVMFS_WRITE ? "" : "total bytes = ", nbytes, + lresult)); + pvm_send(requestor, request); + } + + int + flush_write(struct gop *gp, int min, int maxp1, int request) + { + int i; + long nbytes; + long lresult; + struct queued *qp; + + /* + * Analogous to flush_read... + */ + for (i = min; i < maxp1; i++) { + if (lmap[i].tid == 0) + continue; + if (qp = gop_queue_find(gp, i)) { + nbytes = *(long *)qp->args[0]; + lresult = write(qp->fd, qp->args[1], nbytes); + dprintrw((buf2, "FSR: %d WRITING - got %ld\n", + qp->number, lresult)); + send_write(tidorder[i], request, qp->fd, nbytes, + lresult); + setbit(gp->done, tid2bitpos(tidorder[i])); + gp->numdone++; + gop_queue_delete(gp, i); + } else + break; + } + + return i; + } + + void + fs_write(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int iresult; + long lresult; + long nbytes; + int me; + struct queued *qp; + struct gop *gopp; + int i; + + if (nargs != 3) { + dprint((buf2, "FS: bad nargs in %s request from t%x\n", + request == PVMFS_WRITE ? "write" : "writev", requestor)); + return; + } + + pvm_unpackf("%d %ld", &fd, &nbytes); + if (unpack_write(request, nbytes) == -1) + lresult = -1L; + else if ((gfd = fdtorealfd(lmp, fd)) == -1) { + lresult = -1L; + errno = EBADF; + } else { + int queueit = 0; + + /* + * Much of this is also analogous to fs_read... + */ + switch (lmp->lfd[fd].iomode) { + case PvmIomodeIndependent: + if (lseek(gfd, lmp->lfd[fd].offset, SEEK_SET) == -1) { + lresult = -1L; + break; + } + /* FALLTHROUGH */ + case PvmIomodeIndividual: + case PvmIomodeCommon: + if ((lresult = write(gfd, write_buffer, nbytes)) > 0) + lmp->lfd[fd].offset += lresult; + break; + case PvmIomodeSyncBC: + if ((gopp = gop_find(request, gfd, + globalmap.fd[gfd].st_ino, globalmap.fd[gfd].st_dev, + lmp - lmap)) == NULL + && (gopp = gop_add(request, gfd, + globalmap.fd[gfd].st_ino, globalmap.fd[gfd].st_dev, + 0)) == NULL) + fatal("malloc"); + if ((me = tid2order(requestor)) == -1) + fatal("tid2order"); + else if (me == 0) { + lresult = write(gfd, write_buffer, nbytes); + gopp->result = lresult; + for (i = 0; i < nummaps; i++) { + if (lmap[i].tid == 0) + continue; + if (qp = gop_queue_find(gopp, i)) { + nbytes = *(long *)qp->args[0]; + send_write(tidorder[i], request, + qp->fd, nbytes, lresult); + setbit(gopp->done, + tid2bitpos(tidorder[i])); + gopp->numdone++; + gop_queue_delete(gopp, i); + } + } + /* + * I suppose we should queue these + * but let's go ahead and act like it worked. + */ + #if 0 + } else if (gopp->result == -2) { + /* queue it */ + if ((qp = malloc(sizeof(*qp))) == NULL) + fatal("malloc"); + qp->number = me; + dprintrw((buf2, "FSR: %d WRITE BEING QUEUED\n", + me)); + qp->type = request; + qp->fd = gfd; + qp->nargs = 1; + if ((qp->args = malloc(2 * sizeof(*qp->args))) + == NULL + || (qp->args[0] = malloc(sizeof(long))) + == NULL) + fatal("malloc"); + *(long *)qp->args[0] = nbytes; + qp->tid = lmp->tid; + gop_queue_add(gopp, qp); + return; + #endif + } else + lresult = gopp->result; + break; + case PvmIomodeSyncSeq: + if ((gopp = gop_find(request, gfd, + globalmap.fd[gfd].st_ino, globalmap.fd[gfd].st_dev, + lmp - lmap)) == NULL + && (gopp = gop_add(request, gfd, + globalmap.fd[gfd].st_ino, globalmap.fd[gfd].st_dev, + 0)) == NULL) + fatal("malloc"); + if ((me = tid2order(requestor)) == -1) + fatal("tid2order"); + if (gopp != gop_first(request)) + queueit = 1; + else { + /* + * A previous global write hasn't finished. + */ + (void)flush_write(gopp, gopp->numdone, me, + request); + if (me == gopp->numdone) { + /* + * It's this client's turn! + */ + lresult = write(gfd, write_buffer, + nbytes); + dprintrw((buf2, + "FSR: %d WRITING - got %ld\n", me, + lresult)); + send_write(requestor, request, gfd, + nbytes, lresult); + if (qp = gop_queue_find(gopp, me)) + gop_queue_delete(gopp, me); + /* + * See if we can now do other writes. + */ + if (flush_write(gopp, me + 1, nummaps, + request) == nummaps) { + struct gop *gop2; + + for (gop2 = gopp->next; + gop2 + && gop2->type != request; + gop2 = gop2->next) + ; + if (gop2 + && gop2->type == request) + (void)flush_write(gop2, + gop2->numdone, me, + request); + } + } else + queueit = 1; + } + if (queueit) { + if ((qp = malloc(sizeof(*qp))) == NULL) + fatal("malloc"); + qp->number = me; + dprintrw((buf2, "FSR: %d WRITE BEING QUEUED\n", + me)); + qp->type = request; + qp->fd = gfd; + qp->nargs = 2; + if ((qp->args = malloc(2 * sizeof(*qp->args))) + == NULL + || (qp->args[0] = malloc(sizeof(long))) + == NULL + || nbytes + && (qp->args[1] = malloc(nbytes)) == NULL) + fatal("malloc"); + *(long *)qp->args[0] = nbytes; + if (nbytes) + memcpy(qp->args[1], write_buffer, + nbytes); + else + qp->args[1] = NULL; + qp->tid = lmp->tid; + gop_queue_add(gopp, qp); + return; + } + break; + } + + if (lmp->lfd[fd].iomode == PvmIomodeSyncBC + || lmp->lfd[fd].iomode == PvmIomodeSyncSeq) { + setbit(gopp->done, lmp - lmap); + gopp->numdone++; + if (lmp->lfd[fd].iomode == PvmIomodeSyncBC) + send_write(requestor, request, gfd, nbytes, + lresult); + if (allset(gopp->done)) + gop_delete(gopp); + return; + } + } + + send_write(requestor, request, gfd, nbytes, lresult); + } + + void + fs_dup(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int fd2; + int gfd2; + int iresult = 0; + int i; + + if (nargs != 1 && request == PVMFS_DUP + || nargs != 2 && request == PVMFS_DUP2) { + dprint((buf2, "FS: bad nargs in %s request from t%x\n", + request == PVMFS_DUP ? "dup" : "dup2", requestor)); + return; + } + + pvm_unpackf("%d", &fd); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else if (request == PVMFS_DUP) { + for (i = 0; i < globalmap.numfds; i++) + if (!lmp->lfd[i].fd) + break; + if (i == globalmap.numfds) { + iresult = -1; + errno = EMFILE; + } else { + lmp->lfd[i] = lmp->lfd[fd]; + lmp->lfd[i].fd->nrefs++; + iresult = i; + } + } else { + /* request == PVMFS_DUP2 */ + pvm_unpackf("%d", &fd2); + if (fd2 < 0 || fd2 >= globalmap.numfds) { + iresult = -1; + errno = EBADF; + } else if (fd != fd2) { + struct fd *fdp; + + if ((gfd2 = fdtorealfd(lmp, fd2)) >= 0) { + fdp = &globalmap.fd[gfd2]; + if (fdp->nrefs) + if (--fdp->nrefs == 0) + close(gfd2); + } + lmp->lfd[fd2] = lmp->lfd[fd]; + lmp->lfd[fd2].fd->nrefs++; + iresult = fd2; + } else + iresult = fd; + } + + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, "FS: tid t%x dup(%d) = -1 (pvmerrno = %d)\n", + requestor, fd, iresult)); + } else + dprint((buf2, "FS: tid t%x dup(%d) = %d\n", + requestor, fd, iresult)); + pvm_send(requestor, request); + } + + void + fs_setioorder(struct lmap *lmp, int requestor, int request, int nargs) + { + int order; + int iresult; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in setioorder request from t%x\n", + requestor)); + return; + } + + /* + * Always works as long as there are at least ``order'' clients. + */ + pvm_unpackf("%d", &order); + if (order < nummapsused) { + tidorder[order] = requestor; + iresult = 0; + } else + iresult = -1; + pvm_packf("%+ %d", PvmDataDefault, iresult); + pvm_send(requestor, request); + } + + void + fs_getioorder(struct lmap *lmp, int requestor, int request, int nargs) + { + int i; + int iresult; + + if (nargs != 0) { + dprint((buf2, "FS: bad nargs in getioorder request from t%x\n", + requestor)); + return; + } + + iresult = -1; + for (i = 0; i < nummaps; i++) + if (lmap[i].tid > 0 && tidorder[i] == requestor) { + iresult = i; + break; + } + + pvm_packf("%+ %d", PvmDataDefault, iresult); + pvm_send(requestor, request); + } + + void + fs_setiomode(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int mode; + int iresult; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in setiomode request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d %d", &fd, &mode); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else { + switch (globalmap.fd[gfd].iomode) { + case PvmIomodeIndividual: + if (mode == PvmIomodeIndividual) + iresult = 0; + else { + /* + * Can't change from PvmIomodeIndividual + * (not right now anyway). + */ + iresult = -1; + errno = EINVAL; + } + break; + case PvmIomodeCommon: + case PvmIomodeIndependent: + case PvmIomodeSyncBC: + case PvmIomodeSyncSeq: + /* + * Go ahead and allow the change. Whether things + * make sense after this is their problem. + */ + iresult = 0; + lmp->lfd[fd].iomode = mode; + break; + default: + iresult = -1; + errno = EINVAL; + break; + } + } + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + } + pvm_send(requestor, request); + } + + void + fs_getiomode(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int iresult; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in getiomode request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &fd); + if (lmp->lfd[fd].fd == NULL) { + iresult = -1; + errno = pvmerrno(EBADF); + pvm_packf("%+ %d %d", PvmDataDefault, iresult, errno); + } else + pvm_packf("%+ %d", PvmDataDefault, lmp->lfd[fd].iomode); + pvm_send(requestor, request); + } + + static void + putstat(struct stat *stp) + { + long l; + + #ifdef __STDC__ + #define put(member) l = (long)stp->st_##member; pvm_packf("%ld", l); + put(dev); + put(ino); + put(mode); + put(nlink); + put(uid); + put(gid); + put(rdev); + put(size); + put(atime); + put(ctime); + put(mtime); + put(blksize); + put(blocks); + #undef put + #else + l = (long)stp->st_dev; pvm_packf("%ld", l); + l = (long)stp->st_ino; pvm_packf("%ld", l); + l = (long)stp->st_mode; pvm_packf("%ld", l); + l = (long)stp->st_nlink; pvm_packf("%ld", l); + l = (long)stp->st_uid; pvm_packf("%ld", l); + l = (long)stp->st_gid; pvm_packf("%ld", l); + l = (long)stp->st_rdev; pvm_packf("%ld", l); + l = (long)stp->st_size; pvm_packf("%ld", l); + l = (long)stp->st_atime; pvm_packf("%ld", l); + l = (long)stp->st_ctime; pvm_packf("%ld", l); + l = (long)stp->st_mtime; pvm_packf("%ld", l); + l = (long)stp->st_blksize; pvm_packf("%ld", l); + l = (long)stp->st_blocks; pvm_packf("%ld", l); + #endif + } + + void + fs_stat(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + struct stat stbuf; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in stat request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s", pathname); + iresult = stat(pathname, &stbuf); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x stat(\"%s\", %p) = -1 (pvmerrno = %d)\n", + requestor, pathname, &stbuf, iresult)); + } else { + putstat(&stbuf); + dprint((buf2, "FS: tid t%x stat(\"%s\", %p) = %d\n", + requestor, pathname, &stbuf, iresult)); + } + pvm_send(requestor, request); + } + + void + fs_lstat(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + struct stat stbuf; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in lstat request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s", pathname); + iresult = lstat(pathname, &stbuf); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x lstat(\"%s\", %p) = -1 (pvmerrno = %d)\n", + requestor, pathname, &stbuf, iresult)); + } else { + putstat(&stbuf); + dprint((buf2, "FS: tid t%x lstat(\"%s\", %p) = %d\n", + requestor, pathname, &stbuf, iresult)); + } + pvm_send(requestor, request); + } + + void + fs_fstat(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int iresult; + struct stat stbuf; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in fstat request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &fd); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else + iresult = fstat(gfd, &stbuf); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x fstat(%d, %p) = -1 (pvmerrno = %d)\n", requestor, + fd, &stbuf, iresult)); + } else { + putstat(&stbuf); + dprint((buf2, "FS: tid t%x fstat(%d, %p) = %d\n", + requestor, fd, &stbuf, iresult)); + } + pvm_send(requestor, request); + } + + void + fs_fcntl(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int fd2; + int gfd; + int command; + int iresult; + int flags; + int i; + long l1, l2; + struct flock lock; + + if (nargs != 3) { + dprint((buf2, "FS: bad nargs in fcntl request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d %d", &fd, &command); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else if ((command = pvm_local_fcntl_cmd(command)) == -1) { + iresult = -1; + errno = EINVAL; + } else + /* + * This stuff may be here but it won't work + * for all cases because the local OS won't + * distinguish between the clients... + */ + switch (command) { + case F_GETLK: + case F_SETLK: + case F_SETLKW: + pvm_unpackf("%hd %ld %hd %ld", &lock.l_type, &l1, + &lock.l_whence, &l2); + lock.l_start = (off_t)l1; + lock.l_type = pvm_local_fcntl_ltype(lock.l_type); + lock.l_len = (off_t)l2; + lock.l_whence = pvm_local_lseek_whence(lock.l_whence); + iresult = fcntl(gfd, command, &lock); + break; + case F_DUPFD: + pvm_unpackf("%d", &fd2); + for (i = fd2; i < globalmap.numfds; i++) + if (!lmp->lfd[i].fd) + break; + if (i == globalmap.numfds) { + iresult = -1; + errno = EMFILE; + } else { + lmp->lfd[i] = lmp->lfd[fd]; + lmp->lfd[i].fd->nrefs++; + iresult = i; + } + break; + default: + pvm_unpackf("%d", &flags); + if (command == F_SETFL) + flags = pvm_local_open_oflag(flags); + iresult = fcntl(gfd, command, flags); + if (iresult != -1 && command == F_GETFL) + iresult = pvm_open_oflag(iresult); + break; + } + + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + switch (command) { + case F_GETLK: + case F_SETLK: + case F_SETLKW: + dprint((buf2, + "FS: tid t%x fcntl(%d, %d, ...) = -1 (pvmerrno = %d)\n", + requestor, fd, command, iresult)); + break; + default: + dprint((buf2, "FS: tid t%x fcntl(%d, %d, %d) = %d\n", + requestor, fd, command, flags, iresult)); + break; + } + } else + switch (command) { + case F_GETLK: + lock.l_type = pvm_fcntl_ltype(lock.l_type); + pvm_packf("%d", iresult); + if (lock.l_type != F_UNLCK) { + l1 = (long)lock.l_start; + lock.l_whence = (short) + pvm_lseek_whence(lock.l_whence); + l2 = (long)lock.l_len; + pvm_packf("%ld %hd %ld", l1, lock.l_whence, l2); + } + case F_SETLK: + case F_SETLKW: + dprint((buf2, + "FS: tid t%x fcntl(%d, %d, ...) = -1 (pvmerrno = %d)\n", + requestor, fd, command, iresult)); + break; + case F_DUPFD: + /* convert fd */ + case F_GETFL: + default: + dprint((buf2, "FS: tid t%x fcntl(%d, %d, %d) = %d\n", + requestor, fd, command, flags, iresult)); + break; + } + + pvm_send(requestor, request); + } + + void + fs_unlink(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in unlink request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s", pathname); + iresult = unlink(pathname); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x unlink(\"%s\") = -1 (pvmerrno = %d)\n", + requestor, pathname, iresult)); + } else + dprint((buf2, "FS: tid t%x unlink(\"%s\") = %d\n", + requestor, pathname, iresult)); + pvm_send(requestor, request); + } + + void + fs_rename(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char oldpathname[PATH_MAX]; + char newpathname[PATH_MAX]; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in rename request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %s", oldpathname, newpathname); + iresult = rename(oldpathname, newpathname); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x rename(\"%s\", \"%s\") = -1 (pvmerrno = %d)\n", + requestor, oldpathname, newpathname, iresult)); + } else + dprint((buf2, "FS: tid t%x rename(\"%s\", \"%s\") = %d\n", + requestor, oldpathname, newpathname, iresult)); + pvm_send(requestor, request); + } + + void + fs_mkdir(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + long pvmmode; + mode_t mode; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in mkdir request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %ld", pathname, &pvmmode); + mode = pvm_local_open_mode(pvmmode); + iresult = mkdir(pathname, mode); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x mkdir(\"%s\", %ld) = -1 (pvmerrno = %d)\n", + requestor, pathname, (long)mode, iresult)); + } else + dprint((buf2, "FS: tid t%x mkdir(\"%s\", %ld) = %d\n", + requestor, pathname, (long)mode, iresult)); + pvm_send(requestor, request); + } + + void + fs_rmdir(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in rmdir request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s", pathname); + iresult = rmdir(pathname); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x rmdir(\"%s\") = -1 (pvmerrno = %d)\n", requestor, + pathname, iresult)); + } else + dprint((buf2, "FS: tid t%x rmdir(\"%s\") = %d\n", + requestor, pathname, iresult)); + pvm_send(requestor, request); + } + + void + fs_chroot(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in chroot request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s", pathname); + iresult = chroot(pathname); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x chroot(\"%s\") = -1 (pvmerrno = %d)\n", + requestor, pathname, iresult)); + } else + dprint((buf2, "FS: tid t%x chroot(\"%s\") = %d\n", + requestor, pathname, iresult)); + pvm_send(requestor, request); + } + + void + fs_fchroot(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + int fd; + int gfd; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in fchroot request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &fd); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else + iresult = fchroot(gfd); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, "FS: tid t%x fchroot(%d) = -1 (pvmerrno = %d)\n", + requestor, fd, iresult)); + } else + dprint((buf2, "FS: tid t%x fchroot(%d) = %d\n", + requestor, fd, iresult)); + pvm_send(requestor, request); + } + + void + fs_chdir(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in chdir request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s", pathname); + iresult = chdir(pathname); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x chdir(\"%s\") = -1 (pvmerrno = %d)\n", requestor, + pathname, iresult)); + } else + dprint((buf2, "FS: tid t%x chdir(\"%s\") = %d\n", + requestor, pathname, iresult)); + pvm_send(requestor, request); + } + + void + fs_fchdir(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + int fd; + int gfd; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in fchdir request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &fd); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else + iresult = fchdir(gfd); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, "FS: tid t%x fchdir(%d) = -1 (pvmerrno = %d)\n", + requestor, fd, iresult)); + } else + dprint((buf2, "FS: tid t%x fchdir(%d) = %d\n", + requestor, fd, iresult)); + pvm_send(requestor, request); + } + + void + fs_chmod(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + long pvmmode; + mode_t mode; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in chmod request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %ld", pathname, &pvmmode); + mode = pvm_local_open_mode(pvmmode); + iresult = chmod(pathname, mode); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x chmod(\"%s\", %ld) = -1 (pvmerrno = %d)\n", + requestor, pathname, (long)mode, iresult)); + } else + dprint((buf2, "FS: tid t%x chmod(\"%s\", %ld) = %d\n", + requestor, pathname, (long)mode, iresult)); + pvm_send(requestor, request); + } + + void + fs_fchmod(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + int fd; + int gfd; + long pvmmode; + mode_t mode; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in fchmod request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d %ld", &fd, &pvmmode); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else { + mode = pvm_local_open_mode(pvmmode); + iresult = fchmod(gfd, mode); + } + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x fchmod(%d, %ld) = -1 (pvmerrno = %d)\n", + requestor, fd, (long)mode, iresult)); + } else + dprint((buf2, "FS: tid t%x fchmod(%d, %ld) = %d\n", + requestor, fd, (long)mode, iresult)); + pvm_send(requestor, request); + } + + void + fs_chown(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + long pvmowner; + long pvmgroup; + uid_t owner; + gid_t group; + + if (nargs != 3) { + dprint((buf2, "FS: bad nargs in chown request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %ld %ld", pathname, &pvmowner, &pvmgroup); + owner = pvmowner; + group = pvmgroup; + iresult = chown(pathname, owner, group); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x chown(\"%s\", %ld, %ld) = -1 (pvmerrno = %d)\n", + requestor, pathname, (long)owner, (long)group, iresult)); + } else + dprint((buf2, "FS: tid t%x chown(\"%s\", %ld, %ld) = %d\n", + requestor, pathname, (long)owner, (long)group, iresult)); + pvm_send(requestor, request); + } + + void + fs_fchown(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + int fd; + int gfd; + long pvmowner; + long pvmgroup; + uid_t owner; + gid_t group; + + if (nargs != 3) { + dprint((buf2, "FS: bad nargs in fchown request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d %ld %ld", &fd, &pvmowner, &pvmgroup); + owner = pvmowner; + group = pvmgroup; + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else + iresult = fchown(gfd, owner, group); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x fchown(%d, %ld, %ld) = -1 (pvmerrno = %d)\n", + requestor, fd, (long)owner, (long)group, iresult)); + } else + dprint((buf2, "FS: tid t%x fchown(%d, %ld, %ld) = %d\n", + requestor, fd, (long)owner, (long)group, iresult)); + pvm_send(requestor, request); + } + + void + fs_lchown(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + long pvmowner; + long pvmgroup; + uid_t owner; + gid_t group; + + if (nargs != 3) { + dprint((buf2, "FS: bad nargs in lchown request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %ld %ld", pathname, &pvmowner, &pvmgroup); + owner = pvmowner; + group = pvmgroup; + iresult = lchown(pathname, owner, group); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x lchown(\"%s\", %ld, %ld) = -1 (pvmerrno = %d)\n", + requestor, pathname, (long)owner, (long)group, iresult)); + } else + dprint((buf2, "FS: tid t%x lchown(\"%s\", %ld, %ld) = %d\n", + requestor, pathname, (long)owner, (long)group, iresult)); + pvm_send(requestor, request); + } + + void + fs_link(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char oldpathname[PATH_MAX]; + char newpathname[PATH_MAX]; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in link request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %s", oldpathname, newpathname); + iresult = link(oldpathname, newpathname); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x link(\"%s\", \"%s\") = -1 (pvmerrno = %d)\n", + requestor, oldpathname, newpathname, iresult)); + } else + dprint((buf2, "FS: tid t%x link(\"%s\", \"%s\") = %d\n", + requestor, oldpathname, newpathname, iresult)); + pvm_send(requestor, request); + } + + void + fs_symlink(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char oldpathname[PATH_MAX]; + char newpathname[PATH_MAX]; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in symlink request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %s", oldpathname, newpathname); + iresult = symlink(oldpathname, newpathname); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x symlink(\"%s\", \"%s\") = -1 (pvmerrno = %d)\n", + requestor, oldpathname, newpathname, iresult)); + } else + dprint((buf2, "FS: tid t%x symlink(\"%s\", \"%s\") = %d\n", + requestor, oldpathname, newpathname, iresult)); + pvm_send(requestor, request); + } + + void + fs_mkfifo(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + long pvmmode; + mode_t mode; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in mkfifo request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %ld", pathname, &pvmmode); + mode = pvm_local_open_mode(pvmmode); + iresult = mkfifo(pathname, mode); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x mkfifo(\"%s\", %ld) = -1 (pvmerrno = %d)\n", + requestor, pathname, mode, iresult)); + } else + dprint((buf2, "FS: tid t%x mkfifo(\"%s\", %ld) = %d\n", + requestor, pathname, mode, iresult)); + pvm_send(requestor, request); + } + + void + fs_mknod(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + long pvmmode; + mode_t mode; + long pvmdev; + dev_t dev; + + if (nargs != 3) { + dprint((buf2, "FS: bad nargs in mknod request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %ld %ld", pathname, &pvmmode, &pvmdev); + mode = pvm_local_open_mode(pvmmode); + dev = pvmdev; + iresult = mknod(pathname, mode, dev); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x mknod(\"%s\", %ld, %ld) = -1 (pvmerrno = %d)\n", + requestor, pathname, mode, iresult)); + } else + dprint((buf2, "FS: tid t%x mknod(\"%s\", %ld, %ld) = %d\n", + requestor, pathname, mode, iresult)); + pvm_send(requestor, request); + } + + void + fs_pipe(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd[2]; + int gfd[2]; + int iresult = 0; + int i; + + if (nargs != 0) { + dprint((buf2, "FS: bad nargs in pipe request from t%x\n", + requestor)); + return; + } + + /* + * Find 2 unused client file descriptors. + */ + for (i = 0; i <= 1; i++) { + for (fd[i] = 0; fd[i] < globalmap.numfds; fd[i]++) + if (!lmp->lfd[fd[i]].fd && (i == 0 || fd[i] != fd[0])) + break; + if (fd[i] == globalmap.numfds) { + iresult = -1; + errno = EMFILE; + break; + } + } + + if (iresult == 0) + iresult = pipe(gfd); + + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, "FS: tid t%x pipe(%p) = -1 (pvmerrno = %d)\n", + requestor, gfd, iresult)); + } else { + /* + * Update global and local file descriptor mappings. + * Pretty, huh? + */ + globalmap.fd[gfd[0]].nrefs = 1; + globalmap.fd[gfd[0]].iomode = PvmIomodeIndividual; + globalmap.fd[gfd[0]].from_start = 0; + lmp->lfd[fd[0]].fd = &globalmap.fd[gfd[0]]; + lmp->lfd[fd[0]].iomode = PvmIomodeIndividual; + globalmap.fd[gfd[1]].nrefs = 1; + globalmap.fd[gfd[1]].iomode = PvmIomodeIndividual; + globalmap.fd[gfd[1]].from_start = 0; + lmp->lfd[fd[1]].fd = &globalmap.fd[gfd[1]]; + lmp->lfd[fd[1]].iomode = PvmIomodeIndividual; + pvm_packf("%d %d", fd[0], fd[1]); + dprint((buf2, + "FS: tid t%x pipe(%p) = %d \n", + requestor, gfd, iresult, gfd[0], gfd[1], fd[0], fd[1])); + } + pvm_send(requestor, request); + } + + void + fs_readlink(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + char linkname[PATH_MAX]; + int len; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in readlink request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %d", pathname, &len); + iresult = readlink(pathname, linkname, len); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x readlink(\"%s\", %p, %d) = -1 (pvmerrno = %d)\n", + requestor, pathname, linkname, len, iresult)); + } else if (iresult == len) { + pvm_packf("%*.*c", iresult, iresult, linkname); + dprint((buf2, + "FS: tid t%x readlink(\"%s\", %p, %d) = %d \"%*.*s\"\n", + requestor, pathname, linkname, len, len, len, len, linkname)); + } else { + pvm_packf("%s", linkname); + dprint((buf2, + "FS: tid t%x readlink(\"%s\", %p, %d) = %d \"%s\"\n", + requestor, pathname, linkname, len, iresult, linkname)); + } + pvm_send(requestor, request); + } + + #if 0 + + /* + * Give up on statfs for now. Not much consistency out there... + */ + + #ifdef _AIX + #include + #endif + #ifdef __alpha + #include + #endif + #ifdef __convex__ + #include + #endif + + static void + putstatfs(struct statfs *stp) + { + long l; + + #define put(member) l = (long)stp->f_##member; pvm_packf("%ld", l); + put(type); + put(bsize); + put(blocks); + put(bfree); + put(bavail); + put(files); + put(ffree); + #if 0 + /* these don't seem to be very uniform */ + put(fsid); + put(fname); + put(name_max); + #endif + #undef put + } + + void + fs_statfs(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + struct statfs stbuf; + int len; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in statfs request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %d", pathname, &len); + iresult = statfs(pathname, &stbuf, len); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x statfs(\"%s\", %p, %d) = -1 (pvmerrno = %d)\n", + requestor, pathname, &stbuf, len, iresult)); + } else { + putstatfs(&stbuf); + dprint((buf2, "FS: tid t%x statfs(\"%s\", %p, %d) = %d\n", + requestor, pathname, &stbuf, len, iresult)); + } + pvm_send(requestor, request); + } + + void + fs_fstatfs(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int iresult; + struct statfs stbuf; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in fstatfs request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &fd); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else + iresult = fstatfs(gfd, &stbuf); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x fstatfs(%d, %p, %d) = -1 (pvmerrno = %d)\n", + requestor, fd, &stbuf, len, iresult)); + } else { + putstatfs(&stbuf); + dprint((buf2, "FS: tid t%x fstatfs(%d, %p, %d) = %d\n", + requestor, fd, &stbuf, len, iresult)); + } + pvm_send(requestor, request); + } + #endif + + void + fs_truncate(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + long llen; + off_t len; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in truncate request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %ld", pathname, &llen); + len = llen;; + iresult = truncate(pathname, len); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x truncate(\"%s\", %ld) = -1 (pvmerrno = %d)\n", + requestor, pathname, (long)len, iresult)); + } else + dprint((buf2, "FS: tid t%x truncate(\"%s\", %ld) = %d\n", + requestor, pathname, (long)len, iresult)); + pvm_send(requestor, request); + } + + void + fs_ftruncate(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + int fd; + int gfd; + long llen; + off_t len; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in ftruncate request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d %ld", &fd, &llen); + len = llen; + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else { + struct fd *fdp = &globalmap.fd[gfd]; + + switch (lmp->lfd[fd].iomode) { + case PvmIomodeIndividual: + iresult = ftruncate(gfd, len); + break; + default: + /* + * This is to stop FORTRAN libraries from doing + * write, lseek, ftruncate for files opened with + * mode 'unknown'. One process could squeeze + * a write between the lseek and ftruncate of + * another process... + */ + if (fdp->nrefs == 1) + iresult = ftruncate(gfd, len); + else + iresult = 0; + } + } + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x ftruncate(%d, %ld) = -1 (pvmerrno = %d)\n", + requestor, fd, (long)len, iresult)); + } else + dprint((buf2, "FS: tid t%x ftruncate(%d, %ld) = %d\n", + requestor, fd, (long)len, iresult)); + pvm_send(requestor, request); + } + + void + fs_umask(struct lmap *lmp, int requestor, int request, int nargs) + { + mode_t mode; + long oldmode; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in umask request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%ld", &oldmode); + mode = pvm_local_open_mode(oldmode); + oldmode = pvm_open_mode(umask(mode)); + pvm_packf("%+ %ld", PvmDataDefault, oldmode); + dprint((buf2, "FS: tid t%x umask(%ld) = %ld\n", requestor, (long)mode, + oldmode)); + pvm_send(requestor, request); + } + + void + fs_utime(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + struct utimbuf ut; + struct utimbuf *utp = NULL; + long l1, l2; + + if (nargs != 1 && nargs != 3) { + dprint((buf2, "FS: bad nargs in utime request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s", pathname); + if (nargs == 3) { + pvm_unpackf("%ld %ld", &l1, &l2); + utp = &ut; + utp->actime = l1; + utp->modtime = l2; + } + iresult = utime(pathname, utp); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x utime(\"%s\", %p) = -1 (pvmerrno = %d)\n", + requestor, pathname, utp, iresult)); + } else + dprint((buf2, "FS: tid t%x utime(\"%s\", %p) = %d\n", + requestor, pathname, utp, iresult)); + pvm_send(requestor, request); + } + + void + fs_utimes(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + struct timeval tv[2]; + long l1, l2, l3, l4; + + if (nargs != 5) { + dprint((buf2, "FS: bad nargs in utimes request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %ld %ld %ld %ld", pathname, &l1, &l2, &l3, &l4); + tv[0].tv_sec = l1; + tv[0].tv_usec = l2; + tv[1].tv_sec = l3; + tv[1].tv_usec = l4; + iresult = utimes(pathname, tv); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x utimes(\"%s\", %p) = -1 (pvmerrno = %d)\n", + requestor, pathname, tv, iresult)); + } else + dprint((buf2, "FS: tid t%x utimes(\"%s\", %p) = %d\n", + requestor, pathname, tv, iresult)); + pvm_send(requestor, request); + } + + void + fs_sync(struct lmap *lmp, int requestor, int request, int nargs) + { + dprint((buf2, "FS: tid t%x sync()\n", requestor)); + syscall(SYS_sync); + } + + void + fs_fsync(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int iresult; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in fsync request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &fd); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else + iresult = fsync(gfd); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, "FS: tid t%x fsync(%d) = -1 (pvmerrno = %d)\n", + requestor, fd, iresult)); + } else + dprint((buf2, "FS: tid t%x fsync(%d) = %d\n", requestor, fd, + iresult)); + pvm_send(requestor, request); + } + + void + fs_access(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + char pathname[PATH_MAX]; + int pvmmode; + int mode; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in access request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %d", pathname, &pvmmode); + mode = pvm_local_access_mode(pvmmode); + iresult = access(pathname, mode); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x access(\"%s\", %d) = -1 (pvmerrno = %d)\n", + requestor, pathname, pvmmode, iresult)); + } else + dprint((buf2, "FS: tid t%x access(\"%s\", %d) = %d\n", + requestor, pathname, pvmmode, iresult)); + pvm_send(requestor, request); + } + + static int + fs_convert_fdset(struct lmap *lmp, int maxfdp1, int gmaxfdp1, fd_set *setp, fd_set *gsetp) + { + int numset = 0; + int numdone = 0; + int fd; + int gfd; + fd_set tmp; + + FD_ZERO(&tmp); + + for (fd = 0; fd < maxfdp1; fd++) { + if (!FD_ISSET(fd, setp)) + continue; + if ((gfd = fdtorealfd(lmp, fd)) >= 0 && FD_ISSET(gfd, gsetp)) { + FD_SET(fd, &tmp); + numset++; + } + } + + FD_ZERO(setp); + for (fd = 0; fd < maxfdp1; fd++) + if (FD_ISSET(fd, &tmp)) { + FD_SET(fd, setp); + if (++numdone == numset) + break; + } + + return numset; + } + + int + pvm_select_global_fdset(struct lmap *lmp, int maxfdp1, int *gmaxfdp1p, fd_set *setp, fd_set *gsetp) + { + int fd; + int gfd; + + FD_ZERO(gsetp); + + for (fd = 0; fd < maxfdp1; fd++) + if (FD_ISSET(fd, setp)) { + if ((gfd = fdtorealfd(lmp, fd)) == -1) + return -1; + FD_SET(gfd, gsetp); + if (gfd + 1 > *gmaxfdp1p) + *gmaxfdp1p = gfd + 1; + } + + return 0; + } + + void + fs_select(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + int maxfdp1, gmaxfdp1; + int want_rset, want_wset, want_eset; + fd_set rset, wset, eset; + fd_set grset, gwset, geset; + struct timeval tv; + struct timeval *tvp; + + if (nargs != 4 && nargs != 5) { + dprint((buf2, "FS: bad nargs in select request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &maxfdp1); + if (maxfdp1 > globalmap.numfds) + maxfdp1 = globalmap.numfds; + if (maxfdp1 > FD_SETSIZE) + maxfdp1 = FD_SETSIZE; + want_rset = pvm_select_fdset_unpack(&rset); + want_wset = pvm_select_fdset_unpack(&wset); + want_eset = pvm_select_fdset_unpack(&eset); + if (nargs == 5) { + long l; + + tvp = &tv; + pvm_unpackf("%ld", &l); tvp->tv_sec = l; + pvm_unpackf("%ld", &l); tvp->tv_usec = l; + } else + tvp = NULL; + gmaxfdp1 = 0; + if (want_rset && pvm_select_global_fdset(lmp, maxfdp1, &gmaxfdp1, &rset, + &grset) == -1 || + want_wset && pvm_select_global_fdset(lmp, maxfdp1, &gmaxfdp1, &wset, + &gwset) == -1 || + want_eset && pvm_select_global_fdset(lmp, maxfdp1, &gmaxfdp1, &eset, + &geset) == -1) { + iresult = -1; + errno = EBADF; + } else + iresult = select(gmaxfdp1, want_rset ? &grset : NULL, + want_wset ? &gwset : NULL, want_eset ? &geset : NULL, tvp); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x select(%d, ...) = -1 (pvmerrno = %d)\n", + requestor, maxfdp1, iresult)); + } else if (iresult > 0) { + iresult = 0; + if (want_rset) { + iresult += fs_convert_fdset(lmp, maxfdp1, gmaxfdp1, + &rset, &grset); + pvm_select_fdset_pack(maxfdp1, &rset); + } + if (want_wset) { + iresult += fs_convert_fdset(lmp, maxfdp1, gmaxfdp1, + &wset, &gwset); + pvm_select_fdset_pack(maxfdp1, &wset); + } + if (want_eset) { + iresult += fs_convert_fdset(lmp, maxfdp1, gmaxfdp1, + &eset, &geset); + pvm_select_fdset_pack(maxfdp1, &eset); + } + dprint((buf2, "FS: tid t%x select(%d, ...) = %d\n", requestor, + maxfdp1, iresult)); + } else + dprint((buf2, "FS: tid t%x select(%d, ...) = 0\n", requestor, + maxfdp1)); + pvm_send(requestor, request); + } + + /* + * Mapping for POSIX directory functions. + */ + struct dirmap { + DIR *dp; + struct dirent *dirp; + }; + + static struct dirmap *dirmap = NULL; + static int numdirs = 0; + + void + fs_opendir(struct lmap *lmp, int requestor, int request, int nargs) + { + int i; + int iresult; + char pathname[PATH_MAX]; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in opendir request from t%x\n", + requestor)); + return; + } + + for (i = 0; i < numdirs; i++) + if (dirmap[i].dp == NULL) + break; + if (i == numdirs) { + struct dirmap *tmp; + + #if defined(IMA_SUN3) || defined(IMA_SUN4) + if (dirmap == NULL && (tmp = malloc(sizeof(*dirmap))) == NULL + || dirmap && + #else + if ( + #endif + (tmp = realloc(dirmap, (numdirs + 1) * sizeof(*dirmap))) + == NULL) { + iresult = -1; + errno = pvmerrno(errno); + pvm_packf("%+ %d %d", PvmDataDefault, iresult, errno); + dprint((buf2, + "FS: tid t%x opendir(...) = -1 (pvmerrno = %d)\n", + requestor, errno)); + pvm_send(requestor, request); + return; + } + numdirs++; + dirmap = tmp; + } + + pvm_unpackf("%s", pathname); + dirmap[i].dp = opendir(pathname); + if (dirmap[i].dp == NULL) { + iresult = -1; + errno = pvmerrno(errno); + pvm_packf("%+ %d %d", PvmDataDefault, iresult, errno); + dprint((buf2, + "FS: tid t%x opendir(\"%s\") = NULL (pvmerrno = %d)\n", + requestor, pathname, errno)); + } else { + pvm_packf("%+ %d", PvmDataDefault, i); + dprint((buf2, "FS: tid t%x opendir(\"%s\") = %p (index %d)\n", + requestor, pathname, (void *)dirmap[i].dp, i)); + } + pvm_send(requestor, request); + } + + void + fs_readdir(struct lmap *lmp, int requestor, int request, int nargs) + { + int i; + int iresult; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in readdir request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &i); + if (i < 0 || i >= numdirs || dirmap[i].dp == NULL) { + iresult = -1; + errno = pvmerrno(EBADF); + pvm_packf("%+ %d %d", PvmDataDefault, iresult, errno); + dprint((buf2, + "FS: tid t%x readdir(index %d) = NULL (errno = EBADF)\n", + requestor, i + 1)); + pvm_send(requestor, request); + return; + } + + /* + * We set errno to -2. If we get NULL and errno is still -2, + * we reset errno back to saved_errno. + */ + errno = -2; + dirmap[i].dirp = readdir(dirmap[i].dp); + if (dirmap[i].dirp == NULL) { + iresult = -1; + errno = pvmerrno(errno); + pvm_packf("%+ %d %d", PvmDataDefault, iresult, errno); + dprint((buf2, + "FS: tid t%x readdir(index %d) = NULL (pvmerrno = %d)\n", + requestor, i + 1, errno)); + } else { + iresult = 0; + pvm_packf("%+ %d %s", PvmDataDefault, iresult, + dirmap[i].dirp->d_name); + dprint((buf2, "FS: tid t%x readdir(index %d) = %p\n", + requestor, i + 1, (void *)dirmap[i].dirp)); + } + pvm_send(requestor, request); + } + + void + fs_closedir(struct lmap *lmp, int requestor, int request, int nargs) + { + int i; + int iresult; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in closedir request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &i); + if (i < 0 || i >= numdirs || dirmap[i].dp == NULL) { + iresult = -1; + errno = pvmerrno(EBADF); + pvm_packf("%+ %d %d", PvmDataDefault, iresult, errno); + dprint((buf2, + "FS: tid t%x closedir(index %d) = -1 (errno = EBADF)\n", + requestor, i)); + pvm_send(requestor, request); + return; + } + + iresult = closedir(dirmap[i].dp); + if (iresult == -1) { + errno = pvmerrno(errno); + pvm_packf("%+ %d %d", PvmDataDefault, iresult, errno); + dprint((buf2, + "FS: tid t%x closedir(index %d) = -1 (pvmerrno = %d)\n", + requestor, i, errno)); + } else { + dirmap[i].dp = NULL; + pvm_packf("%+ %d", PvmDataDefault, iresult); + dprint((buf2, "FS: tid t%x closedir(index %d) = %d\n", + requestor, i, iresult)); + } + pvm_send(requestor, request); + } + + void + fs_rewinddir(struct lmap *lmp, int requestor, int request, int nargs) + { + int i; + int iresult; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in rewinddir request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &i); + if (i < 0 || i >= numdirs || dirmap[i].dp == NULL) { + iresult = -1; + errno = pvmerrno(EBADF); + pvm_packf("%+ %d %d", PvmDataDefault, iresult, errno); + dprint((buf2, "FS: tid t%x rewinddir(index %d) - bad index\n", + requestor, i)); + pvm_send(requestor, request); + return; + } + + rewinddir(dirmap[i].dp); + iresult = 0; + pvm_packf("%+ %d", PvmDataDefault, iresult); + dprint((buf2, "FS: tid t%x rewinddir(index %d) ok\n", + requestor, i)); + pvm_send(requestor, request); + } + + void + fs_isatty(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int iresult; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in isatty request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &fd); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = 0; + errno = EBADF; + } else + iresult = isatty(gfd); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == 0) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, "FS: tid t%x isatty(%d) = 0 (pvmerrno = %d)\n", + requestor, fd, iresult)); + } else + dprint((buf2, "FS: tid t%x isatty(%d) = %d\n", requestor, fd, + iresult)); + pvm_send(requestor, request); + } + + void + fs_ttyname(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int len; + char *cresult; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in ttyname request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &fd); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + cresult = NULL; + errno = EBADF; + len = 0; + } else if (cresult = ttyname(gfd)) + len = strlen(cresult); + else + len = 0; + pvm_packf("%+ %d", PvmDataDefault, len); + if (len == 0) { + len = pvmerrno(errno); + pvm_packf("%d", len); + dprint((buf2, + "FS: tid t%x ttyname(%d) = NULL (pvmerrno = %d)\n", + requestor, fd, len)); + } else { + pvm_packf("%s", cresult); + dprint((buf2, "FS: tid t%x ttyname(%d) = %s\n", requestor, fd, + cresult)); + } + pvm_send(requestor, request); + } + + void + fs_ctermid(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int len; + char *cresult; + + if (nargs != 0) { + dprint((buf2, "FS: bad nargs in ctermid request from t%x\n", + requestor)); + return; + } + + cresult = ctermid(NULL); + len = strlen(cresult); + + pvm_packf("%+ %d", PvmDataDefault, len); + if (len == 0) { + len = pvmerrno(errno); + pvm_packf("%d", len); + dprint((buf2, + "FS: tid t%x ctermid(%d) = NULL (pvmerrno = %d)\n", + requestor, fd, len)); + } else { + pvm_packf("%s", cresult); + dprint((buf2, "FS: tid t%x ctermid(NULL) = %s\n", requestor, + cresult)); + } + pvm_send(requestor, request); + } + + void + fs_tcdrain(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int iresult; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in tcdrain request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &fd); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else + iresult = tcdrain(gfd); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, "FS: tid t%x tcdrain(%d) = -1 (pvmerrno = %d)\n", + requestor, fd, iresult)); + } else + dprint((buf2, "FS: tid t%x tcdrain(%d) = %d\n", requestor, fd, + iresult)); + pvm_send(requestor, request); + } + + void + fs_tcflow(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int action; + int iresult; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in tcflow request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d %d", &fd, &action); + action = pvm_local_tcflow_action(action); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else + iresult = tcflow(gfd, action); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x tcflow(%d, %d) = -1 (pvmerrno = %d)\n", + requestor, fd, action, iresult)); + } else + dprint((buf2, + "FS: tid t%x tcflow(%d, %d) = %d\n", requestor, fd, action, + iresult)); + pvm_send(requestor, request); + } + + void + fs_tcflush(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int queue; + int iresult; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in tcflush request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d %d", &fd, &queue); + queue = pvm_local_tcflush_queue(queue); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else + iresult = tcflush(gfd, queue); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x tcflush(%d, %d) = -1 (pvmerrno = %d)\n", + requestor, fd, queue, iresult)); + } else + dprint((buf2, + "FS: tid t%x tcflush(%d, %d) = %d\n", requestor, fd, queue, + iresult)); + pvm_send(requestor, request); + } + + void + fs_tcsendbreak(struct lmap *lmp, int requestor, int request, int nargs) + { + int fd; + int gfd; + int duration; + int iresult; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in tcsendbreak request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d %d", &fd, &duration); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + iresult = -1; + errno = EBADF; + } else + iresult = tcsendbreak(gfd, duration); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x tcsendbreak(%d, %d) = -1 (pvmerrno = %d)\n", + requestor, fd, duration, iresult)); + } else + dprint((buf2, + "FS: tid t%x tcsendbreak(%d, %d) = %d\n", requestor, fd, + duration, iresult)); + pvm_send(requestor, request); + } + + void + fs_pathconf(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + long lresult; + char pathname[PATH_MAX]; + int pvmname; + int name; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in pathconf request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%s %d", pathname, &pvmname); + if (pvmname < 0) + lresult = sysconf(_SC_OPEN_MAX); + else { + name = pvm_local_pathconf_name(pvmname); + lresult = pathconf(pathname, name); + } + pvm_packf("%+ %ld", PvmDataDefault, lresult); + if (lresult == -1L) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + if (pvmname < 0) + dprint((buf2, + "FS: tid t%x sysconf(_SC_OPEN_MAX) = -1 (pvmerrno = %d)\n", + requestor, iresult)); + else + dprint((buf2, + "FS: tid t%x pathconf(\"%s\", %d) = -1 (pvmerrno = %d)\n", + requestor, pathname, name, iresult)); + } else if (pvmname < 0) + dprint((buf2, "FS: tid t%x sysconf(_SC_OPEN_MAX) = %ld\n", + requestor, lresult)); + else + dprint((buf2, "FS: tid t%x pathconf(\"%s\", %d) = %ld\n", + requestor, pathname, name, lresult)); + pvm_send(requestor, request); + } + + void + fs_fpathconf(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + long lresult; + int fd; + int gfd; + int pvmname; + uid_t name; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in fpathconf request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d %d", &fd, &pvmname); + if ((gfd = fdtorealfd(lmp, fd)) == -1) { + lresult = -1L; + errno = EBADF; + } else if (pvmname < 0) + /* + * Get maximum number of file descriptors. + */ + lresult = sysconf(_SC_OPEN_MAX); + else { + name = pvm_local_pathconf_name(pvmname); + lresult = fpathconf(gfd, name); + } + pvm_packf("%+ %ld", PvmDataDefault, lresult); + if (lresult == -1L) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + if (pvmname < 0) + dprint((buf2, + "FS: tid t%x sysconf(_SC_OPEN_MAX) = -1 (pvmerrno = %d)\n", + requestor, iresult)); + else + dprint((buf2, + "FS: tid t%x fpathconf(%d, %d) = -1 (pvmerrno = %d)\n", + requestor, fd, name, iresult)); + } else if (pvmname < 0) + dprint((buf2, "FS: tid t%x sysconf(_SC_OPEN_MAX) = %ld\n", + requestor, fd, lresult)); + else + dprint((buf2, "FS: tid t%x fpathconf(%d, %d) = %ld\n", + requestor, fd, name, lresult)); + pvm_send(requestor, request); + } + + #ifdef IMA_CRAY + #define RLIM_INFINITY 0 + + typedef unsigned long rlim_t; + + struct rlimit { + rlim_t rlim_cur; + rlim_t rlim_max; + }; + #endif + + void + fs_getrlimit(struct lmap *lmp, int requestor, int request, int nargs) + { + int resource; + int iresult; + struct rlimit rlim; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in getrlimit request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &resource); + if ((resource = pvm_local_rlimit_resource(resource)) == -1) { + iresult = -1; + errno = EINVAL; + } else + iresult = getrlimit(resource, &rlim); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x getrlimit(%d, %p) = -1 (pvmerrno = %d)\n", + requestor, resource, &rlim, iresult)); + } else { + int infinity; + unsigned long ul; + + infinity = rlim.rlim_cur == RLIM_INFINITY; + pvm_packf("%d", infinity); + if (!infinity) { + ul = rlim.rlim_cur; + pvm_pkulong(&ul, 1, 1); + } + infinity = rlim.rlim_max == RLIM_INFINITY; + pvm_packf("%d", infinity); + if (!infinity) { + ul = rlim.rlim_max; + pvm_pkulong(&ul, 1, 1); + } + dprint((buf2, "FS: tid t%x getrlimit(%d, %p) = %d\n", + requestor, resource, &rlim, iresult)); + } + pvm_send(requestor, request); + } + + void + fs_setrlimit(struct lmap *lmp, int requestor, int request, int nargs) + { + int resource; + int iresult; + struct rlimit rlim; + + if (nargs != 3) { + dprint((buf2, "FS: bad nargs in setrlimit request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &resource); + if ((resource = pvm_local_rlimit_resource(resource)) == -1) { + iresult = -1; + errno = EINVAL; + } else { + int infinity; + unsigned long ul; + + pvm_unpackf("%d", &infinity); + if (infinity) + rlim.rlim_cur = RLIM_INFINITY; + else { + pvm_upkulong(&ul, 1, 1); + rlim.rlim_cur = ul; + } + pvm_unpackf("%d", &infinity); + if (infinity) + rlim.rlim_max = RLIM_INFINITY; + else { + pvm_upkulong(&ul, 1, 1); + rlim.rlim_max = ul; + } + iresult = setrlimit(resource, &rlim); + } + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x setrlimit(%d, %p) = -1 (pvmerrno = %d)\n", + requestor, resource, (void *)&rlim, iresult)); + } else + dprint((buf2, "FS: tid t%x setrlimit(%d, %p) = %d\n", + requestor, resource, (void *)&rlim, iresult)); + pvm_send(requestor, request); + } + + void + fs_getdtablesize(struct lmap *lmp, int requestor, int request, int nargs) + { + int iresult; + + if (nargs != 0) { + dprint((buf2, + "FS: bad nargs in getdtablesize request from t%x\n", + requestor)); + return; + } + + iresult = getdtablesize(); + pvm_packf("%+ %d", PvmDataDefault, iresult); + if (iresult == -1) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x getdtablesize() = -1 (pvmerrno = %d)\n", + requestor, iresult)); + } else + dprint((buf2, "FS: tid t%x getdtablesize() = %d\n", requestor, + iresult)); + pvm_send(requestor, request); + } + + void + fs_getdirentries(struct lmap *lmp, int requestor, int request, int nargs) + { + } + + void + fs_getcwd(struct lmap *lmp, int requestor, int request, int nargs) + { + unsigned long ul; + char cwd[PATH_MAX]; + int iresult; + + if (nargs != 0) { + dprint((buf2, "FS: bad nargs in getcwd request from t%x\n", + requestor)); + return; + } + + if (getcwd(cwd, sizeof cwd)) + ul = strlen(cwd) + 1; + else + ul = 0; + pvm_packf("%+", PvmDataDefault); + pvm_pkulong(&ul, 1, 1); + if (ul == 0) { + iresult = pvmerrno(errno); + pvm_packf("%d", iresult); + dprint((buf2, + "FS: tid t%x getcwd(...) = NULL (pvmerrno = %d)\n", + requestor, iresult)); + } else { + pvm_packf("%s", cwd); + dprint((buf2, "FS: tid t%x getcwd(...) = \"%s\"\n", requestor, + cwd)); + } + pvm_send(requestor, request); + } + + void + fs_seekdir(struct lmap *lmp, int requestor, int request, int nargs) + { + int i; + int iresult; + long loc; + + if (nargs != 2) { + dprint((buf2, "FS: bad nargs in seekdir request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d %ld", &i, &loc); + if (i < 0 || i >= numdirs || dirmap[i].dp == NULL) { + iresult = -1; + errno = pvmerrno(EBADF); + pvm_packf("%+ %d %d", PvmDataDefault, iresult, errno); + dprint((buf2, + "FS: tid t%x seekdir(index %d, %ld) - bad index\n", + requestor, i, loc)); + pvm_send(requestor, request); + return; + } + + seekdir(dirmap[i].dp, loc); + iresult = 0; + pvm_packf("%+ %d", PvmDataDefault, iresult); + dprint((buf2, "FS: tid t%x seekdir(index %d, %ld) ok\n", + requestor, i, loc)); + pvm_send(requestor, request); + } + + void + fs_telldir(struct lmap *lmp, int requestor, int request, int nargs) + { + int i; + long lresult; + + if (nargs != 1) { + dprint((buf2, "FS: bad nargs in telldir request from t%x\n", + requestor)); + return; + } + + pvm_unpackf("%d", &i); + if (i < 0 || i >= numdirs || dirmap[i].dp == NULL) { + lresult = -1; + errno = pvmerrno(EBADF); + pvm_packf("%+ %ld %d", PvmDataDefault, lresult, errno); + dprint((buf2, + "FS: tid t%x telldir(index %d) = -1 (errno = EBADF)\n", + requestor, i)); + pvm_send(requestor, request); + return; + } + + lresult = telldir(dirmap[i].dp); + if (lresult == -1) { + errno = pvmerrno(errno); + pvm_packf("%+ %ld %d", PvmDataDefault, lresult, errno); + dprint((buf2, + "FS: tid t%x telldir(index %d) = -1 (pvmerrno = %d)\n", + requestor, i, errno)); + } else { + dirmap[i].dp = NULL; + pvm_packf("%+ %ld", PvmDataDefault, lresult); + dprint((buf2, "FS: tid t%x telldir(index %d) = %ld\n", + requestor, i, lresult)); + } + pvm_send(requestor, request); + } *** /dev/null Thu Aug 25 19:19:25 1994 --- pvmfs/gop.c Sun Jul 24 18:25:05 1994 *************** *** 0 **** --- 1,224 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #include + #include + #include + #include + #include + #include + #include "map.h" + #include "bitops.h" + #include "fsp.h" + + struct gop *gop = NULL; + + extern size_t nummaps; + extern size_t nummapsused; + extern struct lmap *lmap; + extern int *tidorder; + extern struct gmap globalmap; + + #if !defined(IMA_RS6K) && !defined(IMA_CRAY) + #include + #else + #include "syscall-fake.h" + #endif + extern char buf2[]; + #define dprint(s) do { \ + sprintf s; \ + syscall(SYS_write, 2, buf2, strlen(buf2)); \ + } while (0) + #if 1 + #undef dprint + #define dprint(s) + #endif + + int + gop_doclose(int fd) + { + struct gop *gp; + + /* + * Should we *really* close the file descriptor? + */ + for (gp = gop; gp; gp = gp->next) + if ((gp->type == PVMFS_OPEN || gp->type == PVMFS_CREAT) + && gp->st_ino == globalmap.fd[fd].st_ino + && gp->st_dev == globalmap.fd[fd].st_dev) { + dprint((buf2, "gop_doclose(%d) = 0\n", fd)); + return 0; + } + + dprint((buf2, "gop_doclose(%d) = 1\n", fd)); + return 1; + } + + struct gop * + gop_add(int type, int fd, ino_t st_ino, dev_t st_dev, long result) + { + size_t nbytes; + struct gop *glp; + struct gop *gp; + + /* + * A new global operation. Add it at the tail. + */ + nbytes = (nummaps + CHAR_BIT - 1) / CHAR_BIT; + if ((glp = malloc(sizeof(*glp))) == NULL + || (glp->done = malloc(nbytes)) == NULL) { + if (glp) + free(glp); + return NULL; + } + (void)memset(glp->done, '\0', nbytes); + glp->next = NULL; + glp->type = type; + glp->fd = fd; + glp->st_ino = st_ino; + glp->st_dev = st_dev; + glp->result = result; + glp->buf = NULL; + glp->numdone = 0; + glp->queue = NULL; + + if (gop) { + for (gp = gop; gp->next; gp = gp->next) + ; + gp->next = glp; + } else + gop = glp; + + return glp; + } + + /* delete at head */ + int + gop_delete(void) + { + struct gop *gp; + + if (!gop) + return -1; + gp = gop; + gop = gop->next; + free(gp->done); + if (gp->buf) + free(gp->buf); + free(gp); + return 0; + } + + struct gop * + gop_find(int type, int fd, ino_t ino, dev_t dev, int bitpos) + { + struct gop *gp; + + /* + * Look for a global operation. + */ + for (gp = gop; gp; gp = gp->next) + if (gp->type == type && isclr(gp->done, bitpos)) + if (type == PVMFS_OPEN || type == PVMFS_CREAT) { + if (gp->st_ino == ino && gp->st_dev == dev) + return gp; + } else if (gp->fd == fd) + return gp; + + return NULL; + } + + struct gop * + gop_first(int type) + { + struct gop *gp; + + /* + * Find the first global operation of type ``type''. + */ + for (gp = gop; gp; gp = gp->next) + if (gp->type == type) + return gp; + + return NULL; + } + + int + allset(unsigned char *vector) + { + int i; + + for (i = 0; i < nummaps; i++) + if (lmap[i].tid && !isset(vector, i)) + return 0; + + return 1; + } + + void + gop_queue_add(struct gop *gp, struct queued *qp) + { + qp->next = gp->queue; + gp->queue = qp; + } + + struct queued * + gop_queue_find(struct gop *gp, int order) + { + struct queued *qp; + + for (qp = gp->queue; qp; qp = qp->next) + if (qp->number == order) + return qp; + + return NULL; + } + + void + gop_queue_delete(struct gop *gp, int order) + { + struct queued *qp; + struct queued *prev; + int i; + + for (prev = NULL, qp = gp->queue; qp; prev = qp, qp = qp->next) + if (qp->number == order) { + if (prev) + prev->next = qp->next; + else + gp->queue = qp->next; + for (i = 0; i < qp->nargs; i++) + if (qp->args[i]) + free(qp->args[i]); + if (qp->args) + free(qp->args); + free(qp); + break; + } + } + + int + tid2order(int tid) + { + int i; + + for (i = 0; i < nummaps; i++) + if (tidorder[i] == tid) + return i; + + return -1; + } *** /dev/null Thu Aug 25 19:19:25 1994 --- pvmfs/lmap.c Sun Jul 24 18:25:05 1994 *************** *** 0 **** --- 1,226 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #include + #include + #include + #include + #include + #include + #include "fs.h" + #include "map.h" + #include "pvm3.h" + + #if !defined(IMA_RS6K) && !defined(IMA_CRAY) + #include + #else + #include "syscall-fake.h" + #endif + extern char buf2[]; + #define dprint(s) do { \ + sprintf s; \ + syscall(SYS_write, 2, buf2, strlen(buf2)); \ + } while (0) + #if 1 + #undef dprint + #define dprint(s) + #endif + + extern int pvmmysfd; + + struct gmap globalmap; + struct lmap *lmap = NULL; + extern struct gop *gop; + + size_t nummaps = 0; + size_t nummapsused = 0; + int *tidorder = NULL; + + int + fdtorealfd(struct lmap *lmp, int filedes) + { + struct fd *fdp; + + /* + * Translate a client fd to our fd. + */ + if (filedes < 0 || filedes >= globalmap.numfds) + return -1; + if (fdp = lmp->lfd[filedes].fd) { + dprint((buf2, "tid t%x: fd %d is global fd %d\n", lmp->tid, + filedes, fdp - globalmap.fd)); + return fdp - globalmap.fd; + } else + return -1; + } + + struct lmap * + lmap_add(int tid) + { + int i; + struct lmap *lmp; + + /* + * Add a new client. + */ + for (i = 0; i < nummaps; i++) + if (lmap[i].tid == 0) + break; + + if (i == nummaps) { + #if defined(IMA_SUN3) || defined(IMA_SUN4) + if (lmap == NULL) { + if ((lmap = malloc(sizeof(*lmap))) == NULL) + return NULL; + } else + #endif + if ((lmap = realloc(lmap, (nummaps + 1) * sizeof(*lmap))) + == NULL) + return NULL; + #if defined(IMA_SUN3) || defined(IMA_SUN4) + if (tidorder == NULL) { + if ((tidorder = malloc(sizeof(*tidorder))) == NULL) + return NULL; + } else + #endif + if ((tidorder = realloc(tidorder, + (nummaps + 1) * sizeof(*tidorder))) == NULL) + return NULL; + tidorder[nummaps] = tid; + if ((lmap[nummaps].lfd = malloc(globalmap.numfds + * sizeof(*lmap[0].lfd))) == NULL) { + lmap[nummaps].tid = tidorder[nummaps] = 0; + return NULL; + } else + nummaps++; + } + + lmap[i].tid = tid; + lmp = &lmap[i]; + for (i = 0; i < globalmap.numfds; i++) + if (globalmap.fd[i].from_start) { + lmp->lfd[i].fd = &globalmap.fd[i]; + lmp->lfd[i].iomode = globalmap.fd[i].iomode; + lmp->lfd[i].offset = globalmap.fd[i].offset; + globalmap.fd[i].nrefs++; + } else + lmp->lfd[i].fd = NULL; + + nummapsused++; + + return lmp; + } + + struct lmap * + lmap_find(int tid) + { + int i; + struct lmap *lmp; + + for (i = 0, lmp = lmap; i < nummaps; i++, lmp++) + if (lmp->tid == tid) + return lmp; + + return NULL; + } + + void + lmap_delete(int tid) + { + int i; + int j; + int fd; + struct lmap *lmp; + + /* + * A client went away... + */ + if (lmp = lmap_find(tid)) { + lmp->tid = 0; + for (i = 0; i < globalmap.numfds; i++) + if ((fd = fdtorealfd(lmp, i)) != -1) + switch (globalmap.fd[fd].iomode) { + case PvmIomodeIndividual: + /*globalmap.fd[i].nrefs--;*/ + close(fd); + break; + case PvmIomodeCommon: + case PvmIomodeIndependent: + case PvmIomodeSyncBC: + case PvmIomodeSyncSeq: + if (--globalmap.fd[i].nrefs == 0) + close(fd); + break; + } + + if (lmp->lfd) + free(lmp->lfd); + + for (i = 0; i < nummapsused; i++) + if (tidorder[i] == tid) + break; + nummapsused--; + } + } + + int + lmap_init(int pfd0, int pfd1, int authfd) + { + int i; + int flags; + struct stat stbuf; + + /* + * Initialize the file descriptor and global operation mapping. + */ + globalmap.numfds = getdtablesize(); + if ((globalmap.fd = malloc(globalmap.numfds * sizeof(*globalmap.fd))) + == NULL) + return -1; + gop = NULL; + tidorder = NULL; + for (i = 0; i < globalmap.numfds; i++) + if (i == pvmmysfd || i == pfd0 || i == pfd1 || i == authfd + || fstat(i, &stbuf) == -1) + globalmap.fd[i].from_start = 0; + else { + globalmap.fd[i].nrefs = 0; + globalmap.fd[i].st_ino = stbuf.st_ino; + globalmap.fd[i].st_dev = stbuf.st_dev; + if (i == 0 || (flags = fcntl(i, F_GETFL, 0)) == 0 + && (flags & O_ACCMODE) == O_RDONLY) + globalmap.fd[i].iomode = PvmIomodeSyncBC; + else + globalmap.fd[i].iomode = PvmIomodeCommon; + globalmap.fd[i].offset = lseek(i, 0, SEEK_CUR); + globalmap.fd[i].from_start = 1; + } + + return 0; + } + + int + tid2bitpos(int tid) + { + int i; + + for (i = 0; i < nummaps; i++) + if (lmap[i].tid == tid) + return i; + + return -1; + } *** /dev/null Thu Aug 25 19:19:25 1994 --- pvmfs/map.h Sun Jul 24 18:25:05 1994 *************** *** 0 **** --- 1,72 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + /* + * File descriptors + */ + struct gmap { + int numfds; + struct fd { + int nrefs; + ino_t st_ino; + dev_t st_dev; + int iomode; + off_t offset; + int from_start; + } *fd; + }; + + /* + * Global operations + */ + struct gop { + struct gop *next; + int type; + int fd; + ino_t st_ino; + dev_t st_dev; + long result; + void *buf; + int numdone; + unsigned char *done; + struct queued *queue; + }; + + /* + * Queued synchronized reads and writes + */ + struct queued { + struct queued *next; + int number; + int type; + int fd; + void **args; + int nargs; + int tid; + }; + + /* + * Clients + */ + struct lmap { + int tid; + struct lfd { + int iomode; + off_t offset; + struct fd *fd; + } *lfd; + }; *** /dev/null Thu Aug 25 19:19:25 1994 --- pvmfs/patchlevel.h Sun Jul 24 18:25:05 1994 *************** *** 0 **** --- 1,21 ---- + /* + * Author: Christopher G. Phillips + * Copyright (C) 1993 All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appear in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + + #define MAJORLEVEL 1 + #define MINORLEVEL 1 + #define PATCHLEVEL 0 + #define PVMLEVEL 3.3.4 *** pvm3.ornl/src/Makefile.aimk Fri Aug 26 14:33:28 1994 --- src/Makefile.aimk Tue Jul 26 17:09:39 1994 *************** *** 37,49 **** # SHELL = /bin/sh SDIR = .. LIBDIR = ../../lib/$(PVM_ARCH) ! OPTIONS = -O #OPTIONS = -g #OPTIONS = -g -DSTATISTICS #OPTIONS = -g -DUSE_PVM_ALLOC -DSTATISTICS -DTIMESTAMPLOG #OPTIONS = -p ! CFLAGS = $(OPTIONS) -I$(SDIR)/../include -DARCHCLASS=\"$(PVM_ARCH)\" -DIMA_$(PVM_ARCH) $(ARCHCFLAGS) DOBJ = ddpro.o pvmfrag.o host.o imalloc.o \ mesg.o nmdclass.o pkt.o pvmalloc.o pvmarchc.o \ --- 37,51 ---- # SHELL = /bin/sh SDIR = .. + IDIR = ../../libc LIBDIR = ../../lib/$(PVM_ARCH) ! OPTIONS = -g ! #CGP OPTIONS = -O #OPTIONS = -g #OPTIONS = -g -DSTATISTICS #OPTIONS = -g -DUSE_PVM_ALLOC -DSTATISTICS -DTIMESTAMPLOG #OPTIONS = -p ! CFLAGS = $(OPTIONS) -I$(SDIR)/../include -DARCHCLASS=\"$(PVM_ARCH)\" -DIMA_$(PVM_ARCH) $(ARCHCFLAGS) -DPVMFS #-DDEBUG DOBJ = ddpro.o pvmfrag.o host.o imalloc.o \ mesg.o nmdclass.o pkt.o pvmalloc.o pvmarchc.o \ *************** *** 98,104 **** imalloc.o: $(SDIR)/imalloc.c $(CC) $(CFLAGS) -c $(SDIR)/imalloc.c lpvm.o: $(SDIR)/lpvm.c ! $(CC) $(CFLAGS) -c $(SDIR)/lpvm.c lpvmcat.o: $(SDIR)/lpvmcat.c $(CC) $(CFLAGS) -c $(SDIR)/lpvmcat.c lpvmgen.o: $(SDIR)/lpvmgen.c --- 100,107 ---- imalloc.o: $(SDIR)/imalloc.c $(CC) $(CFLAGS) -c $(SDIR)/imalloc.c lpvm.o: $(SDIR)/lpvm.c ! $(CC) $(CFLAGS) -I$(IDIR) -I$(IDIR)/$(PVM_ARCH) -c $(SDIR)/lpvm.c ! # $(CC) $(CFLAGS) -c $(SDIR)/lpvm.c lpvmcat.o: $(SDIR)/lpvmcat.c $(CC) $(CFLAGS) -c $(SDIR)/lpvmcat.c lpvmgen.o: $(SDIR)/lpvmgen.c *************** *** 160,165 **** --- 163,170 ---- host.o: $(SDIR)/protoglarp.h host.o: $(SDIR)/pvmalloc.h imalloc.o: $(SDIR)/bfunc.h + lpvm.o: $(IDIR)/fsp.h + lpvm.o: $(IDIR)/pipe.h lpvm.o: $(SDIR)/../include/pvm3.h lpvm.o: $(SDIR)/../include/pvmtev.h lpvm.o: $(SDIR)/bfunc.h *** pvm3.ornl/src/ddpro.c Thu Aug 25 18:05:11 1994 --- src/ddpro.c Sun Jul 24 18:53:00 1994 *************** *** 805,810 **** --- 805,813 ---- int schtid; /* scheduler for new tasks */ { int ptid; /* parent task id */ + #ifdef PVMFS + int fstid; /* fs task id */ + #endif /* PVMFS */ char *file = 0; /* file to exec */ int flags; int count; /* number of tasks */ *************** *** 824,829 **** --- 827,835 ---- /* unpack message */ if (upkuint(mp, &ptid) + #ifdef PVMFS + || upkint(mp, &fstid) + #endif /* PVMFS */ || upkstralloc(mp, &file) || upkint(mp, &flags) || upkint(mp, &count) *************** *** 868,873 **** --- 874,882 ---- tids[0] = err; } else { tp->t_ptid = ptid; + #ifdef PVMFS + tp->t_fstid = fstid; + #endif /* PVMFS */ tids[0] = tp->t_tid; } } else *************** *** 886,891 **** --- 895,903 ---- } else { tp->t_ptid = ptid; + #ifdef PVMFS + tp->t_fstid = fstid; + #endif /* PVMFS */ tp->t_outtid = outtid; tp->t_outcod = outcod; tp->t_trctid = trctid; *************** *** 902,907 **** --- 914,922 ---- pkint(mp2, tp->t_tid); pkint(mp2, TEV_NEWTASK); pkint(mp2, ptid); + #ifdef PVMFS + pkint(mp2, fstid); + #endif /* PVMFS */ pkint(mp2, flags); pkstr(mp2, av[0]); sendmessage(mp2); *************** *** 913,918 **** --- 928,938 ---- pkint(mp2, tp->t_tid); pkint(mp2, -2); pkint(mp2, ptid); + #if 0 + #ifdef PVMFS + pkint(mp2, fstid); + #endif /* PVMFS */ + #endif sendmessage(mp2); } } *************** *** 1458,1463 **** --- 1478,1486 ---- "PvmNoTask", "PvmNoEntry", "PvmDupEntry", + #ifdef PVMFS + "PvmNoFileServer", + #endif /* PVMFS */ 0 }; *************** *** 1839,1844 **** --- 1862,1870 ---- if (tp = task_find(where)) { pkint(mp2, tp->t_tid); pkint(mp2, tp->t_ptid); + #ifdef PVMFS + pkint(mp2, tp->t_fstid); + #endif /* PVMFS */ pkint(mp2, myhostpart); pkint(mp2, tp->t_flag); pkstr(mp2, tp->t_a_out ? tp->t_a_out : ""); *************** *** 1849,1854 **** --- 1875,1883 ---- for (tp = locltasks->t_link; tp != locltasks; tp = tp->t_link) { pkint(mp2, tp->t_tid); pkint(mp2, tp->t_ptid); + #ifdef PVMFS + pkint(mp2, tp->t_fstid); + #endif /* PVMFS */ pkint(mp2, myhostpart); pkint(mp2, tp->t_flag); pkstr(mp2, (tp->t_a_out ? tp->t_a_out : "")); *************** *** 1896,1901 **** --- 1925,1934 ---- pkint(mp2, i); /* tid */ upkint(mp, &i); /* ptid */ pkint(mp2, i); + #ifdef PVMFS + upkint(mp, &i); /* fstid */ + pkint(mp2, i); + #endif /* PVMFS */ upkint(mp, &i); /* host */ pkint(mp2, i); upkint(mp, &i); /* flag */ *** pvm3.ornl/src/lpvm.c Tue Sep 06 10:17:50 1994 --- src/lpvm.c Tue Sep 06 10:40:20 1994 *************** *** 74,79 **** --- 74,93 ---- #include + + #ifdef PVMFS + #include + #include + #include + #if defined(IMA_RS6K) || defined(IMA_CRAY) + #include "syscall-fake.h" + #else + #include + #endif + #include "fsp.h" + #include "pipe.h" + #endif /* PVMFS */ + #ifdef IMA_BSD386 #include #endif *************** *** 80,86 **** --- 94,112 ---- #ifdef IMA_LINUX #include #endif + + #ifdef PVMFS + #ifdef IMA_RS6K + #define _KERNEL + #endif + #endif /* PVMFS */ #include + + #ifdef PVMFS + #ifdef IMA_RS6K + #define _KERNEL + #endif + #endif /* PVMFS */ #include #include #include *************** *** 115,120 **** --- 141,153 ---- #include #include "tevmac.h" + #ifdef PVMFS + #include + #ifndef PATH_MAX + #define PATH_MAX 1024 + #endif + #endif /* PVMFS */ + #ifndef max #define max(a,b) ((a)>(b)?(a):(b)) #endif *************** *** 230,235 **** --- 263,271 ---- "No such task", "No such entry", "Duplicate entry", + #ifdef PVMFS + "No file server", + #endif /* PVMFS */ }; int pvmautoerr = 1; /* whether to auto print err msgs */ *************** *** 239,244 **** --- 275,285 ---- int pvmctrccod = 0; int pvmfrgsiz = UDPMAXLEN; /* message frag length (to pack) */ int pvmmyptid = -1; /* parent task id */ + #ifdef PVMFS + int pvmmyfstid = -1; /* fs task id */ + int pvmmysfd = -1; /* socket descriptor to pvmd */ + int pvmfs = 0; /* by default, don't use an fs */ + #endif /* PVMFS */ int pvmmytid = -1; /* this task id */ int pvmmyupid = -1; /* process unix pid */ int pvmudpmtu = UDPMAXLEN; /* local UDP MTU */ *************** *** 278,284 **** --- 319,350 ---- static int pvmtrcmid = 0; /* message buffer for trace */ static int pvmtrcsbf = 0; /* existing other buffer during trace */ + #ifdef PVMFS + /* Needed? */ + int + includefsfuncs() + { + close(-1); + } + #ifdef IMA_CRAY + static int + pvmfs_dup2(int fd1, int fd2) + { + int fstid; + int result; + + fstid = pvmmyfstid; + pvmmyfstid = -1; + result = dup2(fd1, fd2); + pvmmyfstid = fstid; + + return result; + } + #endif + #endif /* PVMFS */ + + /************************** ** Internal Functions ** ** ** *************** *** 461,467 **** --- 527,537 ---- } if (pcbp->tt_fd != -1) { pvm_fd_delete(pcbp->tt_fd, 3); + #ifdef PVMFS + (void)syscall(SYS_close, pcbp->tt_fd); + #else (void)close(pcbp->tt_fd); + #endif /* PVMFS */ } if (up = pcbp->tt_rxfrag) { while (up->ub_link != up) *************** *** 472,478 **** --- 542,552 ---- fr_unref(pcbp->tt_rxf); #ifndef NOUNIXDOM if (pcbp->tt_spath) + #ifdef PVMFS + (void)syscall(SYS_unlink, pcbp->tt_spath); + #else (void)unlink(pcbp->tt_spath); + #endif /* PVMFS */ #endif PVM_FREE(pcbp); *************** *** 535,546 **** --- 609,628 ---- pcbp->tt_state = TTDEAD; if (pcbp->tt_fd != -1) { pvm_fd_delete(pcbp->tt_fd, 3); + #ifdef PVMFS + (void)syscall(SYS_close, pcbp->tt_fd); + #else (void)close(pcbp->tt_fd); + #endif /* PVMFS */ pcbp->tt_fd = -1; } #ifndef NOUNIXDOM if (pcbp->tt_spath) { + #ifdef PVMFS + (void)syscall(SYS_unlink, pcbp->tt_spath); + #else (void)unlink(pcbp->tt_spath); + #endif /* PVMFS */ pcbp->tt_spath = 0; } #endif *************** *** 640,646 **** --- 722,732 ---- if (bind(s, (struct sockaddr*)&uns, sizeof(uns)) == -1) { pvmlogperror("mroute() bind"); + #ifdef PVMFS + (void)syscall(SYS_close, s); + #else (void)close(s); + #endif /* PVMFS */ s = -1; } else { *************** *** 662,674 **** --- 748,768 ---- l = sizeof(sad); if (bind(s, (struct sockaddr*)&sad, sizeof(sad)) == -1) { pvmlogperror("mroute() bind"); + #ifdef PVMFS + (void)syscall(SYS_close, s); + #else (void)close(s); + #endif /* PVMFS */ s = -1; } else { if (getsockname(s, (struct sockaddr*)&sad, &l) == -1) { pvmlogperror("mroute() getsockname"); + #ifdef PVMFS + (void)syscall(SYS_close, s); + #else (void)close(s); + #endif /* PVMFS */ s = -1; } else { *************** *** 837,843 **** --- 931,941 ---- } if (pcbp->tt_state == TTOPEN) { + #ifdef PVMFS + if ((i = syscall(SYS_fcntl, pcbp->tt_fd, F_GETFL, 0)) == -1) + #else if ((i = fcntl(pcbp->tt_fd, F_GETFL, 0)) == -1) + #endif /* PVMFS */ pvmlogperror("pvmmctl() fcntl"); else { #ifdef O_NDELAY *************** *** 845,851 **** --- 943,953 ---- #else i |= FNDELAY; #endif + #ifdef PVMFS + (void)syscall(SYS_fcntl, pcbp->tt_fd, F_SETFL, i); + #else (void)fcntl(pcbp->tt_fd, F_SETFL, i); + #endif /* PVMFS */ } pvm_fd_add(pcbp->tt_fd, 1); } *************** *** 1020,1026 **** --- 1122,1132 ---- } else { pcbp->tt_state = TTOPEN; + #ifdef PVMFS + if ((i = syscall(SYS_fcntl, pcbp->tt_fd, F_GETFL, 0)) == -1) + #else if ((i = fcntl(pcbp->tt_fd, F_GETFL, 0)) == -1) + #endif /* PVMFS */ pvmlogperror("pvmmctl() fcntl"); else { #ifdef O_NDELAY *************** *** 1028,1034 **** --- 1134,1144 ---- #else i |= FNDELAY; #endif + #ifdef PVMFS + (void)syscall(SYS_fcntl, pcbp->tt_fd, F_SETFL, i); + #else (void)fcntl(pcbp->tt_fd, F_SETFL, i); + #endif /* PVMFS */ } pvm_fd_add(pcbp->tt_fd, 1); } *************** *** 1051,1057 **** --- 1161,1171 ---- (char*)linger, sizeof(linger)) == -1) pvmlogperror("pvmmctl() setsockopt"); #endif /*NOSOCKOPT*/ + #ifdef PVMFS + if ((i = syscall(SYS_fcntl, pcbp->tt_fd, F_GETFL, 0)) == -1) + #else if ((i = fcntl(pcbp->tt_fd, F_GETFL, 0)) == -1) + #endif /* PVMFS */ pvmlogperror("pvmmctl() fcntl"); else { #ifdef O_NDELAY *************** *** 1059,1065 **** --- 1173,1183 ---- #else i |= FNDELAY; #endif + #ifdef PVMFS + (void)syscall(SYS_fcntl, pcbp->tt_fd, F_SETFL, i); + #else (void)fcntl(pcbp->tt_fd, F_SETFL, i); + #endif /* PVMFS */ } pvm_fd_add(pcbp->tt_fd, 1); } *************** *** 1069,1075 **** --- 1187,1197 ---- if (ackd != 0) { pcbp->tt_state = TTDENY; + #ifdef PVMFS + (void)syscall(SYS_close, pcbp->tt_fd); + #else (void)close(pcbp->tt_fd); + #endif /* PVMFS */ pcbp->tt_fd = -1; } *************** *** 1234,1240 **** --- 1356,1366 ---- pcbp->tt_tid, fp->fr_len, fp->fr_dat - fp->fr_buf, n); pvmlogerror(pvmtxt); } + #ifdef PVMFS + n = syscall(SYS_read, pcbp->tt_fd, fp->fr_dat + fp->fr_len, n); + #else n = read(pcbp->tt_fd, fp->fr_dat + fp->fr_len, n); + #endif /* PVMFS */ if (debugmask & TDMPACKET) { sprintf(pvmtxt, "mxinput() read=%d\n", n); pvmlogerror(pvmtxt); *************** *** 1467,1473 **** --- 1593,1603 ---- print_fdset("mxfer() wfds=", pvmnfds, &wfds); } + #ifdef PVMFS + if ((n = syscall(SYS_select, pvmnfds, &rfds, &wfds, (fd_set*)0, tvp)) == -1 + #else if ((n = select(pvmnfds, &rfds, &wfds, (fd_set*)0, tvp)) == -1 + #endif /* PVMFS */ && errno != EINTR) { pvmlogperror("mxfer() select"); return PvmSysErr; *************** *** 1562,1572 **** --- 1692,1714 ---- pcbp->tt_tid); pvmlogerror(pvmtxt); } + #ifdef PVMFS + (void)syscall(SYS_close, pcbp->tt_fd); + /* + #ifdef IMA_CRAY + (void)pvmfs_dup2(s, pcbp->tt_fd); + #else + (void)syscall(SYS_dup2, s, pcbp->tt_fd); + #endif + (void)syscall(SYS_close, s); + */ + #else (void)close(pcbp->tt_fd); /* (void)dup2(s, pcbp->tt_fd); (void)close(s); */ + #endif /* PVMFS */ pvm_fd_delete(pcbp->tt_fd, 1); pcbp->tt_fd = s; pcbp->tt_state = TTOPEN; *************** *** 1624,1634 **** --- 1766,1784 ---- txup->ub_dst, txtogo); pvmlogerror(pvmtxt); } + #ifdef PVMFS #if defined(IMA_RS6K) || defined(IMA_POWER4) + n = syscall(SYS_write, txpcbp->tt_fd, txcp, min(txtogo, 4096)); + #else + n = syscall(SYS_write, txpcbp->tt_fd, txcp, txtogo); + #endif + #else /* PVMFS */ + #if defined(IMA_RS6K) || defined(IMA_POWER4) n = write(txpcbp->tt_fd, txcp, min(txtogo, 4096)); #else n = write(txpcbp->tt_fd, txcp, txtogo); #endif + #endif /* PVMFS */ if (debugmask & TDMPACKET) { sprintf(pvmtxt, "mxfer() wrote %d\n", n); *************** *** 1772,1778 **** --- 1922,1932 ---- pvmlogerror("mksocs() pvmdsockfile() failed\n"); goto bail; } + #ifdef PVMFS + if ((d = syscall(SYS_open, p, O_RDONLY, 0)) == -1) { + #else if ((d = open(p, O_RDONLY, 0)) == -1) { + #endif /* PVMFS */ pvmlogperror(p); goto bail; } *************** *** 1779,1785 **** --- 1933,1943 ---- try = 3; do { + #ifdef PVMFS + if ((n = syscall(SYS_read, d, buf, sizeof(buf))) == -1) { + #else if ((n = read(d, buf, sizeof(buf))) == -1) { + #endif /* PVMFS */ pvmlogperror("mksocs() read addr file"); goto bail; } *************** *** 1797,1803 **** --- 1955,1965 ---- /* while (n != 13); XXX */ + #ifdef PVMFS + (void)syscall(SYS_close, d); + #else (void)close(d); + #endif /* PVMFS */ buf[n] = 0; p = buf; } *************** *** 1884,1889 **** --- 2046,2054 ---- goto bail; } } + #ifdef PVMFS + pvmmysfd = topvmd->tt_fd; + #endif /* PVMFS */ topvmd->tt_state = TTOPEN; pvm_fd_add(topvmd->tt_fd, 1); *************** *** 1915,1921 **** --- 2080,2106 ---- return 0; } + #ifdef PVMFS + static int + fswait(fd) + int fd; + { + int fsver; + int nbytes; + /* + * Wait for file server to tell us it's ok + * to go ahead with talking to the pvmd. + */ + nbytes = syscall(SYS_read, fd, &fsver, sizeof fsver); + if (nbytes == sizeof fsver && fsver == FSPROTOCOL) + return 1; + else + return -1; + } + #endif /* PVMFS */ + + /* pvmbeatask() * * Initialize libpvm, config process as a task. *************** *** 1998,2004 **** --- 2183,2193 ---- */ (void)TMPNAMFUN(authfn); + #ifdef PVMFS + if ((authfd = syscall(SYS_open, authfn, O_RDONLY|O_CREAT|O_TRUNC, 0600)) == -1) { + #else if ((authfd = open(authfn, O_RDONLY|O_CREAT|O_TRUNC, 0600)) == -1) { + #endif /* PVMFS */ pvmlogperror(authfn); pvmlogerror("pvmbeatask() can't creat t-auth file\n"); cc = PvmSysErr; *************** *** 2036,2042 **** --- 2225,2235 ---- * check our t-auth file; write in pvmd d-auth file */ + #ifdef PVMFS + if ((cc = syscall(SYS_read, authfd, (char*)&cc, 1)) == -1) { + #else if ((cc = read(authfd, (char*)&cc, 1)) == -1) { + #endif /* PVMFS */ pvmlogperror("pvmbeatask() read authfile"); cc = PvmSysErr; goto bail; *************** *** 2046,2056 **** --- 2239,2258 ---- cc = PvmSysErr; goto bail; } + #ifdef PVMFS + (void)syscall(SYS_close, authfd); + (void)syscall(SYS_unlink, authfn); + #else (void)close(authfd); (void)unlink(authfn); + #endif /* PVMFS */ pvm_upkstr(authfn); + #ifdef PVMFS + if ((authfd = syscall(SYS_open, authfn, O_WRONLY, 0)) == -1) { + #else if ((authfd = open(authfn, O_WRONLY, 0)) == -1) { + #endif /* PVMFS */ pvmlogperror(authfn); pvmlogerror("pvmbeatask() failed to open d-auth file\n"); authfn[0] = 0; *************** *** 2057,2064 **** --- 2259,2271 ---- cc = PvmSysErr; goto bail; } + #ifdef PVMFS + cc = syscall(SYS_write, authfd, authfn, 1); + (void)syscall(SYS_close, authfd); + #else cc = write(authfd, authfn, 1); (void)close(authfd); + #endif /* PVMFS */ if (cc != 1) { if (cc == -1) pvmlogperror(authfn); *************** *** 2077,2082 **** --- 2284,2292 ---- pvm_initsend(PvmDataFoo); pvm_pkint(&pvmmyupid, 1, 1); pvm_pkint(&altpid, 1, 1); + #ifdef PVMFS + pvm_pkint(&pvmfs, 1, 1); + #endif /* PVMFS */ if ((cc = msendrecv(TIDPVMD, TM_CONN2)) <= 0) goto bail; pvm_upkint(&cc, 1, 1); *************** *** 2086,2091 **** --- 2296,2304 ---- } pvm_upkint(&pvmmytid, 1, 1); pvm_upkint(&pvmmyptid, 1, 1); + #ifdef PVMFS + pvm_upkint(&pvmmyfstid, 1, 1); + #endif /* PVMFS */ pvm_upkint(&pvmouttid, 1, 1); pvm_upkint(&pvmoutcod, 1, 1); *************** *** 2111,2126 **** pvm_upkint(&pvmmyndf, 1, 1); pvm_upkstr(buf); hex_inadport(buf, &pvmourinet); pvmourinet.sin_family = AF_INET; pvmourinet.sin_port = 0; ! pvm_upkint(&pvmschedtid, 1, 1); pvm_freebuf(pvm_setrbuf(rbf)); pvm_freebuf(pvm_setsbuf(sbf)); mxfersingle = 0; pvmtoplvl = x; return 0; --- 2324,2473 ---- pvm_upkint(&pvmmyndf, 1, 1); pvm_upkstr(buf); + pvm_upkint(&pvmschedtid, 1, 1); + #ifdef PVMFS + if (!pvmmyptid && pvmfs) + pvm_upkstr(authfn); + #endif /* PVMFS */ hex_inadport(buf, &pvmourinet); pvmourinet.sin_family = AF_INET; pvmourinet.sin_port = 0; ! #ifdef PVMFS ! if (!pvmmyptid && pvmfs) { ! char buf[PATH_MAX]; ! #ifdef DEBUG ! char buf2[PATH_MAX]; ! #endif ! char *home; ! int fspid; /* int, NOT pid_t (well, mayby long...) */ ! int pfd[2]; + /* + * Get a pipe to synchronize with the file server. + */ + #ifdef DEBUG + #define PIPE "/tmp/fspipe" + if ((pfd[1] = open(PIPE, O_RDWR)) == -1 + || (pfd[0] = open(PIPE, O_RDONLY)) == -1) { + pvmlogerror("pvmbeatask() pipe() /tmp/fspipe failed\n"); + #else + #ifdef SYSCALL_PIPE_IS_OK + if (syscall(SYS_pipe, pfd) == -1) { + #else + if (pipe(pfd) == -1) { + #endif + pvmlogerror("pvmbeatask() pipe() failed\n"); + #endif + goto bail; + } + if (home = getenv("HOME")) { + /* + * PVM_ROOT anyone? + */ + strcpy(buf, home); + strcat(buf, "/pvm3/lib/"); + #ifdef DEBUG + strcpy(buf2, buf); + strcat(buf2, "debugger"); + #endif + strcat(buf, ARCHCLASS); + strcat(buf, "/pvmfs"); + } else { + pvmlogerror("pvmbeatask() can't getenv(\"HOME\")\n"); + goto bail; + } + /*fflush(NULL);*/ + if ((fspid = fork()) == -1) { + pvmlogerror("pvmbeatask() can't fork\n"); + goto bail; + } else if (fspid == 0) { + #define ARGLEN 100 + char ptid[ARGLEN]; + char psock[ARGLEN]; + char pfds[2][ARGLEN]; + char ppid[ARGLEN]; + + (void)syscall(SYS_close, authfd); + sprintf(ptid, "%d", pvmmytid); + sprintf(psock, "%d", pvmmysfd); + sprintf(ppid, "%d", pvmmyupid); + sprintf(pfds[0], "%d", pfd[0]); + sprintf(pfds[1], "%d", pfd[1]); + #ifdef DEBUG + execlp(buf2, buf2, buf, authfn, (char *)NULL); + #else + execl(buf, "pvmfs", + authfn, psock, pfds[0], pfds[1], (char *)NULL); + #endif + perror("execl"); + pvmlogerror("pvmbeatask() can't exec pvmfs\n"); + _exit(1); + } + if (fswait(pfd[0]) != 1) { + pvmlogerror("pvmbeatask() pvmfs synchronization failed\n"); + goto bail; + } + #ifdef DEBUG + { + char buf[100]; + + printf("Enter fspid: "); + fflush(stdout); + fgets(buf, sizeof buf - 1, stdin); + fspid = atoi(buf); + } + #endif + (void)syscall(SYS_close, pfd[0]); + (void)syscall(SYS_close, pfd[1]); + + /* + * send third connect message to pvmd + */ + + pvm_initsend(PvmDataFoo); + pvm_pkint(&fspid, 1, 1); + pvm_pkint(&pvmmyupid, 1, 1); + pvm_pkint(&altpid, 1, 1); + + if ((cc = msendrecv(TIDPVMD, TM_CONN3)) <= 0) + goto bail; + pvm_upkint(&cc, 1, 1); + if (!cc) { + pvmlogerror("pvmbeatask() pvmd refuses connection (pvmfs problem)\n"); + goto bail; + } + pvm_upkint(&pvmmytid, 1, 1); + pvm_upkint(&pvmmyfstid, 1, 1); + } + + (void)syscall(SYS_close, authfd); + authfd = -1; + (void)syscall(SYS_unlink, authfn); + authfn[0] = '\0'; + #endif /* PVMFS */ + pvm_freebuf(pvm_setrbuf(rbf)); pvm_freebuf(pvm_setsbuf(sbf)); mxfersingle = 0; + #ifdef PVMFS + /* + * Register with the file server. + */ + if (pvmfs) { + sbf = pvm_setsbuf(pvm_mkbuf(PvmDataDefault)); + rbf = pvm_setrbuf(pvm_mkbuf(PvmDataDefault)); + pvm_send(pvmmyfstid, PVMFS_NEW_TASK); + pvm_recv(pvmmyfstid, PVMFS_INIT); + pvm_upkint(&cc, 1, 1); + if (cc) + /* complain? */; + pvm_freebuf(pvm_setsbuf(sbf)); + pvm_freebuf(pvm_setrbuf(rbf)); + } + #endif /* PVMFS */ + pvmtoplvl = x; return 0; *************** *** 2133,2141 **** --- 2480,2496 ---- pvm_setsbuf(sbf); if (authfd != -1) + #ifdef PVMFS + (void)syscall(SYS_close, authfd); + #else (void)close(authfd); + #endif /* PVMFS */ if (authfn[0]) + #ifdef PVMFS + (void)syscall(SYS_unlink, authfn); + #else (void)unlink(authfn); + #endif /* PVMFS */ unmksocs(); bail2: *************** *** 2149,2156 **** --- 2504,2517 ---- { if (pvmmytid != -1) { unmksocs(); + #ifdef PVMFS + pvmmytid = -2; + pvmmyfstid = 0; + pvmtrctid = 0; + #else pvmmytid = -1; pvmtrctid = 0; + #endif /* PVMFS */ } return 0; *************** *** 2589,2595 **** --- 2950,2960 ---- goto bail; } + #ifdef PVMFS + if (syscall(SYS_stat, sfn, &sb) != -1) { + #else if (stat(sfn, &sb) != -1) { + #endif /* PVMFS */ cc = PvmDupHost; goto bail; } *************** *** 2606,2614 **** --- 2971,2989 ---- if (!fork()) { for (cc = getdtablesize(); cc-- > 0; ) (void)close(cc); + #ifdef PVMFS + (void)syscall(SYS_open, "/dev/null", O_RDONLY, 0); + (void)syscall(SYS_open, "/dev/null", O_WRONLY, 0); + #ifdef IMA_CRAY + (void)pvmfs_dup2(1, 2); + #else + (void)syscall(SYS_dup2, 1, 2); + #endif /* IMA_CRAY */ + #else (void)open("/dev/null", O_RDONLY, 0); (void)open("/dev/null", O_WRONLY, 0); (void)dup2(1, 2); + #endif /* PVMFS */ execvp(av[0], av); } _exit(0); *************** *** 2617,2623 **** --- 2992,3002 ---- PVM_FREE(av); + #ifdef PVMFS + for (cc = 8; cc > 0 && syscall(SYS_stat, sfn, &sb) == -1; cc--) + #else for (cc = 8; cc > 0 && stat(sfn, &sb) == -1; cc--) + #endif /* PVMFS */ sleep(1); if (cc <= 0) { *** pvm3.ornl/src/lpvmgen.c Thu Aug 25 18:05:13 1994 --- src/lpvmgen.c Mon Jul 25 16:25:20 1994 *************** *** 90,95 **** --- 90,99 ---- extern int pvmcoutcod; /* from lpvm.c */ extern int pvmctrctid; /* from lpvm.c */ extern int pvmctrccod; /* from lpvm.c */ + #ifdef PVMFS + extern int pvmmyfstid; /* from lpvm.c */ + extern int pvmfs; + #endif /* PVMFS */ extern int pvmmyptid; /* from lpvm.c */ extern int pvmmytid; /* from lpvm.c */ extern int pvmrbufmid; /* from pack.c */ *************** *** 511,517 **** --- 515,532 ---- return cc; } + #ifdef PVMFS + int + pvm_fstid() + { + int cc; + if (cc = BEATASK) + return lpvmerr("pvm_fstid", cc); + return pvmmyfstid > 0 ? pvmmyfstid : PvmNoFileServer; + } + #endif /* PVMFS */ + int pvm_halt() { *************** *** 1585,1590 **** --- 1600,1608 ---- ntask = 0; while (!pvm_upkint(&tlist[ntask].ti_tid, 1, 1)) { pvm_upkint(&tlist[ntask].ti_ptid, 1, 1); + #ifdef PVMFS + pvm_upkint(&tlist[ntask].ti_fstid, 1, 1); + #endif /* PVMFS */ pvm_upkint(&tlist[ntask].ti_host, 1, 1); pvm_upkint(&tlist[ntask].ti_flag, 1, 1); pvm_upkstr(buf); *************** *** 1692,1697 **** --- 1710,1736 ---- { return (tid & pvmtidhmask); } + + + #ifdef PVMFS + int + pvm_usefs(on) + int on; + { + if (on) { + if (pvmmytid < 0) { + pvmfs = 1; + return 0; + } else + return lpvmerr("pvm_usefs", + pvmmyfstid > 0 ? PvmAlready : PvmCantStart); + } else if (pvmmyfstid > 0) { + pvmmyfstid = 0; + return 0; + } else + return lpvmerr("pvm_usefs", PvmNoFileServer); + } + #endif /* PVMFS */ int *** pvm3.ornl/src/pvmd.c Tue Sep 06 10:17:51 1994 --- src/pvmd.c Tue Sep 06 10:40:20 1994 *************** *** 790,796 **** --- 790,801 ---- gettimeofday(&tnow, (struct timezone*)0); if (debugmask || myhostpart) { + #ifdef PVMFS + sprintf(pvmtxt, "ready %s (fs-capable) %s", PVM_VER, + ctime(&tnow.tv_sec)); + #else sprintf(pvmtxt, "ready %s %s", PVM_VER, ctime(&tnow.tv_sec)); + #endif /* PVMFS */ pvmlogerror(pvmtxt); } *** pvm3.ornl/src/task.h Thu Aug 25 18:05:20 1994 --- src/task.h Mon Jul 25 10:10:38 1994 *************** *** 50,55 **** --- 50,58 ---- struct task *t_prlink; int t_tid; /* task id */ int t_ptid; /* parent task id */ + #ifdef PVMFS + int t_fstid; /* fs task id */ + #endif /* PVMFS */ int t_flag; /* status */ int t_pid; /* unix pid */ int t_sock; /* t-d tcp socket */ *************** *** 79,84 **** --- 82,90 ---- #define TF_CONN 4 /* task is connected */ #define TF_AUTH 8 /* task needs to auth */ #define TF_CLOSE 16 /* should delete context after flushing msgs */ + #ifdef PVMFS + #define TF_CONNALMOST 32 /* tm_conn2, not yet tm_conn3 */ + #endif /* PVMFS */ #define TF_ISSCHED 0x100 /* task is scheduler */ #define TF_ISHOSTER 0x200 /* task is hoster */ #define TF_ISTASKER 0x400 /* task is tasker */ *** pvm3.ornl/src/tdpro.c Thu Aug 25 18:05:20 1994 --- src/tdpro.c Wed Jul 27 12:38:54 1994 *************** *** 66,71 **** --- 66,76 ---- #include #include + #ifdef PVMFS + #include + #include + #endif /* PVMFS */ + #include "global.h" #include "fromlib.h" #include "tdpro.h" *************** *** 137,142 **** --- 142,150 ---- int tm_addhost(); int tm_config(); int tm_conn2(); + #ifdef PVMFS + int tm_conn3(); + #endif /* PVMFS */ int tm_connect(); int tm_db(); int tm_delhost(); *************** *** 178,183 **** --- 186,194 ---- tm_hoster, tm_hostsync, tm_setopt, + #ifdef PVMFS + tm_conn3, + #endif /* PVMFS */ }; *************** *** 203,208 **** --- 214,222 ---- "tm_hoster", "tm_hostsync", "tm_setopt", + #ifdef PVMFS + "tm_conn3", + #endif /* PVMFS */ }; char * *************** *** 246,253 **** --- 260,274 ---- goto bail; } + #ifdef PVMFS + if ((!(tp->t_flag & TF_CONN) && c != TM_CONNECT && c != TM_CONN2 + && c != TM_CONN3) + || ((tp->t_flag & TF_AUTH) && c != TM_CONN2 && c != TM_CONN3) + || ((tp->t_flag & TF_CONNALMOST) && c != TM_CONN3)) { + #else if ((!(tp->t_flag & TF_CONN) && c != TM_CONNECT && c != TM_CONN2) || ((tp->t_flag & TF_AUTH) && c != TM_CONN2)) { + #endif /* PVMFS */ pvmlogerror("loclentry() non-connect message from anon task\n"); tp->t_flag |= TF_CLOSE; goto bail; *************** *** 404,414 **** --- 425,442 ---- int tid; int pid; /* real pid of task */ int ipid; /* fake pid to identify task or 0 */ + #ifdef PVMFS + int dofs; + #endif /* PVMFS */ struct task *tp2; /* to search for existing context */ int cc; char c; + #ifdef PVMFS + if (upkint(mp, &pid) || upkint(mp, &ipid) || upkint(mp, &dofs)) { + #else if (upkint(mp, &pid) || upkint(mp, &ipid)) { + #endif /* PVMFS */ pvmlogerror("tm_conn2() bad msg format\n"); goto bail; } *************** *** 447,463 **** * else make it one */ if ((tp2 = task_findpid(ipid)) && !(tp2->t_flag & (TF_AUTH|TF_CONN))) { if (debugmask & PDMTASK) { ! sprintf(pvmtxt, "tm_conn2() reconnect task t%x\n", tp2->t_tid); pvmlogerror(pvmtxt); } - tp->t_sched = tp2->t_sched; - } else { if ((tid = tid_new()) < 0) { ! pvmlogerror("tm_conn2() out of tids?\n"); ! goto bail; /* XXX should disconnect nicely */ } tp2 = task_new(tid); --- 475,712 ---- * else make it one */ + #ifndef PVMFS if ((tp2 = task_findpid(ipid)) && !(tp2->t_flag & (TF_AUTH|TF_CONN))) { + #else + if ((tp2 = task_findpid(ipid)) && !(tp2->t_flag & (TF_AUTH|TF_CONN)) + || !dofs) { + if (tp2) { + #endif /* PVMFS */ + if (debugmask & PDMTASK) { + #ifdef PVMFS + sprintf(pvmtxt, "tm_conn2() reconnect task t%x, ptid = t%x, fstid = t%x\n", tp2->t_tid, tp2->t_ptid, tp2->t_fstid); + #else + sprintf(pvmtxt, "tm_conn2() reconnect task t%x\n", tp2->t_tid); + #endif /* PVMFS */ + pvmlogerror(pvmtxt); + } + tp->t_sched = tp2->t_sched; + + } else { + if ((tid = tid_new()) < 0) { + pvmlogerror("tm_conn2() out of tids?\n"); + goto bail; /* XXX should disconnect nicely */ + } + tp2 = task_new(tid); + + if (pvmschedtid) { + /* inform the scheduler about the new task */ + + tp->t_sched = pvmschedtid; + mp = mesg_new(0); + pkint(mp, 1); + pkint(mp, tid); + mp->m_cod = SM_EXECACK; /* XXX yecch, overload */ + mp->m_dst = pvmschedtid; + sendmessage(mp); + } + + if (debugmask & PDMTASK) { + #ifdef PVMFS + sprintf(pvmtxt, "tm_conn2() new task t%x, ptid = t%x, fstid = t%x\n", tp2->t_tid, tp2->t_ptid, tp2->t_fstid); + #else + sprintf(pvmtxt, "tm_conn2() new task t%x\n", tp2->t_tid); + #endif /* PVMFS */ + pvmlogerror(pvmtxt); + } + } + + /* + * brundle-fly the contexts together + */ + + tp2->t_sock = tp->t_sock; + tp2->t_sad = tp->t_sad; + tp2->t_salen = tp->t_salen; + if (tp2->t_pid != pid) + task_setpid(tp2, pid); + tp2->t_rxp = tp->t_rxp; + tp2->t_sched = tp->t_sched; + tp->t_sock = -1; /* tp will be freed by loclinput() */ + tp->t_rxp = 0; + tp = tp2; + + /* + * kick it in the butt; it's ready to go + */ + + tp->t_flag &= ~TF_AUTH; + tp->t_flag |= TF_CONN; + #ifdef PVMFS + } else + tp->t_flag |= TF_CONNALMOST; /* not quite ready to go */ + #endif /* PVMFS */ + + mp = mesg_new(0); + pkint(mp, 1); + pkint(mp, tp->t_tid); + pkint(mp, tp->t_ptid); + #ifdef PVMFS + pkint(mp, tp->t_fstid); + #endif /* PVMFS */ + pkint(mp, tp->t_outtid); + pkint(mp, tp->t_outcod); + pkint(mp, tp->t_trctid); + pkint(mp, tp->t_trccod); + pkint(mp, ourudpmtu); + pkint(mp, myndf); + pkstr(mp, inadport_hex(&(hosts->ht_hosts[hosts->ht_local]->hd_sad))); + pkint(mp, pvmschedtid); + + #ifdef PVMFS + if (!tp2) { + tp->t_authnam = TALLOC(LEN_OF_TMP_NAM, char, "auth"); + (void)TMPNAMFUN(tp->t_authnam); + if ((tp->t_authfd = open(tp->t_authnam, + O_RDONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) == -1) { + pvmlogerror("tm_conn2() can't create d-auth file"); + goto bail; + } + pkstr(mp, tp->t_authnam); + } + #endif /* PVMFS */ + + mp->m_dst = tp->t_tid; + mp->m_cod = TM_CONN2; + mp->m_flag |= MM_PRIO; + #ifdef PVMFS + if (!tp2) { + mesg_to_task(tp, mp); + mesg_unref(mp); + } else + #endif /* PVMFS */ + sendmessage(mp); + #ifdef PVMFS + PVM_FREE(tp->t_authnam); + tp->t_authnam = 0; + #endif /* PVMFS */ + return 0; + + bail: + tp->t_flag |= TF_CLOSE; + return 0; + } + + + #ifdef PVMFS + /* tm_conn3() + * + * Task connecting to pvmd phase 3. + * We check d-auth file and give it config info, attach to real context. + * + * TM_CONN3 + * call { + * int unixpid // real pid + * int identpid // pid assigned by pvmd or 0 + * } + * ret { + * int acknack // 1 if pvmd accepts connection + * int tid // task tid + * int ptid // parent tid + * } + */ + + int + tm_conn3(tp, mp) + struct task *tp; + struct mesg *mp; + { + int tid; + int pid; /* real pid of task */ + int ipid; /* fake pid to identify task or 0 */ + int fstid; /* tid of fs */ + int fspid; /* pid of fs as told by task starting up */ + struct task *tp2; /* to search for existing context */ + int cc; + char c; + + if (upkint(mp, &fspid) || upkint(mp, &pid) || upkint(mp, &ipid)) { + pvmlogerror("tm_conn3() bad msg format\n"); + mp = mesg_new(0); + mp->m_dst = tp->t_tid; + mp->m_cod = TM_CONN3; + mp->m_flag |= MM_PRIO; + pkint(mp, 0); + sendmessage(mp); + goto bail; + } + + mp = mesg_new(0); + mp->m_dst = tp->t_tid; + mp->m_cod = TM_CONN3; + mp->m_flag |= MM_PRIO; + + if (!(tp->t_flag & TF_CONNALMOST)) { + sprintf(pvmtxt, + "tm_conn3() message from t%x, TF_CONNALMOST not set\n", + tp->t_tid); + pvmlogerror(pvmtxt); + pkint(mp, 0); + sendmessage(mp); + return 0; + } + + /* + * check that task could write d-auth file + */ + + if ((cc = read(tp->t_authfd, &fstid, sizeof fstid)) == -1) { + pvmlogperror("tm_conn3() can't read d-auth file"); + pkint(mp, 0); + sendmessage(mp); + return 0; + } + + if (cc != sizeof fstid) { + pvmlogerror("tm_conn3() (1) fs didn't validate itself\n"); + pkint(mp, 0); + sendmessage(mp); + goto bail; + } + + (void)close(tp->t_authfd); + tp->t_authfd = -1; + (void)unlink(tp->t_authnam); + PVM_FREE(tp->t_authnam); + tp->t_authnam = 0; + + /* + * find fs in list of tasks + */ + + if ((tp2 = task_find(fstid)) == NULL || tp2->t_pid != fspid) { + pvmlogerror("tm_conn3() (2) fs didn't validate itself\n"); + (void)kill(tp2->t_pid, SIGKILL); + pkint(mp, 0); + sendmessage(mp); + goto bail; + } + + /* + * if task spawned by us, already has a context, + * else make it one + */ + if ((tp2 = task_findpid(ipid)) && !(tp2->t_flag & (TF_AUTH|TF_CONN))) { if (debugmask & PDMTASK) { ! sprintf(pvmtxt, ! "tm_conn3() reconnect task t%x, ptid = t%x, fstid = t%x\n", ! tp2->t_tid, tp2->t_ptid, fstid); pvmlogerror(pvmtxt); } } else { if ((tid = tid_new()) < 0) { ! pvmlogerror("tm_conn3() out of tids?\n"); ! goto bail; /* XXX should disconnect nicely */ } tp2 = task_new(tid); *************** *** 472,480 **** mp->m_dst = pvmschedtid; sendmessage(mp); } - if (debugmask & PDMTASK) { ! sprintf(pvmtxt, "tm_conn2() new task t%x\n", tp2->t_tid); pvmlogerror(pvmtxt); } } --- 721,730 ---- mp->m_dst = pvmschedtid; sendmessage(mp); } if (debugmask & PDMTASK) { ! sprintf(pvmtxt, ! "tm_conn3() new task t%x, ptid = t%x, fstid = t%x\n", ! tp2->t_tid, tp2->t_ptid, fstid); pvmlogerror(pvmtxt); } } *************** *** 493,521 **** tp->t_sock = -1; /* tp will be freed by loclinput() */ tp->t_rxp = 0; tp = tp2; /* * kick it in the butt; it's ready to go */ ! tp->t_flag &= ~TF_AUTH; tp->t_flag |= TF_CONN; ! mp = mesg_new(0); pkint(mp, 1); pkint(mp, tp->t_tid); ! pkint(mp, tp->t_ptid); ! pkint(mp, tp->t_outtid); ! pkint(mp, tp->t_outcod); ! pkint(mp, tp->t_trctid); ! pkint(mp, tp->t_trccod); ! pkint(mp, ourudpmtu); ! pkint(mp, myndf); ! pkstr(mp, inadport_hex(&(hosts->ht_hosts[hosts->ht_local]->hd_sad))); ! pkint(mp, pvmschedtid); ! mp->m_dst = tp->t_tid; ! mp->m_cod = TM_CONN2; ! mp->m_flag |= MM_PRIO; sendmessage(mp); return 0; --- 743,761 ---- tp->t_sock = -1; /* tp will be freed by loclinput() */ tp->t_rxp = 0; tp = tp2; + tp->t_fstid = fstid; /* * kick it in the butt; it's ready to go */ ! tp->t_flag &= ~TF_CONNALMOST; tp->t_flag |= TF_CONN; ! mp->m_dst = tp->t_tid; pkint(mp, 1); pkint(mp, tp->t_tid); ! pkint(mp, tp->t_fstid); sendmessage(mp); return 0; *************** *** 523,528 **** --- 763,769 ---- tp->t_flag |= TF_CLOSE; return 0; } + #endif /* PVMFS */ /* tm_exit() *************** *** 822,827 **** --- 1063,1071 ---- * assign each task to a host */ + #ifdef PVMFS + wxp->w_fstid = tp->t_fstid; + #endif /* PVMFS */ wxp->w_ht = htp; wxp->w_vec = TALLOC(wxp->w_veclen, int, "vec"); BZERO((char*)wxp->w_vec, wxp->w_veclen * sizeof(int)); *************** *** 985,990 **** --- 1229,1237 ---- mp = mesg_new(0); pkint(mp, wp->wa_tid); + #ifdef PVMFS + pkint(mp, wxp->w_fstid); + #endif /* PVMFS */ pkstr(mp, wxp->w_file); pkint(mp, wxp->w_flags); pkint(mp, na); *** pvm3.ornl/src/tdpro.h Thu Aug 25 18:05:20 1994 --- src/tdpro.h Mon Jul 25 10:12:42 1994 *************** *** 85,91 **** --- 85,96 ---- #define TM_HOSTER (TM_FIRST+18) /* register task as pvmd starter */ #define TM_HOSTSYNC (TM_FIRST+19) /* get clock delta to host */ #define TM_SETOPT (TM_FIRST+20) /* set task parameters */ + #ifdef PVMFS + #define TM_CONN3 (TM_FIRST+21) /* 3rd round of connect - get an fs */ + #define TM_LAST (TM_FIRST+21) /* last TM_ message */ + #else #define TM_LAST (TM_FIRST+20) /* last TM_ message */ + #endif /* PVMFS */ #define TMDB_INSERT 1 #define TMDB_DELETE 2 *** pvm3.ornl/src/waitc.h Thu Aug 25 18:05:21 1994 --- src/waitc.h Mon Jul 25 10:14:04 1994 *************** *** 86,91 **** --- 86,94 ---- struct waitc_spawn { char *w_file; /* executable name */ + #ifdef PVMFS + int w_fstid; /* fs task id */ + #endif /* PVMFS */ int w_flags; /* spawn flags */ int w_argc; /* length of argv */ char **w_argv; /* arg list */