All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: Gene Czarcinski <gene@czarc.net>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] Btrfs-progs: Exit if not running as root
Date: Fri, 25 Jan 2013 10:06:10 -0600	[thread overview]
Message-ID: <5102AD72.2050307@redhat.com> (raw)
In-Reply-To: <51029EFB.90301@czarc.net>

On 1/25/13 9:04 AM, Gene Czarcinski wrote:
> OK, I think I have gotten the message that this is a bad idea as
> implemented and that it should be dropped as such.  I believe that
> there are some things ("btrfs fi show" comes to mind) which will need
> root and I am going to explore doing something for that case.  And it
> also might be reasonable for some situations to issue the message
> about root if something errors-out.

So, in that particular case, I think the right fix is to make the code
in that spot be more informative; there are probably a whole lot of
places that could use fixes like this, though, not just this one.
Still, it would be helpful to the user, I think.

i.e. show:

[testuser@host btrfs-progs]$ whoami
testuser
[testuser@host btrfs-progs]$ ./btrfs fi show
failed to open /dev/sda: Permission denied
failed to open /dev/sda1: Permission denied
...


[PATCH] print more informative error when we fail to open a device

If open() fails, we should let the user know why it failed.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/utils.c b/utils.c
index 595850b..a5673f7 100644
--- a/utils.c
+++ b/utils.c
@@ -1237,7 +1237,8 @@ scan_again:
 
 		fd = open(fullpath, O_RDONLY);
 		if (fd < 0) {
-			fprintf(stderr, "failed to read %s\n", fullpath);
+			fprintf(stderr, "failed to open %s: %s\n",
+				fullpath, strerror(errno));
 			continue;
 		}
 		ret = btrfs_scan_one_device(fd, fullpath, &tmp_devices,


  parent reply	other threads:[~2013-01-25 16:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-25 11:32 [PATCH] Btrfs-progs: Exit if not running as root Gene Czarcinski
2013-01-25 11:41 ` Stefan Behrens
2013-01-25 12:03   ` Gene Czarcinski
2013-01-25 12:17     ` Stefan Behrens
2013-01-25 13:22       ` Gene Czarcinski
2013-01-25 11:55 ` Roman Mamedov
2013-01-25 12:29   ` Gene Czarcinski
2013-01-25 12:43     ` Hugo Mills
2013-01-25 15:19       ` Brendan Hide
2013-01-25 13:00     ` Roman Mamedov
2013-01-25 13:52   ` Russell Coker
2013-01-25 15:04 ` Gene Czarcinski
2013-01-25 15:10   ` Gene Czarcinski
2013-01-25 15:30   ` cwillu
2013-01-25 16:06   ` Eric Sandeen [this message]
2013-01-26  2:18   ` Russell Coker
2013-01-26  7:46     ` Goffredo Baroncelli
2013-01-25 15:07 ` Eric Sandeen

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=5102AD72.2050307@redhat.com \
    --to=sandeen@redhat.com \
    --cc=gene@czarc.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.