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 <[email protected]> --- 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 _______________________________________________ fedfs-utils-devel mailing list [email protected] https://oss.oracle.com/mailman/listinfo/fedfs-utils-devel
