diff mbox

btrfs-progs: add the error message when open fails

Message ID 201606090123.AA00000@WIN-5MHF4RKU941.jp.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Tsutomu Itoh June 9, 2016, 1:23 a.m. UTC
When open in btrfs_open_devices failed, only the following message is
displayed. Therefore the user doesn't understand the reason why open
failed.

  # btrfs check /dev/sdb8
  Couldn't open file system

This patch adds the error message when open fails.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
---
 volumes.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Sterba June 9, 2016, 1:13 p.m. UTC | #1
On Thu, Jun 09, 2016 at 10:23:15AM +0900, Tsutomu Itoh wrote:
> When open in btrfs_open_devices failed, only the following message is
> displayed. Therefore the user doesn't understand the reason why open
> failed.
> 
>   # btrfs check /dev/sdb8
>   Couldn't open file system
> 
> This patch adds the error message when open fails.

I think the message should be printed by the caller, not by the helper.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tsutomu Itoh June 9, 2016, 11:32 p.m. UTC | #2
Hi, David,

On 2016/06/09 22:13, David Sterba wrote:
> On Thu, Jun 09, 2016 at 10:23:15AM +0900, Tsutomu Itoh wrote:
>> When open in btrfs_open_devices failed, only the following message is
>> displayed. Therefore the user doesn't understand the reason why open
>> failed.
>>
>>   # btrfs check /dev/sdb8
>>   Couldn't open file system
>>
>> This patch adds the error message when open fails.
>
> I think the message should be printed by the caller, not by the helper.

However in this case, error device name is not understood in the caller.

Thanks,
Tsutomu

> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba July 8, 2016, 3:08 p.m. UTC | #3
On Fri, Jun 10, 2016 at 08:32:12AM +0900, Tsutomu Itoh wrote:
> Hi, David,
> 
> On 2016/06/09 22:13, David Sterba wrote:
> > On Thu, Jun 09, 2016 at 10:23:15AM +0900, Tsutomu Itoh wrote:
> >> When open in btrfs_open_devices failed, only the following message is
> >> displayed. Therefore the user doesn't understand the reason why open
> >> failed.
> >>
> >>   # btrfs check /dev/sdb8
> >>   Couldn't open file system
> >>
> >> This patch adds the error message when open fails.
> >
> > I think the message should be printed by the caller, not by the helper.
> 
> However in this case, error device name is not understood in the caller.

Right, makes more sense to print from within btrfs_open_devices.
Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/volumes.c b/volumes.c
index ccfa732..80d61cf 100644
--- a/volumes.c
+++ b/volumes.c
@@ -227,6 +227,8 @@  int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int flags)
 		fd = open(device->name, flags);
 		if (fd < 0) {
 			ret = -errno;
+			error("cannot open '%s': %s", device->name,
+			      strerror(errno));
 			goto fail;
 		}