summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJacob Gruber <gruber1@hdfgroup.org>2012-02-23 21:46:03 (GMT)
committerJacob Gruber <gruber1@hdfgroup.org>2012-02-23 21:46:03 (GMT)
commitb843341c4d8b5f17ff13b31b80ddd3ee7626655b (patch)
tree943b36ae22124ae40398561b487b7bfd1cd80468 /src
parent7456cf282cd79f7d063a47ea08a03508e8524b3b (diff)
downloadhdf5-b843341c4d8b5f17ff13b31b80ddd3ee7626655b.zip
hdf5-b843341c4d8b5f17ff13b31b80ddd3ee7626655b.tar.gz
hdf5-b843341c4d8b5f17ff13b31b80ddd3ee7626655b.tar.bz2
[svn-r21976] Added sb_verify and replaced the exisiting compatability checks with sb_verify calls.
Diffstat (limited to 'src')
-rw-r--r--src/H5FD.c43
-rw-r--r--src/H5FDcore.c1
-rw-r--r--src/H5FDdirect.c1
-rw-r--r--src/H5FDfamily.c40
-rw-r--r--src/H5FDlog.c1
-rw-r--r--src/H5FDmpio.c2
-rw-r--r--src/H5FDmpiposix.c1
-rw-r--r--src/H5FDmulti.c36
-rw-r--r--src/H5FDnull.c40
-rw-r--r--src/H5FDprivate.h1
-rw-r--r--src/H5FDpublic.h1
-rw-r--r--src/H5FDsec2.c1
-rw-r--r--src/H5FDstdio.c1
-rw-r--r--src/H5Fsuper_cache.c12
14 files changed, 173 insertions, 8 deletions
diff --git a/src/H5FD.c b/src/H5FD.c
index 6c2a024..2a7225b 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -559,6 +559,49 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5FD_null_sb_verify
+ *
+ * Purpose: Verify that the driver is compatable with the driver
+ * that created the file. driver_id is the driver identifier
+ * field stored in the superblock. This is called when
+ * reopening a file and ensures that the driver is able to
+ * decode the superblock info.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Jacob Gruber
+ * Friday, January 13, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FD_sb_verify(H5FD_t *file, const char *driver_id)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5FD_sb_verify, FAIL)
+
+ HDassert(file && file->cls);
+
+ /* Delegate to the driver if possible. If driver doesn't implement
+ * this function, it means that it can't support files with driver info
+ * in the superblock.
+ */
+ if(file->cls->sb_verify) {
+ if((file->cls->sb_verify)(file, driver_id) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_verify request failed")
+ }
+ else
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver doesn't support sb_verify")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_sb_verify() */
+
+
+
+/*-------------------------------------------------------------------------
* Function: H5FD_pl_copy
*
* Purpose: Copies the driver-specific part of the a property list.
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index b9a7eee..a200be5 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -137,6 +137,7 @@ static const H5FD_class_t H5FD_core_g = {
NULL, /*sb_size */
NULL, /*sb_encode */
NULL, /*sb_decode */
+ NULL, /*sb_verify */
sizeof(H5FD_core_fapl_t), /*fapl_size */
H5FD_core_fapl_get, /*fapl_get */
NULL, /*fapl_copy */
diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c
index 3cd40be..63d83ed 100644
--- a/src/H5FDdirect.c
+++ b/src/H5FDdirect.c
@@ -181,6 +181,7 @@ static const H5FD_class_t H5FD_direct_g = {
NULL, /*sb_size */
NULL, /*sb_encode */
NULL, /*sb_decode */
+ NULL, /*sb_verify */
sizeof(H5FD_direct_fapl_t), /*fapl_size */
H5FD_direct_fapl_get, /*fapl_get */
H5FD_direct_fapl_copy, /*fapl_copy */
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index c7059af..4f6a58d 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -99,6 +99,7 @@ static herr_t H5FD_family_sb_encode(H5FD_t *_file, char *name/*out*/,
unsigned char *buf/*out*/);
static herr_t H5FD_family_sb_decode(H5FD_t *_file, const char *name,
const unsigned char *buf);
+static herr_t H5FD_family_sb_verify(H5FD_t *_file, const char *driver_id);
static H5FD_t *H5FD_family_open(const char *name, unsigned flags,
hid_t fapl_id, haddr_t maxaddr);
static herr_t H5FD_family_close(H5FD_t *_file);
@@ -124,6 +125,7 @@ static const H5FD_class_t H5FD_family_g = {
H5FD_family_sb_size, /*sb_size */
H5FD_family_sb_encode, /*sb_encode */
H5FD_family_sb_decode, /*sb_decode */
+ H5FD_family_sb_verify, /*sb_verify */
sizeof(H5FD_family_fapl_t), /*fapl_size */
H5FD_family_fapl_get, /*fapl_get */
H5FD_family_fapl_copy, /*fapl_copy */
@@ -706,6 +708,44 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5FD_family_sb_verify
+ *
+ * Purpose: Verify that the family driver is compatable with the driver
+ * that created the file. driver_id is the driver identifier
+ * field stored in the superblock. This is called when
+ * reopening a file and ensures that the driver is able to
+ * decode the superblock info.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Jacob Gruber
+ * Friday, January 13, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_family_sb_verify(H5FD_t UNUSED *_file, const char *driver_id)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5FD_family_sb_verify, FAIL)
+
+ if(HDstrncmp(driver_id, "NCSAfami", (size_t)8)) {
+ char err_msg[128];
+
+ HDsnprintf(err_msg, sizeof(err_msg), "File type %s not supported by the family driver",
+ driver_id);
+
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, err_msg)
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_family_sb_verify() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5FD_family_open
*
* Purpose: Creates and/or opens a family of files as an HDF5 file.
diff --git a/src/H5FDlog.c b/src/H5FDlog.c
index 092d7e6..ae4b87f 100644
--- a/src/H5FDlog.c
+++ b/src/H5FDlog.c
@@ -209,6 +209,7 @@ static const H5FD_class_t H5FD_log_g = {
NULL, /*sb_size */
NULL, /*sb_encode */
NULL, /*sb_decode */
+ NULL, /*sb_verify */
sizeof(H5FD_log_fapl_t), /*fapl_size */
H5FD_log_fapl_get, /*fapl_get */
H5FD_log_fapl_copy, /*fapl_copy */
diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c
index fc93a85..76ed314 100644
--- a/src/H5FDmpio.c
+++ b/src/H5FDmpio.c
@@ -103,6 +103,7 @@ static const H5FD_class_mpi_t H5FD_mpio_g = {
NULL, /*sb_size */
NULL, /*sb_encode */
NULL, /*sb_decode */
+ NULL, /*sb_verify */
sizeof(H5FD_mpio_fapl_t), /*fapl_size */
H5FD_mpio_fapl_get, /*fapl_get */
H5FD_mpio_fapl_copy, /*fapl_copy */
@@ -2096,3 +2097,4 @@ done:
}
#endif /* H5_HAVE_PARALLEL */
+
diff --git a/src/H5FDmpiposix.c b/src/H5FDmpiposix.c
index 496f474..c87b95b 100644
--- a/src/H5FDmpiposix.c
+++ b/src/H5FDmpiposix.c
@@ -212,6 +212,7 @@ static const H5FD_class_mpi_t H5FD_mpiposix_g = {
NULL, /*sb_size */
NULL, /*sb_encode */
NULL, /*sb_decode */
+ NULL, /*sb_verify */
sizeof(H5FD_mpiposix_fapl_t), /*fapl_size */
H5FD_mpiposix_fapl_get, /*fapl_get */
H5FD_mpiposix_fapl_copy, /*fapl_copy */
diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c
index 5751596..03978fa 100644
--- a/src/H5FDmulti.c
+++ b/src/H5FDmulti.c
@@ -123,6 +123,7 @@ static herr_t H5FD_multi_sb_encode(H5FD_t *file, char *name/*out*/,
unsigned char *buf/*out*/);
static herr_t H5FD_multi_sb_decode(H5FD_t *file, const char *name,
const unsigned char *buf);
+static herr_t H5FD_multi_sb_verify(H5FD_t *file, const char *driver_id);
static void *H5FD_multi_fapl_get(H5FD_t *file);
static void *H5FD_multi_fapl_copy(const void *_old_fa);
static herr_t H5FD_multi_fapl_free(void *_fa);
@@ -157,6 +158,7 @@ static const H5FD_class_t H5FD_multi_g = {
H5FD_multi_sb_size, /*sb_size */
H5FD_multi_sb_encode, /*sb_encode */
H5FD_multi_sb_decode, /*sb_decode */
+ H5FD_multi_sb_verify, /*sb_verify */
sizeof(H5FD_multi_fapl_t), /*fapl_size */
H5FD_multi_fapl_get, /*fapl_get */
H5FD_multi_fapl_copy, /*fapl_copy */
@@ -982,6 +984,40 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf)
/*-------------------------------------------------------------------------
+ * Function: H5FD_multi_sb_verify
+ *
+ * Purpose: Verify that the multi driver is compatable with the driver
+ * that created the file. driver_id is the driver identifier
+ * field stored in the superblock. This is called when
+ * reopening a file and ensures that the driver is able to
+ * decode the superblock info.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Jacob Gruber
+ * Friday, January 13, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_multi_sb_verify(H5FD_t *_file, const char *driver_id)
+{
+ static const char *func = "H5FD_multi_sb_verify";
+
+ if(strncmp(driver_id, "NCSAmult", (size_t)8)) {
+ char err_msg[128];
+
+ snprintf(err_msg, sizeof(err_msg), "File type %s not supported by the multi driver",
+ driver_id);
+
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADVALUE, err_msg, -1);
+ }
+ return 0;
+} /* end H5FD_family_sb_verify() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5FD_multi_fapl_get
*
* Purpose: Returns a file access property list which indicates how the
diff --git a/src/H5FDnull.c b/src/H5FDnull.c
index 01be3ac..c940786 100644
--- a/src/H5FDnull.c
+++ b/src/H5FDnull.c
@@ -71,6 +71,7 @@ static herr_t H5FD_null_sb_encode(H5FD_t *_file, char *name/*out*/,
unsigned char *buf/*out*/);
static herr_t H5FD_null_sb_decode(H5FD_t *_file, const char *name,
const unsigned char *buf);
+static herr_t H5FD_null_sb_verify(H5FD_t *_file, const char *driver_id);
static H5FD_t *H5FD_null_open(const char *name, unsigned flags,
hid_t fapl_id, haddr_t maxaddr);
static herr_t H5FD_null_close(H5FD_t *_file);
@@ -101,6 +102,7 @@ static const H5FD_class_t H5FD_null_g = {
H5FD_null_sb_size, /* sb_size */
H5FD_null_sb_encode, /* sb_encode */
H5FD_null_sb_decode, /* sb_decode */
+ H5FD_null_sb_verify, /* sb_verify */
sizeof(H5FD_null_fapl_t), /* fapl_size */
H5FD_null_fapl_get, /* fapl_get */
H5FD_null_fapl_copy, /* fapl_copy */
@@ -634,6 +636,44 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FD_null_sb_decode() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_null_sb_verify
+ *
+ * Purpose: Verify that the inner driver is compatable with the driver
+ * that created the file. driver_id is the driver identifier
+ * field stored in the superblock. This is called when
+ * reopening a file and ensures that the driver is able to
+ * decode the superblock info.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Jacob Gruber
+ * Friday, January 13, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_null_sb_verify(H5FD_t *_file, const char *driver_id)
+{
+ H5FD_null_t *file = (H5FD_null_t*)_file;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5FD_null_sb_verify, FAIL)
+
+ HDassert(file);
+
+ /* Delegate to the inner driver */
+ if(H5FD_sb_verify(file->inner_file, driver_id) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "inner driver sb_verify failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+}
+
+
/*-------------------------------------------------------------------------
* Function: H5FD_null_open
diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h
index fe770d2..61538dc 100644
--- a/src/H5FDprivate.h
+++ b/src/H5FDprivate.h
@@ -70,6 +70,7 @@ H5_DLL H5FD_class_t *H5FD_get_class(hid_t id);
H5_DLL hsize_t H5FD_sb_size(H5FD_t *file);
H5_DLL herr_t H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf);
H5_DLL herr_t H5FD_sb_decode(H5FD_t *file, const char *name, const uint8_t *buf);
+H5_DLL herr_t H5FD_sb_verify(H5FD_t *file, const char *driver_id);
H5_DLL void *H5FD_fapl_get(H5FD_t *file);
H5_DLL herr_t H5FD_fapl_open(struct H5P_genplist_t *plist, hid_t driver_id, const void *driver_info);
H5_DLL herr_t H5FD_fapl_copy(hid_t driver_id, const void *fapl, void **copied_fapl);
diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h
index f495e2d..a5d8ed9 100644
--- a/src/H5FDpublic.h
+++ b/src/H5FDpublic.h
@@ -236,6 +236,7 @@ typedef struct H5FD_class_t {
herr_t (*sb_encode)(H5FD_t *file, char *name/*out*/,
unsigned char *p/*out*/);
herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p);
+ herr_t (*sb_verify)(H5FD_t *f, const char *name);
size_t fapl_size;
void * (*fapl_get)(H5FD_t *file);
void * (*fapl_copy)(const void *fapl);
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index 140342d..7b65cf0 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -167,6 +167,7 @@ static const H5FD_class_t H5FD_sec2_g = {
NULL, /*sb_size */
NULL, /*sb_encode */
NULL, /*sb_decode */
+ NULL, /*sb_verify */
0, /*fapl_size */
NULL, /*fapl_get */
NULL, /*fapl_copy */
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c
index b67e01e..35c844b 100644
--- a/src/H5FDstdio.c
+++ b/src/H5FDstdio.c
@@ -189,6 +189,7 @@ static const H5FD_class_t H5FD_stdio_g = {
NULL, /*sb_size */
NULL, /*sb_encode */
NULL, /*sb_decode */
+ NULL, /*sb_verify */
0, /*fapl_size */
NULL, /*fapl_get */
NULL, /*fapl_copy */
diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c
index cb4ee0e..b877e7a 100644
--- a/src/H5Fsuper_cache.c
+++ b/src/H5Fsuper_cache.c
@@ -363,10 +363,8 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
/* Check if driver matches driver information saved. Unfortunately, we can't push this
* function to each specific driver because we're checking if the driver is correct.
*/
- if(!HDstrncmp(drv_name, "NCSAfami", (size_t)8) && HDstrcmp(lf->cls->name, "family"))
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "family driver should be used")
- if(!HDstrncmp(drv_name, "NCSAmult", (size_t)8) && HDstrcmp(lf->cls->name, "multi"))
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "multi driver should be used")
+ if(H5FD_sb_verify(lf, drv_name) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "driver does not support this file")
/* Read in variable-sized portion of driver info block */
if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, sblock->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drv_variable_size) < 0)
@@ -525,10 +523,8 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
/* Check if driver matches driver information saved. Unfortunately, we can't push this
* function to each specific driver because we're checking if the driver is correct.
*/
- if(!HDstrncmp(drvinfo.name, "NCSAfami", (size_t)8) && HDstrcmp(lf->cls->name, "family"))
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "family driver should be used")
- if(!HDstrncmp(drvinfo.name, "NCSAmult", (size_t)8) && HDstrcmp(lf->cls->name, "multi"))
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "multi driver should be used")
+ if(H5FD_sb_verify(lf, drvinfo.name) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "driver does not support this file")
/* Decode driver information */
if(H5FD_sb_decode(lf, drvinfo.name, drvinfo.buf) < 0)