diff options
Diffstat (limited to 'src/H5Fsuper.c')
-rw-r--r-- | src/H5Fsuper.c | 76 |
1 files changed, 6 insertions, 70 deletions
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 81aaca2..dd80a46 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -100,75 +100,6 @@ H5F_init_super_interface(void) /*------------------------------------------------------------------------- - * Function: H5F_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 -H5F_locate_signature(H5FD_t *file, hid_t dxpl_id, haddr_t *sig_addr) -{ - H5P_genplist_t *dxpl; /* DXPL object */ - 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); - - /* Get the DXPL plist object for DXPL ID */ - if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - - /* - * 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 H5F_locate_signature() */ - - -/*------------------------------------------------------------------------- * Function: H5F_super_ext_create * * Purpose: Create the superblock extension @@ -325,6 +256,7 @@ done: herr_t H5F_super_read(H5F_t *f, hid_t dxpl_id) { + H5P_genplist_t *dxpl; /* DXPL object */ H5F_super_t * sblock = NULL; /* superblock structure */ unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */ haddr_t super_addr; /* Absolute address of superblock */ @@ -334,8 +266,12 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id) FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__SUPERBLOCK_TAG, FAIL) + /* Get the DXPL plist object for DXPL ID */ + if(NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + /* Find the superblock */ - if(H5F_locate_signature(f->shared->lf, dxpl_id, &super_addr) < 0) + if(H5FD_locate_signature(f->shared->lf, dxpl, &super_addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") if(HADDR_UNDEF == super_addr) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "file signature not found") |