From patchwork Thu Nov 29 01:50:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 202642 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "userp1040.oracle.com", Issuer "VeriSign Class 3 International Server CA - G3" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 1A11C2C0086 for ; Thu, 29 Nov 2012 12:50:45 +1100 (EST) Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qAT1ogo6031782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 29 Nov 2012 01:50:43 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 qAT1og5C000302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 29 Nov 2012 01:50:42 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1TdtH0-00083x-5A; Wed, 28 Nov 2012 17:50:42 -0800 Received: from ucsinet22.oracle.com ([156.151.31.94]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1TdtGv-00083m-5P for fedfs-utils-devel@oss.oracle.com; Wed, 28 Nov 2012 17:50:37 -0800 Received: from acsinet13.oracle.com (acsinet13.oracle.com [141.146.126.235]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id qAT1oaf0026692 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 29 Nov 2012 01:50:36 GMT Received: from mail-ia0-f171.google.com (mail-ia0-f171.google.com [209.85.210.171]) by acsinet13.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qAT1nQXD002765 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 29 Nov 2012 01:50:35 GMT Received: by mail-ia0-f171.google.com with SMTP id b35so8185184iac.2 for ; Wed, 28 Nov 2012 17:50:35 -0800 (PST) Received: by 10.50.12.166 with SMTP id z6mr21503311igb.56.1354153835573; Wed, 28 Nov 2012 17:50:35 -0800 (PST) Received: from seurat.1015granger.net (adsl-99-26-161-222.dsl.sfldmi.sbcglobal.net. [99.26.161.222]) by mx.google.com with ESMTPS id c3sm6103813igj.1.2012.11.28.17.50.34 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 28 Nov 2012 17:50:35 -0800 (PST) From: Chuck Lever To: fedfs-utils-devel@oss.oracle.com Date: Wed, 28 Nov 2012 20:50:34 -0500 Message-ID: <20121129015034.2497.88374.stgit@seurat.1015granger.net> In-Reply-To: <20121129014751.2497.93909.stgit@seurat.1015granger.net> References: <20121129014751.2497.93909.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.210.171 ct-class=R5 ct-vol1=-97 ct-vol2=8 ct-vol3=7 ct-risk=49 ct-spam1=78 ct-spam2=8 ct-bulk=5 rcpts=1 size=7707 X-MM-CT-Classification: not spam X-MM-CT-RefID: str=0001.0A090203.50B6BF6C.0008,ss=1,re=0.000,fgs=0 Subject: [fedfs-utils] [PATCH 8/8] libnsdb: remove XDR path helpers 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] fedfsNfsPath was the only attribute that required XDR-encoding of an NFSv4 pathname. Now that it's gone, we can remove these helpers. Signed-off-by: Chuck Lever --- src/include/nsdb.h | 4 - src/libnsdb/ldap.c | 43 -------------- src/libnsdb/nsdb-internal.h | 2 - src/libnsdb/path.c | 136 ------------------------------------------- 4 files changed, 0 insertions(+), 185 deletions(-) diff --git a/src/include/nsdb.h b/src/include/nsdb.h index 95702cc..9d4468b 100644 --- a/src/include/nsdb.h +++ b/src/include/nsdb.h @@ -403,10 +403,6 @@ char *nsdb_normalize_path(const char *pathname); _Bool nsdb_pathname_is_utf8(const char *pathname); void nsdb_free_fedfspathname(FedFsPathName *fpath); -FedFsStatus nsdb_path_array_to_xdr(char * const *path_array, - struct berval *xdr_path); -FedFsStatus nsdb_xdr_to_path_array(const struct berval *xdr_path, - char ***path_array); FedFsStatus nsdb_path_array_to_posix(char * const *path_array, char **pathname); FedFsStatus nsdb_posix_to_path_array(const char *pathname, diff --git a/src/libnsdb/ldap.c b/src/libnsdb/ldap.c index 5ede0d3..d93fa3c 100644 --- a/src/libnsdb/ldap.c +++ b/src/libnsdb/ldap.c @@ -390,49 +390,6 @@ nsdb_parse_singlevalue_str(char *attr, struct berval **values, } /** - * Parse the value of an attribute containing an XDR-encoded FedFsPathname - * - * @param attr a NUL-terminated C string containing the name of an attribute - * @param values pointer to a berval containing value of fedfsNfsPath attribute - * @param result OUT: dynamically allocated string array containing XDR-decoded path - * @return a FedFsStatus code - * - * Caller must free "result" with nsdb_free_string_array(3) - */ -FedFsStatus -nsdb_parse_singlevalue_xdrpath(char *attr, struct berval **values, char ***result) -{ - char **tmp, *pathname; - FedFsStatus retval; - - if (values[1] != NULL) { - xlog(L_ERROR, "%s: Expecting only one value for attribute %s", - __func__, attr); - return FEDFS_ERR_NSDB_RESPONSE; - } - - retval = nsdb_xdr_to_path_array(values[0], &tmp); - if (retval != FEDFS_OK) { - xlog(L_ERROR, "%s: Bad %s value", __func__, attr); - return retval; - } - - /* This is useful sanity checking while implementations - * remain immature */ - retval = nsdb_path_array_to_posix(tmp, &pathname); - if (retval != FEDFS_OK) { - xlog(L_ERROR, "%s: Reverse conversion failed", __func__); - return retval; - } - - xlog(D_CALL, "%s: Attribute %s contains value \'%s\'", - __func__, attr, pathname); - free(pathname); - *result = tmp; - return FEDFS_OK; -} - -/** * Parse the values of a multi-value string attribute * * @param attr a NUL-terminated C string containing the name of an attribute diff --git a/src/libnsdb/nsdb-internal.h b/src/libnsdb/nsdb-internal.h index 09c3d03..d293dd7 100644 --- a/src/libnsdb/nsdb-internal.h +++ b/src/libnsdb/nsdb-internal.h @@ -72,8 +72,6 @@ FedFsStatus nsdb_parse_singlevalue_int(char *attr, FedFsStatus nsdb_parse_singlevalue_str(char *attr, struct berval **values, char *result, const size_t len); -FedFsStatus nsdb_parse_singlevalue_xdrpath(char *attr, - struct berval **values, char ***result); FedFsStatus nsdb_parse_multivalue_str(char *attr, struct berval **values, char ***result); diff --git a/src/libnsdb/path.c b/src/libnsdb/path.c index 6894ee2..11bf73b 100644 --- a/src/libnsdb/path.c +++ b/src/libnsdb/path.c @@ -258,142 +258,6 @@ nsdb_free_fedfspathname(FedFsPathName *fpath) } /** - * XDR encode an array of component strings - * - * @param path_array array of pointers to NUL-terminated C strings - * @param xdr_path OUT: berval set up with XDR-encoded binary path - * @return a FedFsStatus code - * - * Caller must free "xdr_path.bval" with ber_memfree(3t). - */ -FedFsStatus -nsdb_path_array_to_xdr(char * const *path_array, struct berval *xdr_path) -{ - unsigned int p, count; - size_t len, length; - uint32_t *xdrbuf; - char *component; - - if (path_array == NULL || xdr_path == NULL) { - xlog(L_ERROR, "%s: Invalid argument", __func__); - return FEDFS_ERR_INVAL; - } - - for (length = XDR_UINT_BYTES, count = 0; - path_array[count] != NULL; - count++) { - component = path_array[count]; - len = strlen(component); - - if (len == 0) { - xlog(D_GENERAL, "%s: Zero-length component", - __func__); - return FEDFS_ERR_BADNAME; - } - if (!nsdb_pathname_is_utf8(component)) { - xlog(D_GENERAL, "%s: Bad character in component", - __func__); - return FEDFS_ERR_BADCHAR; - } - length += XDR_UINT_BYTES + (nsdb_quadlen(len) << 2); - } - - xdrbuf = (uint32_t *)ber_memcalloc(1, (ber_len_t)length); - if (xdrbuf == NULL) { - xlog(L_ERROR, "%s: Failed to allocate XDR buffer", - __func__); - return FEDFS_ERR_SVRFAULT; - } - - xdrbuf[0] = htonl(count); - for (p = 1, count = 0; path_array[count] != NULL; count++) { - component = path_array[count]; - len = strlen(component); - - xdrbuf[p++] = htonl(len); - memcpy(&xdrbuf[p], component, len); - p += nsdb_quadlen(len); - } - - xdr_path->bv_val = (char *)xdrbuf; - xdr_path->bv_len = (ber_len_t)(length); - return FEDFS_OK; -} - -/** - * XDR decode an XDR byte stream into an array of component strings - * - * @param xdr_path berval with XDR-encoded binary path - * @param path_array OUT: pointer to array of pointers to NUL-terminated C strings - * @return a FedFsStatus code - * - * Caller must free "path_array" with nsdb_free_string_array(). - * - * NB: The use of fixed constants for NAME_MAX and PATH_MAX are required - * here because, on the client side, the pathname likely does not - * exist, so pathconf(3) cannot be used. - */ -FedFsStatus -nsdb_xdr_to_path_array(const struct berval *xdr_path, char ***path_array) -{ - uint32_t *xdrbuf = (uint32_t *)xdr_path->bv_val; - unsigned int len, i, p, count, length; - char **result; - - if (xdr_path == NULL || path_array == NULL) { - xlog(L_ERROR, "%s: Invalid argument", __func__); - return FEDFS_ERR_INVAL; - } - length = nsdb_quadlen((unsigned int)xdr_path->bv_len); - xlog(D_CALL, "%s: Received %u XDR'd quads", __func__, length); - - p = 0; - count = ntohl(xdrbuf[p]); - if (count == 0) - return nsdb_alloc_zero_component_pathname(path_array); - - result = (char **)calloc(count + 1, sizeof(char *)); - if (result == NULL) { - xlog(L_ERROR, "%s: Failed to allocate array", - __func__); - return FEDFS_ERR_SVRFAULT; - } - - p = 1; - for (i = 0; i < count; i++) { - len = ntohl(xdrbuf[p++]); - if (len > NAME_MAX) { - nsdb_free_string_array(result); - xlog(L_ERROR, "%s: Component too long", __func__); - return FEDFS_ERR_BADNAME; - } - if (p + nsdb_quadlen(len) > length) { - nsdb_free_string_array(result); - xlog(L_ERROR, "%s: XDR buffer overflow", __func__); - return FEDFS_ERR_BADXDR; - } - - result[i] = strndup((char *)&xdrbuf[p], len); - if (result[i] == NULL) { - nsdb_free_string_array(result); - xlog(L_ERROR, "%s: Failed to allocate component string", - __func__); - return FEDFS_ERR_SVRFAULT; - } - - if (!nsdb_pathname_is_utf8(result[i])) { - nsdb_free_string_array(result); - xlog(D_GENERAL, "%s: Bad character in pathname", __func__); - return FEDFS_ERR_BADCHAR; - } - p += nsdb_quadlen(len); - } - - *path_array = result; - return FEDFS_OK; -} - -/** * Construct a local POSIX-style pathname from an array of component strings * * @param path_array array of pointers to NUL-terminated C strings