From patchwork Fri Sep 2 21:22:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill O'Donnell X-Patchwork-Id: 9311679 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C49AF60772 for ; Fri, 2 Sep 2016 21:22:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B262D2983D for ; Fri, 2 Sep 2016 21:22:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6DC929848; Fri, 2 Sep 2016 21:22:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from oss.sgi.com (oss.sgi.com [192.48.182.195]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 23B922983D for ; Fri, 2 Sep 2016 21:22:19 +0000 (UTC) Received: from oss.sgi.com (localhost [IPv6:::1]) by oss.sgi.com (Postfix) with ESMTP id 825A37CAE; Fri, 2 Sep 2016 16:22:18 -0500 (CDT) X-Original-To: xfs@oss.sgi.com Delivered-To: xfs@oss.sgi.com Received: from relay.sgi.com (relay3.corp.sgi.com [198.149.34.15]) by oss.sgi.com (Postfix) with ESMTP id 897927CA7 for ; Fri, 2 Sep 2016 16:22:15 -0500 (CDT) Received: from cuda.sgi.com (cuda2.sgi.com [192.48.176.25]) by relay3.corp.sgi.com (Postfix) with ESMTP id DAB62AC002 for ; Fri, 2 Sep 2016 14:22:11 -0700 (PDT) X-ASG-Debug-ID: 1472851330-0bf57b15a871180001-NocioJ Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by cuda.sgi.com with ESMTP id 4URyBEEKLKtTMHvq (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 02 Sep 2016 14:22:10 -0700 (PDT) X-Barracuda-Envelope-From: billodo@redhat.com X-Barracuda-Effective-Source-IP: mx1.redhat.com[209.132.183.28] X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-ASG-Whitelist: Client Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF5DF4E4CF; Fri, 2 Sep 2016 21:22:09 +0000 (UTC) Received: from localhost.localdomain.com (vpn-48-181.rdu2.redhat.com [10.10.48.181]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u82LM95s021946; Fri, 2 Sep 2016 17:22:09 -0400 From: "Bill O'Donnell" To: linux-xfs@vger.kernel.org Subject: [PATCH v2] xfsprogs: (xfs_quota) foreign fs path handling changes Date: Fri, 2 Sep 2016 16:22:08 -0500 X-ASG-Orig-Subj: [PATCH v2] xfsprogs: (xfs_quota) foreign fs path handling changes Message-Id: <1472851328-25542-1-git-send-email-billodo@redhat.com> In-Reply-To: <1472478012-23627-1-git-send-email-billodo@redhat.com> References: <1472478012-23627-1-git-send-email-billodo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 02 Sep 2016 21:22:09 +0000 (UTC) X-Barracuda-Connect: mx1.redhat.com[209.132.183.28] X-Barracuda-Start-Time: 1472851330 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://192.48.176.25:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 4106 X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-BRTS-Status: 1 Cc: xfs@oss.sgi.com X-BeenThere: xfs@oss.sgi.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com X-Virus-Scanned: ClamAV using ClamSMTP Version 2 of this patch to xfs_quota in order to properly handle foreign fs mount paths. Note that this version (2) abandons the incorrect approach of version 1, in which the fs-table wasn't populated with the foreign fs paths. Commits b20b6c2 and 29647c8 modified xfs_quota for use on non-XFS filesystems. Modifications to fs_initialise_mounts (paths.c) resulted in an xfstest fail (xfs/261), due to foreign fs paths being picked up from the fs table, and the xfs_quota print command complaining about not being able to print the foreign paths. This patch fixes the foreign path print problem, with a modification of the print and path commands to always be allowed, regardless of fs type (similar to the help and quit commands). Additionally, the printpath() function in path.c is corrected to skip printing foreign paths unless the -f flag is thrown in the xfs_quota invocation. Also, some minor formatting changes and comment clarifications to the print command are made. Signed-off-by: Bill O'Donnell --- quota/init.c | 19 +++++++++++++------ quota/path.c | 19 ++++++++++++++----- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/quota/init.c b/quota/init.c index 44be322..9f95e8f 100644 --- a/quota/init.c +++ b/quota/init.c @@ -112,21 +112,28 @@ init_check_command( if (!fs_path) return 1; - /* Always run commands that we are told to skip here */ + /* Always run commands that are valid for all fs types. */ if (ct->flags & CMD_ALL_FSTYPES) return 1; - /* if it's an XFS filesystem, always run the command */ + /* If it's an XFS filesystem, always run the command. */ if (!(fs_path->fs_flags & FS_FOREIGN)) return 1; - /* If the user specified foreign filesysetms are ok, run it */ + /* If the user specified foreign filesystems are ok (-f), run cmd. */ if (foreign_allowed && - (ct->flags & CMD_FLAG_FOREIGN_OK)) + (ct->flags & CMD_FLAG_FOREIGN_OK)) return 1; - /* foreign filesystem and it's not a valid command! */ - fprintf(stderr, _("%s command is for XFS filesystems only\n"), + /* If cmd not allowed on foreign fs, regardless of -f flag, skip it. */ + if (!(ct->flags & CMD_FLAG_FOREIGN_OK)) { + fprintf(stderr, _("%s: command is for XFS filesystems only\n"), + ct->name); + return 0; + } + + /* foreign fs, but cmd only allowed via -f flag. Skip it. */ + fprintf(stderr, _("%s: foreign filesystem. Use -f to enable.\n"), ct->name); return 0; } diff --git a/quota/path.c b/quota/path.c index a623d25..d8f8f3c 100644 --- a/quota/path.c +++ b/quota/path.c @@ -36,14 +36,23 @@ printpath( int c; if (index == 0) { - printf(_("%sFilesystem Pathname\n"), + printf(_("%s Filesystem Pathname\n"), number ? _(" ") : ""); } if (number) { printf(_("%c%03d%c "), braces? '[':' ', index, braces? ']':' '); } - printf("%s ", (path->fs_flags & FS_FOREIGN) ? "(F)" : " "); - printf(_("%-19s %s"), path->fs_dir, path->fs_name); + if (path->fs_flags & FS_FOREIGN) { + if (foreign_allowed) { + printf("(F) "); + printf(_("%-19s %s"), path->fs_dir, path->fs_name); + } + } + else { + printf(" "); + printf(_("%-19s %s"), path->fs_dir, path->fs_name); + } + if (path->fs_flags & FS_PROJECT_PATH) { prj = getprprid(path->fs_prid); printf(_(" (project %u"), path->fs_prid); @@ -128,7 +137,7 @@ path_init(void) path_cmd.cfunc = path_f; path_cmd.argmin = 0; path_cmd.argmax = 1; - path_cmd.flags = CMD_FLAG_GLOBAL | CMD_FLAG_FOREIGN_OK; + path_cmd.flags = CMD_FLAG_GLOBAL | CMD_ALL_FSTYPES; path_cmd.oneline = _("set current path, or show the list of paths"); print_cmd.name = "print"; @@ -136,7 +145,7 @@ path_init(void) print_cmd.cfunc = print_f; print_cmd.argmin = 0; print_cmd.argmax = 0; - print_cmd.flags = CMD_FLAG_GLOBAL | CMD_FLAG_FOREIGN_OK; + print_cmd.flags = CMD_FLAG_GLOBAL | CMD_ALL_FSTYPES; print_cmd.oneline = _("list known mount points and projects"); if (expert)