e2fsprogs icon indicating copy to clipboard operation
e2fsprogs copied to clipboard

fuse2fs incorrectly assigns to stdout/stderr

Open q66 opened this issue 6 months ago • 0 comments

first added probably in 5cdebf3eebc22cb850e7ba0344379a4918ef4a1a

the code does the following:

	/* Set up error logging */
	logfile = getenv("FUSE2FS_LOGFILE");
	if (logfile) {
		FILE *fp = fopen(logfile, "a");
		if (!fp) {
			perror(logfile);
			goto out;
		}
		stderr = fp;
		stdout = fp;
	} else if (fctx.kernel) {
		/* in kernel mode, try to log errors to the kernel log */
		FILE *fp = fopen("/dev/ttyprintk", "a");
		if (fp) {
			stderr = fp;
			stdout = fp;
		}
	}

this is not standard c and is not required or expected to compile or work and will fail on anything that is not glibc (stdout/stderr can be a macro)

the standard way is to use freopen

q66 avatar Jul 20 '25 00:07 q66