From patchwork Thu Apr 24 21:38:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=JTOywXO4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=g1d4=xk=vger.kernel.org=linux-ext4+bounces-7460-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8Vc4M87z1yMg for ; Fri, 25 Apr 2025 07:38:48 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8Vy0gg3z4x8Y for ; Fri, 25 Apr 2025 07:39:06 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8Vy0dYLz4wcQ; Fri, 25 Apr 2025 07:39:06 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.199.223 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530746; cv=pass; b=Lv+ySWKMviEnElO/kPbkLzgsK764nfb+dYlDybRZ2f3zZrmU5VrWdWVPT8bxUmM4aDM8GxYLV/IvPsU7K4iT+A/p6xlQmwhX2Jp3vW9ONxZmb+5YfjEy8PUZnEvOwDCPcQUKSI0Ch4p24Wt5CCKdwJj3YCczLbNenOPTxk8DQwshb2KZagQmKmAAVn8tZApDpGBhx+cKkDLzeDNcdngmRm/ZPvZeHDTgbYfZLypFXEZ42+CWoSKdgSzy+UjZMjNFZUaMEHrAApEA9hIEojYOJGv5iLvi5vlhJmZmE0bq7miKw7UxdDgK1976T5rB9TM9D0x9xkLHEoN6ir0SfhKufQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530746; c=relaxed/relaxed; bh=Iugua8Lzr27cSEmdQBSlfDu0bXss8tVpcCLKKscIkOM=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uMdRG0Y5AYUD9dOEn17jGRWxnujiJpjYXPtZChhXsi0ZcWLpJNgSFzNM60Gs8A1ck5PloFA55hoRP/eRgzbkZ0GyNoQo5Kz2fHQZIui9u00rY75faXyvOsMvor/LYlocthuzObF1fJSjT+pKF671wz2JwE0drG150VTvnSMjFcfH+vbqor9imtMnvwjyxTb4vnro+6IEZf8X+LfIAr+nONegIna2woGBvl4d6Mgvmr9JAz2qxMjpeHwe/9tOWIHOQA8BUtsIYDINv5O5aRD3/D9Ao0NTqEqCfkSN3RGNzkloS2QgyIccY8oJErNcUt4w4NiRKBXFIPtlc9wZ1DWwbg== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=JTOywXO4; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=JTOywXO4; dkim-atps=neutral Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8Vt5JQ3z4x8Y for ; Fri, 25 Apr 2025 07:39:02 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E7BBD16C2AC for ; Thu, 24 Apr 2025 21:39:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FEE71F4297; Thu, 24 Apr 2025 21:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JTOywXO4" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D203C218ACA for ; Thu, 24 Apr 2025 21:38:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530738; cv=none; b=Kvwx6IJQadj7pq/rY+Zn9vwIumEgII3v0WvNmbc6dMtZ9Meh9+HVGPRR7kXCiw1Or0WZND8JuX3l07KBaW0a41SC0bZPsJpCPvXCMtwENymco8KvVfbRhhDKCH8saX4kyPeOFciK5PxTJJBquAOMio7DU1/JcWQArmeUMVhiThM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530738; c=relaxed/simple; bh=zdOe9MSdgW1n7t9IIRAXArpmNLZHQTD0s3gesOhu4dU=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nuvWTZTcVWIhIQqREcDKhT7ryYxAQq++PJNZcV//rYh2ZpZSxuOf/SI21mPU1btFjLTbrVILOL3uJquK+tG0LdjAHCIKKuUdQBQKJ7IzepdvKNe0isb7SQzj5+NYk815THhzp0r7K5jv4hgAeO+M8P/uAWRXnbgi58kGsoelpno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JTOywXO4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48349C4CEE3; Thu, 24 Apr 2025 21:38:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530738; bh=zdOe9MSdgW1n7t9IIRAXArpmNLZHQTD0s3gesOhu4dU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=JTOywXO4Xm5hFJX9U+YB52RDtSFC9RjxQ57RMyjQRDrh/GPIjFzvE3abD7Azyw98H CDR+H8lgPA2LlDm+WTYEEHVx2rWG8F2jhIR4uwDwflQF2jdwRARyqIBjN+FfhXJEbw Yh+S0R7LVKkbD18abwtOT9Mu/tRdQiuw0l/1w5TH8KvMqfjs62xOlyS31EgK2SF3rI Esj3D5rE8w7FMDgy6gfZGG/e202y4CcYL7qx6nQ5Hhd5tte3e4sLkpTTMbDQ2KwP0v vZscXTkHly97RbDW7HEn2CUicDvq1F1FIDrnVMxvxsrycgbkkMUY+D3jJjDhW/+5m1 iyPPF6kHCaCsw== Date: Thu, 24 Apr 2025 14:38:57 -0700 Subject: [PATCH 1/5] fuse2fs: enable runtime debugging From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553064473.1160047.16179858742889092063.stgit@frogsfrogsfrogs> In-Reply-To: <174553064436.1160047.577374015997116030.stgit@frogsfrogsfrogs> References: <174553064436.1160047.577374015997116030.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Whenever fuse2fs is started with -o fuse2fs_debug, we should log all the debugging messages generated by fuse2fs itself and libfuse. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 174 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 92 insertions(+), 82 deletions(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index a6390ab5d8c61b..18ae442c7ece03 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -82,15 +82,12 @@ static ext2_filsys global_fs; /* Try not to use this directly */ -#undef DEBUG - -#ifdef DEBUG -# define dbg_printf(f, a...) do {printf("FUSE2FS-" f, ## a); \ - fflush(stdout); \ -} while (0) -#else -# define dbg_printf(f, a...) -#endif +#define dbg_printf(fuse2fs, format, ...) \ + while ((fuse2fs)->debug) { \ + printf("FUSE2FS (%s): " format, (fuse2fs)->shortdev, ##__VA_ARGS__); \ + fflush(stdout); \ + break; \ + } #if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8) # ifdef _IOR @@ -337,6 +334,7 @@ struct fuse2fs { ext2_filsys fs; pthread_mutex_t bfl; char *device; + char *shortdev; int ro; int debug; int no_default_opts; @@ -623,7 +621,7 @@ static int fs_can_allocate(struct fuse2fs *ff, blk64_t num) ext2_filsys fs = ff->fs; blk64_t reserved; - dbg_printf("%s: Asking for %llu; alloc_all=%d total=%llu free=%llu " + dbg_printf(ff, "%s: Asking for %llu; alloc_all=%d total=%llu free=%llu " "rsvd=%llu\n", __func__, num, ff->alloc_all_blocks, ext2fs_blocks_count(fs->super), ext2fs_free_blocks_count(fs->super), @@ -667,7 +665,7 @@ static int check_inum_access(ext2_filsys fs, ext2_ino_t ino, mode_t mask) return translate_error(fs, ino, err); perms = inode.i_mode & 0777; - dbg_printf("access ino=%d mask=e%s%s%s perms=0%o fuid=%d fgid=%d " + dbg_printf(ff, "access ino=%d mask=e%s%s%s perms=0%o fuid=%d fgid=%d " "uid=%d gid=%d\n", ino, (mask & R_OK ? "r" : ""), (mask & W_OK ? "w" : ""), (mask & X_OK ? "x" : ""), perms, inode_uid(inode), @@ -732,7 +730,7 @@ static void op_destroy(void *p EXT2FS_ATTR((unused))) return; } fs = ff->fs; - dbg_printf("%s: dev=%s\n", __func__, fs->device_name); + dbg_printf(ff, "%s: dev=%s\n", __func__, fs->device_name); if (fs->flags & EXT2_FLAG_RW) { fs->super->s_state |= EXT2_VALID_FS; if (fs->super->s_error_count) @@ -764,7 +762,7 @@ static void *op_init(struct fuse_conn_info *conn return NULL; } fs = ff->fs; - dbg_printf("%s: dev=%s\n", __func__, fs->device_name); + dbg_printf(ff, "%s: dev=%s\n", __func__, fs->device_name); #ifdef FUSE_CAP_IOCTL_DIR conn->want |= FUSE_CAP_IOCTL_DIR; #endif @@ -777,6 +775,8 @@ static void *op_init(struct fuse_conn_info *conn if (err) translate_error(fs, 0, err); } + if (ff->debug) + cfg->debug = 1; return ff; } @@ -837,7 +837,7 @@ static int op_getattr(const char *path, struct stat *statbuf FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; - dbg_printf("%s: path=%s\n", __func__, path); + dbg_printf(ff, "%s: path=%s\n", __func__, path); pthread_mutex_lock(&ff->bfl); err = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, path, &ino); if (err) { @@ -864,7 +864,7 @@ static int op_readlink(const char *path, char *buf, size_t len) FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; - dbg_printf("%s: path=%s\n", __func__, path); + dbg_printf(ff, "%s: path=%s\n", __func__, path); pthread_mutex_lock(&ff->bfl); err = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, path, &ino); if (err || ino == 0) { @@ -941,7 +941,7 @@ static int op_mknod(const char *path, mode_t mode, dev_t dev) FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; - dbg_printf("%s: path=%s mode=0%o dev=0x%x\n", __func__, path, mode, + dbg_printf(ff, "%s: path=%s mode=0%o dev=0x%x\n", __func__, path, mode, (unsigned int)dev); temp_path = strdup(path); if (!temp_path) { @@ -995,7 +995,7 @@ static int op_mknod(const char *path, mode_t mode, dev_t dev) goto out2; } - dbg_printf("%s: create ino=%d/name=%s in dir=%d\n", __func__, child, + dbg_printf(ff, "%s: create ino=%d/name=%s in dir=%d\n", __func__, child, node_name, parent); err = ext2fs_link(fs, parent, node_name, child, filetype); if (err == EXT2_ET_DIR_NO_SPACE) { @@ -1073,7 +1073,7 @@ static int op_mkdir(const char *path, mode_t mode) FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; - dbg_printf("%s: path=%s mode=0%o\n", __func__, path, mode); + dbg_printf(ff, "%s: path=%s mode=0%o\n", __func__, path, mode); temp_path = strdup(path); if (!temp_path) { ret = -ENOMEM; @@ -1142,7 +1142,7 @@ static int op_mkdir(const char *path, mode_t mode) ret = translate_error(fs, 0, err); goto out2; } - dbg_printf("%s: created ino=%d/path=%s in dir=%d\n", __func__, child, + dbg_printf(ff, "%s: created ino=%d/path=%s in dir=%d\n", __func__, child, node_name, parent); memset(&inode, 0, sizeof(inode)); @@ -1198,8 +1198,9 @@ static int op_mkdir(const char *path, mode_t mode) return ret; } -static int unlink_file_by_name(ext2_filsys fs, const char *path) +static int unlink_file_by_name(struct fuse2fs *ff, const char *path) { + ext2_filsys fs = ff->fs; errcode_t err; ext2_ino_t dir; char *filename = strdup(path); @@ -1226,7 +1227,7 @@ static int unlink_file_by_name(ext2_filsys fs, const char *path) return ret; } - dbg_printf("%s: unlinking name=%s from dir=%d\n", __func__, + dbg_printf(ff, "%s: unlinking name=%s from dir=%d\n", __func__, base_name, dir); err = ext2fs_unlink(fs, dir, base_name, 0, 0); free(filename); @@ -1250,7 +1251,7 @@ static int remove_inode(struct fuse2fs *ff, ext2_ino_t ino) ret = translate_error(fs, ino, err); goto out; } - dbg_printf("%s: put ino=%d links=%d\n", __func__, ino, + dbg_printf(ff, "%s: put ino=%d links=%d\n", __func__, ino, inode.i_links_count); switch (inode.i_links_count) { @@ -1312,7 +1313,7 @@ static int __op_unlink(struct fuse2fs *ff, const char *path) goto out; } - ret = unlink_file_by_name(fs, path); + ret = unlink_file_by_name(ff, path); if (ret) goto out; @@ -1378,7 +1379,7 @@ static int __op_rmdir(struct fuse2fs *ff, const char *path) ret = translate_error(fs, 0, err); goto out; } - dbg_printf("%s: rmdir path=%s ino=%d\n", __func__, path, child); + dbg_printf(ff, "%s: rmdir path=%s ino=%d\n", __func__, path, child); rds.parent = 0; rds.empty = 1; @@ -1394,7 +1395,7 @@ static int __op_rmdir(struct fuse2fs *ff, const char *path) goto out; } - ret = unlink_file_by_name(fs, path); + ret = unlink_file_by_name(ff, path); if (ret) goto out; /* Directories have to be "removed" twice. */ @@ -1406,7 +1407,7 @@ static int __op_rmdir(struct fuse2fs *ff, const char *path) goto out; if (rds.parent) { - dbg_printf("%s: decr dir=%d link count\n", __func__, + dbg_printf(ff, "%s: decr dir=%d link count\n", __func__, rds.parent); err = ext2fs_read_inode_full(fs, rds.parent, (struct ext2_inode *)&inode, @@ -1460,7 +1461,7 @@ static int op_symlink(const char *src, const char *dest) FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; - dbg_printf("%s: symlink %s to %s\n", __func__, src, dest); + dbg_printf(ff, "%s: symlink %s to %s\n", __func__, src, dest); temp_path = strdup(dest); if (!temp_path) { ret = -ENOMEM; @@ -1517,7 +1518,7 @@ static int op_symlink(const char *src, const char *dest) ret = translate_error(fs, 0, err); goto out2; } - dbg_printf("%s: symlinking ino=%d/name=%s to dir=%d\n", __func__, + dbg_printf(ff, "%s: symlinking ino=%d/name=%s to dir=%d\n", __func__, child, node_name, parent); memset(&inode, 0, sizeof(inode)); @@ -1589,7 +1590,7 @@ static int op_rename(const char *from, const char *to FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; - dbg_printf("%s: renaming %s to %s\n", __func__, from, to); + dbg_printf(ff, "%s: renaming %s to %s\n", __func__, from, to); pthread_mutex_lock(&ff->bfl); if (!fs_can_allocate(ff, 5)) { ret = -ENOSPC; @@ -1687,7 +1688,7 @@ static int op_rename(const char *from, const char *to goto out2; } - dbg_printf("%s: unlinking %s ino=%d\n", __func__, + dbg_printf(ff, "%s: unlinking %s ino=%d\n", __func__, LINUX_S_ISDIR(inode.i_mode) ? "dir" : "file", to_ino); if (LINUX_S_ISDIR(inode.i_mode)) @@ -1706,7 +1707,7 @@ static int op_rename(const char *from, const char *to } /* Link in the new file */ - dbg_printf("%s: linking ino=%d/path=%s to dir=%d\n", __func__, + dbg_printf(ff, "%s: linking ino=%d/path=%s to dir=%d\n", __func__, from_ino, cp + 1, to_dir_ino); err = ext2fs_link(fs, to_dir_ino, cp + 1, from_ino, ext2_file_type(inode.i_mode)); @@ -1734,7 +1735,7 @@ static int op_rename(const char *from, const char *to if (LINUX_S_ISDIR(inode.i_mode)) { ud.new_dotdot = to_dir_ino; - dbg_printf("%s: updating .. entry for dir=%d\n", __func__, + dbg_printf(ff, "%s: updating .. entry for dir=%d\n", __func__, to_dir_ino); err = ext2fs_dir_iterate2(fs, from_ino, 0, NULL, update_dotdot_helper, &ud); @@ -1744,7 +1745,7 @@ static int op_rename(const char *from, const char *to } /* Decrease from_dir_ino's links_count */ - dbg_printf("%s: moving linkcount from dir=%d to dir=%d\n", + dbg_printf(ff, "%s: moving linkcount from dir=%d to dir=%d\n", __func__, from_dir_ino, to_dir_ino); err = ext2fs_read_inode(fs, from_dir_ino, &inode); if (err) { @@ -1782,7 +1783,7 @@ static int op_rename(const char *from, const char *to goto out2; /* Remove the old file */ - ret = unlink_file_by_name(fs, from); + ret = unlink_file_by_name(ff, from); if (ret) goto out2; @@ -1813,7 +1814,7 @@ static int op_link(const char *src, const char *dest) FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; - dbg_printf("%s: src=%s dest=%s\n", __func__, src, dest); + dbg_printf(ff, "%s: src=%s dest=%s\n", __func__, src, dest); temp_path = strdup(dest); if (!temp_path) { ret = -ENOMEM; @@ -1873,7 +1874,7 @@ static int op_link(const char *src, const char *dest) goto out2; } - dbg_printf("%s: linking ino=%d/name=%s to dir=%d\n", __func__, ino, + dbg_printf(ff, "%s: linking ino=%d/name=%s to dir=%d\n", __func__, ino, node_name, parent); err = ext2fs_link(fs, parent, node_name, ino, ext2_file_type(inode.i_mode)); @@ -1925,7 +1926,7 @@ static int op_chmod(const char *path, mode_t mode ret = translate_error(fs, 0, err); goto out; } - dbg_printf("%s: path=%s mode=0%o ino=%d\n", __func__, path, mode, ino); + dbg_printf(ff, "%s: path=%s mode=0%o ino=%d\n", __func__, path, mode, ino); memset(&inode, 0, sizeof(inode)); err = ext2fs_read_inode_full(fs, ino, (struct ext2_inode *)&inode, @@ -1988,7 +1989,7 @@ static int op_chown(const char *path, uid_t owner, gid_t group ret = translate_error(fs, 0, err); goto out; } - dbg_printf("%s: path=%s owner=%d group=%d ino=%d\n", __func__, + dbg_printf(ff, "%s: path=%s owner=%d group=%d ino=%d\n", __func__, path, owner, group, ino); memset(&inode, 0, sizeof(inode)); @@ -2062,7 +2063,7 @@ static int op_truncate(const char *path, off_t len ret = translate_error(fs, 0, err); goto out; } - dbg_printf("%s: ino=%d len=%jd\n", __func__, ino, len); + dbg_printf(ff, "%s: ino=%d len=%jd\n", __func__, ino, len); ret = check_inum_access(fs, ino, W_OK); if (ret) @@ -2125,7 +2126,7 @@ static int __op_open(struct fuse2fs *ff, const char *path, struct fuse2fs_file_handle *file; int check = 0, ret = 0; - dbg_printf("%s: path=%s\n", __func__, path); + dbg_printf(ff, "%s: path=%s\n", __func__, path); err = ext2fs_get_mem(sizeof(*file), &file); if (err) return translate_error(fs, 0, err); @@ -2156,7 +2157,7 @@ static int __op_open(struct fuse2fs *ff, const char *path, ret = translate_error(fs, 0, err); goto out; } - dbg_printf("%s: ino=%d\n", __func__, file->ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, file->ino); ret = check_inum_access(fs, file->ino, check); if (ret) { @@ -2214,7 +2215,7 @@ static int op_read(const char *path EXT2FS_ATTR((unused)), char *buf, FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf("%s: ino=%d off=%jd len=%jd\n", __func__, fh->ino, offset, + dbg_printf(ff, "%s: ino=%d off=%jd len=%jd\n", __func__, fh->ino, offset, len); pthread_mutex_lock(&ff->bfl); err = ext2fs_file_open(fs, fh->ino, fh->open_flags, &efp); @@ -2271,7 +2272,7 @@ static int op_write(const char *path EXT2FS_ATTR((unused)), FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf("%s: ino=%d off=%jd len=%jd\n", __func__, fh->ino, offset, + dbg_printf(ff, "%s: ino=%d off=%jd len=%jd\n", __func__, fh->ino, offset, len); pthread_mutex_lock(&ff->bfl); if (!fs_writeable(fs)) { @@ -2341,7 +2342,7 @@ static int op_release(const char *path EXT2FS_ATTR((unused)), FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf("%s: ino=%d\n", __func__, fh->ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); pthread_mutex_lock(&ff->bfl); if (fs_writeable(fs) && fh->open_flags & EXT2_FILE_WRITE) { err = ext2fs_flush2(fs, EXT2_FLAG_FLUSH_NO_SYNC); @@ -2371,7 +2372,7 @@ static int op_fsync(const char *path EXT2FS_ATTR((unused)), FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf("%s: ino=%d\n", __func__, fh->ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); /* For now, flush everything, even if it's slow */ pthread_mutex_lock(&ff->bfl); if (fs_writeable(fs) && fh->open_flags & EXT2_FILE_WRITE) { @@ -2395,7 +2396,7 @@ static int op_statfs(const char *path EXT2FS_ATTR((unused)), FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; - dbg_printf("%s: path=%s\n", __func__, path); + dbg_printf(ff, "%s: path=%s\n", __func__, path); buf->f_bsize = fs->blocksize; buf->f_frsize = 0; @@ -2483,7 +2484,7 @@ static int op_getxattr(const char *path, const char *key, char *value, ret = translate_error(fs, 0, err); goto out; } - dbg_printf("%s: ino=%d\n", __func__, ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, ino); ret = check_inum_access(fs, ino, R_OK); if (ret) @@ -2585,7 +2586,7 @@ static int op_listxattr(const char *path, char *names, size_t len) ret = translate_error(fs, ino, err); goto out; } - dbg_printf("%s: ino=%d\n", __func__, ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, ino); ret = check_inum_access(fs, ino, R_OK); if (ret) @@ -2665,7 +2666,7 @@ static int op_setxattr(const char *path EXT2FS_ATTR((unused)), ret = translate_error(fs, 0, err); goto out; } - dbg_printf("%s: ino=%d\n", __func__, ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, ino); ret = check_inum_access(fs, ino, W_OK); if (ret == -EACCES) { @@ -2744,7 +2745,7 @@ static int op_removexattr(const char *path, const char *key) ret = translate_error(fs, 0, err); goto out; } - dbg_printf("%s: ino=%d\n", __func__, ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, ino); ret = check_inum_access(fs, ino, W_OK); if (ret) @@ -2829,7 +2830,7 @@ static int op_readdir(const char *path EXT2FS_ATTR((unused)), FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf("%s: ino=%d\n", __func__, fh->ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); pthread_mutex_lock(&ff->bfl); i.buf = buf; i.func = fill_func; @@ -2860,7 +2861,7 @@ static int op_access(const char *path, int mask) FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; - dbg_printf("%s: path=%s mask=0x%x\n", __func__, path, mask); + dbg_printf(ff, "%s: path=%s mask=0x%x\n", __func__, path, mask); pthread_mutex_lock(&ff->bfl); err = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, path, &ino); if (err || ino == 0) { @@ -2892,7 +2893,7 @@ static int op_create(const char *path, mode_t mode, struct fuse_file_info *fp) FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; - dbg_printf("%s: path=%s mode=0%o\n", __func__, path, mode); + dbg_printf(ff, "%s: path=%s mode=0%o\n", __func__, path, mode); temp_path = strdup(path); if (!temp_path) { ret = -ENOMEM; @@ -2934,7 +2935,7 @@ static int op_create(const char *path, mode_t mode, struct fuse_file_info *fp) goto out2; } - dbg_printf("%s: creating ino=%d/name=%s in dir=%d\n", __func__, child, + dbg_printf(ff, "%s: creating ino=%d/name=%s in dir=%d\n", __func__, child, node_name, parent); err = ext2fs_link(fs, parent, node_name, child, filetype); if (err == EXT2_ET_DIR_NO_SPACE) { @@ -3019,7 +3020,7 @@ static int op_ftruncate(const char *path EXT2FS_ATTR((unused)), FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf("%s: ino=%d len=%jd\n", __func__, fh->ino, len); + dbg_printf(ff, "%s: ino=%d len=%jd\n", __func__, fh->ino, len); pthread_mutex_lock(&ff->bfl); if (!fs_writeable(fs)) { ret = -EROFS; @@ -3070,7 +3071,7 @@ static int op_fgetattr(const char *path EXT2FS_ATTR((unused)), FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf("%s: ino=%d\n", __func__, fh->ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); pthread_mutex_lock(&ff->bfl); ret = stat_inode(fs, fh->ino, statbuf); pthread_mutex_unlock(&ff->bfl); @@ -3102,7 +3103,7 @@ static int op_utimens(const char *path, const struct timespec ctv[2] ret = translate_error(fs, 0, err); goto out; } - dbg_printf("%s: ino=%d\n", __func__, ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, ino); ret = check_inum_access(fs, ino, W_OK); if (ret) @@ -3147,14 +3148,15 @@ static int op_utimens(const char *path, const struct timespec ctv[2] } #ifdef SUPPORT_I_FLAGS -static int ioctl_getflags(ext2_filsys fs, struct fuse2fs_file_handle *fh, +static int ioctl_getflags(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, void *data) { + ext2_filsys fs = ff->fs; errcode_t err; struct ext2_inode_large inode; FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf("%s: ino=%d\n", __func__, fh->ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); memset(&inode, 0, sizeof(inode)); err = ext2fs_read_inode_full(fs, fh->ino, (struct ext2_inode *)&inode, sizeof(inode)); @@ -3170,18 +3172,18 @@ static int ioctl_getflags(ext2_filsys fs, struct fuse2fs_file_handle *fh, EXT2_NOATIME_FL | EXT3_JOURNAL_DATA_FL | EXT2_DIRSYNC_FL | \ EXT2_TOPDIR_FL) -static int ioctl_setflags(ext2_filsys fs, struct fuse2fs_file_handle *fh, +static int ioctl_setflags(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, void *data) { + ext2_filsys fs = ff->fs; errcode_t err; struct ext2_inode_large inode; int ret; __u32 flags = *(__u32 *)data; struct fuse_context *ctxt = fuse_get_context(); - struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf("%s: ino=%d\n", __func__, fh->ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); memset(&inode, 0, sizeof(inode)); err = ext2fs_read_inode_full(fs, fh->ino, (struct ext2_inode *)&inode, sizeof(inode)); @@ -3209,14 +3211,15 @@ static int ioctl_setflags(ext2_filsys fs, struct fuse2fs_file_handle *fh, return 0; } -static int ioctl_getversion(ext2_filsys fs, struct fuse2fs_file_handle *fh, +static int ioctl_getversion(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, void *data) { + ext2_filsys fs = ff->fs; errcode_t err; struct ext2_inode_large inode; FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf("%s: ino=%d\n", __func__, fh->ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); memset(&inode, 0, sizeof(inode)); err = ext2fs_read_inode_full(fs, fh->ino, (struct ext2_inode *)&inode, sizeof(inode)); @@ -3227,18 +3230,18 @@ static int ioctl_getversion(ext2_filsys fs, struct fuse2fs_file_handle *fh, return 0; } -static int ioctl_setversion(ext2_filsys fs, struct fuse2fs_file_handle *fh, +static int ioctl_setversion(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, void *data) { + ext2_filsys fs = ff->fs; errcode_t err; struct ext2_inode_large inode; int ret; __u32 generation = *(__u32 *)data; struct fuse_context *ctxt = fuse_get_context(); - struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf("%s: ino=%d\n", __func__, fh->ino); + dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); memset(&inode, 0, sizeof(inode)); err = ext2fs_read_inode_full(fs, fh->ino, (struct ext2_inode *)&inode, sizeof(inode)); @@ -3264,16 +3267,17 @@ static int ioctl_setversion(ext2_filsys fs, struct fuse2fs_file_handle *fh, #endif /* SUPPORT_I_FLAGS */ #ifdef FITRIM -static int ioctl_fitrim(ext2_filsys fs, struct fuse2fs_file_handle *fh, +static int ioctl_fitrim(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, void *data) { + ext2_filsys fs = ff->fs; struct fstrim_range *fr = data; blk64_t start, end, max_blocks, b, cleared; errcode_t err = 0; start = fr->start / fs->blocksize; end = (fr->start + fr->len - 1) / fs->blocksize; - dbg_printf("%s: start=%llu end=%llu\n", __func__, start, end); + dbg_printf(ff, "%s: start=%llu end=%llu\n", __func__, start, end); if (start < fs->super->s_first_data_block) start = fs->super->s_first_data_block; @@ -3331,34 +3335,32 @@ static int op_ioctl(const char *path EXT2FS_ATTR((unused)), struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)(uintptr_t)fp->fh; - ext2_filsys fs; int ret = 0; FUSE2FS_CHECK_CONTEXT(ff); - fs = ff->fs; pthread_mutex_lock(&ff->bfl); switch ((unsigned long) cmd) { #ifdef SUPPORT_I_FLAGS case EXT2_IOC_GETFLAGS: - ret = ioctl_getflags(fs, fh, data); + ret = ioctl_getflags(ff, fh, data); break; case EXT2_IOC_SETFLAGS: - ret = ioctl_setflags(fs, fh, data); + ret = ioctl_setflags(ff, fh, data); break; case EXT2_IOC_GETVERSION: - ret = ioctl_getversion(fs, fh, data); + ret = ioctl_getversion(ff, fh, data); break; case EXT2_IOC_SETVERSION: - ret = ioctl_setversion(fs, fh, data); + ret = ioctl_setversion(ff, fh, data); break; #endif #ifdef FITRIM case FITRIM: - ret = ioctl_fitrim(fs, fh, data); + ret = ioctl_fitrim(ff, fh, data); break; #endif default: - dbg_printf("%s: Unknown ioctl %d\n", __func__, cmd); + dbg_printf(ff, "%s: Unknown ioctl %d\n", __func__, cmd); ret = -ENOTTY; } pthread_mutex_unlock(&ff->bfl); @@ -3385,7 +3387,7 @@ static int op_bmap(const char *path, size_t blocksize EXT2FS_ATTR((unused)), ret = translate_error(fs, 0, err); goto out; } - dbg_printf("%s: ino=%d blk=%"PRIu64"\n", __func__, ino, *idx); + dbg_printf(ff, "%s: ino=%d blk=%"PRIu64"\n", __func__, ino, *idx); err = ext2fs_bmap2(fs, ino, NULL, NULL, 0, *idx, 0, (blk64_t *)idx); if (err) { @@ -3419,7 +3421,7 @@ static int fallocate_helper(struct fuse_file_info *fp, int mode, off_t offset, FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); start = offset / fs->blocksize; end = (offset + len - 1) / fs->blocksize; - dbg_printf("%s: ino=%d mode=0x%x start=%jd end=%llu\n", __func__, + dbg_printf(ff, "%s: ino=%d mode=0x%x start=%jd end=%llu\n", __func__, fh->ino, mode, offset / fs->blocksize, end); if (!fs_can_allocate(ff, len / fs->blocksize)) return -ENOSPC; @@ -3552,7 +3554,7 @@ static int punch_helper(struct fuse_file_info *fp, int mode, off_t offset, FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf("%s: offset=%jd len=%jd\n", __func__, offset, len); + dbg_printf(ff, "%s: offset=%jd len=%jd\n", __func__, offset, len); /* kernel ext4 punch requires this flag to be set */ if (!(mode & FL_KEEP_SIZE_FLAG)) @@ -3561,7 +3563,7 @@ static int punch_helper(struct fuse_file_info *fp, int mode, off_t offset, /* Punch out a bunch of blocks */ start = (offset + fs->blocksize - 1) / fs->blocksize; end = (offset + len - fs->blocksize) / fs->blocksize; - dbg_printf("%s: ino=%d mode=0x%x start=%llu end=%llu\n", __func__, + dbg_printf(ff, "%s: ino=%d mode=0x%x start=%llu end=%llu\n", __func__, fh->ino, mode, start, end); memset(&inode, 0, sizeof(inode)); @@ -3813,6 +3815,13 @@ int main(int argc, char *argv[]) exit(1); } + /* /dev/sda -> sda for reporting */ + fctx.shortdev = strrchr(fctx.device, '/'); + if (fctx.shortdev) + fctx.shortdev++; + else + fctx.shortdev = fctx.device; + if (fctx.norecovery) fctx.ro = 1; if (fctx.ro) @@ -3947,10 +3956,11 @@ int main(int argc, char *argv[]) if (fctx.debug) { int i; - printf("fuse arguments:"); + printf("FUSE2FS (%s): fuse arguments:", fctx.shortdev); for (i = 0; i < args.argc; i++) printf(" '%s'", args.argv[i]); printf("\n"); + fflush(stdout); } pthread_mutex_init(&fctx.bfl, NULL); From patchwork Thu Apr 24 21:39:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Gox9FrvD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=nzwk=xk=vger.kernel.org=linux-ext4+bounces-7461-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8Vz2xQDz1yMg for ; Fri, 25 Apr 2025 07:39:07 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8WJ6L0Nz4x8Y for ; Fri, 25 Apr 2025 07:39:24 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8WJ6H29z4x8f; Fri, 25 Apr 2025 07:39:24 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.80.249 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530764; cv=pass; b=GKkQzF1rlgLy4TK4gZ2TfR1rIe+Pq6JaknXrQ88U5hkPeO95z1naiex5s5+8Kwvd8pL3fJzv/k4GVR0uhp2f2OcrQs2xLI26tchdev/M9YdYJAO7iU+jRjBBRaOCDy1OwDdYteT9a9oubCELZdCQuWPq7wyrkNqYGds8SlWRsAFUkt83Hu7zHNWk13RaJ1f2NQJ5JpOeHpyQL5/OieYWcrzr14v55NR3EN5bw9bMSgwObHzWSrjebhs0qkGU8XrzWYYIZPTr7Y0Bavj9askD8UmIG/hf6Hm5rEYAiDmYXBKnbex/MGPjWkBtz1E+79dPOXn7L7J3JA1vDLbA1GI6lQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530764; c=relaxed/relaxed; bh=bkkc3YzpKyMP5xr55hXmVloG3mO1jNeuaeQiwXeEWqg=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m1YfNKXnJ4h1qE5mVHHnR4W3+MbHEX05epc7RaUXu20kdS4ahJhzZ/EVaI10TT1Wr1sEp2nrYmqhxVuQbJpynWQIrEvqoq/5hJ9eKQiQwb82FjeqEQwKZRLs7eVxkT2v525+kAJUwFV7nvlxzzad2PxUB5d0A9V+w9V+hClWXrbQMefnp9TxlpHEtA3n/igMsHTMBbCJ4GayijZvfmmcSYAgaEyKVG5bo7CDqxwWWy2tQe+tSEY1z2rNjHdcnDdM+wLG+7TmnNX5RZUMffhYGWLSqs5OMI+NU+JP8sN6kGnbrxGAlX5Dr2JiEwmH8tAsvdNcNLSHEY7t3mvjT/ZRqQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Gox9FrvD; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Gox9FrvD; dkim-atps=neutral Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8WF3fL6z4x8Y for ; Fri, 25 Apr 2025 07:39:21 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0490C1B82981 for ; Thu, 24 Apr 2025 21:39:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 636FF218ACA; Thu, 24 Apr 2025 21:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Gox9FrvD" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 235D0198851 for ; Thu, 24 Apr 2025 21:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530754; cv=none; b=J/YyILAFiEoHyD1icgttNmKxplMJWlLoWhqDxmLmhI4CkF+z2nCNY8ELvPNr9IAF2l4dU9dCTjS0zRo9FJHD3cPHmowAT5OcBlq+/D7VcnjrRjkDorCTRD8bSbcRJFyblMKpxJPiL+858Pw0nGaeDBPobDe8UrJvOi8ZhcXA3Nw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530754; c=relaxed/simple; bh=mi56lLRubnxtJ6e9jiukPbRlKAVZGuVcHHaWsUxMvV8=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lfLlv3jQF6MWkWh+D1/BvLVT11fLvYg5ifRnnAJKHZpBiF3f7rid+VA8najc4NSHvWMc4OWdwR2yHYgZ93xFowGjXF9DWHmOH45gV9W3zzUWYpvFh08iTsvn3RYRKdJ6g8KrTNr/b3VEr/SaYmM0lB2bbtDh8M/mNdz+KWq5Y5o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Gox9FrvD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4C10C4CEE3; Thu, 24 Apr 2025 21:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530754; bh=mi56lLRubnxtJ6e9jiukPbRlKAVZGuVcHHaWsUxMvV8=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Gox9FrvD8BukoSSI4L/4RA8riTc6J4t483clq1T/HEXBS/KsqI5XSjVDlu+VPU37n GaoS96/46hsKQPIwDtD4JfwJ42yqxd2WaBR3nOhiC/4R/FKukz7Lh3X4yaymqa6GD3 R/DanTbAMI1aHlRixO7OJYNOayXz7ipboyyzV/L9ee3L2yrtMpaOnCU2LLkjuHoxsd wvOoKs5QKTfYqPdRt8KMpooS4XVNWCFZSc0Nd/LXqgOefljQa30IYnWpAdaGymCFOo EAznG4cb5NfexMHsdpVM+i24BaOdZCObtEKNOUeQI9NcB8QQ1NAflN9CDXxTRUbuLO 0pmzHVuFOB1Ew== Date: Thu, 24 Apr 2025 14:39:13 -0700 Subject: [PATCH 2/5] fuse2fs: stop aliasing stderr with ff->err_fp From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553064491.1160047.2269966041756188067.stgit@frogsfrogsfrogs> In-Reply-To: <174553064436.1160047.577374015997116030.stgit@frogsfrogsfrogs> References: <174553064436.1160047.577374015997116030.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Remove this pointless aliasing of error stream pointers. Signed-off-by: "Darrick J. Wong" --- 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); From patchwork Thu Apr 24 21:39:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=N3U75ota; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=ymw2=xk=vger.kernel.org=linux-ext4+bounces-7462-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8WF35pyz1yMg for ; Fri, 25 Apr 2025 07:39:21 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8WZ5sBYz4wcQ for ; Fri, 25 Apr 2025 07:39:38 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8WZ5qLrz4x8f; Fri, 25 Apr 2025 07:39:38 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:45d1:ec00::1" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530778; cv=pass; b=G3Gj/4oNqAUoR1RA8pkQo7WuRgSwmdeh7Hb1Z10SrCXZjIfQit173uwR296z5hvdp1rBMttMq51xV7ls2bkyf9cLuowey9pn3c1U5HN/0UFLRbxr/Vsa6465GXy5MT+NX3HfRyjq/uB1RuJzeFD3WJ5nE50v0GTnsFTfen0g29bl2oRLffXfGumKbW8CyOU72avEow+1EGv//SY/2JyCbRAaFclSM7ubZC6WK37HT64ExTPekhHUlqV1g2a5Coh9JjrEdfbmZBp62lNpzcb1H+wJ9L29H8L54CxR3JFku5RLJQ1v00E2IwjlsAF0wctf+22KzTrFWa5xqkY/8n9FMA== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530778; c=relaxed/relaxed; bh=xPZaoz4AaTxvUz+pP0fjJin9zvZcH/aoCt/EZimu6fQ=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rK651N9V5BROpSwHtUQgSD2NwpeHvP0Pm/bNSdiOuH7L/6aSMOfExT9uEi6uc9hgObNk3H76yd5ZJICMr00CbKWb8ZOU0Wj7sIjskrLGhvSLms5IhznBqdGn1N6jzd+daUBwAOZpQtCRdW6D5M2kHblQuazilJ9hxYmOLNck+uEdSlGpSqKXfONHP13SOllMlZ+gxBcH5pvozCA2WCa/o71h3ffdMDEjnkvJ1iNVhZU6Wo6fSJ0+sOaG4IsxMHhjYeXimLDjUXIra1+gkvI2oCxAgIoJ5W1Ipv17k8pFQikYfW0FQ6jtUKQPjg4PeK9xZD3BzTunRrhKccAogFK1Rw== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=N3U75ota; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=N3U75ota; dkim-atps=neutral Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8WW3cM4z4x8Y for ; Fri, 25 Apr 2025 07:39:35 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DEF034639B0 for ; Thu, 24 Apr 2025 21:39:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BA0D21ADCB; Thu, 24 Apr 2025 21:39:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N3U75ota" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A9F1198851 for ; Thu, 24 Apr 2025 21:39:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530770; cv=none; b=lebpTaEn2hh1SR2Ra7CKVPwKxbS52wP0SvM5zSei7JndS8JjcVc+QUOzWEVdSx6mCD8N1BWHL99PZyXTkBbbWS5odLaOkuVIte4abBJUEB8Y8rcpTPzuoqYSh6XWD8IuW/6yhBaFgVlVDIWjI3i+0Yvtvm8RX9BDsmyBsUsdM7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530770; c=relaxed/simple; bh=/NI7UASRHVCThISDs1QjV7Wg9LYWhIJSx9jQKUZTs80=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bXIAIFHnPXM4jotluXwGzdFAOhoXKQ8V+xq6o+4JcXORskoBE8j4W9l8jk6Rszbu6HclFJSqOjpplpieoaAlBx0jHfkkLgTRtBPb18XUFtxhjmfWj/oYz6qQZurYxI9e/6evA+2z35zpmM9YphYh6L9DRtr+yZoTOWeof596bbc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N3U75ota; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96E7FC4CEE3; Thu, 24 Apr 2025 21:39:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530769; bh=/NI7UASRHVCThISDs1QjV7Wg9LYWhIJSx9jQKUZTs80=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=N3U75otaW9fzY9YA5uu0JnvkJjITyVaPcvXe/krzaacjRuL6DyoIc4QYst9hwclFf QaE5Qb6rT1koAheO+/6wu1wzdFhsX0WBB1i5eChMSM49+v34VHaHueMLko1OdmYs9z abUsLD7ZFGUH/aMwGS1xw+x+tX1yj5nthxv4oqMmzgS/KDtjwYjx1UETKWJeyyzxjf NsqWGggaReFsdCa9yuAlzui45OF8QL+nCWr/EcAxAuVSzMituOjrjL04N9wQlRcJR/ k5HdCpl4QROqDxOoiw4C/SrH+Pp9xywv860uNO12X6plqNCBWKc5pjk8kLAaKsuXGl n7e9an+NU1wBw== Date: Thu, 24 Apr 2025 14:39:29 -0700 Subject: [PATCH 3/5] fuse2fs: use error logging macro for mount errors From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553064509.1160047.12034355870702470696.stgit@frogsfrogsfrogs> In-Reply-To: <174553064436.1160047.577374015997116030.stgit@frogsfrogsfrogs> References: <174553064436.1160047.577374015997116030.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.2 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Use err_printf for mount errors so that they all have a standard format and go where all the other errors go. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index f2d0e1f2441f83..e3e747dec33fd9 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -3868,8 +3868,8 @@ int main(int argc, char *argv[]) err = ext2fs_open2(fctx.device, options, flags, 0, 0, unix_io_manager, &global_fs); if (err) { - printf(_("%s: %s.\n"), fctx.device, error_message(err)); - printf(_("Please run e2fsck -fy %s.\n"), fctx.device); + err_printf(&fctx, "%s.\n", error_message(err)); + err_printf(&fctx, "%s\n", _("Please run e2fsck -fy.")); goto out; } fctx.fs = global_fs; @@ -3886,17 +3886,16 @@ int main(int argc, char *argv[]) printf(_("%s: recovering journal\n"), fctx.device); err = ext2fs_run_ext3_journal(&global_fs); if (err) { - printf(_("%s: %s.\n"), fctx.device, - error_message(err)); - printf(_("Please run e2fsck -fy %s.\n"), - fctx.device); + err_printf(&fctx, "%s.\n", error_message(err)); + err_printf(&fctx, "%s\n", + _("Please run e2fsck -fy.")); goto out; } ext2fs_clear_feature_journal_needs_recovery(global_fs->super); ext2fs_mark_super_dirty(global_fs); } else { - printf("%s", _("Journal needs recovery; running " - "`e2fsck -E journal_only' is required.\n")); + err_printf(&fctx, "%s\n", + _("Journal needs recovery; running `e2fsck -E journal_only' is required.")); goto out; } } @@ -3918,24 +3917,24 @@ int main(int argc, char *argv[]) } if (!(global_fs->super->s_state & EXT2_VALID_FS)) - printf("%s", _("Warning: Mounting unchecked fs, running e2fsck " - "is recommended.\n")); + err_printf(&fctx, "%s\n", + _("Warning: Mounting unchecked fs, running e2fsck is recommended.")); if (global_fs->super->s_max_mnt_count > 0 && global_fs->super->s_mnt_count >= global_fs->super->s_max_mnt_count) - printf("%s", _("Warning: Maximal mount count reached, running " - "e2fsck is recommended.\n")); + err_printf(&fctx, "%s\n", + _("Warning: Maximal mount count reached, running e2fsck is recommended.")); if (global_fs->super->s_checkinterval > 0 && (time_t) (global_fs->super->s_lastcheck + global_fs->super->s_checkinterval) <= time(0)) - printf("%s", _("Warning: Check time reached; running e2fsck " - "is recommended.\n")); + err_printf(&fctx, "%s\n", + _("Warning: Check time reached; running e2fsck is recommended.")); if (global_fs->super->s_last_orphan) - printf("%s", - _("Orphans detected; running e2fsck is recommended.\n")); + err_printf(&fctx, "%s\n", + _("Orphans detected; running e2fsck is recommended.")); if (global_fs->super->s_state & EXT2_ERROR_FS) { - printf("%s", - _("Errors detected; running e2fsck is required.\n")); + err_printf(&fctx, "%s\n", + _("Errors detected; running e2fsck is required.")); goto out; } From patchwork Thu Apr 24 21:39:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=UzamJLkn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=xhgt=xk=vger.kernel.org=linux-ext4+bounces-7463-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8Wb1LZYz1yMg for ; Fri, 25 Apr 2025 07:39:39 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8Ww4mNPz4wcQ for ; Fri, 25 Apr 2025 07:39:56 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8Ww4kQLz4x8Y; Fri, 25 Apr 2025 07:39:56 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.199.223 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530796; cv=pass; b=kntDKsTcd2c0LjQnUbmwnhCtwkSgXpTq/b/49clqcILyMXT18MQlOay+0548iVQteVbPmQpbqKSwhTyaG1dM8BoGOls6fJKHjRqB1eJqnq7M4JlA7lFiiTSSUuIQHreNdixHPpUID0jEz1PS2bWjj2zG3jf8apH+jAnm5Ampho5jq8R2/tB6oWiAbSo5gzz3JwFgjX4DnN9ZtrozsyFkHwLO05yyE00c8ll2hISMFktvlKi/T0aJGqAhVzVsagUG2kcAij66/3EKlLII63jKFd5CW2NQ1i5y1Q8OnKImBn7paVgrZBMQEeMsaJlk+0cDzDKNzdIT2FRYiDLVdULFhw== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530796; c=relaxed/relaxed; bh=ahe8NpgVeUxzimCZmwAOuDpr5SQXKTUn3P3dUVa/PZU=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S20VD23KhS90KGw9sdzTHGXUTQV0I3xfeJSHedZVB2fZQl+0s18U0XuPevjXA/Dp5ANTt7lDMuA46S1G38L3NcRwIU/TYO/T8t5wJzio8HYSVIfcmKu1lgiIoLX+UOtf275lj0ur2zCXpUOCMlmkEG6epbiOpdRmNfiZJaqpxh1R3/NbuhtCKeVaHaJ8ec+XudZn/kRplqHabhxAx0jsR4ozIsRncDYeXHXOUD4l20Fte+Upp7dQKMlx7m06U9/TwD/RG+IoTEGlyeNlgsacsogIvFP7YldU1csEP301uk2pCfRp1q6qjRXfQtc0McF2Aejl4PhLv4lRumDr36IEYw== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=UzamJLkn; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=UzamJLkn; dkim-atps=neutral Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8Ws2S1zz4wcQ for ; Fri, 25 Apr 2025 07:39:53 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B390A4A5201 for ; Thu, 24 Apr 2025 21:39:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DFF821E087; Thu, 24 Apr 2025 21:39:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UzamJLkn" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E9E1198851 for ; Thu, 24 Apr 2025 21:39:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530785; cv=none; b=neaWQ6QFTihYATVhqfQMW3dQ9Af7vLFTulVi+3AXlrGr3Jg1RhKvkmmC1/UqDOVEYSbKs2Evg16ar4EQrtxG35+j8iqrlj1YTbLwFjjA/IrU9n3JX7Jo7IaFlXPywkH1ePxWN9riMZMA9Q29k6PG8KU1+wggM1g3Sp71odyxQnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530785; c=relaxed/simple; bh=bv0bvNTCZtZeJv0I9P2+KZpVeKWVEQnVgrtVJoNm2zU=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NeK6EVmTKhhaENTC+qZZDPk3RoQ8XUe3sz6DHRszd/qdZ/jAUOSdaAOiZu7iRbnjQlflFsmeHCKss25Y4hJcm01BfxK0bJLxLUBU7LKYF9G0rSiDxvM75lCisQbzpBFr0H/LCduHWEIUd2Z1++qP5xUpGDerWuURRxn092yhuqw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UzamJLkn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35CF3C4CEE3; Thu, 24 Apr 2025 21:39:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530785; bh=bv0bvNTCZtZeJv0I9P2+KZpVeKWVEQnVgrtVJoNm2zU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=UzamJLknM1QjU1WOvTWXf35fc0h3ZXOLvy1gMhPbjqGuczJaY+ldyM7d/1L2rH6c9 cUL/m5P4JyOQEi8jFepkWBpT72FBVjQAi35R0QB15203zCdp0aabiYhxZGB3uLJeei OEgEiTjs/HDHxdbq+9vHdMCL8PFJk1vn/9yfYa7kVqn0bCcI9V8JM1ElmE2d3coZCD PEDe9ehEq2DfC1CDjMzX60xtZ7LQsM9j3SrcFYvQ9pzFfajxKuYZMUKMiFaizj3kFB LM1ClqIpdc0vKek8VZHlhRxTYxkxnQ96u7dYWoOYDbwwMEE+9WWbQ8VjUK1e7ei1PL krsqgrfPaFzzQ== Date: Thu, 24 Apr 2025 14:39:44 -0700 Subject: [PATCH 4/5] fuse2fs: make other logging consistent From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553064527.1160047.12420605972373641844.stgit@frogsfrogsfrogs> In-Reply-To: <174553064436.1160047.577374015997116030.stgit@frogsfrogsfrogs> References: <174553064436.1160047.577374015997116030.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Make all the other advisory messages have a consistent format. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index e3e747dec33fd9..9fd35d14e10556 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 log_printf(fuse2fs, format, ...) \ + do { \ + printf("FUSE2FS (%s): " format, (fuse2fs)->shortdev, ##__VA_ARGS__); \ + fflush(stdout); \ + } while (0) + #define err_printf(fuse2fs, format, ...) \ do { \ fprintf(stderr, "FUSE2FS (%s): " format, (fuse2fs)->shortdev, ##__VA_ARGS__); \ @@ -3830,7 +3836,7 @@ int main(int argc, char *argv[]) if (fctx.norecovery) fctx.ro = 1; if (fctx.ro) - printf("%s", _("Mounting read-only.\n")); + log_printf(&fctx, "%s\n", _("Mounting read-only.")); #ifdef ENABLE_NLS setlocale(LC_MESSAGES, ""); @@ -3854,8 +3860,8 @@ int main(int argc, char *argv[]) /* Will we allow users to allocate every last block? */ if (getenv("FUSE2FS_ALLOC_ALL_BLOCKS")) { - printf(_("%s: Allowing users to allocate all blocks. " - "This is dangerous!\n"), fctx.device); + log_printf(&fctx, "%s\n", + _("Allowing users to allocate all blocks. This is dangerous!")); fctx.alloc_all_blocks = 1; } @@ -3879,11 +3885,10 @@ int main(int argc, char *argv[]) if (ext2fs_has_feature_journal_needs_recovery(global_fs->super)) { if (fctx.norecovery) { - printf(_("%s: mounting read-only without " - "recovering journal\n"), - fctx.device); + log_printf(&fctx, "%s\n", + _("Mounting read-only without recovering journal.")); } else if (!fctx.ro) { - printf(_("%s: recovering journal\n"), fctx.device); + log_printf(&fctx, "%s\n", _("Recovering journal.")); err = ext2fs_run_ext3_journal(&global_fs); if (err) { err_printf(&fctx, "%s.\n", error_message(err)); @@ -3902,8 +3907,8 @@ int main(int argc, char *argv[]) if (!fctx.ro) { if (ext2fs_has_feature_journal(global_fs->super)) - printf(_("%s: Writing to the journal is not supported.\n"), - fctx.device); + log_printf(&fctx, "%s\n", + _("Writing to the journal is not supported.")); err = ext2fs_read_inode_bitmap(global_fs); if (err) { translate_error(global_fs, 0, err); From patchwork Thu Apr 24 21:40:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076922 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=AxXMODZ7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=nl/f=xk=vger.kernel.org=linux-ext4+bounces-7464-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8Wt1Pyxz1yN2 for ; Fri, 25 Apr 2025 07:39:54 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8XC4r8bz4x8Y for ; Fri, 25 Apr 2025 07:40:11 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8XC4pP3z4wbr; Fri, 25 Apr 2025 07:40:11 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.80.249 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530811; cv=pass; b=wTRLPRAbY6G7zpDInTMytHHoL0PumNoEm9vZt+BTFLPLG+6eBMSRQX1QcQEpK/bblG2yYWYs2I7WEWDWcB1Loef8azk7z4gr26tud9J88uzC/aeEIRKRTBp8/kjBEpOlU9IvNUZWfziPivbLQm74tNfXapKnxkemqCIvjzE9M9d0uUSCrQ4f4o1ODr5NT03sSRZCTifMbBv5M2aNGRrRMkznQQTJ5fv0iME+R9CiFLtjPx1sRzYg5ThfUgEbO3LWXkv/7GfOiit57AZMIMpvi/dFqtX7/z/E4zPoJat499v/lcw+TGYtUZVwbVE8pUh5Qz7l28U1HVni69txPTIAAA== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530811; c=relaxed/relaxed; bh=d4N0UTQjhqwWQSDgh+xRGKPCakgyAmsPAQUJHydfjzQ=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dUhZvY4KyDA5Rixy5pL+zOBzCa18BAgkS7SskidcFXCPwJXUiDjAJFcmyb5oOtkquf0bqPKmD/sfI19anpyxLX2lZSsbBHjgRPciK8GxrcHO17HFqTrtrhAJzvKTMhXlki2d0qCqdxPxdLJgxCUiEXTpu5QBf2I9dKqlr9Zl9p5KGhIUkw726J1Y3TNjTolh4UeTorVxa4/IZfGbeqpOEj7CR9aIRMV6/8gI5CbufntZy1KDk4F+LrLvffyyCA+KB7MNzge3R0OGbyT7ya18VCz2vZ7TdbQTLKAxVKpO9PCF1K+y97Vgl0mmrOLteHTE+f8TRztrpjtUfcL+G9Rehw== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=AxXMODZ7; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=AxXMODZ7; dkim-atps=neutral Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8X83v7gz4x8Y for ; Fri, 25 Apr 2025 07:40:08 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E9CD31B826A2 for ; Thu, 24 Apr 2025 21:40:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3DFE62222C5; Thu, 24 Apr 2025 21:40:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AxXMODZ7" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1ED121E087 for ; Thu, 24 Apr 2025 21:40:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530801; cv=none; b=U0vVsNoTfN5/zBcx/ce07SKJj3lKvxTp61ISc19r+5K1mqLHcf6n9koERL5t6iqAnYorRfCabvvs6YoiYB+j7BzT3cjA/tWCEciO7kwKnCLSfyz64QWUAC4CvE0034h98KKe4NKX0lBNRVDfhl0zkAWVb0lckzVb/Ji1XgafV04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530801; c=relaxed/simple; bh=DTIpx0ArwpDw6VdkoFhXSsHuScCiEWQX7W65Ms2t1EM=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZOGbWu2PWIfuiIJr0FuYPsklxUUI/qwMkUPipcEXSpUUcPeof/AdIi5RzsU2+l1tf6PuNg3vAD2M5QXPIbCTRQGk+7Ku/ELn36/AbDD5bDrpYbJYBeiLZzAOSqM31J6ys4clnzbAoLLZZvggQLpAGaO/WQyA++c7hrpH2fgBzGg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AxXMODZ7; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA717C4CEE3; Thu, 24 Apr 2025 21:40:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530800; bh=DTIpx0ArwpDw6VdkoFhXSsHuScCiEWQX7W65Ms2t1EM=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=AxXMODZ7f760eb1I9MZRHPwolbaBLuMSePXWSvXVeo0i9PguPz/Cy5ty0GSlkQEap FnDTDkFJ6HVMaUHSaonAYGplVJEkrKaIQ3mpQLtCB74N+qWnJnJ/aeMT7gqlCZQ09i WPwpU/b4DYgEAS/PsXQ8c4SojWw1JyJifW2bLry0CmYGQmxX1rZHT7+6Wya69N/7zI CQziqrXJhTiI0egGKrmQij9etzS0VKnT+e1+vduZlM5kUo7aqYJZLhWby26pHgL8gk WsEtRGLLtqC9nkVvx8naySXE1n0C93LfqKLoWNI4LyjjluM++YD1hd+WbMgrFjLmOi KjtXuVnLzUomA== Date: Thu, 24 Apr 2025 14:40:00 -0700 Subject: [PATCH 5/5] fuse2fs: redirect all messages when FUSE2FS_LOGFILE is set From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553064545.1160047.7348261379704899161.stgit@frogsfrogsfrogs> In-Reply-To: <174553064436.1160047.577374015997116030.stgit@frogsfrogsfrogs> References: <174553064436.1160047.577374015997116030.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong If the user sets FUSE2FS_LOGFILE, redirect all debug messages and error reports to that file. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 9fd35d14e10556..fa48956396e9d1 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -3856,6 +3856,7 @@ int main(int argc, char *argv[]) goto out; } stderr = fp; + stdout = fp; } /* Will we allow users to allocate every last block? */