public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Klotz <peter.klotz@aon.at>
To: linux-btrfs@vger.kernel.org
Subject: Misleading error message in btrfsctl
Date: Sun, 18 Jan 2009 14:40:08 +0100	[thread overview]
Message-ID: <49733138.4010309@aon.at> (raw)

[-- Attachment #1: Type: text/plain, Size: 602 bytes --]

Calling btrfsctl results in this message when module btrfs.ko is not loaded:

root@asus:/root# btrfsctl -A /dev/sda
ioctl:: Bad file descriptor

An strace shows that actually opening of /dev/btrfs-control failed.

open("/dev/btrfs-control", O_RDWR)      = -1 ENOENT (No such file or 
directory)
ioctl(4294967295, 0x50009404, 0x7fff11fb76b0) = -1 EBADF (Bad file 
descriptor)

The attached patch (against btrfsctl 0.18) terminates btrfsctl if 
/dev/btrfs-control cannot be opened.

The output with applied patch:

root@asus:/root# btrfsctl -A /dev/sda
failed to open /dev/btrfs-control

Regards, Peter.

[-- Attachment #2: btrfs-control-open.patch --]
[-- Type: text/x-patch, Size: 522 bytes --]

diff -Nur btrfs-progs-0.18/btrfsctl.c btrfs-progs-0.18.patched/btrfsctl.c
--- btrfs-progs-0.18/btrfsctl.c	2009-01-17 02:08:19.000000000 +0100
+++ btrfs-progs-0.18.patched/btrfsctl.c	2009-01-18 14:16:25.000000000 +0100
@@ -189,6 +189,10 @@
 
 	if (command == BTRFS_IOC_SCAN_DEV) {
 		fd = open("/dev/btrfs-control", O_RDWR);
+		if (fd < 0) {
+                	fprintf(stderr, "failed to open /dev/btrfs-control\n");
+                       exit(1);
+	        }
 		name = fname;
 	 } else {
 		fd = open_file_or_dir(fname);

             reply	other threads:[~2009-01-18 13:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-18 13:40 Peter Klotz [this message]
2009-01-18 14:12 ` Misleading error message in btrfsctl Calvin Walton
2009-01-21 15:05   ` Chris Mason

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=49733138.4010309@aon.at \
    --to=peter.klotz@aon.at \
    --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