summaryrefslogtreecommitdiffstats
path: root/src/H5Dvirtual.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@jam.ad.hdfgroup.org>2018-05-17 16:51:34 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2018-05-17 16:51:34 (GMT)
commit4df595946c82f739554060c846e4586d07e3d585 (patch)
tree523709249b055a89f97eb4bcca1c0b27af58bd7a /src/H5Dvirtual.c
parent6da75cffd2356fb5b5b92204b2d1c34a0e2e99ea (diff)
downloadhdf5-4df595946c82f739554060c846e4586d07e3d585.zip
hdf5-4df595946c82f739554060c846e4586d07e3d585.tar.gz
hdf5-4df595946c82f739554060c846e4586d07e3d585.tar.bz2
Fix for HDFFV-10469: set to latest format for virtual layout encoding.
Diffstat (limited to 'src/H5Dvirtual.c')
-rw-r--r--src/H5Dvirtual.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c
index dd3508f..d80e086 100644
--- a/src/H5Dvirtual.c
+++ b/src/H5Dvirtual.c
@@ -417,6 +417,11 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout)
hsize_t tmp_nentries; /* Temp. variable for # of VDS entries */
uint32_t chksum; /* Checksum for heap data */
size_t i; /* Local index variable */
+ H5P_genplist_t *fapl_plist; /* The file access property list */
+ hid_t new_fapl_id; /* The file access property list ID */
+ H5F_libver_t low_bound = H5F_LIBVER_V110; /* Set the low bound in fapl to latest */
+ H5F_libver_t high_bound = H5F_LIBVER_V110; /* Set the high bound in fapl to latest */
+ H5F_t *tmp_f = NULL; /* Pointer to faked file structure */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -428,6 +433,24 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout)
/* Create block if # of used entries > 0 */
if(layout->storage.u.virt.list_nused > 0) {
+
+ /* Make a copy of the default file access property list */
+ if(NULL == (fapl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+
+ /* Set latest format in fapl_plist for virtual layout encoding */
+ if(H5P_set(fapl_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &low_bound) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'low' bound for library format versions")
+ if(H5P_set(fapl_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &high_bound) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'high' bound for library format versions")
+ /* Copy and return the fapl id */
+ if((new_fapl_id = H5P_copy_plist(fapl_plist, FALSE)) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy file access property list")
+
+ /* Allocate "fake" file structure with the fapl setting */
+ if(NULL == (tmp_f = H5F_fake_alloc((uint8_t)0, new_fapl_id)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate fake file struct")
+
/* Allocate array for caching results of strlen */
if(NULL == (str_size = (size_t *)H5MM_malloc(2 * layout->storage.u.virt.list_nused * sizeof(size_t))))
HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, FAIL, "unable to allocate string length array")
@@ -457,12 +480,12 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout)
block_size += str_size[(2 * i) + 1];
/* Source selection */
- if((select_serial_size = H5S_SELECT_SERIAL_SIZE(layout->storage.u.virt.list[i].source_select,f)) < 0)
+ if((select_serial_size = H5S_SELECT_SERIAL_SIZE(layout->storage.u.virt.list[i].source_select, tmp_f)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to check dataspace selection size")
block_size += (size_t)select_serial_size;
/* Virtual dataset selection */
- if((select_serial_size = H5S_SELECT_SERIAL_SIZE(layout->storage.u.virt.list[i].source_dset.virtual_select,f)) < 0)
+ if((select_serial_size = H5S_SELECT_SERIAL_SIZE(layout->storage.u.virt.list[i].source_dset.virtual_select, tmp_f)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to check dataspace selection size")
block_size += (size_t)select_serial_size;
} /* end for */
@@ -499,11 +522,11 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout)
heap_block_p += str_size[(2 * i) + 1];
/* Source selection */
- if(H5S_SELECT_SERIALIZE(layout->storage.u.virt.list[i].source_select, &heap_block_p,f) < 0)
+ if(H5S_SELECT_SERIALIZE(layout->storage.u.virt.list[i].source_select, &heap_block_p, tmp_f) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to serialize source selection")
/* Virtual selection */
- if(H5S_SELECT_SERIALIZE(layout->storage.u.virt.list[i].source_dset.virtual_select, &heap_block_p,f) < 0)
+ if(H5S_SELECT_SERIALIZE(layout->storage.u.virt.list[i].source_dset.virtual_select, &heap_block_p, tmp_f) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to serialize virtual selection")
} /* end for */
@@ -517,9 +540,14 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout)
} /* end if */
done:
+ /* Release fake file structure */
+ if(tmp_f && H5F_fake_free(tmp_f) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release fake file struct")
+
heap_block = (uint8_t *)H5MM_xfree(heap_block);
str_size = (size_t *)H5MM_xfree(str_size);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__virtual_store_layout() */