public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: 肖鹏 <xiaopeng_phy@163.com>
Cc: libc-help@sourceware.org
Subject: Re: glibc interception problems
Date: Mon, 24 May 2021 23:10:35 -0400	[thread overview]
Message-ID: <YKxqqwDeWypwZfdJ@vapier> (raw)
In-Reply-To: <cd6040e.12c1.179a15c68cf.Coremail.xiaopeng_phy@163.com>

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

  reply	other threads:[~2021-05-25  3:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25  2:30 肖鹏
2021-05-25  3:10 ` Mike Frysinger [this message]
     [not found]   ` <4f73c540.6a6.179a6344524.Coremail.xiaopeng_phy@163.com>
2021-05-26  3:47     ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YKxqqwDeWypwZfdJ@vapier \
    --to=vapier@gentoo.org \
    --cc=libc-help@sourceware.org \
    --cc=xiaopeng_phy@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).