home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.misc
- Path: sparky!uunet!charon.amdahl.com!amdahl!rtech!sgiblab!sdd.hp.com!cs.utexas.edu!hermes.chpc.utexas.edu!pefv700
- From: pefv700@chpc.utexas.edu (Christopher Phillips)
- Subject: intercepting system calls (again)
- Message-ID: <1993Jan27.202256.20794@chpc.utexas.edu>
- Organization: The University of Texas System - CHPC
- Date: Wed, 27 Jan 93 20:22:56 GMT
- Lines: 42
-
- I would like to implement a function that given a
- FORTRAN logical unit would return the UNIX file descriptor.
- My idea is to have an intermediate open that saves the file descriptor
- that the "real" open returns. Then the user must call a function
- that remembers the logical unit-file descriptor pair.
-
- What I tried was to rename all the o's in /_*open_*/ patterns to p:
- % perl -pe 's/\b(_*)open(_*)\b/$1ppen$2/go;' /lib/libc.a >libmy.a
-
- Then I added the following functions:
- c.c:
- 1) int cgetfd(int *lu) - called by getfd
- 2) void storefd(int *lu) - "remembers" lu-fd pair
- 3) int open(char *path, int flags, int mode)
- { return fd = ppen(path, flags, mode); }
- f.f:
- 4) integer function getfd(lu)
- with
- % ar rv libmy.a c.o f.o
- % ranlib libmy.a
-
- I tried a test file ugh.f:
- integer getfd
- open(4, file='/tmp/ugh', status='unknown')
- call storefd(4)
- print *, getfd(4)
- stop
- end
-
- On an AIX 3.1 box...
- % xlf -o ugh ugh.o -L$HOME/lib -lds -lmy
- # lib ds above does the lu-fd saving
- % ugh
- Could not load program ugh
- Symbol ppen in /u/pefv700/lib/libmy.a is undefined
- Symbol ppen in ugh is undefined
- Error was: Exec format error
-
- I didn't even get this far on SunOS 4.1.
- Should this idea work? Other ideas?
-
- Chris
-