From 91eb17db8ee7fcda566436fa2336fac2cf2c3660 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Tue, 16 Jun 2015 12:27:20 -0500 Subject: [svn-r27215] Fix issue where % characters could not be used in non-printf mappings. Other minor fixes/cleanup. Tested: ummon --- src/H5Dvirtual.c | 118 ++++++++++++++++++++++++++++++++++++++++++------------- src/H5Olayout.c | 37 +++++++++++------ src/H5Oprivate.h | 6 ++- src/H5Pdcpl.c | 40 ++++++++++++------- test/vds.c | 47 ++++++++++++++-------- 5 files changed, 174 insertions(+), 74 deletions(-) diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index f6a16ee..4a9f79f 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -228,22 +228,31 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) /* Copy the list entries, though set source_dset.dset and sub_dset to * NULL */ for(i = 0; i < layout->storage.u.virt.list_nused; i++) { - if(NULL == (layout->storage.u.virt.list[i].source_dset.file_name - = HDstrdup(orig_list[i].source_dset.file_name))) - HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") - if(NULL == (layout->storage.u.virt.list[i].source_dset.dset_name - = HDstrdup(orig_list[i].source_dset.dset_name))) - HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") + /* Copy virtual selection */ if(NULL == (layout->storage.u.virt.list[i].source_dset.virtual_select = H5S_copy(orig_list[i].source_dset.virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") + + /* Copy original source names */ + if(NULL == (layout->storage.u.virt.list[i].source_file_name + = HDstrdup(orig_list[i].source_file_name))) + HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") + if(NULL == (layout->storage.u.virt.list[i].source_dset_name + = HDstrdup(orig_list[i].source_dset_name))) + HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") + + /* Copy source selection */ if(NULL == (layout->storage.u.virt.list[i].source_select = H5S_copy(orig_list[i].source_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy source selection") + + /* Initialize clipped selections */ if(orig_list[i].unlim_dim_virtual < 0) { layout->storage.u.virt.list[i].source_dset.clipped_source_select = layout->storage.u.virt.list[i].source_select; layout->storage.u.virt.list[i].source_dset.clipped_virtual_select = layout->storage.u.virt.list[i].source_dset.virtual_select; } /* end if */ + + /* Copy parsed names */ if(H5D__virtual_copy_parsed_name(&layout->storage.u.virt.list[i].parsed_source_file_name, orig_list[i].parsed_source_file_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy parsed source file name") layout->storage.u.virt.list[i].psfn_static_strlen = orig_list[i].psfn_static_strlen; @@ -252,6 +261,43 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy parsed source dataset name") layout->storage.u.virt.list[i].psdn_static_strlen = orig_list[i].psdn_static_strlen; layout->storage.u.virt.list[i].psdn_nsubs = orig_list[i].psdn_nsubs; + + /* Copy source names in source dset or add reference as appropriate + */ + if(orig_list[i].source_dset.file_name) { + if(orig_list[i].source_dset.file_name + == orig_list[i].source_file_name) + layout->storage.u.virt.list[i].source_dset.file_name = layout->storage.u.virt.list[i].source_file_name; + else if(orig_list[i].parsed_source_file_name + && (orig_list[i].source_dset.file_name + != orig_list[i].parsed_source_file_name->name_segment)) { + HDassert(layout->storage.u.virt.list[i].parsed_source_file_name); + HDassert(layout->storage.u.virt.list[i].parsed_source_file_name->name_segment); + layout->storage.u.virt.list[i].source_dset.file_name = layout->storage.u.virt.list[i].parsed_source_file_name->name_segment; + } /* end if */ + else + if(NULL == (layout->storage.u.virt.list[i].source_dset.file_name + = HDstrdup(orig_list[i].source_dset.file_name))) + HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") + } /* end if */ + if(orig_list[i].source_dset.dset_name) { + if(orig_list[i].source_dset.dset_name + == orig_list[i].source_dset_name) + layout->storage.u.virt.list[i].source_dset.dset_name = layout->storage.u.virt.list[i].source_dset_name; + else if(orig_list[i].parsed_source_dset_name + && (orig_list[i].source_dset.dset_name + != orig_list[i].parsed_source_dset_name->name_segment)) { + HDassert(layout->storage.u.virt.list[i].parsed_source_dset_name); + HDassert(layout->storage.u.virt.list[i].parsed_source_dset_name->name_segment); + layout->storage.u.virt.list[i].source_dset.dset_name = layout->storage.u.virt.list[i].parsed_source_dset_name->name_segment; + } /* end if */ + else + if(NULL == (layout->storage.u.virt.list[i].source_dset.dset_name + = HDstrdup(orig_list[i].source_dset.dset_name))) + HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") + } /* end if */ + + /* Copy other fields in entry */ layout->storage.u.virt.list[i].unlim_dim_source = orig_list[i].unlim_dim_source; layout->storage.u.virt.list[i].unlim_dim_virtual = orig_list[i].unlim_dim_virtual; layout->storage.u.virt.list[i].unlim_extent_source = orig_list[i].unlim_extent_source; @@ -263,7 +309,7 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) } /* end for */ } /* end if */ else { - HDassert(0 && "checking code coverage...");//VDSINC + HDassert(0 && "checking code coverage..."); //VDSINC /* Zero out other fields related to list, just to be sure */ layout->storage.u.virt.list = NULL; layout->storage.u.virt.list_nalloc = 0; @@ -318,6 +364,10 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) if(H5D__virtual_reset_source_dset(&layout->storage.u.virt.list[i], &layout->storage.u.virt.list[i].source_dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset source dataset") + /* Free original source names */ + (void)H5MM_xfree(layout->storage.u.virt.list[i].source_file_name); + (void)H5MM_xfree(layout->storage.u.virt.list[i].source_dset_name); + /* Free sub_dset */ for(j = 0; j < layout->storage.u.virt.list[i].sub_dset_nalloc; j++) if(H5D__virtual_reset_source_dset(&layout->storage.u.virt.list[i], &layout->storage.u.virt.list[i].sub_dset[j]) < 0) @@ -495,14 +545,28 @@ H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, } /* end if */ /* Free file name */ - if((source_dset == &virtual_ent->source_dset) - || virtual_ent->parsed_source_file_name) + if(virtual_ent->parsed_source_file_name + && (source_dset->file_name + != virtual_ent->parsed_source_file_name->name_segment)) source_dset->file_name = (char *)H5MM_xfree(source_dset->file_name); + else + HDassert((source_dset->file_name == virtual_ent->source_file_name) + || (virtual_ent->parsed_source_file_name + && (source_dset->file_name + == virtual_ent->parsed_source_file_name->name_segment)) + || !source_dset->file_name); /* Free dataset name */ - if((source_dset == &virtual_ent->source_dset) - || virtual_ent->parsed_source_dset_name) + if(virtual_ent->parsed_source_dset_name + && (source_dset->dset_name + != virtual_ent->parsed_source_dset_name->name_segment)) source_dset->dset_name = (char *)H5MM_xfree(source_dset->dset_name); + else + HDassert((source_dset->dset_name == virtual_ent->source_dset_name) + || (virtual_ent->parsed_source_dset_name + && (source_dset->dset_name + == virtual_ent->parsed_source_dset_name->name_segment)) + || !source_dset->dset_name); /* Free clipped virtual selection */ if(source_dset->clipped_virtual_select) { @@ -695,8 +759,9 @@ H5D_virtual_parse_source_name(const char *source_name, p = pct + 2; } /* end while */ - /* Copy last segment of name, if any, unless there were no substitutions */ - if(tmp_nsubs > 0) { + /* Copy last segment of name, if any, unless the parsed name was not + * allocated */ + if(tmp_parsed_name) { HDassert(p >= source_name); if(*p == '\0') HDassert((size_t)(p - source_name) == tmp_strlen); @@ -849,8 +914,10 @@ H5D__virtual_build_source_name(char *source_name, /* Check for static name */ if(nsubs == 0) { - HDassert(!parsed_name); - *built_name = source_name; + if(parsed_name) + *built_name = parsed_name->name_segment; + else + *built_name = source_name; } /* end if */ else { const H5O_storage_virtual_name_seg_t *name_seg = parsed_name; @@ -1105,12 +1172,12 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset, hid_t dxpl_id) else { /* Resolve file name */ if(!storage->list[i].sub_dset[j].file_name) - if(H5D__virtual_build_source_name(storage->list[i].source_dset.file_name, storage->list[i].parsed_source_file_name, storage->list[i].psfn_static_strlen, storage->list[i].psfn_nsubs, j, &storage->list[i].sub_dset[j].file_name) < 0) + if(H5D__virtual_build_source_name(storage->list[i].source_file_name, storage->list[i].parsed_source_file_name, storage->list[i].psfn_static_strlen, storage->list[i].psfn_nsubs, j, &storage->list[i].sub_dset[j].file_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to build source file name") /* Resolve dset name */ if(!storage->list[i].sub_dset[j].dset_name) - if(H5D__virtual_build_source_name(storage->list[i].source_dset.dset_name, storage->list[i].parsed_source_dset_name, storage->list[i].psdn_static_strlen, storage->list[i].psdn_nsubs, j, &storage->list[i].sub_dset[j].dset_name) < 0) + if(H5D__virtual_build_source_name(storage->list[i].source_dset_name, storage->list[i].parsed_source_dset_name, storage->list[i].psdn_static_strlen, storage->list[i].psdn_nsubs, j, &storage->list[i].sub_dset[j].dset_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to build source dataset name") /* Resolve virtual selection for block */ @@ -1399,7 +1466,7 @@ done: */ herr_t H5D__virtual_init(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, - const H5D_t *dset, hid_t dapl_id) + const H5D_t *dset, hid_t dapl_id) { H5O_storage_virtual_t *storage; /* Convenience pointer */ H5P_genplist_t *dapl; /* Data access property list object pointer */ @@ -1521,8 +1588,7 @@ H5D__virtual_pre_io(H5D_io_info_t *io_info, HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); /* Check for "printf" source dataset resolution */ - if(storage->list[i].parsed_source_file_name - || storage->list[i].parsed_source_dset_name) { + if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { hbool_t partial_block; HDassert(storage->list[i].unlim_dim_virtual >= 0); @@ -1667,8 +1733,7 @@ H5D__virtual_post_io(H5O_storage_virtual_t *storage) /* Iterate over mappings */ for(i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].parsed_source_file_name - || storage->list[i].parsed_source_dset_name) { + if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) @@ -1795,8 +1860,7 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); /* Check for "printf" source dataset resolution */ - if(storage->list[i].parsed_source_file_name - || storage->list[i].parsed_source_dset_name) { + if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) @@ -1820,8 +1884,7 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, /* Iterate over mappings */ for(i = 0; i < storage->list_nused; i++) /* Check for "printf" source dataset resolution */ - if(storage->list[i].parsed_source_file_name - || storage->list[i].parsed_source_dset_name) { + if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) @@ -1978,8 +2041,7 @@ H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert(storage->list[i].virtual_space_status == H5O_VIRTUAL_STATUS_CORRECT); /* Check for "printf" source dataset resolution */ - if(storage->list[i].parsed_source_file_name - || storage->list[i].parsed_source_dset_name) { + if(storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ for(j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) { diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 33c35ed..5a388fe 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -283,16 +283,16 @@ H5O_layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED * for(i = 0; i < mesg->storage.u.virt.list_nused; i++) { /* Source file name */ tmp_size = HDstrlen((const char *)heap_block_p) + 1; - if(NULL == (mesg->storage.u.virt.list[i].source_dset.file_name = (char *)H5MM_malloc(tmp_size))) + if(NULL == (mesg->storage.u.virt.list[i].source_file_name = (char *)H5MM_malloc(tmp_size))) HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, "unable to allocate memory for source file name") - (void)HDmemcpy(mesg->storage.u.virt.list[i].source_dset.file_name, heap_block_p, tmp_size); + (void)HDmemcpy(mesg->storage.u.virt.list[i].source_file_name, heap_block_p, tmp_size); heap_block_p += tmp_size; /* Source dataset name */ tmp_size = HDstrlen((const char *)heap_block_p) + 1; - if(NULL == (mesg->storage.u.virt.list[i].source_dset.dset_name = (char *)H5MM_malloc(tmp_size))) + if(NULL == (mesg->storage.u.virt.list[i].source_dset_name = (char *)H5MM_malloc(tmp_size))) HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, "unable to allocate memory for source dataset name") - (void)HDmemcpy(mesg->storage.u.virt.list[i].source_dset.dset_name, heap_block_p, tmp_size); + (void)HDmemcpy(mesg->storage.u.virt.list[i].source_dset_name, heap_block_p, tmp_size); heap_block_p += tmp_size; /* Source selection */ @@ -305,11 +305,24 @@ H5O_layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED * /* Parse source file and dataset names for "printf" * style format specifiers */ - if(H5D_virtual_parse_source_name(mesg->storage.u.virt.list[i].source_dset.file_name, &mesg->storage.u.virt.list[i].parsed_source_file_name, &mesg->storage.u.virt.list[i].psfn_static_strlen, &mesg->storage.u.virt.list[i].psfn_nsubs) < 0) + if(H5D_virtual_parse_source_name(mesg->storage.u.virt.list[i].source_file_name, &mesg->storage.u.virt.list[i].parsed_source_file_name, &mesg->storage.u.virt.list[i].psfn_static_strlen, &mesg->storage.u.virt.list[i].psfn_nsubs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't parse source file name") - if(H5D_virtual_parse_source_name(mesg->storage.u.virt.list[i].source_dset.dset_name, &mesg->storage.u.virt.list[i].parsed_source_dset_name, &mesg->storage.u.virt.list[i].psdn_static_strlen, &mesg->storage.u.virt.list[i].psdn_nsubs) < 0) + if(H5D_virtual_parse_source_name(mesg->storage.u.virt.list[i].source_dset_name, &mesg->storage.u.virt.list[i].parsed_source_dset_name, &mesg->storage.u.virt.list[i].psdn_static_strlen, &mesg->storage.u.virt.list[i].psdn_nsubs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't parse source dataset name") + /* Set source names in source_dset struct */ + if((mesg->storage.u.virt.list[i].psfn_nsubs == 0) + && (mesg->storage.u.virt.list[i].psdn_nsubs == 0)) { + if(mesg->storage.u.virt.list[i].parsed_source_file_name) + mesg->storage.u.virt.list[i].source_dset.file_name = mesg->storage.u.virt.list[i].parsed_source_file_name->name_segment; + else + mesg->storage.u.virt.list[i].source_dset.file_name = mesg->storage.u.virt.list[i].source_file_name; + if(mesg->storage.u.virt.list[i].parsed_source_dset_name) + mesg->storage.u.virt.list[i].source_dset.dset_name = mesg->storage.u.virt.list[i].parsed_source_dset_name->name_segment; + else + mesg->storage.u.virt.list[i].source_dset.dset_name = mesg->storage.u.virt.list[i].source_dset_name; + } /* end if */ + /* unlim_dim fields */ mesg->storage.u.virt.list[i].unlim_dim_source = H5S_get_select_unlim_dim(mesg->storage.u.virt.list[i].source_select); mesg->storage.u.virt.list[i].unlim_dim_virtual = H5S_get_select_unlim_dim(mesg->storage.u.virt.list[i].source_dset.virtual_select); @@ -486,17 +499,17 @@ H5O_layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c /* Calculate size of each entry */ for(i = 0; i < mesg->storage.u.virt.list_nused; i++) { - HDassert(mesg->storage.u.virt.list[i].source_dset.file_name); - HDassert(mesg->storage.u.virt.list[i].source_dset.dset_name); + HDassert(mesg->storage.u.virt.list[i].source_file_name); + HDassert(mesg->storage.u.virt.list[i].source_dset_name); HDassert(mesg->storage.u.virt.list[i].source_select); HDassert(mesg->storage.u.virt.list[i].source_dset.virtual_select); /* Source file name */ - str_size[2 * i] = HDstrlen(mesg->storage.u.virt.list[i].source_dset.file_name) + (size_t)1; + str_size[2 * i] = HDstrlen(mesg->storage.u.virt.list[i].source_file_name) + (size_t)1; block_size += str_size[2 * i]; /* Source dset name */ - str_size[(2 * i) + 1] = HDstrlen(mesg->storage.u.virt.list[i].source_dset.dset_name) + (size_t)1; + str_size[(2 * i) + 1] = HDstrlen(mesg->storage.u.virt.list[i].source_dset_name) + (size_t)1; block_size += str_size[(2 * i) + 1]; /* Source selection */ @@ -529,11 +542,11 @@ H5O_layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c /* Encode each entry */ for(i = 0; i < mesg->storage.u.virt.list_nused; i++) { /* Source file name */ - (void)HDstrcpy((char *)heap_block_p, mesg->storage.u.virt.list[i].source_dset.file_name); + (void)HDstrcpy((char *)heap_block_p, mesg->storage.u.virt.list[i].source_file_name); heap_block_p += str_size[2 * i]; /* Source dataset name */ - (void)HDstrcpy((char *)heap_block_p, mesg->storage.u.virt.list[i].source_dset.dset_name); + (void)HDstrcpy((char *)heap_block_p, mesg->storage.u.virt.list[i].source_dset_name); heap_block_p += str_size[(2 * i) + 1]; /* Source selection */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 8462382..29f727d 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -415,11 +415,11 @@ typedef struct H5O_storage_compact_t { typedef struct H5O_storage_virtual_srcdset_t { /* Stored */ - char *file_name; /* Source file name used for virtual dataset mapping */ - char *dset_name; /* Source dataset name used for virtual dataset mapping */ struct H5S_t *virtual_select; /* Selection in the virtual dataset that is mapped to source selection */ /* Not stored */ + char *file_name; /* Source file name used for virtual dataset mapping */ + char *dset_name; /* Source dataset name used for virtual dataset mapping */ struct H5S_t *clipped_source_select; /* Clipped version of source_select */ struct H5S_t *clipped_virtual_select; /* Clipped version of virtual_select */ struct H5D_t *dset; /* Source dataset */ @@ -443,6 +443,8 @@ typedef enum H5O_virtual_space_status_t { typedef struct H5O_storage_virtual_ent_t { /* Stored */ H5O_storage_virtual_srcdset_t source_dset; /* Information about the source dataset */ + char *source_file_name; /* Original (unparsed) source file name */ + char *source_dset_name; /* Original (unparsed) source dataset name */ struct H5S_t *source_select; /* Selection in the source dataset for mapping */ /* Not stored */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index d17a281..54694a0 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -1674,19 +1674,29 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, /* Add virtual dataset mapping entry */ ent = &layout.storage.u.virt.list[layout.storage.u.virt.list_nused]; - if(NULL == (ent->source_dset.file_name = HDstrdup(src_file_name))) - HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") - adding_entry = TRUE; - if(NULL == (ent->source_dset.dset_name = HDstrdup(src_dset_name))) - HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") if(NULL == (ent->source_dset.virtual_select = H5S_copy(vspace, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") + adding_entry = TRUE; + if(NULL == (ent->source_file_name = HDstrdup(src_file_name))) + HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") + if(NULL == (ent->source_dset_name = HDstrdup(src_dset_name))) + HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") if(NULL == (ent->source_select = H5S_copy(src_space, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy source selection") - if(H5D_virtual_parse_source_name(ent->source_dset.file_name, &ent->parsed_source_file_name, &ent->psfn_static_strlen, &ent->psfn_nsubs) < 0) + if(H5D_virtual_parse_source_name(ent->source_file_name, &ent->parsed_source_file_name, &ent->psfn_static_strlen, &ent->psfn_nsubs) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source file name") - if(H5D_virtual_parse_source_name(ent->source_dset.dset_name, &ent->parsed_source_dset_name, &ent->psdn_static_strlen, &ent->psdn_nsubs) < 0) + if(H5D_virtual_parse_source_name(ent->source_dset_name, &ent->parsed_source_dset_name, &ent->psdn_static_strlen, &ent->psdn_nsubs) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't parse source dataset name") + if((ent->psfn_nsubs == 0) && (ent->psdn_nsubs == 0)) { + if(ent->parsed_source_file_name) + ent->source_dset.file_name = ent->parsed_source_file_name->name_segment; + else + ent->source_dset.file_name = ent->source_file_name; + if(ent->parsed_source_dset_name) + ent->source_dset.dset_name = ent->parsed_source_dset_name->name_segment; + else + ent->source_dset.dset_name = ent->source_dset_name; + } /* end if */ ent->unlim_dim_source = H5S_get_select_unlim_dim(src_space); ent->unlim_dim_virtual = H5S_get_select_unlim_dim(vspace); if(ent->unlim_dim_virtual < 0) { @@ -1735,8 +1745,8 @@ done: if(ret_value < 0) { /* Free incomplete entry if present */ if(ent) { - ent->source_dset.file_name = (char *)H5MM_xfree(ent->source_dset.file_name); - ent->source_dset.dset_name = (char *)H5MM_xfree(ent->source_dset.dset_name); + ent->source_file_name = (char *)H5MM_xfree(ent->source_file_name); + ent->source_dset_name = (char *)H5MM_xfree(ent->source_dset_name); if(ent->source_dset.virtual_select && H5S_close(ent->source_dset.virtual_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release virtual selection") ent->source_dset.virtual_select = NULL; @@ -1960,10 +1970,10 @@ H5Pget_virtual_filename(hid_t dcpl_id, size_t index, char *name/*out*/, if(index >= layout.storage.u.virt.list_nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); - HDassert(layout.storage.u.virt.list[index].source_dset.file_name); + HDassert(layout.storage.u.virt.list[index].source_file_name); if(name && (size > 0)) - (void)HDstrncpy(name, layout.storage.u.virt.list[index].source_dset.file_name, size); - ret_value = (ssize_t)HDstrlen(layout.storage.u.virt.list[index].source_dset.file_name); + (void)HDstrncpy(name, layout.storage.u.virt.list[index].source_file_name, size); + ret_value = (ssize_t)HDstrlen(layout.storage.u.virt.list[index].source_file_name); done: FUNC_LEAVE_API(ret_value) @@ -2007,10 +2017,10 @@ H5Pget_virtual_dsetname(hid_t dcpl_id, size_t index, char *name/*out*/, if(index >= layout.storage.u.virt.list_nused) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)") HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc); - HDassert(layout.storage.u.virt.list[index].source_dset.dset_name); + HDassert(layout.storage.u.virt.list[index].source_dset_name); if(name && (size > 0)) - (void)HDstrncpy(name, layout.storage.u.virt.list[index].source_dset.dset_name, size); - ret_value = (ssize_t)HDstrlen(layout.storage.u.virt.list[index].source_dset.dset_name); + (void)HDstrncpy(name, layout.storage.u.virt.list[index].source_dset_name, size); + ret_value = (ssize_t)HDstrlen(layout.storage.u.virt.list[index].source_dset_name); done: FUNC_LEAVE_API(ret_value) diff --git a/test/vds.c b/test/vds.c index f39136d..6540e5a 100644 --- a/test/vds.c +++ b/test/vds.c @@ -35,6 +35,7 @@ const char *FILENAME[] = { "vds_virt", "vds_src_0", "vds_src_1", + "vds%_src", NULL }; @@ -993,6 +994,9 @@ test_basic_io(unsigned config, hid_t fapl) { char srcfilename[FILENAME_BUF_SIZE]; char vfilename[FILENAME_BUF_SIZE]; + char srcfilenamepct[FILENAME_BUF_SIZE]; + char srcfilenamepct_fmt_fix[FILENAME_BUF_SIZE]; + const char *srcfilenamepct_fmt = "vds%%_src"; hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ hid_t vfile = -1; /* File with virtual dset */ hid_t dcpl = -1; /* Dataset creation property list */ @@ -1001,7 +1005,7 @@ test_basic_io(unsigned config, hid_t fapl) hid_t memspace = -1; /* Memory dataspace */ hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */ hid_t vdset = -1; /* Virtual dataset */ - hsize_t dims[4] = {10, 26, -1, -1}; /* Data space current size */ + hsize_t dims[4] = {10, 26, 0, 0}; /* Data space current size */ hsize_t start[4]; /* Hyperslab start */ hsize_t stride[4]; /* Hyperslab stride */ hsize_t count[4]; /* Hyperslab count */ @@ -1018,6 +1022,8 @@ test_basic_io(unsigned config, hid_t fapl) h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename); h5_fixname(FILENAME[1], fapl, srcfilename, sizeof srcfilename); + h5_fixname(FILENAME[3], fapl, srcfilenamepct, sizeof srcfilenamepct); + h5_fixname(srcfilenamepct_fmt, fapl, srcfilenamepct_fmt_fix, sizeof srcfilenamepct_fmt_fix); /* Create DCPL */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -1169,7 +1175,8 @@ test_basic_io(unsigned config, hid_t fapl) /* - * Test 2: 2 Source datasets, hyperslab virtual mappings + * Test 2: 2 Source datasets, hyperslab virtual mappings, '%' in source + * dataset name */ /* Clear virtual layout in DCPL */ if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) @@ -1201,9 +1208,9 @@ test_basic_io(unsigned config, hid_t fapl) TEST_ERROR /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename : ".", "src_dset1", srcspace[0]) < 0) + if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename : ".", "%%src_dset1", srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename : ".", "src_dset2", srcspace[0]) < 0) + if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename : ".", "src_dset2%%", srcspace[0]) < 0) TEST_ERROR /* Reset dims */ @@ -1225,9 +1232,9 @@ test_basic_io(unsigned config, hid_t fapl) } /* end if */ /* Create source datasets */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if((srcdset[0] = H5Dcreate2(srcfile[0], "%src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2%", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create virtual dataset */ @@ -1300,9 +1307,9 @@ test_basic_io(unsigned config, hid_t fapl) if(config & TEST_IO_DIFFERENT_FILE) if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) + if((srcdset[0] = H5Dopen2(srcfile[0], "%src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR - if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2", H5P_DEFAULT)) < 0) + if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2%", H5P_DEFAULT)) < 0) TEST_ERROR } /* end if */ @@ -1348,7 +1355,7 @@ test_basic_io(unsigned config, hid_t fapl) /* * Test 3: 2 Source datasets, hyperslab virtual mappings on one mapping at a - * time + * time, '%' in source file name */ /* Clear virtual layout in DCPL */ if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) @@ -1380,9 +1387,9 @@ test_basic_io(unsigned config, hid_t fapl) TEST_ERROR /* Add virtual layout mappings */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename : ".", "src_dset1", srcspace[0]) < 0) + if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilenamepct_fmt_fix : ".", "src_dset1", srcspace[0]) < 0) TEST_ERROR - if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename : ".", "src_dset2", srcspace[0]) < 0) + if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilenamepct_fmt_fix : ".", "src_dset2", srcspace[0]) < 0) TEST_ERROR /* Reset dims */ @@ -1394,7 +1401,7 @@ test_basic_io(unsigned config, hid_t fapl) /* Create source file if requested */ if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((srcfile[0] = H5Fcreate(srcfilenamepct, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } /* end if */ else { @@ -1499,7 +1506,7 @@ test_basic_io(unsigned config, hid_t fapl) /* Reopen srcdsets and srcfile if config option specified */ if(config & TEST_IO_CLOSE_SRC) { if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if((srcfile[0] = H5Fopen(srcfilenamepct, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0) TEST_ERROR @@ -5175,6 +5182,9 @@ test_printf(unsigned config, hid_t fapl) char vfilename[FILENAME_BUF_SIZE]; char printf_srcfilename[FILENAME_BUF_SIZE]; const char *printf_srcfilename_fmt = "vds_src_%b"; + char srcfilenamepct[FILENAME_BUF_SIZE]; + char srcfilenamepct_fmt_fix[FILENAME_BUF_SIZE]; + const char *srcfilenamepct_fmt = "vds%%_src"; hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ hid_t vfile = -1; /* File with virtual dset */ hid_t dcpl = -1; /* Dataset creation property list */ @@ -5204,6 +5214,8 @@ test_printf(unsigned config, hid_t fapl) h5_fixname(FILENAME[1], fapl, srcfilename, sizeof srcfilename); h5_fixname(FILENAME[2], fapl, srcfilename2, sizeof srcfilename2); h5_fixname(printf_srcfilename_fmt, fapl, printf_srcfilename, sizeof printf_srcfilename); + h5_fixname(FILENAME[3], fapl, srcfilenamepct, sizeof srcfilenamepct); + h5_fixname(srcfilenamepct_fmt, fapl, srcfilenamepct_fmt_fix, sizeof srcfilenamepct_fmt_fix); /* Create DCPL */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -5610,7 +5622,8 @@ test_printf(unsigned config, hid_t fapl) /* - * Test 2: 1 Source dataset mapping, 10x1 blocks, test printf gap setting + * Test 2: 1 Source dataset mapping, 10x1 blocks, test printf gap setting, + * '%' in source file name */ /* Clear virtual layout in DCPL */ if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) @@ -5636,7 +5649,7 @@ test_printf(unsigned config, hid_t fapl) TEST_ERROR /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename : ".", "src_dset%b", srcspace) < 0) + if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilenamepct_fmt_fix : ".", "src_dset%b", srcspace) < 0) TEST_ERROR /* Create virtual file */ @@ -5645,7 +5658,7 @@ test_printf(unsigned config, hid_t fapl) /* Create source file if requested */ if(config & TEST_IO_DIFFERENT_FILE) { - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((srcfile[0] = H5Fcreate(srcfilenamepct, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR } /* end if */ else { @@ -5707,7 +5720,7 @@ test_printf(unsigned config, hid_t fapl) /* Reopen srcfile if config option specified */ if(config & TEST_IO_CLOSE_SRC) if(config & TEST_IO_DIFFERENT_FILE) - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if((srcfile[0] = H5Fopen(srcfilenamepct, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR /* Create source datasets in a pattern with increasing gaps: -- cgit v0.12