Thursday, January 7, 2010

Strace Mensa Puzzle

It is necessary to get the correct full path to properly track files created or changed. It is also necessary to use strace -f so as not to miss files affected in child processes.

Some installers make this difficult when they chdir around and do the action on a relative path. Some are even more inventive and start a subshell, do a chdir, and act on a relative path.

Two difficulties arise.
(1) cp, mv, maybe others, spawn a new process before doing the action.
(2) a chdir inside a subshell will not hold true once the subshell exits.

The solution I had tried in a previous post worked in (1) but not in (2).
The solution instmon-2.0 tried (in strace.awk) worked in (2) but not in (1).

A likely soulution involves keeping track of the appropriate dir for each pid. A hash of dirs keyed by pid and a hash of parent pids keyed by pid should work. The idea is for each newly encountered pid to initially get the dir of its parent. If a chdir occurs, only the dir of the pid will be updated. The first pid encountered gets the initial working dir.

The final solution will also need to check for possible syscall failures. I wonder what happens when something fails in the middle of "make install". Presumably, there would still be a record of what succeeded.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

Click blog title for the latest post