From patchwork Wed Sep 14 15:19:39 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: 9331869 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 26FC8607FD for ; Wed, 14 Sep 2016 15:20:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16F3E284A6 for ; Wed, 14 Sep 2016 15:20:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02CEC2A14C; Wed, 14 Sep 2016 15:20:40 +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 F3E4A284A6 for ; Wed, 14 Sep 2016 15:20:36 +0000 (UTC) Received: from oss.sgi.com (localhost [IPv6:::1]) by oss.sgi.com (Postfix) with ESMTP id 05A197CB5; Wed, 14 Sep 2016 10:20:20 -0500 (CDT) X-Original-To: xfs@oss.sgi.com Delivered-To: xfs@oss.sgi.com Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (Postfix) with ESMTP id 271197CA6 for ; Wed, 14 Sep 2016 10:20:17 -0500 (CDT) Received: from cuda.sgi.com (cuda1.sgi.com [192.48.157.11]) by relay1.corp.sgi.com (Postfix) with ESMTP id D1ACD8F8050 for ; Wed, 14 Sep 2016 08:20:13 -0700 (PDT) X-ASG-Debug-ID: 1473866412-0bf815415a1ae570001-NocioJ Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by cuda.sgi.com with ESMTP id EmNHFAC4I4OAcD1D (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 14 Sep 2016 08:20:12 -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-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 241C6C04D2B8; Wed, 14 Sep 2016 15:20:12 +0000 (UTC) Received: from localhost.localdomain.com (unused [10.10.50.234] (may be forged)) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8EFKADN028181; Wed, 14 Sep 2016 11:20:11 -0400 From: "Bill O'Donnell" To: linux-xfs@vger.kernel.org Subject: [PATCH 1/3] xfsprogs: populate fs table with xfs entries first, foreign entries last Date: Wed, 14 Sep 2016 10:19:39 -0500 X-ASG-Orig-Subj: [PATCH 1/3] xfsprogs: populate fs table with xfs entries first, foreign entries last Message-Id: <1473866381-28975-2-git-send-email-billodo@redhat.com> In-Reply-To: <1473866381-28975-1-git-send-email-billodo@redhat.com> References: <1473866381-28975-1-git-send-email-billodo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 14 Sep 2016 15:20:12 +0000 (UTC) X-Barracuda-Connect: mx1.redhat.com[209.132.183.28] X-Barracuda-Start-Time: 1473866412 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://192.48.157.11:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 2858 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 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 first from the fs table. The xfs_quota print command then complained about not being able to print the foreign paths, instead of previous behavior (quiet). This patch restores correct behavior, sorting the table so that xfs entries are first, followed by foreign fs entries. The patch maintains the order of xfs entries and foreign entries in the same order as mtab entries. Signed-off-by: Bill O'Donnell --- libxcmd/paths.c | 12 +++++++++++- quota/path.c | 21 ++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/libxcmd/paths.c b/libxcmd/paths.c index 4158688..6363d40 100644 --- a/libxcmd/paths.c +++ b/libxcmd/paths.c @@ -34,6 +34,7 @@ extern char *progname; int fs_count; struct fs_path *fs_table; struct fs_path *fs_path; +int xfs_fs_count; char *mtab_file; #define PROC_MOUNTS "/proc/self/mounts" @@ -138,7 +139,16 @@ fs_table_insert( goto out_norealloc; fs_table = tmp_fs_table; - fs_path = &fs_table[fs_count]; + /* Put foreign filesystems at the end, xfs filesystems at the front */ + if (flags & FS_FOREIGN || fs_count == 0) { + fs_path = &fs_table[fs_count]; + } else { + /* move foreign fs entries down, insert new one just before */ + memmove(&fs_table[xfs_fs_count], &fs_table[xfs_fs_count - 1], + sizeof(fs_path_t)*(fs_count - xfs_fs_count + 1)); + fs_path = &fs_table[xfs_fs_count]; + xfs_fs_count++; + } fs_path->fs_dir = dir; fs_path->fs_prid = prid; fs_path->fs_flags = flags; diff --git a/quota/path.c b/quota/path.c index a623d25..aa3d33e 100644 --- a/quota/path.c +++ b/quota/path.c @@ -75,9 +75,15 @@ static int pathlist_f(void) { int i; + struct fs_path *path; - for (i = 0; i < fs_count; i++) - printpath(&fs_table[i], i, 1, &fs_table[i] == fs_path); + for (i = 0; i < fs_count; i++) { + path = &fs_table[i]; + /* Table is ordered xfs first, then foreign */ + if (path->fs_flags & FS_FOREIGN && !foreign_allowed) + break; + printpath(path, i, 1, path == fs_path); + } return 0; } @@ -98,7 +104,7 @@ path_f( int argc, char **argv) { - int i; + int i; if (fs_count == 0) { printf(_("No paths are available\n")); @@ -113,8 +119,13 @@ path_f( printf(_("value %d is out of range (0-%d)\n"), i, fs_count-1); } else { - fs_path = &fs_table[i]; - pathlist_f(); + for (i = 0; i < fs_count; i++) { + fs_path = &fs_table[i]; + /* Table is ordered xfs first, then foreign */ + if (fs_path->fs_flags & FS_FOREIGN && !foreign_allowed) + break; + pathlist_f(); + } } return 0; }