Re: [PATCH 2/5] fuse2fs: stop aliasing stderr with ff->err_fp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 21, 2025 at 07:41:17AM -0400, Theodore Ts'o wrote:
> On Sun, Jul 20, 2025 at 10:42:34PM -0700, Darrick J. Wong wrote:
> > Oh wait no it turns out that libfuse obliterates std{in,out,err} in
> > fuse_daemonize() by opening /dev/null and using that exact trick.  So
> > the only reason why I was ever getting any FUSE2FS debug output
> > throughout *any* of the fuse+iomap development sprints was that glibc
> > lets you assign stdout/stderr directly.
> > 
> > freopen also won't work (at least on glibc) because its freopen
> > implementation uses the dup2 trick which will be undone by libfuse.
> > 
> > GREAT!  I only got to debug my program because OF A WEIRD GLIBC QUIRK!!
> 
> So either we need to find some way to inhibit fuse_daemonize() and
> then have fuse2fs handling doing the daemonization.  Or maybe we can
> arrange to have some kind callback to set up stdout/stderr after
> fuse_main() is called?  fuse_daemonize() is called from fuse_main(),
> right?

Right.  We could just set up the log file again in op_init, which will
fix the daemonize() problem; use dup2 to cover any libraries that output
directly to STDOUT/ERR_FILE; and use freopen on /dev/fd/XX which will
cover any other libraries that call printf or fprintf(stdout/err.

$ diffstat < patches-djwong-dev/019*
 fuse2fs.c |  141 +++++++++++++++++++++++++----
 1 file changed, 123 insertions(+), 18 deletions(-)

Yuuuuuck.

--D

> 						- Ted




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux