[PATCH 2/4] fuse2fs: print the function name in error messages, not the file name

Darrick J. Wong
2025-11-06T22:40:40Z

It would be nice to know which fuse op actually causes failures such as:
FUSE2FS (sda4): Directory block checksum does not match directory block at ../../misc/fuse2fs.c:819.

The filename is utterly pointless, there's only one for the whole
daemon.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
misc/fuse2fs.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index c2896de2316bce..cede10765f5c1b 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -293,9 +293,9 @@ struct fuse2fs {
__FUSE2FS_CHECK_CONTEXT((ff), abort())

static int __translate_error(ext2_filsys fs, ext2_ino_t ino, errcode_t err,
- const char *file, int line);
+ const char *func, int line);
#define translate_error(fs, ino, err) __translate_error((fs), (ino), (err), \
- __FILE__, __LINE__)
+ __func__, __LINE__)

/* for macosx */
#ifndef W_OK
@@ -5678,7 +5678,7 @@ int main(int argc, char *argv[])
}

static int __translate_error(ext2_filsys fs, ext2_ino_t ino, errcode_t err,
- const char *file, int line)
+ const char *func, int line)
{
struct timespec now;
int ret = err;
@@ -5805,10 +5805,10 @@ static int __translate_error(ext2_filsys fs, ext2_ino_t ino, errcode_t err,

if (ino)
err_printf(ff, "%s (inode #%d) at %s:%d.\n",
- error_message(err), ino, file, line);
+ error_message(err), ino, func, line);
else
err_printf(ff, "%s at %s:%d.\n",
- error_message(err), file, line);
+ error_message(err), func, line);

/* Make a note in the error log */
get_now(&now);
@@ -5816,14 +5816,14 @@ static int __translate_error(ext2_filsys fs, ext2_ino_t ino, errcode_t err,
fs->super->s_last_error_ino = ino;
fs->super->s_last_error_line = line;
fs->super->s_last_error_block = err; /* Yeah... */
- strncpy((char *)fs->super->s_last_error_func, file,
+ strncpy((char *)fs->super->s_last_error_func, func,
sizeof(fs->super->s_last_error_func));
if (ext2fs_get_tstamp(fs->super, s_first_error_time) == 0) {
ext2fs_set_tstamp(fs->super, s_first_error_time, now.tv_sec);
fs->super->s_first_error_ino = ino;
fs->super->s_first_error_line = line;
fs->super->s_first_error_block = err;
- strncpy((char *)fs->super->s_first_error_func, file,
+ strncpy((char *)fs->super->s_first_error_func, func,
sizeof(fs->super->s_first_error_func));
}