[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <174553064491.1160047.2269966041756188067.stgit@frogsfrogsfrogs>
Date: Thu, 24 Apr 2025 14:39:13 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org
Subject: [PATCH 2/5] fuse2fs: stop aliasing stderr with ff->err_fp
From: Darrick J. Wong <djwong@...nel.org>
Remove this pointless aliasing of error stream pointers.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
misc/fuse2fs.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 18ae442c7ece03..f2d0e1f2441f83 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -89,6 +89,12 @@ static ext2_filsys global_fs; /* Try not to use this directly */
break; \
}
+#define err_printf(fuse2fs, format, ...) \
+ do { \
+ fprintf(stderr, "FUSE2FS (%s): " format, (fuse2fs)->shortdev, ##__VA_ARGS__); \
+ fflush(stderr); \
+ } while (0)
+
#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8)
# ifdef _IOR
# ifdef _IOW
@@ -344,7 +350,6 @@ struct fuse2fs {
int alloc_all_blocks;
int norecovery;
unsigned long offset;
- FILE *err_fp;
unsigned int next_generation;
};
@@ -3839,13 +3844,13 @@ int main(int argc, char *argv[])
/* Set up error logging */
logfile = getenv("FUSE2FS_LOGFILE");
if (logfile) {
- fctx.err_fp = fopen(logfile, "a");
- if (!fctx.err_fp) {
+ FILE *fp = fopen(logfile, "a");
+ if (!fp) {
perror(logfile);
goto out;
}
- } else
- fctx.err_fp = stderr;
+ stderr = fp;
+ }
/* Will we allow users to allocate every last block? */
if (getenv("FUSE2FS_ALLOC_ALL_BLOCKS")) {
@@ -4052,14 +4057,11 @@ static int __translate_error(ext2_filsys fs, errcode_t err, ext2_ino_t ino,
return ret;
if (ino)
- fprintf(ff->err_fp, "FUSE2FS (%s): %s (inode #%d) at %s:%d.\n",
- fs->device_name ? fs->device_name : "???",
+ err_printf(ff, "%s (inode #%d) at %s:%d.\n",
error_message(err), ino, file, line);
else
- fprintf(ff->err_fp, "FUSE2FS (%s): %s at %s:%d.\n",
- fs->device_name ? fs->device_name : "???",
+ err_printf(ff, "%s at %s:%d.\n",
error_message(err), file, line);
- fflush(ff->err_fp);
/* Make a note in the error log */
get_now(&now);
Powered by blists - more mailing lists