* [PATCH] fuse2fs: clean up the lockfile handling
@ 2025-06-16 15:06 Darrick J. Wong
2025-06-26 3:35 ` Theodore Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2025-06-16 15:06 UTC (permalink / raw)
To: Theodore Ts'o; +Cc: Tim Woodall, linux-ext4
From: Darrick J. Wong <djwong@kernel.org>
Fix various problems with the new lockfile code in fuse2fs: the printfs
should use the actual logging function err_printf, the messages should
be looked up in gettext, we should actually exit main properly on
error instead of calling exit(), and the error message printing for the
final lockfile unlink is broken.
Fixes: e83c0df0135f98 ("fuse2fs: rename the inusefile option to lockfile")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
misc/fuse2fs.c | 45 +++++++++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 16 deletions(-)
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 0f9cb6849aa7ad..bb75d9421283ed 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -4417,19 +4417,31 @@ int main(int argc, char *argv[])
fctx.alloc_all_blocks = 1;
}
- if(fctx.lockfile) {
- FILE* lockfile=fopen(fctx.lockfile, "w");
- if(!lockfile) {
- fprintf(stderr, "Requested lockfile=%s but couldn't open the file for writing\n", fctx.lockfile);
- exit(1);
+ if (fctx.lockfile) {
+ FILE *lockfile = fopen(fctx.lockfile, "w");
+ char *resolved;
+
+ if (!lockfile) {
+ err = errno;
+ err_printf(&fctx, "%s: %s: %s\n", fctx.lockfile,
+ _("opening lockfile failed"),
+ strerror(err));
+ fctx.lockfile = NULL;
+ ret |= 32;
+ goto out;
}
fclose(lockfile);
- char* resolved = realpath(fctx.lockfile, NULL);
+
+ resolved = realpath(fctx.lockfile, NULL);
if (!resolved) {
- perror("realpath");
- fprintf(stderr, "Could not resolve realpath for lockfile=%s\n", fctx.lockfile);
+ err = errno;
+ err_printf(&fctx, "%s: %s: %s\n", fctx.lockfile,
+ _("resolving lockfile failed"),
+ strerror(err));
unlink(fctx.lockfile);
- exit(1);
+ fctx.lockfile = NULL;
+ ret |= 32;
+ goto out;
}
free(fctx.lockfile);
fctx.lockfile = resolved;
@@ -4639,14 +4651,15 @@ int main(int argc, char *argv[])
com_err(argv[0], err, "while closing fs");
global_fs = NULL;
}
- if(fctx.lockfile) {
- err = unlink(fctx.lockfile);
- if (err)
- com_err(argv[0], errno, "while unlinking '%s'",
- fctx.lockfile);
- }
- if (fctx.lockfile)
+ if (fctx.lockfile) {
+ if (unlink(fctx.lockfile)) {
+ err = errno;
+ err_printf(&fctx, "%s: %s: %s\n", fctx.lockfile,
+ _("removing lockfile failed"),
+ strerror(err));
+ }
free(fctx.lockfile);
+ }
if (fctx.device)
free(fctx.device);
fuse_opt_free_args(&args);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fuse2fs: clean up the lockfile handling
2025-06-16 15:06 [PATCH] fuse2fs: clean up the lockfile handling Darrick J. Wong
@ 2025-06-26 3:35 ` Theodore Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2025-06-26 3:35 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Theodore Ts'o, Tim Woodall, linux-ext4
On Mon, 16 Jun 2025 08:06:14 -0700, Darrick J. Wong wrote:
> Fix various problems with the new lockfile code in fuse2fs: the printfs
> should use the actual logging function err_printf, the messages should
> be looked up in gettext, we should actually exit main properly on
> error instead of calling exit(), and the error message printing for the
> final lockfile unlink is broken.
>
>
> [...]
Applied, thanks!
[1/1] fuse2fs: clean up the lockfile handling
commit: e50fbaa4d156a6ff62dc85c4737fa97c4cb858aa
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-26 3:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-16 15:06 [PATCH] fuse2fs: clean up the lockfile handling Darrick J. Wong
2025-06-26 3:35 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox