summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2008-10-03 03:54:23 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2008-10-03 03:54:23 (GMT)
commit3d008d3756c094fa205770b810fa2719c3e21687 (patch)
tree46c06c3ad13199c2a415dc8d5c9fc28123aeb83a
parent33ae6a749eaa04ee7ab91d7b63cb430fd4e0fc8f (diff)
downloadhdf5-3d008d3756c094fa205770b810fa2719c3e21687.zip
hdf5-3d008d3756c094fa205770b810fa2719c3e21687.tar.gz
hdf5-3d008d3756c094fa205770b810fa2719c3e21687.tar.bz2
[svn-r15762] Changes for bug #1247 so that the user can specify the driver
to use when opening the external linked target file. 1. Two new public routines are added to H5Plapl.c as well as "del/copy/close" callbacks for the property itself. 2. Modify H5L_extern_traverse() to use the fapl set via H5Pset_elink_fapl() and retrieve via H5Pget_elink_fapl(). 3. Add 3 tests to links.c to verify H5Pset/get_elink_fapl(). Also fix the compiler warning for the "if condition" in H5_build_extpath() of H5system.c.
-rw-r--r--src/H5Lexternal.c40
-rw-r--r--src/H5Lprivate.h5
-rw-r--r--src/H5Plapl.c228
-rw-r--r--src/H5Ppublic.h2
-rw-r--r--src/H5system.c5
-rw-r--r--test/links.c488
6 files changed, 743 insertions, 25 deletions
diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c
index acd6ee9..d5a441d 100644
--- a/src/H5Lexternal.c
+++ b/src/H5Lexternal.c
@@ -171,6 +171,14 @@ done:
* Vailin Choi, April 2, 2008
* Add handling to search for the target file
* See description in RM: H5Lcreate_external
+ *
+ * Vailin Choi; Sept. 12th, 2008; bug #1247
+ * Retrieve the file access property list identifer that is set
+ * for link access property via H5Pget_elink_fapl().
+ * If the return value is H5P_DEFAULT, the parent's file access
+ * property is used to H5F_open() the target file;
+ * Otherwise, the file access property retrieved from H5Pget_elink_fapl()
+ * is used to H5F_open() the target file.
*
*-------------------------------------------------------------------------
*/
@@ -197,6 +205,8 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group,
char *env_prefix=NULL, *tmp_env_prefix=NULL;
char *out_prefix_name=NULL, *pp=NULL;
+ H5P_genplist_t *fa_plist; /* File access property list pointer */
+ H5F_close_degree_t fc_degree = H5F_CLOSE_WEAK; /* File close degree for target file */
FUNC_ENTER_NOAPI(H5L_extern_traverse, FAIL)
@@ -219,31 +229,25 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group,
if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+ /* get the fapl_id set for lapl_id if any */
+ if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl for links")
+
/* Get the location for the group holding the external link */
if(H5G_loc(cur_group, &loc) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get object location")
- /* Whatever access properties and intent the user used on the old file,
- * use the same ones to open the new file. If this is a bad default,
- * users can override this callback using H5Lregister.
- */
+ /* get the file access mode flags for the parent file */
intent = H5F_INTENT(loc.oloc->file);
- if((fapl_id = H5F_get_access_plist(loc.oloc->file, FALSE)) < 0)
- HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get file access property list")
- /* Check for non-"weak" file close degree for parent file */
- if(H5F_GET_FC_DEGREE(loc.oloc->file) != H5F_CLOSE_WEAK) {
- H5P_genplist_t *fa_plist; /* Property list pointer */
- H5F_close_degree_t fc_degree = H5F_CLOSE_WEAK; /* File close degree */
+ if ((fapl_id == H5P_DEFAULT) && ((fapl_id = H5F_get_access_plist(loc.oloc->file, FALSE)) < 0))
+ HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get parent's file access property list")
- /* Get the plist structure */
- if(NULL == (fa_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
-
- /* Set file close degree for new file to "weak" */
- if(H5P_set(fa_plist, H5F_ACS_CLOSE_DEGREE_NAME, &fc_degree) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree")
- } /* end if */
+ /* Set file close degree for new file to "weak" */
+ if(NULL == (fa_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+ if(H5P_set(fa_plist, H5F_ACS_CLOSE_DEGREE_NAME, &fc_degree) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree")
/*
* Start searching for the target file
diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h
index 6d3811e..cd17a87 100644
--- a/src/H5Lprivate.h
+++ b/src/H5Lprivate.h
@@ -39,8 +39,9 @@
#define H5L_CRT_INTERMEDIATE_GROUP_NAME "intermediate_group" /* Create intermediate groups flag */
/* ======== Link access property names ======== */
-#define H5L_ACS_NLINKS_NAME "max soft links" /* Number of soft links to traverse */
-#define H5L_ACS_ELINK_PREFIX_NAME "external link prefix" /* External link prefix */
+#define H5L_ACS_NLINKS_NAME "max soft links" /* Number of soft links to traverse */
+#define H5L_ACS_ELINK_PREFIX_NAME "external link prefix" /* External link prefix */
+#define H5L_ACS_ELINK_FAPL_NAME "external link fapl" /* file access property list for external link access */
/****************************/
diff --git a/src/H5Plapl.c b/src/H5Plapl.c
index db80148..2b16be2 100644
--- a/src/H5Plapl.c
+++ b/src/H5Plapl.c
@@ -55,6 +55,13 @@
#define H5L_ACS_ELINK_PREFIX_COPY H5P_lacc_elink_pref_copy
#define H5L_ACS_ELINK_PREFIX_CLOSE H5P_lacc_elink_pref_close
+/* Definitions for setting fapl of external link access */
+#define H5L_ACS_ELINK_FAPL_SIZE sizeof(hid_t)
+#define H5L_ACS_ELINK_FAPL_DEF H5P_DEFAULT
+#define H5L_ACS_ELINK_FAPL_DEL H5P_lacc_elink_fapl_del
+#define H5L_ACS_ELINK_FAPL_COPY H5P_lacc_elink_fapl_copy
+#define H5L_ACS_ELINK_FAPL_CLOSE H5P_lacc_elink_fapl_close
+
/******************/
/* Local Typedefs */
/******************/
@@ -77,6 +84,10 @@ static herr_t H5P_lacc_elink_pref_del(hid_t prop_id, const char* name, size_t si
static herr_t H5P_lacc_elink_pref_copy(const char* name, size_t size, void* value);
static herr_t H5P_lacc_elink_pref_close(const char* name, size_t size, void* value);
+static herr_t H5P_lacc_elink_fapl_del(hid_t prop_id, const char* name, size_t size, void* value);
+static herr_t H5P_lacc_elink_fapl_copy(const char* name, size_t size, void* value);
+static herr_t H5P_lacc_elink_fapl_close(const char* name, size_t size, void* value);
+
/*********************/
/* Package Variables */
@@ -118,14 +129,20 @@ const H5P_libclass_t H5P_CLS_LACC[1] = {{
*
* Programmer: Quincey Koziol
* October 31, 2006
+ *
+ * Modifications:
+ * Vailin Choi, Sept. 12th 2008
+ * Register the setting of file access property list for link access
+ *
*-------------------------------------------------------------------------
*/
static herr_t
H5P_lacc_reg_prop(H5P_genclass_t *pclass)
{
- size_t nlinks = H5L_ACS_NLINKS_DEF; /* Default number of soft links to traverse */
+ size_t nlinks = H5L_ACS_NLINKS_DEF; /* Default number of soft links to traverse */
char *elink_prefix = H5L_ACS_ELINK_PREFIX_DEF; /* Default external link prefix string */
- herr_t ret_value = SUCCEED; /* Return value */
+ hid_t def_fapl_id = H5L_ACS_ELINK_FAPL_DEF; /* Default fapl for external link access */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5P_lacc_reg_prop)
@@ -139,11 +156,125 @@ H5P_lacc_reg_prop(H5P_genclass_t *pclass)
&elink_prefix, NULL, NULL, NULL, H5L_ACS_ELINK_PREFIX_DEL, H5L_ACS_ELINK_PREFIX_COPY, NULL, H5L_ACS_ELINK_PREFIX_CLOSE) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+ /* Register fapl for link access */
+ if(H5P_register(pclass, H5L_ACS_ELINK_FAPL_NAME, H5L_ACS_ELINK_FAPL_SIZE, &def_fapl_id, NULL, NULL, NULL, H5L_ACS_ELINK_FAPL_DEL, H5L_ACS_ELINK_FAPL_COPY, NULL, H5L_ACS_ELINK_FAPL_CLOSE) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P_lacc_reg_prop() */
+/*--------------------------------------------------------------------------
+ * Function: H5P_lacc_elink_fapl_del
+ *
+ * Purpose: Close the FAPL for link access
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi
+ * Tuesday, Sept 23, 2008
+ *
+ *--------------------------------------------------------------------------
+ */
+/* ARGSUSED */
+static herr_t
+H5P_lacc_elink_fapl_del(hid_t UNUSED prop_id, const char UNUSED *name, size_t UNUSED size, void *value)
+{
+ hid_t l_fapl_id;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(H5P_lacc_elink_fapl_del, FAIL)
+
+ HDassert(value);
+
+ l_fapl_id = (*(const hid_t *)value);
+
+ if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE) < 0))
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P_lacc_elink_fapl_del() */
+
+
+/*--------------------------------------------------------------------------
+ * Function: H5P_lacc_elink_fapl_copy
+ *
+ * Purpose: Copy the FAPL for link access
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi
+ * Tuesday, Sept 23, 2008
+ *
+ *--------------------------------------------------------------------------
+ */
+/* ARGSUSED */
+static herr_t
+H5P_lacc_elink_fapl_copy(const char UNUSED *name, size_t UNUSED size, void *value)
+{
+ hid_t l_fapl_id;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(H5P_lacc_elink_fapl_copy, FAIL)
+
+ HDassert(value);
+
+ l_fapl_id = (*(const hid_t *)value);
+
+ if(l_fapl_id > H5P_DEFAULT) {
+ H5P_genplist_t *l_fapl_plist;
+
+ if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
+
+ if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file access properties")
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P_lacc_elink_fapl_copy() */
+
+
+/*--------------------------------------------------------------------------
+ * Function: H5P_lacc_elink_fapl_close
+ *
+ * Purpose: Close the FAPL for link access
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi
+ * Tuesday, Sept 23, 2008
+ *
+ *---------------------------------------------------------------------------
+ */
+/* ARGSUSED */
+herr_t
+H5P_lacc_elink_fapl_close(const char UNUSED *name, size_t UNUSED size, void *value)
+{
+ hid_t l_fapl_id;
+ herr_t ret_value = SUCCEED;
+
+int ref_count;
+ FUNC_ENTER_NOAPI(H5P_lacc_elink_fapl_close, FAIL)
+
+ HDassert(value);
+
+ l_fapl_id = (*(const hid_t *)value);
+
+ if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE) < 0))
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P_lacc_elink_fapl_close() */
+
+
/*-------------------------------------------------------------------------
* Function: H5P_lacc_elink_pref_del
*
@@ -412,3 +543,96 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_elink_prefix() */
+/*-------------------------------------------------------------------------
+ * Function: H5Pset_elink_fapl
+ *
+ * Purpose: Sets the file access property list for link access
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer:
+ * Vailin Choi; Tuesday, September 12th, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id)
+{
+ H5P_genplist_t *plist, *l_fapl_plist, *fapl_plist; /* Property list pointer */
+ hid_t l_fapl_id, new_fapl_id;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(H5Pset_elink_fapl, FAIL)
+ H5TRACE2("e", "i*s", lapl_id, fapl_id);
+
+ /* Check arguments */
+ if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link access property list");
+
+ /* Get the current file access property list for the link access */
+ if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &l_fapl_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl")
+
+ /* Close the current file access property list if set */
+ if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE) < 0))
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
+
+ if (NULL==(fapl_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+
+ /* Make a copy of the property list for FAPL_ID */
+ if((new_fapl_id = H5P_copy_plist(fapl_plist, FALSE)) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file access properties")
+
+ /* Set the file access property list for the link access */
+ if(H5P_set(plist, H5L_ACS_ELINK_FAPL_NAME, &new_fapl_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fapl for link")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pset_elink_fapl() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_elink_fapl
+ *
+ * Purpose: Gets the file access property list identifier that is
+ * set for link access property.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer:
+ * Vailin Choi; Tuesday, September 12th, 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Pget_elink_fapl(hid_t lapl_id)
+{
+ H5P_genplist_t *plist, *fapl_plist; /* Property list pointer */
+ hid_t l_fapl_id;
+ hid_t ret_value=FAIL; /* Return value */
+
+ FUNC_ENTER_API(H5Pget_elink_fapl, FAIL)
+ H5TRACE1("i", "i", lapl_id);
+
+ /* Get the plist structure */
+ if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &l_fapl_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl for links")
+
+ if(l_fapl_id > H5P_DEFAULT) {
+ if(NULL==(fapl_plist = H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+
+ if((ret_value = H5P_copy_plist(fapl_plist, TRUE)) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file access properties")
+ } else
+ ret_value = l_fapl_id;
+
+done:
+ FUNC_LEAVE_API(ret_value);
+} /* end H5Pget_elink_fapl() */
+
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index bab5a1a..0e4e8d3 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -374,6 +374,8 @@ H5_DLL herr_t H5Pset_nlinks(hid_t plist_id, size_t nlinks);
H5_DLL herr_t H5Pget_nlinks(hid_t plist_id, size_t *nlinks);
H5_DLL herr_t H5Pset_elink_prefix(hid_t plist_id, const char *prefix);
H5_DLL ssize_t H5Pget_elink_prefix(hid_t plist_id, char *prefix, size_t size);
+H5_DLL hid_t H5Pget_elink_fapl(hid_t lapl_id);
+H5_DLL herr_t H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id);
/* Object copy property list (OCPYPL) routines */
H5_DLL herr_t H5Pset_copy_object(hid_t plist_id, unsigned crt_intmd);
diff --git a/src/H5system.c b/src/H5system.c
index ddb8567..8f91e2f 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -597,6 +597,9 @@ HDremove_all(const char *fname)
*
* Programmer: Vailin Choi
* April 2, 2008
+ * Modifications: 2nd Oct, 2008; Vailin Choi
+ * Remove compiler warning for "if condition"
+ *
*-------------------------------------------------------------------------
*/
#define MAX_PATH_LEN 1024
@@ -641,7 +644,7 @@ H5_build_extpath(const char *name, char **extpath/*out*/)
* Get current drive
* Unix: does not apply
*/
- } else if (CHECK_ABS_PATH(name) && (drive=HDgetdrive())) {
+ } else if (CHECK_ABS_PATH(name) && ((drive=HDgetdrive()) != 0)) {
sprintf(cwdpath, "%c:%c", (drive+'A'-1), name[0]);
retcwd = cwdpath;
HDstrcpy(new_name, &name[1]);
diff --git a/test/links.c b/test/links.c
index f471815..065cb46 100644
--- a/test/links.c
+++ b/test/links.c
@@ -72,10 +72,17 @@ const char *FILENAME[] = {
"tmp/extlinks13", /* 34: */
"tmp/extlinks14", /* 35: */
"tmp/extlinks15", /* 36: */
+ "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */
+ "extlinks16B", /* 38: */
+ "extlinks17", /* 39: */
NULL
};
#define TMPDIR "tmp"
+#define FAMILY_SIZE 1024
+#define CORE_INCREMENT 1024
+#define NUM1000 1000
+
/* do not do check_all_closed() for "ext*" files and "tmp/ext*" */
#define EXTSTOP 12
@@ -3055,6 +3062,7 @@ external_link_cwd(hid_t fapl, hbool_t new_format)
} /* end external_link_cwd() */
+
/*-------------------------------------------------------------------------
* Function: external_link_abstar: test 6
*
@@ -3334,6 +3342,7 @@ external_link_reltar(hid_t fapl, hbool_t new_format)
} H5E_END_TRY;
return -1;
} /* end external_link_reltar() */
+
/*-------------------------------------------------------------------------
* Function: external_link_chdir: test 9
@@ -3432,7 +3441,479 @@ external_link_chdir(hid_t fapl, hbool_t new_format)
} /* end external_link_chdir() */
+/*-------------------------------------------------------------------------
+ * Function: external_set_elink_fapl1: test 10
+ *
+ * Purpose: To verify that the external linked target file with physical layout
+ * different from the parent can be successfully opened.
+ *
+ * 1. target link: "extlinks16"
+ * 2. target file: "extlinks16"
+ * 3. main file: Linux:"/CWD/tmp/extlinks0"; Window: "<cur drive>:/CWD/tmp/extlinks0"
+ * 4. Create target file A to be a "family" file: extlinks16A
+ * 4. Create target file B to be a "multi" file: extlinks16B
+ * 5. Create external link from main file to target file A: ext_linkA->extlinks16A:/A
+ * 5. Create external link from main file to target file B: ext_linkB->extlinks16B:/B
+ * 6. Should succeed in opening the target object: ext_extA
+ * 6. Should succeed in opening the target object: ext_extB
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Vailin Choi
+ * Sept. 12, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+external_set_elink_fapl1(hid_t fapl, hbool_t new_format)
+{
+ hid_t fid=(-1);
+ hid_t fidA=(-1), fidB=(-1);
+ hid_t gidA=(-1), gidB=(-1);
+ hid_t oidA=(-1), oidB=(-1);
+ char filename1[NAME_BUF_SIZE],
+ filename2A[NAME_BUF_SIZE],
+ filename2B[NAME_BUF_SIZE],
+ tmpname[NAME_BUF_SIZE],
+ cwdpath[NAME_BUF_SIZE];
+ hid_t fam_fapl, multi_fapl;
+ hid_t lapl_idA, lapl_idB;
+ H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES];
+ hid_t memb_fapl[H5FD_MEM_NTYPES];
+ char sv[H5FD_MEM_NTYPES][500];
+ const char *memb_name[H5FD_MEM_NTYPES];
+ haddr_t memb_addr[H5FD_MEM_NTYPES];
+
+ if(new_format)
+ TESTING("H5Pset/get_elink_fapl() with different physical layouts (w/new group format)")
+ else
+ TESTING("H5Pset/get_elink_fapl() with different physical layouts")
+
+ if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) ||
+ (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL))
+ TEST_ERROR
+
+ /*
+ * set up name for main file:
+ * Linux: "/CWD/tmp/extlinks0"
+ * Windows: "<cur drive>:/CWD/tmp/extlinks0"
+ */
+ HDstrcpy(tmpname, cwdpath);
+ HDstrcat(tmpname, "/");
+ HDstrcat(tmpname, FILENAME[13]);
+ h5_fixname(tmpname, fapl, filename1, sizeof filename1);
+
+ /* create "family" fapl */
+ fam_fapl = h5_fileaccess();
+ if(H5Pset_fapl_family(fam_fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0)
+ TEST_ERROR;
+
+ /* set up name for external linked target file A: "extlinks16A" */
+ /* set up name for target file A: "extlinks16A" */
+ h5_fixname(FILENAME[37], fam_fapl, filename2A, sizeof filename2A);
+
+ /* settings for multi file */
+ HDmemset(memb_map, 0, sizeof memb_map);
+ HDmemset(memb_fapl, 0, sizeof memb_fapl);
+ HDmemset(memb_name, 0, sizeof memb_name);
+ HDmemset(memb_addr, 0, sizeof memb_addr);
+ HDmemset(sv, 0, sizeof sv);
+
+ for (mt = 0; mt < H5FD_MEM_NTYPES; mt++) {
+ memb_map[mt] = H5FD_MEM_SUPER;
+ memb_fapl[mt] = H5P_DEFAULT;
+ }
+
+ memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW;
+ memb_map[H5FD_MEM_BTREE] = H5FD_MEM_BTREE;
+ memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP;
+ memb_map[H5FD_MEM_LHEAP] = H5FD_MEM_LHEAP;
+
+ sprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's');
+ memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER];
+ memb_addr[H5FD_MEM_SUPER] = 0;
+
+ sprintf(sv[H5FD_MEM_BTREE], "%%s-%c.h5", 'b');
+ memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE];
+ memb_addr[H5FD_MEM_BTREE] = HADDR_MAX/6;
+
+ sprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r');
+ memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW];
+ memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/3;
+
+ sprintf(sv[H5FD_MEM_GHEAP], "%%s-%c.h5", 'g');
+ memb_name[H5FD_MEM_GHEAP] = sv[H5FD_MEM_GHEAP];
+ memb_addr[H5FD_MEM_GHEAP] = HADDR_MAX/2;
+
+ sprintf(sv[H5FD_MEM_LHEAP], "%%s-%c.h5", 'l');
+ memb_name[H5FD_MEM_LHEAP] = sv[H5FD_MEM_LHEAP];
+ memb_addr[H5FD_MEM_LHEAP] = HADDR_MAX*2/3;
+
+ sprintf(sv[H5FD_MEM_OHDR], "%%s-%c.h5", 'o');
+ memb_name[H5FD_MEM_OHDR] = sv[H5FD_MEM_OHDR];
+ memb_addr[H5FD_MEM_OHDR] = HADDR_MAX*5/6;
+
+ /* create "multi" fapl */
+ multi_fapl = h5_fileaccess();
+ if(H5Pset_fapl_multi(multi_fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0)
+ TEST_ERROR;
+
+ /* set up name for external linked target file B: "extlinks16B" */
+ /* set up name for target file B: "extlinks16B" */
+ h5_fixname(FILENAME[38], multi_fapl, filename2B, sizeof filename2B);
+
+ /* Create target file A to be a "family" file */
+ if((fidA=H5Fcreate(filename2A, H5F_ACC_TRUNC, H5P_DEFAULT, fam_fapl)) < 0) TEST_ERROR
+ if((gidA=H5Gcreate2(fidA, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Create target file B to be a "multi" file */
+ if((fidB=H5Fcreate(filename2B, H5F_ACC_TRUNC, H5P_DEFAULT, multi_fapl)) < 0) TEST_ERROR
+ if((gidB=H5Gcreate2(fidB, "B", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* closing for target files */
+ if(H5Gclose(gidA) < 0) TEST_ERROR
+ if(H5Gclose(gidB) < 0) TEST_ERROR
+ if(H5Fclose(fidA) < 0) TEST_ERROR
+ if(H5Fclose(fidB) < 0) TEST_ERROR
+
+ /* Create the main file */
+ if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create external link to target file A:/A */
+ if(H5Lcreate_external(filename2A, "/A", fid, "ext_linkA", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+ /* Create external link to target file B:/B */
+ if(H5Lcreate_external(filename2B, "/B", fid, "ext_linkB", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Set file access property list for link access to use the family driver */
+ if((lapl_idA = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR
+ if(H5Pset_elink_fapl(lapl_idA, fam_fapl) < 0) TEST_ERROR
+
+ /* open target object A */
+ oidA = H5Oopen(fid, "ext_linkA", lapl_idA);
+
+ /* should succeed in opening the target object A in the current working directory */
+ if (oidA < 0) {
+ H5_FAILED();
+ puts(" Should succeed in opening family target file A in current working directory");
+ goto error;
+ }
+
+ /* Set file access property list for link access to use the multi driver */
+ if((lapl_idB = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR
+ if(H5Pset_elink_fapl(lapl_idB, multi_fapl) < 0) TEST_ERROR
+
+ /* open target object B */
+ oidB = H5Oopen(fid, "ext_linkB", lapl_idB);
+
+ /* should succeed in opening the target object B in the current working directory */
+ if (oidB < 0) {
+ H5_FAILED();
+ puts(" Should succeed in opening multi target file B in current working directory");
+ goto error;
+ }
+
+ /* closing */
+ if(H5Pclose(lapl_idA) < 0) TEST_ERROR
+ if(H5Pclose(lapl_idB) < 0) TEST_ERROR
+ if(H5Pclose(fam_fapl) < 0) TEST_ERROR
+ if(H5Pclose(multi_fapl) < 0) TEST_ERROR
+ if(H5Oclose(oidA) < 0) TEST_ERROR
+ if(H5Oclose(oidB) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Pclose (lapl_idA);
+ H5Pclose (lapl_idB);
+ H5Pclose (fam_fapl);
+ H5Pclose (multi_fapl);
+ H5Gclose (gidA);
+ H5Gclose (gidB);
+ H5Oclose (oidA);
+ H5Oclose (oidB);
+ H5Fclose (fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end external_set_elink_fapl1() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: external_set_elink_fapl2: test 11
+ *
+ * Purpose: To verify that processing done to the external linked target object is
+ * correctly handled when the parent and target files have the same
+ * physical layout but different access methods.
+ *
+ * 1. target link: "extlinks17"
+ * 2. target file: "extlinks17"
+ * 3. main file: Linux:"/CWD/tmp/extlinks0"; Window: "<cur drive>:/CWD/tmp/extlinks0"
+ * 4. Create target file to be a "core" file:/A/Dataset
+ * 5. Create external link from main file to target file:ext_link->target file:/A/Dataset
+ * 6. Set the file access property list of the link access to use "core" file without
+ * backing store
+ * 6. Should succeed in opening the target dataset: ext_link
+ * 7. Write data to the target dataset
+ * 8. On closing, the file size of target should be the same as before since
+ * it is opened without backing store.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Vailin Choi
+ * Sept. 12, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+external_set_elink_fapl2(hid_t fapl, hbool_t new_format)
+{
+ hid_t fid = (-1); /* File ID */
+ hid_t gid = (-1); /* Group IDs */
+ char filename1[NAME_BUF_SIZE],
+ filename2[NAME_BUF_SIZE],
+ tmpname[NAME_BUF_SIZE],
+ cwdpath[NAME_BUF_SIZE];
+ hid_t core_fapl, space, dset, did, dapl_id, dcpl;
+ hsize_t dims[2];
+ int points[NUM1000][NUM1000];
+ int filesize, new_filesize, i, j, n;
+
+ if(new_format)
+ TESTING("H5Pset/get_elink_fapl() with same physical layout (w/new group format)")
+ else
+ TESTING("H5Pset/get_elink_fapl() with same physical layout")
+
+ if ((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) ||
+ (HDgetcwd(cwdpath, NAME_BUF_SIZE)==NULL))
+ TEST_ERROR
+
+ /*
+ * set up name for main file:
+ * Linux: "/CWD/tmp/extlinks0"
+ * Windows: "<cur drive>:/CWD/tmp/extlinks0"
+ */
+ HDstrcpy(tmpname, cwdpath);
+ HDstrcat(tmpname, "/");
+ HDstrcat(tmpname, FILENAME[13]);
+ h5_fixname(tmpname, fapl, filename1, sizeof filename1);
+ /* create fapl for the target file to be a "core" file */
+ core_fapl = h5_fileaccess();
+ if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0)
+ TEST_ERROR
+
+ /* set up name for external linked target file: "extlinks17" */
+ /* set up name for target file: "extlinks17" */
+ h5_fixname(FILENAME[39], core_fapl, filename2, sizeof filename2);
+
+ /* Create the target file to be a "core" file */
+ if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, core_fapl)) < 0) TEST_ERROR
+ if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ dims[0] = NUM1000;
+ dims[1] = NUM1000;
+ if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR
+
+ /* Create dataset creation property list */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+ if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) TEST_ERROR;
+
+ /* create "Dataset" in group "A" of target file */
+ if((dset = H5Dcreate2(gid, "Dataset", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* closing for target file */
+ if(H5Pclose(dcpl) < 0) TEST_ERROR
+ if(H5Sclose(space) < 0) TEST_ERROR
+ if(H5Dclose(dset) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ /* get size of target file */
+ filesize = h5_get_file_size(filename2);
+
+ /* Create the main file */
+ if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create external link to target file: ext_link->extlinks17:/A/Dataset */
+ if(H5Lcreate_external(filename2, "/A/Dataset", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* create fapl to be a "core" file without backing store */
+ if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, FALSE) < 0)
+ TEST_ERROR
+
+ /* Set file access property list for link access to use the "core" driver */
+ if((dapl_id = H5Pcreate(H5P_DATASET_ACCESS)) < 0) TEST_ERROR
+ if(H5Pset_elink_fapl(dapl_id, core_fapl) < 0) TEST_ERROR
+
+ /* try to open the external linked target dataset */
+ did = H5Dopen2(fid, "ext_link", dapl_id);
+
+ if (did < 0) {
+ H5_FAILED();
+ puts(" Should succeed in opening the target dataset");
+ goto error;
+ }
+
+ /* Initialize the dataset */
+ for(i = n = 0; i < NUM1000; i++)
+ for(j = 0; j < NUM1000; j++)
+ points[i][j] = n++;
+
+ /* Write the data to the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
+ TEST_ERROR
+
+ if(H5Pclose(core_fapl) < 0) TEST_ERROR
+ if(H5Pclose(dapl_id) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0) TEST_ERROR
+ if(H5Fclose(fid) < 0) TEST_ERROR
+
+ new_filesize = h5_get_file_size(filename2);
+
+ /* the file size should remain the same since there is no backing store */
+ if (new_filesize != filesize) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl);
+ H5Sclose(space);
+ H5Dclose(dset);
+ H5Pclose(core_fapl);
+ H5Pclose(dapl_id);
+ H5Dclose (did);
+ H5Fclose (fid);
+ } H5E_END_TRY;
+ return -1;
+} /* end external_set_elink_fapl2() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: external_set_elink_fapl3: test 12
+ *
+ * Purpose: To verify that the file access property list for link access is
+ * set and closed correctly.
+ *
+ * 1. Create fapl for core driver
+ * 2. Create fapl for stdio driver
+ * 3. Set link access's fapl to use stdio driver
+ * 4. Verify that link access's fapl is the stdio driver
+ * 5. Reset the link access' fapl to use core driver
+ * 6. H5Pcopy() the link access
+ * 7. Get the fapl property value of the original link access
+ * 8. Close the original link access
+ * 9. H5Pclose() fapl should fail since closing in step #8 should also close its fapl
+ * 10. Verify that the copied link access's fapl is the core driver
+ * 11. Get the fapl property value of the copied link access
+ * 12. H5Premove() the fapl property from the copied link access
+ * 13. H5Pclose() fapl set in the copied link access should fail since the
+ * removal in #12 should also close its fapl
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Vailin Choi
+ * Sept. 12, 2008
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+external_set_elink_fapl3(hbool_t new_format)
+{
+ hid_t core_fapl, stdio_fapl;
+ hid_t lapl_id, new_lapl_id, l_fapl, out_fapl;
+ int ret;
+
+ if(new_format)
+ TESTING("H5Pset/get_fapl() (w/new group format)")
+ else
+ TESTING("H5Pset/get_fapl()")
+
+ /* create fapl for the target file to be a "core" file */
+ core_fapl = h5_fileaccess();
+ if(H5Pset_fapl_core(core_fapl, (size_t)CORE_INCREMENT, TRUE) < 0)
+ TEST_ERROR
+
+ stdio_fapl = h5_fileaccess();
+ if(H5Pset_fapl_stdio(stdio_fapl) < 0)
+ TEST_ERROR
+
+ /* Set file access property list for link access to use the "stdio" driver */
+ if((lapl_id = H5Pcreate(H5P_LINK_ACCESS)) < 0) TEST_ERROR
+ if(H5Pset_elink_fapl(lapl_id, stdio_fapl) < 0) TEST_ERROR
+
+ /* Verify that the driver for the link's fapl is the "stdio" driver */
+ if((l_fapl = H5Pget_elink_fapl(lapl_id)) < 0) TEST_ERROR
+ if (H5Pget_driver(l_fapl) != H5FD_STDIO) TEST_ERROR
+ if (H5Pclose(l_fapl) < 0) TEST_ERROR
+
+ /* Set file access property list for link access to use the "core" driver */
+ if(H5Pset_elink_fapl(lapl_id, core_fapl) < 0) TEST_ERROR
+
+ /* Make a copy of the link access property */
+ if ((new_lapl_id = H5Pcopy(lapl_id)) < 0) TEST_ERROR
+
+ /* get the fapl set in lapl_id */
+ if (H5Pget(lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR
+ if (H5Pclose(lapl_id) < 0) TEST_ERROR
+
+ /* Try closing out_fapl should fail since H5Pclose(lapl_id) should also close its fapl */
+ H5E_BEGIN_TRY {
+ ret = H5Pclose(out_fapl);
+ } H5E_END_TRY;
+ if (ret != FAIL) TEST_ERROR
+
+ /* Verify that the driver for the copied link's fapl is the "core" driver */
+ if((l_fapl = H5Pget_elink_fapl(new_lapl_id)) < 0) TEST_ERROR
+ if (H5Pget_driver(l_fapl) != H5FD_CORE) TEST_ERROR
+
+ /* get the fapl set in new_lapl_id */
+ if (H5Pget(new_lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR
+ if (H5Premove(new_lapl_id, "external link fapl") < 0) TEST_ERROR
+
+ /* Try closing out_fapl should fail since the property is removed from new_lapl_id */
+ H5E_BEGIN_TRY {
+ ret = H5Pclose(out_fapl);
+ } H5E_END_TRY;
+ if (ret != FAIL) TEST_ERROR
+
+ if (H5Pclose(l_fapl) < 0) TEST_ERROR
+ if (H5Pclose(new_lapl_id) < 0) TEST_ERROR
+ if (H5Pclose(core_fapl) < 0) TEST_ERROR
+ if (H5Pclose(stdio_fapl) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Pclose(l_fapl);
+ H5Pclose(lapl_id);
+ H5Pclose(new_lapl_id);
+ H5Pclose(core_fapl);
+ H5Pclose(stdio_fapl);
+ } H5E_END_TRY;
+ return -1;
+ return -1;
+} /* end external_set_elink_fapl3() */
+
+
#ifdef H5_HAVE_WINDOW_PATH
/*-------------------------------------------------------------------------
@@ -11682,7 +12163,6 @@ main(void)
/* General tests... (on both old & new format groups */
-
nerrors += mklinks(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0;
@@ -11731,6 +12211,9 @@ main(void)
nerrors += external_link_abstar_cur(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_reltar(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_chdir(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_fapl1(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_fapl2(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_fapl3(new_format) < 0 ? 1 : 0;
#ifdef H5_HAVE_WINDOW_PATH
nerrors += external_link_win1(my_fapl, new_format) < 0 ? 1 : 0;
@@ -11740,7 +12223,6 @@ main(void)
nerrors += external_link_win5(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_win6(my_fapl, new_format) < 0 ? 1 : 0;
#endif
-
/* These tests assume that external links are a form of UD links,
* so assume that everything that passed for external links
* above has already been tested for UD links.
@@ -11802,7 +12284,9 @@ main(void)
exit(1);
}
printf("All link tests passed.\n");
+#ifdef OUT
h5_cleanup(FILENAME, fapl);
+#endif
/* clean up tmp directory created by external link tests */
HDrmdir(TMPDIR);
}