From patchwork Thu Oct 11 19:09:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 190978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "acsinet15.oracle.com", Issuer "VeriSign Class 3 International Server CA - G3" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B1B4D2C008E for ; Fri, 12 Oct 2012 06:09:52 +1100 (EST) Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q9BJ9m12007695 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 11 Oct 2012 19:09:48 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q9BJ9lAk011801 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 11 Oct 2012 19:09:48 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1TMO8h-0004Xx-OL; Thu, 11 Oct 2012 12:09:47 -0700 Received: from ucsinet21.oracle.com ([156.151.31.93]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1TMO8c-0004Xc-Uu for fedfs-utils-devel@oss.oracle.com; Thu, 11 Oct 2012 12:09:43 -0700 Received: from rcsinet12.oracle.com (rcsinet12.oracle.com [148.87.113.124]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q9BJ9g8m029923 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Oct 2012 19:09:42 GMT Received: from mail-ie0-f171.google.com (mail-ie0-f171.google.com [209.85.223.171]) by rcsinet12.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q9BJ8i2H031915 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 11 Oct 2012 19:09:41 GMT Received: by mail-ie0-f171.google.com with SMTP id s9so3817388iec.2 for ; Thu, 11 Oct 2012 12:09:41 -0700 (PDT) Received: by 10.50.171.4 with SMTP id aq4mr1901067igc.72.1349982581127; Thu, 11 Oct 2012 12:09:41 -0700 (PDT) Received: from seurat.1015granger.net ([99.26.161.222]) by mx.google.com with ESMTPS id i10sm13006igb.12.2012.10.11.12.09.40 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 11 Oct 2012 12:09:40 -0700 (PDT) From: Chuck Lever To: fedfs-utils-devel@oss.oracle.com Date: Thu, 11 Oct 2012 15:09:39 -0400 Message-ID: <20121011190939.31447.93783.stgit@seurat.1015granger.net> In-Reply-To: <20121011190220.31447.12725.stgit@seurat.1015granger.net> References: <20121011190220.31447.12725.stgit@seurat.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Flow-Control-Info: class=Default reputation=ipRepBelow100 ip=209.85.223.171 ct-class=R5 ct-vol1=0 ct-vol2=9 ct-vol3=8 ct-risk=49 ct-spam1=75 ct-spam2=8 ct-bulk=6 rcpts=1 size=7710 X-MM-CT-Classification: not spam X-MM-CT-RefID: str=0001.0A090207.50771975.0157,ss=1,re=0.000,fgs=0 Subject: [fedfs-utils] [PATCH 7/8] libjunction: Save directory mode in junction XML X-BeenThere: fedfs-utils-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list Reply-To: fedfs-utils Developers List-Id: fedfs-utils Developers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: fedfs-utils-devel-bounces@oss.oracle.com Errors-To: fedfs-utils-devel-bounces@oss.oracle.com X-Source-IP: acsinet22.oracle.com [141.146.126.238] Today, when we convert a directory into a junction, we save the directory's mode bits in an extended attribute, and then set them to a known weird value, which the kernel can detect. As an experiment, save the directory mode in the junction XML as well. If this works out, we can avoid using a separate extended attribute for the saved mode. Signed-off-by: Chuck Lever --- src/libjunction/fedfs.c | 38 ++++++++++++++++++++++++++++++++ src/libjunction/junction-internal.h | 10 +++++++++ src/libjunction/junction.c | 41 ++++++++++++++++++++++++++++++----- src/libjunction/nfs.c | 38 ++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+), 6 deletions(-) diff --git a/src/libjunction/fedfs.c b/src/libjunction/fedfs.c index 5acd58e..a39925b 100644 --- a/src/libjunction/fedfs.c +++ b/src/libjunction/fedfs.c @@ -28,6 +28,7 @@ * * * + * * * * + * * * * @@ -708,6 +709,38 @@ nfs_fileset_xml(const char *pathname, xmlNodePtr root, } /** + * Construct a "savedmode" element + * + * @param pathname NUL-terminated C string containing pathname of a junction + * @param root root element of XML document tree + * @return a FedFsStatus code + */ +static FedFsStatus +nfs_savedmode_xml(const char *pathname, xmlNodePtr root) +{ + xmlNodePtr savedmode; + FedFsStatus retval; + mode_t mode; + char buf[8]; + + retval = junction_get_mode(pathname, &mode); + if (retval != FEDFS_OK) + return retval; + + savedmode = xmlNewTextChild(root, NULL, JUNCTION_XML_SAVEDMODE_TAG, NULL); + if (savedmode == NULL) { + xlog(D_GENERAL, "%s: Failed to add savedmode element for %s\n", + __func__, pathname); + return FEDFS_ERR_SVRFAULT; + } + + (void)snprintf(buf, sizeof(buf), "%o", ALLPERMS & mode); + xmlSetProp(savedmode, JUNCTION_XML_MODEBITS_ATTR, (const xmlChar *)buf); + + return FEDFS_OK; +} + +/** * Construct NFS junction XML document from list of NFS locations * * @param pathname NUL-terminated C string containing pathname of a junction @@ -719,6 +752,7 @@ static FedFsStatus nfs_junction_xml(const char *pathname, xmlDocPtr doc, struct nfs_fsloc *fslocs) { + FedFsStatus retval; xmlNodePtr root; root = xmlNewNode(NULL, JUNCTION_XML_ROOT_TAG); @@ -729,6 +763,10 @@ nfs_junction_xml(const char *pathname, xmlDocPtr doc, } (void)xmlDocSetRootElement(doc, root); + retval = nfs_savedmode_xml(pathname, root); + if (retval != FEDFS_OK) + return retval; + return nfs_fileset_xml(pathname, root, fslocs); }