From patchwork Tue Apr 29 15:58:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 4088241 X-Patchwork-Delegate: dave@jikos.cz Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A49809F169 for ; Tue, 29 Apr 2014 16:01:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C968C201C0 for ; Tue, 29 Apr 2014 16:01:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E19E4201F4 for ; Tue, 29 Apr 2014 16:01:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758078AbaD2QBP (ORCPT ); Tue, 29 Apr 2014 12:01:15 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57251 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757482AbaD2QBO (ORCPT ); Tue, 29 Apr 2014 12:01:14 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D433AAC4F for ; Tue, 29 Apr 2014 16:01:13 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id A1F2BDA935; Tue, 29 Apr 2014 18:01:13 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 04/14] btrfs-progs: check if we can't get info from ioctls due to permissions Date: Tue, 29 Apr 2014 17:58:25 +0200 Message-Id: <3a6b570007c4010771ce046e1cc6cfadde4842de.1398786620.git.dsterba@suse.cz> X-Mailer: git-send-email 1.9.0 In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The TREE_SEARCH ioctl is root-only, FS_INFO will be available for non-root users with an updated kernel, let the user know. Signed-off-by: David Sterba --- cmds-fi-disk_usage.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c index 17202de1b6e8..64c85acafd51 100644 --- a/cmds-fi-disk_usage.c +++ b/cmds-fi-disk_usage.c @@ -171,6 +171,12 @@ int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count) while (1) { ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); e = errno; + if (ret == -EPERM) { + fprintf(stderr, + "ERROR: can't read detailed chunk info from ioctl(TREE_SEARCH), run as root\n"); + return 0; + } + if (ret < 0) { fprintf(stderr, "ERROR: can't perform the search - %s\n", @@ -461,6 +467,10 @@ int load_device_info(int fd, struct device_info **device_info_ptr, *device_info_ptr = 0; ret = ioctl(fd, BTRFS_IOC_FS_INFO, &fi_args); + if (ret == -EPERM) { + fprintf(stderr, "ERROR: can't get filesystem info from ioctl(FS_INFO), run as root\n"); + return -1; + } if (ret < 0) { fprintf(stderr, "ERROR: cannot get filesystem info\n"); return -1;