summaryrefslogtreecommitdiffstats
path: root/src/H5FDint.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2014-04-25 19:54:57 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2014-04-25 19:54:57 (GMT)
commit4257a32de13576155efc6df64aa0282bdf074ff1 (patch)
tree4da2d29685eb8c88e804d6daed0b59830cdbbffa /src/H5FDint.c
parentb018ba48ced579975e60362e3acfb6afb1f1d384 (diff)
downloadhdf5-4257a32de13576155efc6df64aa0282bdf074ff1.zip
hdf5-4257a32de13576155efc6df64aa0282bdf074ff1.tar.gz
hdf5-4257a32de13576155efc6df64aa0282bdf074ff1.tar.bz2
[svn-r25109] Description:
Bring r25084, 25088, 25092, 25097 from trunk to 1.8 branch: r25084: Begin process of migrating from using property list IDs internally to the library to using the internal generic property list data structure. r25088: Introduce "file I/O info" struct, to hold file & dxpl pointers, and start propagating up through library. r25092: More migration to using H5F_io_info_t pointers and away from using property list IDs internally. Also, clean up some compiler warnings in the cache code. r25097: Make progress toward moving from DXPL IDs to property list structures within the library. Also move the signature location code from the H5F package to the H5FD package, where it's a better fit. Also, clean up some more compiler warnings along the way. Tested: Mac OSX/64 10.9.2 (amazon) w/C++, FORTRAN & parallel (h5committested on trunk)
Diffstat (limited to 'src/H5FDint.c')
-rw-r--r--src/H5FDint.c79
1 files changed, 70 insertions, 9 deletions
diff --git a/src/H5FDint.c b/src/H5FDint.c
index c9e9a67..9f02a25 100644
--- a/src/H5FDint.c
+++ b/src/H5FDint.c
@@ -42,7 +42,6 @@
#include "H5Fprivate.h" /* File access */
#include "H5FDpkg.h" /* File Drivers */
#include "H5Iprivate.h" /* IDs */
-#include "H5Pprivate.h" /* Property lists */
/****************/
@@ -104,6 +103,70 @@ H5FD_int_init_interface(void)
/*-------------------------------------------------------------------------
+ * Function: H5FD_locate_signature
+ *
+ * Purpose: Finds the HDF5 superblock signature in a file. The
+ * signature can appear at address 0, or any power of two
+ * beginning with 512.
+ *
+ * Return: Success: SUCCEED
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 7, 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FD_locate_signature(H5FD_t *file, const H5P_genplist_t *dxpl, haddr_t *sig_addr)
+{
+ haddr_t addr, eoa;
+ uint8_t buf[H5F_SIGNATURE_LEN];
+ unsigned n, maxpow;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Find the least N such that 2^N is larger than the file size */
+ if(HADDR_UNDEF == (addr = H5FD_get_eof(file)) || HADDR_UNDEF == (eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER)))
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to obtain EOF/EOA value")
+ for(maxpow = 0; addr; maxpow++)
+ addr >>= 1;
+ maxpow = MAX(maxpow, 9);
+
+ /*
+ * Search for the file signature at format address zero followed by
+ * powers of two larger than 9.
+ */
+ for(n = 8; n < maxpow; n++) {
+ addr = (8 == n) ? 0 : (haddr_t)1 << n;
+ if(H5FD_set_eoa(file, H5FD_MEM_SUPER, addr + H5F_SIGNATURE_LEN) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to set EOA value for file signature")
+ if(H5FD_read(file, dxpl, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to read file signature")
+ if(!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN))
+ break;
+ } /* end for */
+
+ /*
+ * If the signature was not found then reset the EOA value and return
+ * HADDR_UNDEF.
+ */
+ if(n >= maxpow) {
+ if(H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to reset EOA value")
+ *sig_addr = HADDR_UNDEF;
+ } /* end if */
+ else
+ /* Set return value */
+ *sig_addr = addr;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_locate_signature() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5FD_read
*
* Purpose: Private version of H5FDread()
@@ -117,7 +180,7 @@ H5FD_int_init_interface(void)
*-------------------------------------------------------------------------
*/
herr_t
-H5FD_read(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr,
+H5FD_read(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t addr,
size_t size, void *buf/*out*/)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -125,8 +188,7 @@ H5FD_read(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr,
FUNC_ENTER_NOAPI(FAIL)
HDassert(file && file->cls);
- HDassert(H5I_GENPROP_LST == H5I_get_type(dxpl_id));
- HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER));
+ HDassert(TRUE == H5P_class_isa(H5P_CLASS(dxpl), H5P_CLS_DATASET_XFER_g));
HDassert(buf);
#ifndef H5_HAVE_PARALLEL
@@ -138,7 +200,7 @@ H5FD_read(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr,
#endif /* H5_HAVE_PARALLEL */
/* Dispatch to driver */
- if((file->cls->read)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0)
+ if((file->cls->read)(file, type, H5P_PLIST_ID(dxpl), addr + file->base_addr, size, buf) < 0)
HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed")
done:
@@ -160,7 +222,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5FD_write(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr,
+H5FD_write(H5FD_t *file, const H5P_genplist_t *dxpl, H5FD_mem_t type, haddr_t addr,
size_t size, const void *buf)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -168,8 +230,7 @@ H5FD_write(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr,
FUNC_ENTER_NOAPI(FAIL)
HDassert(file && file->cls);
- HDassert(H5I_GENPROP_LST == H5I_get_type(dxpl_id));
- HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER));
+ HDassert(TRUE == H5P_class_isa(H5P_CLASS(dxpl), H5P_CLS_DATASET_XFER_g));
HDassert(buf);
#ifndef H5_HAVE_PARALLEL
@@ -181,7 +242,7 @@ H5FD_write(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr,
#endif /* H5_HAVE_PARALLEL */
/* Dispatch to driver */
- if((file->cls->write)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0)
+ if((file->cls->write)(file, type, H5P_PLIST_ID(dxpl), addr + file->base_addr, size, buf) < 0)
HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed")
done: