jacereda / fsatrace

Filesystem access tracer
ISC License
78 stars 12 forks source link

embed extra files, .so/.dll? #13

Open droundy opened 8 years ago

droundy commented 8 years ago

Would it be possible to embed the extra files into fsatrace itself?

It would seem lovely to be able to enable at least the possibility of static linking (when there is, e.g. a C API). Not needed, but it does seem like it could enhance the user experience.

jacereda commented 8 years ago

The injection is based on LD_PRELOAD/DYLD_INSERT_LIBRARIES, the injected code must reside as a separate file AFAIK.

droundy commented 8 years ago

Yes, but could the file be generated dynamically? On the other hand, perhaps it would be disingenuous to support static linking of a tool that doesn't work with statically linked tools...

jacereda commented 8 years ago

We can always cat both files and generate the DLL in a temporary directory. Would require checking the executable and DLL timestamps to decide if the DLL must be overwritten. Doing it properly would be tricky, some other process might be trying to write the DLL at the same time.

droundy commented 8 years ago

Yes, it's definitely doable. I might be tempted to put it in ~/.cache/fsatrace/, so it would seldom need to be replaced, and you avoid the dangers of working with /tmp/. One option if you have a fsatrace version (possibly git-derived) would be to use that in the filename to ensure synchronicity. Simultaneous writing is typically handled on posix systems pretty easily by writing to another name and then using rename. I don't know how to deal very well with Windows semantics, but am sure it's just a question of reading up on file writing on Windows.

ndmitchell commented 8 years ago

Doing it on Windows is possible, but a bit of a pain. However, if the file changes names with each git revision, and has a known size, that might be enough to make the extraction predictable. Having a single "lump" to pass around would be useful.