From patchwork Sun Sep 8 22:41:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 2859091 Return-Path: X-Original-To: patchwork-linux-nfs@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 0BC2E9F499 for ; Sun, 8 Sep 2013 22:41:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2D5C920414 for ; Sun, 8 Sep 2013 22:41:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 383AD203F0 for ; Sun, 8 Sep 2013 22:41:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750811Ab3IHWl1 (ORCPT ); Sun, 8 Sep 2013 18:41:27 -0400 Received: from mx11.netapp.com ([216.240.18.76]:53188 "EHLO mx11.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750769Ab3IHWl0 (ORCPT ); Sun, 8 Sep 2013 18:41:26 -0400 X-IronPort-AV: E=Sophos;i="4.90,866,1371106800"; d="scan'208";a="48076605" Received: from vmwexceht04-prd.hq.netapp.com ([10.106.77.34]) by mx11-out.netapp.com with ESMTP; 08 Sep 2013 15:41:26 -0700 Received: from smtp2.corp.netapp.com (10.57.159.114) by VMWEXCEHT04-PRD.hq.netapp.com (10.106.77.34) with Microsoft SMTP Server id 14.3.123.3; Sun, 8 Sep 2013 15:41:26 -0700 Received: from leira.trondhjem.org.com (leira.trondhjem.org.vpn.netapp.com [10.55.78.114]) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id r88MfPeM003584; Sun, 8 Sep 2013 15:41:25 -0700 (PDT) From: Trond Myklebust To: Steve Dickson CC: Subject: [PATCH] exportfs: insecure/secure should be a secinfo_flag Date: Sun, 8 Sep 2013 18:41:22 -0400 Message-ID: <1378680082-19229-1-git-send-email-Trond.Myklebust@netapp.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 'insecure' flag is listed in /proc/fs/nfsd/export_features in newer kernels as being a secinfo_flag, however it is not displayed by secinfo_show. This patch fixes that, and sets up a framework which should make it easy to add new flags to /proc/fs/nfsd/export_features and have them be displayed properly. Signed-off-by: Trond Myklebust --- support/nfs/exports.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/support/nfs/exports.c b/support/nfs/exports.c index 3e99de6..8d2adf7 100644 --- a/support/nfs/exports.c +++ b/support/nfs/exports.c @@ -197,10 +197,35 @@ getexportent(int fromkernel, int fromexports) return ⅇ } +static const struct secinfo_flag_displaymap { + unsigned int flag; + const unsigned char *set; + const unsigned char *unset; +} secinfo_flag_displaymap[] = { + { NFSEXP_READONLY, "ro", "rw" }, + { NFSEXP_INSECURE_PORT, "insecure", "secure" }, + { NFSEXP_ROOTSQUASH, "root_squash", "no_root_squash" }, + { NFSEXP_ALLSQUASH, "all_squash", "no_all_squash" }, + { 0, NULL, NULL } +}; + +static void secinfo_flags_show(FILE *fp, unsigned int flags, unsigned int mask) +{ + const struct secinfo_flag_displaymap *p; + + for (p = &secinfo_flag_displaymap[0]; p->flag != 0; p++) { + if (!(mask & p->flag)) + continue; + fprintf(fp, ",%s", (flags & p->flag) ? p->set : p->unset); + } +} + void secinfo_show(FILE *fp, struct exportent *ep) { + const struct export_features *ef; struct sec_entry *p1, *p2; - int flags; + + ef = get_export_features(); if (ep->e_secinfo[0].flav == NULL) secinfo_addflavor(find_flavor("sys"), ep); @@ -211,12 +236,7 @@ void secinfo_show(FILE *fp, struct exportent *ep) p2++) { fprintf(fp, ":%s", p2->flav->flavour); } - flags = p1->flags; - fprintf(fp, ",%s", (flags & NFSEXP_READONLY) ? "ro" : "rw"); - fprintf(fp, ",%sroot_squash", (flags & NFSEXP_ROOTSQUASH)? - "" : "no_"); - fprintf(fp, ",%sall_squash", (flags & NFSEXP_ALLSQUASH)? - "" : "no_"); + secinfo_flags_show(fp, p1->flags, ef->secinfo_flags); } }