home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / misc / 5019 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.6 KB  |  52 lines

  1. Newsgroups: comp.unix.misc
  2. Path: sparky!uunet!charon.amdahl.com!amdahl!rtech!sgiblab!sdd.hp.com!cs.utexas.edu!hermes.chpc.utexas.edu!pefv700
  3. From: pefv700@chpc.utexas.edu (Christopher Phillips)
  4. Subject: intercepting system calls (again)
  5. Message-ID: <1993Jan27.202256.20794@chpc.utexas.edu>
  6. Organization: The University of Texas System - CHPC
  7. Date: Wed, 27 Jan 93 20:22:56 GMT
  8. Lines: 42
  9.  
  10. I would like to implement a function that given a
  11. FORTRAN logical unit would return the UNIX file descriptor.
  12. My idea is to have an intermediate open that saves the file descriptor
  13. that the "real" open returns.  Then the user must call a function
  14. that remembers the logical unit-file descriptor pair.
  15.  
  16. What I tried was to rename all the o's in /_*open_*/ patterns to p:
  17.     % perl -pe 's/\b(_*)open(_*)\b/$1ppen$2/go;' /lib/libc.a >libmy.a
  18.  
  19. Then I added the following functions:
  20.     c.c:
  21.     1) int cgetfd(int *lu)    - called by getfd
  22.     2) void storefd(int *lu) - "remembers" lu-fd pair
  23.     3) int open(char *path, int flags, int mode)
  24.         { return fd = ppen(path, flags, mode); }
  25.     f.f:
  26.     4) integer function getfd(lu)
  27. with
  28.     % ar rv libmy.a c.o f.o
  29.     % ranlib libmy.a
  30.  
  31. I tried a test file ugh.f:
  32.     integer getfd
  33.     open(4, file='/tmp/ugh', status='unknown')
  34.     call storefd(4)
  35.     print *, getfd(4)
  36.     stop
  37.     end
  38.  
  39. On an AIX 3.1 box...
  40.     % xlf -o ugh ugh.o -L$HOME/lib -lds -lmy 
  41.         # lib ds above does the lu-fd saving
  42.     % ugh
  43.     Could not load program ugh 
  44.     Symbol ppen in /u/pefv700/lib/libmy.a is undefined
  45.     Symbol ppen in ugh is undefined
  46.     Error was: Exec format error
  47.     
  48. I didn't even get this far on SunOS 4.1.
  49. Should this idea work?  Other ideas?
  50.  
  51. Chris
  52.