glibc interception problems
Mike Frysinger
vapier@gentoo.org
Tue May 25 03:10:35 GMT 2021
On 25 May 2021 10:30, 肖鹏 via Libc-help wrote:
> I'm developping a library for a distributed file system, using LD_PRELOAD to intercept file related calls to glibc.
> Programs directly using unbuffered IO (close/open/read/write) work well with my library. But programs using buffered IO (fclose/fopen/fread/fwrite) will call unbuffered functions of glibc instead of my library.
> The reason is that in glibc, buffered IO depend on internal symbols, which cannot be intercepted.
> I can see two ways to work around this:
> 1. Implement buffered IO in my library.
> 2. Modify glibc buffered IO to use public symbols, and maintain a custom version of glibc.
> Both ways have drawbacks. Do you have any suggestions about this?
what is your end goal ?
is this a research project ?
are you developing an open source project that you want to share with others ?
something else ?
if it's a short-term project (e.g. for research), (2) might be your best bet.
it's hacky, but if it gathers the info you need, it's not that bad.
if it's a long-term project you want to share with others, i'd recommend not
using LD_PRELOAD at all. maybe FUSE would be better.
-mike
More information about the Libc-help
mailing list