From: Jeff Mahoney <jeffm@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Jeff Mahoney <jeffm@suse.com>
Subject: [PATCH 5/5] btrfs-progs: mkfs: print error messages instead of just error number
Date: Tue, 13 Aug 2019 21:04:02 -0400 [thread overview]
Message-ID: <20190814010402.22546-5-jeffm@suse.com> (raw)
In-Reply-To: <20190814010402.22546-1-jeffm@suse.com>
Printing the error number means having to go look up what that error
number means. For a developer, it's easy. For a user, it's unhelpful.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
mkfs/main.c | 47 ++++++++++++++++++++++++++++++-----------------
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/mkfs/main.c b/mkfs/main.c
index b752da13..7bfeb610 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1197,37 +1197,43 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
ret = create_metadata_block_groups(root, mixed, &allocation);
if (ret) {
- error("failed to create default block groups: %d", ret);
+ error("failed to create default block groups: %d/%s",
+ ret, strerror(-ret));
goto error;
}
trans = btrfs_start_transaction(root, 1);
if (IS_ERR(trans)) {
- error("failed to start transaction");
+ error("failed to start transaction: %ld/%s",
+ PTR_ERR(trans), strerror(-PTR_ERR(trans)));
goto error;
}
ret = create_data_block_groups(trans, root, mixed, &allocation);
if (ret) {
- error("failed to create default data block groups: %d", ret);
+ error("failed to create default data block groups: %d/%s",
+ ret, strerror(-ret));
goto error;
}
ret = make_root_dir(trans, root);
if (ret) {
- error("failed to setup the root directory: %d", ret);
+ error("failed to setup the root directory: %d/%s",
+ ret, strerror(-ret));
goto error;
}
ret = btrfs_commit_transaction(trans, root);
if (ret) {
- error("unable to commit transaction: %d", ret);
+ error("unable to commit transaction: %d/%s",
+ ret, strerror(-ret));
goto out;
}
trans = btrfs_start_transaction(root, 1);
if (IS_ERR(trans)) {
- error("failed to start transaction");
+ error("failed to start transaction: %ld/%s",
+ PTR_ERR(trans), strerror(-PTR_ERR(trans)));
goto error;
}
@@ -1267,7 +1273,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
ret = btrfs_add_to_fsid(trans, root, fd, file, dev_block_count,
sectorsize, sectorsize, sectorsize);
if (ret) {
- error("unable to add %s to filesystem: %d", file, ret);
+ error("unable to add %s to filesystem: %d/%s", file, ret, strerror(-ret));
goto error;
}
if (verbose >= 2) {
@@ -1284,46 +1290,52 @@ raid_groups:
ret = create_raid_groups(trans, root, data_profile,
metadata_profile, mixed, &allocation);
if (ret) {
- error("unable to create raid groups: %d", ret);
+ error("unable to create raid groups: %d/%s",
+ ret, strerror(-ret));
goto out;
}
ret = create_data_reloc_tree(trans);
if (ret) {
- error("unable to create data reloc tree: %d", ret);
+ error("unable to create data reloc tree: %d/%s",
+ ret, strerror(-ret));
goto out;
}
ret = create_uuid_tree(trans);
if (ret)
warning(
- "unable to create uuid tree, will be created after mount: %d", ret);
+ "unable to create uuid tree, will be created after mount: %d/%s",
+ ret, strerror(-ret));
ret = btrfs_commit_transaction(trans, root);
if (ret) {
- error("unable to commit transaction: %d", ret);
+ error("unable to commit transaction: %d/%s",
+ ret, strerror(-ret));
goto out;
}
ret = cleanup_temp_chunks(fs_info, &allocation, data_profile,
metadata_profile, metadata_profile);
if (ret < 0) {
- error("failed to cleanup temporary chunks: %d", ret);
+ error("failed to cleanup temporary chunks: %d/%s",
+ ret, strerror(-ret));
goto out;
}
if (source_dir_set) {
ret = btrfs_mkfs_fill_dir(source_dir, root, verbose);
if (ret) {
- error("error while filling filesystem: %d", ret);
+ error("error while filling filesystem: %d/%s",
+ ret, strerror(-ret));
goto out;
}
if (shrink_rootdir) {
ret = btrfs_mkfs_shrink_fs(fs_info, &shrink_size,
shrink_rootdir);
if (ret < 0) {
- error("error while shrinking filesystem: %d",
- ret);
+ error("error while shrinking filesystem: %d/%s",
+ ret, strerror(-ret));
goto out;
}
}
@@ -1383,8 +1395,9 @@ out:
if (!ret && close_ret) {
ret = close_ret;
- error("failed to close ctree, the filesystem may be inconsistent: %d",
- ret);
+ error(
+ "failed to close ctree, the filesystem may be inconsistent: %d/%s",
+ ret, strerror(-ret));
}
btrfs_close_all_devices();
--
2.16.4
next prev parent reply other threads:[~2019-08-14 1:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-14 1:03 [PATCH 1/5] btrfs-progs: mkfs: treat btrfs_add_to_fsid as fatal error Jeff Mahoney
2019-08-14 1:03 ` [PATCH 2/5] btrfs-progs: btrfs_add_to_fsid: check if adding device would overflow Jeff Mahoney
2019-08-14 1:50 ` Qu Wenruo
2019-08-27 15:23 ` David Sterba
2019-08-14 1:04 ` [PATCH 3/5] btrfs-progs: qgroups: use parse_size instead of open coding it Jeff Mahoney
2019-08-14 1:51 ` Qu Wenruo
2019-08-14 1:04 ` [PATCH 4/5] btrfs-progs: resize: more sensible error messages for bad sizes Jeff Mahoney
2019-08-14 1:53 ` Qu Wenruo
2019-08-27 15:22 ` David Sterba
2019-08-14 1:04 ` Jeff Mahoney [this message]
2019-08-14 1:54 ` [PATCH 5/5] btrfs-progs: mkfs: print error messages instead of just error number Qu Wenruo
2019-08-14 2:30 ` Jeff Mahoney
2019-08-14 1:48 ` [PATCH 1/5] btrfs-progs: mkfs: treat btrfs_add_to_fsid as fatal error Qu Wenruo
2019-08-27 15:27 ` David Sterba
2019-08-27 15:30 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190814010402.22546-5-jeffm@suse.com \
--to=jeffm@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).