Path: utzoo!mnetor!uunet!mcvax!enea!zyx!aj From: aj@zyx.UUCP (Arndt Jonasson) Newsgroups: comp.unix.questions Subject: Re: Two Top-20 features sought for UNIX Message-ID: <2331@zyx.UUCP> Date: 6 Mar 88 02:44:01 GMT References: <12970@sri-unix.SRI.COM> Reply-To: aj@zyx.UUCP (Arndt Jonasson) Organization: ZYX Sweden AB, Stockholm Lines: 29 Keywords: advise file-open In article <12970@sri-unix.SRI.COM> cole@sri-unix.ARPA (Susan E. Cole) writes: >I like UNIX better than Tops-20,really, but there are two Tops-20 capabilities >that I wish I could get on my Pyramid system. > ... >The other capability I'd like is called "trap file openings" on Tops-20. >Once you set this feature on, the system announces every file open >done on your behalf (and whether it is for reading or writing). This >can also clear up confusion real fast -- "it's looking in THAT directory?!" Of course, this can't be implemented with the full generality of the Tops-20 Set Trap File-Openings without changing the kernel, but your question inspired me to investigate what could be done with 'ptrace'. It took me a day and I now have a program that is invoked as e.g. 'trapfile myprog foo bar'. It will then run 'myprog foo bar', while displaying all calls to 'open' and 'close' on stderr. It makes very heavy use of 'ptrace' and is thus fairly unportable (I use HP-UX on a 68020) and it doesn't work for programs that fork and then use 'open' or 'close', although that could be fixed (so that they don't crash, that is - there can't be any tracing output for the forked processes). It doesn't make any use of any symbol table that myprog might have, although that would make it a little faster to find the 'open' and 'close' calls. If this program is going to be at all useful remains to be seen, but this shows that it can be done. -- Arndt Jonasson, ZYX Sweden AB, Styrmansgatan 6, 114 54 Stockholm, Sweden email address: !mcvax!enea!zyx!aj = aj@zyx.SE