From 171af55b461eb4724ad00a6f0babf43b81cf5e7f Mon Sep 17 00:00:00 2001 From: Jacob Gruber Date: Tue, 21 Aug 2012 17:29:20 -0500 Subject: [svn-r22705] Updated the failure behavior of inner driver calls. Expanded the tests of the inner fapl. Other minor updates and fixes. --- src/H5FD.c | 3 --- src/H5FDfamily.c | 6 +++--- src/H5FDfamily.h | 1 + src/H5FDmulti.c | 6 +++--- src/H5FDmulti.h | 1 + src/H5FDnull.c | 60 ++++++++++++++++++++++++++++++++++++------------------- src/H5FDpkg.h | 1 - src/H5FDprivate.h | 1 - src/H5FDpublic.h | 6 ++++++ 9 files changed, 54 insertions(+), 31 deletions(-) diff --git a/src/H5FD.c b/src/H5FD.c index 525dbea..e13998d 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -443,12 +443,10 @@ H5FD_get_class(hid_t id) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") if(TRUE == H5P_isa_class(id, H5P_FILE_ACCESS)) { - //if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) if((driver_id = H5P_get_driver(plist)) < 0 ) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID") ret_value = H5FD_get_class(driver_id); } else if(TRUE == H5P_isa_class(id, H5P_DATASET_XFER)) { - //if(H5P_get(plist, H5D_XFER_VFL_ID_NAME, &driver_id) < 0) if((driver_id = H5P_get_driver(plist)) < 0 ) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID") ret_value = H5FD_get_class(driver_id); @@ -1100,7 +1098,6 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") /* Get the VFD to open the file with */ - //if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) if((driver_id = H5P_get_driver(plist)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID") diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 9a82fb0..3454402 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -42,7 +42,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ -#include "H5FDfamily.h" /* Family file driver */ +#include "H5FDfamily.h" /* Family file driver */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ @@ -625,7 +625,7 @@ H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/, unsigned char *buf/*out* FUNC_ENTER_NOAPI_NOINIT_NOERR /* Name and version number */ - HDstrncpy(name, "NCSAfami", (size_t)9); + HDstrncpy(name, H5FD_DRIVER_ID_FAMILY, (size_t)9); name[8] = '\0'; /* Store member file size. Use the member file size from the property here. @@ -724,7 +724,7 @@ H5FD_family_sb_verify(H5FD_t UNUSED *_file, const char *sb_driver_id) FUNC_ENTER_NOAPI(FAIL) /* Check if the suerblock was written by a family driver. */ - if(HDstrncmp(sb_driver_id, "NCSAfami", (size_t)8) == 0) { + if(HDstrncmp(sb_driver_id, H5FD_DRIVER_ID_FAMILY, (size_t)8) == 0) { ret_value = TRUE; } diff --git a/src/H5FDfamily.h b/src/H5FDfamily.h index 80969c3..95fc884 100644 --- a/src/H5FDfamily.h +++ b/src/H5FDfamily.h @@ -23,6 +23,7 @@ #define H5FDfamily_H #define H5FD_FAMILY (H5FD_family_init()) +#define H5FD_DRIVER_ID_FAMILY "NCSAfami" #ifdef __cplusplus extern "C" { diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 9eb0330..abb04df 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -780,7 +780,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, H5Eclear2(H5E_DEFAULT); /* Name and version number */ - strncpy(name, "NCSAmulti", (size_t)8); + strncpy(name, H5FD_DRIVER_ID_MULTI, (size_t)8); name[8] = '\0'; assert(7==H5FD_MEM_NTYPES); @@ -865,7 +865,7 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) H5Eclear2(H5E_DEFAULT); /* Make sure the name/version number is correct */ - if (strcmp(name, "NCSAmult")) + if (strcmp(name, H5FD_DRIVER_ID_MULTI)) H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, "invalid multi superblock", -1) /* Set default values */ @@ -1004,7 +1004,7 @@ H5FD_multi_sb_verify(H5FD_t *_file, const char *sb_driver_id) static const char *func = "H5FD_multi_sb_verify"; /* Check that the superblock was written by the multi driver */ - if(strncmp(sb_driver_id, "NCSAmult", (size_t)8) == 0) { + if(strncmp(sb_driver_id, H5FD_DRIVER_ID_MULTI, (size_t)8) == 0) { return 1; } diff --git a/src/H5FDmulti.h b/src/H5FDmulti.h index da16b0c..fd0226b 100644 --- a/src/H5FDmulti.h +++ b/src/H5FDmulti.h @@ -23,6 +23,7 @@ #define H5FDmulti_H #define H5FD_MULTI (H5FD_multi_init()) +#define H5FD_DRIVER_ID_MULTI "NCSAmult" #ifdef __cplusplus extern "C" { diff --git a/src/H5FDnull.c b/src/H5FDnull.c index 8d4c674..5d1403b 100644 --- a/src/H5FDnull.c +++ b/src/H5FDnull.c @@ -246,15 +246,19 @@ H5Pset_fapl_null(hid_t fapl_id, hid_t inner_fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if(H5P_DEFAULT == inner_fapl_id) - inner_fapl_id = H5P_FILE_ACCESS_DEFAULT; - else + fa.inner_fapl_id = H5P_FILE_ACCESS_DEFAULT; + else { if(TRUE != H5P_isa_class(inner_fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - /* - * Initialize driver specific information. - */ - fa.inner_fapl_id = inner_fapl_id; + /* Make a copy of the inner fapl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(inner_fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") + + fa.inner_fapl_id = H5P_copy_plist(plist, TRUE); + } + + /* init driver info */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") @@ -557,7 +561,7 @@ H5FD_null_sb_size(H5FD_t *_file) H5FD_null_t *file = (H5FD_null_t*)_file; hsize_t ret_value = 0; /*size of header*/ - FUNC_ENTER_NOAPI(UFAIL) + FUNC_ENTER_NOAPI(0) HDassert(file); @@ -752,7 +756,7 @@ done: } /* end if */ if(H5I_dec_ref(file->inner_fapl_id) < 0) - HDONE_ERROR(H5E_VFL, H5E_CANTDEC, NULL, "can't close driver ID") + HDONE_ERROR(H5E_VFL, H5E_CANTDEC, NULL, "can't close inner driver ID") H5MM_xfree(file); } /* end if */ @@ -850,14 +854,16 @@ static herr_t H5FD_null_query(const H5FD_t *_file, unsigned long *flags /* out */) { const H5FD_null_t *file = (const H5FD_null_t*)_file; + herr_t ret_value; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_NOAPI(FAIL) /* Query the inner driver */ if(flags && file) - H5FDquery(file->inner_file, flags); + ret_value = H5FDquery(file->inner_file, flags); - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_null_query() */ @@ -887,6 +893,9 @@ H5FD_null_get_type_map(const H5FD_t *_file, H5FD_mem_t *type_map) /* Delegate to the underlying driver */ ret_value = H5FD_get_fs_type_map(file->inner_file, type_map); + if(ret_value < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "inner driver get type map failed") + done: FUNC_LEAVE_NOAPI(ret_value); @@ -898,8 +907,8 @@ done: * * Purpose: Allocate file memory in the inner driver. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: The format address of the new file memory. + * Failure: The undefined address HADDR_UNDEF * * Programmer: Jacob Gruber * Thursday, January 5, 2012 @@ -911,9 +920,9 @@ H5FD_null_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { const H5FD_null_t *file = (const H5FD_null_t*)_file; hid_t inner_dxpl_id = H5P_DATASET_XFER_DEFAULT; - herr_t ret_value; + haddr_t ret_value; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(HADDR_UNDEF) HDassert(file); @@ -925,7 +934,7 @@ H5FD_null_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) H5FD_null_dxpl_t *dx; /* Null-specific info */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data xfer property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a data xfer property list") dx = (H5FD_null_dxpl_t *)H5P_get_driver_info(plist); @@ -936,7 +945,8 @@ H5FD_null_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) /* Delegate to the inner file */ ret_value = H5FDalloc(file->inner_file, type, inner_dxpl_id, size); - + if(ret_value == HADDR_UNDEF) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate inner file memory") done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5FD_null_alloc() */ @@ -985,6 +995,8 @@ H5FD_null_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsiz /* Delegate to the inner file */ ret_value = H5FDfree(file->inner_file, type, inner_dxpl_id, addr, size); + if(ret_value < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "inner file deallocation request failed") done: FUNC_LEAVE_NOAPI(ret_value); @@ -1020,6 +1032,8 @@ H5FD_null_get_eoa(const H5FD_t *_file, H5FD_mem_t type) /* Delegate to the inner file */ ret_value = H5FD_get_eoa(file->inner_file, type); + if(ret_value == HADDR_UNDEF) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "inner file get eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1053,7 +1067,9 @@ H5FD_null_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) /* Delegate to the inner file */ ret_value = H5FD_set_eoa(file->inner_file, type, abs_eoa); - + if(ret_value < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "inner file set eoa request failed") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_null_set_eof() */ @@ -1086,7 +1102,9 @@ H5FD_null_get_eof(const H5FD_t *_file) /* Delegate to the inner file */ ret_value = H5FD_get_eof(file->inner_file); - + if(ret_value == HADDR_UNDEF) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "inner file get eof request failed") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_null_get_eof() */ @@ -1118,7 +1136,9 @@ H5FD_null_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) /* Delegate to the inner file */ ret_value = H5FD_get_vfd_handle(file->inner_file, file->inner_fapl_id, file_handle); - + if(ret_value < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for inner file driver") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_null_get_handle() */ diff --git a/src/H5FDpkg.h b/src/H5FDpkg.h index 7c0988e..5291b95 100644 --- a/src/H5FDpkg.h +++ b/src/H5FDpkg.h @@ -38,7 +38,6 @@ /* Package Private Macros */ /**************************/ - /****************************/ /* Package Private Typedefs */ /****************************/ diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index e839d21..28c6f3f 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -39,7 +39,6 @@ /* Length of filename buffer */ #define H5FD_MAX_FILENAME_LEN 1024 - /****************************/ /* Library Private Typedefs */ /****************************/ diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 247bd88..1cc61ee 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -235,6 +235,12 @@ typedef enum H5F_mem_t H5FD_mem_t; */ #define H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS 0x00000800 +/* + * Define the internal 8 character identifier stored in the superblock for + * files created by drivers that modify the file structure. + */ +#define H5FD_DRIVER_ID_FAMILY "NCSAfami" +#define H5FD_DRIVER_ID_MULTI "NCSAmulti" /* Forward declaration */ typedef struct H5FD_t H5FD_t; -- cgit v0.12