From patchwork Wed Dec 21 22:51:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 132752 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" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 1FFF6B713B for ; Thu, 22 Dec 2011 09:52:06 +1100 (EST) Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by acsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pBLMpwBj006106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Dec 2011 22:51:59 GMT Received: from oss.oracle.com (oss.oracle.com [141.146.12.120]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id pBLMpvjn017358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 21 Dec 2011 22:51:58 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1RdV0v-0001sh-Nr; Wed, 21 Dec 2011 14:51:57 -0800 Received: from rcsinet12.oracle.com ([148.87.113.124]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1RdV0u-0001sa-Gg for fedfs-utils-devel@oss.oracle.com; Wed, 21 Dec 2011 14:51:56 -0800 Received: from mail-gy0-f171.google.com (mail-gy0-f171.google.com [209.85.160.171]) by rcsinet12.oracle.com (Sentrion-MTA-4.2.0/Sentrion-MTA-4.2.0) with ESMTP id pBLMplCN000749 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 21 Dec 2011 22:51:56 GMT Received: by mail-gy0-f171.google.com with SMTP id 10so4564811ghy.2 for ; Wed, 21 Dec 2011 14:51:56 -0800 (PST) Received: by 10.236.77.232 with SMTP id d68mr12005866yhe.98.1324507915939; Wed, 21 Dec 2011 14:51:55 -0800 (PST) Received: from degas.1015granger.net (adsl-99-26-161-222.dsl.sfldmi.sbcglobal.net. [99.26.161.222]) by mx.google.com with ESMTPS id q16sm18215187anb.19.2011.12.21.14.51.54 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Dec 2011 14:51:55 -0800 (PST) From: Chuck Lever To: fedfs-utils-devel@oss.oracle.com Date: Wed, 21 Dec 2011 17:51:54 -0500 Message-ID: <20111221225153.23950.97724.stgit@degas.1015granger.net> In-Reply-To: <20111221222832.23950.14134.stgit@degas.1015granger.net> References: <20111221222832.23950.14134.stgit@degas.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Flow-Control-Info: class=ISPs ip=209.85.160.171 ct-class=R6 ct-vol1=0 ct-vol2=0 ct-vol3=0 ct-risk=68 ct-spam1=0 ct-spam2=0 ct-bulk=0 rcpts=1 size=4033 Subject: [fedfs-utils] [PATCH 4/8] libnsdb: Use path array for fedfsNfsPath attribute in nsdb_update_fsl_s() 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: ucsinet22.oracle.com [156.151.31.94] X-CT-RefId: str=0001.0A02020B.4EF26310.0038:SCFSTAT3865452, ss=1, re=-4.000, fgs=0 Since the beginning, I've tried to stick with representing local pathnames using a C string, and converting to the array form only when I need to transmit the pathname off-system. That seemed more natural for operating on Linux, whose VFS is POSIX-style. However, if we want to allow creation of junctions that point to servers that don't necessarily use '/' as the pathname component separator, we will need a more general way to represent pathnames in struct fedfs_fsl and friends. That general way to represent pathnames is as an array of component character strings. This is, after all, what is done for fs_locations in NFS. Change the nsdb_update_fsl_s() API to expect an array of components when asked to change the fedfsNfsPath attribute of an NFS FSL record. Aside from exposing the richer fs_locations data structure to FedFS callers, this change moves an important part of pathname resolution policy out of libnsdb and into callers. It should also provide an opportunity for stronger and more consistent checks on incoming pathnames. Signed-off-by: Chuck Lever --- src/include/nsdb.h | 2 +- src/libnsdb/administrator.c | 8 +++++--- src/nsdbc/nsdb-update-fsl.c | 13 +++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/include/nsdb.h b/src/include/nsdb.h index ba31135..84cabaf 100644 --- a/src/include/nsdb.h +++ b/src/include/nsdb.h @@ -279,7 +279,7 @@ FedFsStatus nsdb_delete_fsl_s(nsdb_t host, const char *nce, FedFsStatus nsdb_update_fsl_s(nsdb_t host, const char *nce, const char *fsl_uuid, const char *attribute, - const char *value, + const void *value, unsigned int *ldap_err); /** diff --git a/src/libnsdb/administrator.c b/src/libnsdb/administrator.c index 117b0ba..cff679c 100644 --- a/src/libnsdb/administrator.c +++ b/src/libnsdb/administrator.c @@ -1001,14 +1001,14 @@ nsdb_update_fsl_remove_attribute_s(LDAP *ld, const char *dn, */ static FedFsStatus nsdb_update_fsl_update_attribute_s(LDAP *ld, const char *dn, - const char *attribute, const char *value, + const char *attribute, const void *value, unsigned int *ldap_err) { struct berval newval; FedFsStatus retval; if (strcasecmp(attribute, "fedfsNfsPath") == 0) { - retval = nsdb_posix_path_to_xdr(value, &newval); + retval = nsdb_path_array_to_xdr((char * const *)value, &newval); if (retval != FEDFS_OK) return retval; } else { @@ -1020,6 +1020,8 @@ nsdb_update_fsl_update_attribute_s(LDAP *ld, const char *dn, retval = nsdb_modify_attribute_s(ld, dn, attribute, &newval, ldap_err); + if (strcasecmp(attribute, "fedfsNfsPath") == 0) + ber_memfree(newval.bv_val); if (retval != FEDFS_OK) return retval; @@ -1046,7 +1048,7 @@ nsdb_update_fsl_update_attribute_s(LDAP *ld, const char *dn, */ FedFsStatus nsdb_update_fsl_s(nsdb_t host, const char *nce, const char *fsl_uuid, - const char *attribute, const char *value, + const char *attribute, const void *value, unsigned int *ldap_err) { FedFsStatus retval; diff --git a/src/nsdbc/nsdb-update-fsl.c b/src/nsdbc/nsdb-update-fsl.c index ff0db80..e025a15 100644 --- a/src/nsdbc/nsdb-update-fsl.c +++ b/src/nsdbc/nsdb-update-fsl.c @@ -192,6 +192,17 @@ main(int argc, char **argv) nsdb_update_fsl_usage(progname); } + if (strcasecmp(attribute, "fedfsNfsPath") == 0) { + char **path_array; + retval = nsdb_posix_to_path_array(value, &path_array); + if (retval != FEDFS_OK) { + fprintf(stderr, "Bad path: %s\n", + nsdb_display_fedfsstatus(retval)); + goto out; + } + value = (char *)path_array; + } + retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host, NULL); switch (retval) { case FEDFS_OK: @@ -265,6 +276,8 @@ main(int argc, char **argv) out_free: nsdb_free_nsdb(host); + if (strcasecmp(attribute, "fedfsNfsPath") == 0) + nsdb_free_string_array((char **)value); out: exit((int)retval);