From patchwork Fri Jan 25 16:06:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2046091 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 0646CE01ED for ; Fri, 25 Jan 2013 16:06:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757507Ab3AYQGV (ORCPT ); Fri, 25 Jan 2013 11:06:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55382 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756137Ab3AYQGS (ORCPT ); Fri, 25 Jan 2013 11:06:18 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0PG6CX8005025 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 25 Jan 2013 11:06:12 -0500 Received: from liberator.sandeen.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0PG6ANo006785 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 25 Jan 2013 11:06:12 -0500 Message-ID: <5102AD72.2050307@redhat.com> Date: Fri, 25 Jan 2013 10:06:10 -0600 From: Eric Sandeen User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: Gene Czarcinski CC: linux-btrfs Subject: Re: [PATCH] Btrfs-progs: Exit if not running as root References: <1359113550-23962-1-git-send-email-gene@czarc.net> <51029EFB.90301@czarc.net> In-Reply-To: <51029EFB.90301@czarc.net> X-Enigmail-Version: 1.5 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org 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 --- -- 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 --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,