summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5F.c23
-rw-r--r--src/H5FDlog.c10
-rw-r--r--src/H5Fint.c21
-rw-r--r--src/H5VLnative.c3
-rw-r--r--test/tfile.c46
-rw-r--r--test/vfd.c110
6 files changed, 171 insertions, 42 deletions
diff --git a/src/H5F.c b/src/H5F.c
index b2a1b55..dbef722 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -247,23 +247,38 @@ hid_t
H5Fget_access_plist(hid_t file_id)
{
H5VL_t *vol_plugin;
- void *obj;
- hid_t ret_value; /* Return value */
+ void *file;
+ void *vol_info = NULL;
+ H5P_genplist_t *plist = NULL; /* Property list pointer */
+ hid_t fapl_id = FAIL, ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", file_id);
/* get the file object */
- if(NULL == (obj = (void *)H5I_object(file_id)))
+ if(NULL == (file = (void *)H5I_object(file_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
/* get the plugin pointer */
if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
- if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_FAPL, H5AC_dxpl_id, H5_EVENT_STACK_NULL, &ret_value) < 0)
+ if(H5VL_file_get(file, vol_plugin, H5VL_FILE_GET_FAPL, H5AC_dxpl_id,
+ H5_EVENT_STACK_NULL, &fapl_id, &vol_info) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file creation properties")
+ /* Set the vol properties for the list */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(fapl_id, H5I_GENPROP_LST)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+ if(H5P_set_vol(plist, vol_plugin->cls, vol_info) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol")
+
+ ret_value = fapl_id;
+
done:
+ if(ret_value < 0 && fapl_id != FAIL)
+ if(H5I_dec_ref(fapl_id) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "decrementing plist ID failed")
+
FUNC_LEAVE_API(ret_value)
} /* end H5Fget_access_plist() */
diff --git a/src/H5FDlog.c b/src/H5FDlog.c
index cb04b80..fdc2c92 100644
--- a/src/H5FDlog.c
+++ b/src/H5FDlog.c
@@ -598,6 +598,11 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
/* Get the flags for logging */
file->fa.flags = fa->flags;
+ if(fa->logfile)
+ file->fa.logfile = HDstrdup(fa->logfile);
+ else
+ file->fa.logfile = NULL;
+ file->fa.buf_size = fa->buf_size;
/* Check if we are doing any logging at all */
if(file->fa.flags != 0) {
@@ -798,6 +803,11 @@ H5FD_log_close(H5FD_t *_file)
HDfclose(file->logfp);
} /* end if */
+ if(file->fa.logfile) {
+ HDfree(file->fa.logfile);
+ file->fa.logfile = NULL;
+ }
+
/* Release the file info */
file = H5FL_FREE(H5FD_log_t, file);
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 6fe465a..1fe046f 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -634,26 +634,32 @@ done:
htri_t
H5F_is_hdf5(const char *name, hid_t fapl_id)
{
- H5FD_t *file = NULL; /* Low-level file struct */
+ H5F_t *file = NULL; /* Low-level file struct */
haddr_t sig_addr; /* Addess of hdf5 file signature */
htri_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Open the file at the virtual file layer */
- if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF)))
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file")
+ //if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF)))
+ //HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file")
+
+ /* Open the file */
+ if(NULL == (file = H5F_open(name, H5F_ACC_RDONLY, H5P_FILE_CREATE_DEFAULT,
+ fapl_id, H5AC_ind_dxpl_id)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FALSE, "unable to open file")
/* The file is an hdf5 file if the hdf5 file signature can be found */
- if(H5FD_locate_signature(file, H5AC_ind_dxpl_g, &sig_addr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature")
+ if(H5FD_locate_signature(file->shared->lf, H5AC_ind_dxpl_g, &sig_addr) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FALSE, "unable to locate file signature")
ret_value = (HADDR_UNDEF != sig_addr);
done:
/* Close the file */
if(file)
- if(H5FD_close(file) < 0 && ret_value >= 0)
- HDONE_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
+ //if(H5FD_close(file) < 0 && ret_value >= 0)
+ if(H5F_close(file) < 0 && ret_value >= 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_is_hdf5() */
@@ -1338,7 +1344,6 @@ H5F_close(H5F_t *f)
/* Sanity check */
HDassert(f);
- HDassert(f->id_exists); /* This routine should only be called when a file ID's ref count drops to zero */
/* Perform checks for "semi" file close degree here, since closing the
* file is not allowed if there are objects still open */
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index 6dacb5e..c649650 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -2347,6 +2347,8 @@ H5VL_native_file_close(void *file, hid_t UNUSED dxpl_id, void UNUSED **req)
FUNC_ENTER_NOAPI_NOINIT
+ HDassert(f->id_exists); /* This routine should only be called when a file ID's ref count drops to zero */
+
/* Flush file if this is the last reference to this id and we have write
* intent, unless it will be flushed by the "shared" file being closed.
* This is only necessary to replicate previous behaviour, and could be
@@ -2362,6 +2364,7 @@ H5VL_native_file_close(void *file, hid_t UNUSED dxpl_id, void UNUSED **req)
if(H5F_flush(f, H5AC_dxpl_id, FALSE) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache")
} /* end if */
+
/* close the file */
if(H5F_close(f) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file")
diff --git a/test/tfile.c b/test/tfile.c
index 213c6b0..974a388 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -1577,6 +1577,38 @@ test_file_freespace(void)
VERIFY(mod_filesize, empty_filesize, "H5Fget_freespace");
} /* end test_file_freespace() */
+static void
+test_file_isaccessible_helper(const char *filename, htri_t expected)
+{
+ htri_t status; /* Whether a file is an HDF5 file */
+ hid_t fapl; /* File access property list */
+ herr_t ret;
+
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Verify that the file is an HDF5 file with the sec2 default driver*/
+ status = H5Fis_accessible(filename, fapl);
+ VERIFY(status, expected, "H5Fis_accessible");
+
+ /* Verify that the file is an HDF5 file with the core VFD*/
+ ret = H5Pset_fapl_core(fapl, (size_t)1024, 0);
+ CHECK(ret, FAIL, "H5Pset_fapl_core");
+ status = H5Fis_accessible(filename, fapl);
+ VERIFY(status, expected, "H5Fis_accessible");
+
+#ifdef H5_HAVE_DIRECT
+ /* Verify that the file is an HDF5 file with the direct VFD*/
+ ret = H5Pset_fapl_direct(fapl, 1024, 4096, 8*4096);
+ CHECK(ret, FAIL, "H5Pset_fapl_direct");
+ status = H5Fis_accessible(filename, fapl);
+ VERIFY(status, expected, "H5Fis_accessible");
+#endif
+
+ ret = H5Pclose (fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+}
+
/****************************************************************
**
** test_file_isaccessible(): low-level file test routine.
@@ -1593,7 +1625,6 @@ test_file_isaccessible(void)
ssize_t nbytes; /* Number of bytes written */
unsigned u; /* Local index variable */
unsigned char buf[1024]; /* Buffer of data to write */
- htri_t status; /* Whether a file is an HDF5 file */
herr_t ret;
/* Output message about test being performed */
@@ -1608,9 +1639,7 @@ test_file_isaccessible(void)
CHECK(ret, FAIL, "H5Fclose");
/* Verify that the file is an HDF5 file */
- status = H5Fis_accessible(FILE1, H5P_DEFAULT);
- VERIFY(status, TRUE, "H5Fis_accessible");
-
+ test_file_isaccessible_helper(FILE1, TRUE);
/* Create a file creation property list with a non-default user block size */
fcpl = H5Pcreate(H5P_FILE_CREATE);
@@ -1632,9 +1661,7 @@ test_file_isaccessible(void)
CHECK(ret, FAIL, "H5Fclose");
/* Verify that the file is an HDF5 file */
- status = H5Fis_accessible(FILE1, H5P_DEFAULT);
- VERIFY(status, TRUE, "H5Fis_accessible");
-
+ test_file_isaccessible_helper(FILE1, TRUE);
/* Create non-HDF5 file and check it */
fd=HDopen(FILE1, O_RDWR|O_CREAT|O_TRUNC, 0666);
@@ -1652,9 +1679,8 @@ test_file_isaccessible(void)
ret = HDclose(fd);
CHECK(ret, FAIL, "HDclose");
- /* Verify that the file is not an HDF5 file */
- status = H5Fis_accessible(FILE1, H5P_DEFAULT);
- VERIFY(status, FALSE, "H5Fis_accessible");
+ /* Verify that the file is NOT an HDF5 file */
+ test_file_isaccessible_helper(FILE1, FALSE);
} /* end test_file_isaccessible() */
diff --git a/test/vfd.c b/test/vfd.c
index 4ece2ba..f525679 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -106,10 +106,6 @@ test_sec2(void)
if(H5FD_SEC2 != H5Pget_driver(access_fapl))
TEST_ERROR;
- /* ...and close the property list */
- if(H5Pclose(access_fapl) < 0)
- TEST_ERROR;
-
/* Check file handle API */
if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0)
TEST_ERROR;
@@ -129,6 +125,14 @@ test_sec2(void)
if(H5Fclose(file) < 0)
TEST_ERROR;
+ /* Verify that the file is an HDF5 file */
+ if(H5Fis_accessible(filename, access_fapl) != TRUE)
+ TEST_ERROR;
+
+ /* ...and close the property list */
+ if(H5Pclose(access_fapl) < 0)
+ TEST_ERROR;
+
h5_cleanup(FILENAME, fapl);
PASSED();
return 0;
@@ -216,10 +220,6 @@ test_direct(void)
if(H5FD_DIRECT != H5Pget_driver(access_fapl))
TEST_ERROR;
- /* ...and close the property list */
- if (H5Pclose(access_fapl) < 0)
- TEST_ERROR;
-
/* Check file handle API */
if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0)
TEST_ERROR;
@@ -333,6 +333,14 @@ test_direct(void)
HDassert(check);
HDfree(check);
+ /* Verify that the file is an HDF5 file */
+ if(H5Fis_accessible(filename, access_fapl) != TRUE)
+ TEST_ERROR;
+
+ /* ...and close the property list */
+ if(H5Pclose(access_fapl) < 0)
+ TEST_ERROR;
+
h5_cleanup(FILENAME, fapl);
PASSED();
return 0;
@@ -438,12 +446,19 @@ test_core(void)
if(H5Fclose(file) < 0)
TEST_ERROR;
+ /* Verify that the file is an HDF5 file */
+ if(H5Fis_accessible(filename, fapl) != TRUE)
+ TEST_ERROR;
/* Open the file with backing store off for read and write.
* Changes won't be saved in file. */
if(H5Pset_fapl_core(fapl, (size_t)CORE_INCREMENT, FALSE) < 0)
TEST_ERROR;
+ /* Verify that the file is an HDF5 file */
+ if(H5Fis_accessible(filename, fapl) != TRUE)
+ TEST_ERROR;
+
if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
TEST_ERROR;
@@ -501,6 +516,10 @@ test_core(void)
if(H5Fclose(file) < 0)
TEST_ERROR;
+ /* Verify that the file is an HDF5 file */
+ if(H5Fis_accessible(filename, fapl) != TRUE)
+ TEST_ERROR;
+
/* Open the file with backing store on for read and write.
* Changes will be saved in file. */
if(H5Pset_fapl_core(fapl, (size_t)CORE_INCREMENT, TRUE) < 0)
@@ -610,6 +629,12 @@ test_family_opens(char *fname, hid_t fa_pl)
/* Case 1: reopen file with 1st member file name and default property list */
HDsnprintf(first_name, sizeof(first_name), fname, 0);
+ /* Verify that the file is not accessible */
+ H5E_BEGIN_TRY {
+ if(H5Fis_accessible(first_name, H5P_DEFAULT) != FALSE)
+ TEST_ERROR;
+ } H5E_END_TRY;
+
H5E_BEGIN_TRY {
file = H5Fopen(first_name, H5F_ACC_RDWR, H5P_DEFAULT);
} H5E_END_TRY;
@@ -617,6 +642,11 @@ test_family_opens(char *fname, hid_t fa_pl)
TEST_ERROR
/* Case 2: reopen file with correct name template but default property list */
+
+ /* Verify that the file is not accessible */
+ if(H5Fis_accessible(fname, H5P_DEFAULT) != FALSE)
+ TEST_ERROR;
+
H5E_BEGIN_TRY {
file = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT);
} H5E_END_TRY;
@@ -627,6 +657,10 @@ test_family_opens(char *fname, hid_t fa_pl)
if(H5Pset_fapl_family(fa_pl, (hsize_t)128, H5P_DEFAULT) < 0)
TEST_ERROR;
+ /* Verify that the file is not accessible */
+ if(H5Fis_accessible(fname, fa_pl) != FALSE)
+ TEST_ERROR;
+
H5E_BEGIN_TRY {
file = H5Fopen(fname, H5F_ACC_RDWR, fa_pl);
} H5E_END_TRY;
@@ -644,6 +678,10 @@ test_family_opens(char *fname, hid_t fa_pl)
if(H5Pset_fapl_family(fa_pl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0)
TEST_ERROR;
+ /* Verify that the file is not accessible */
+ if(H5Fis_accessible(wrong_name, fa_pl) != FALSE)
+ TEST_ERROR;
+
H5E_BEGIN_TRY {
file = H5Fopen(wrong_name, H5F_ACC_RDWR, fa_pl);
} H5E_END_TRY;
@@ -707,6 +745,10 @@ test_family(void)
if(H5Pset_fapl_family(fapl, (hsize_t)H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0)
TEST_ERROR;
+ /* Verify that the file is accessible with correct fapl */
+ if(H5Fis_accessible(filename, fapl) != TRUE)
+ TEST_ERROR;
+
if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
TEST_ERROR;
@@ -871,6 +913,10 @@ test_family_compat(void)
HDsnprintf(pathname_individual, sizeof(pathname_individual), pathname, counter);
}
+ /* Verify that the file is accessible */
+ if(H5Fis_accessible(newname, fapl) != TRUE)
+ TEST_ERROR;
+
/* Make sure we can open the file. Use the read and write mode to flush the
* superblock. */
if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0)
@@ -939,6 +985,10 @@ test_multi_opens(char *fname)
HDsnprintf(super_name, sizeof(super_name), "%%s-%c.h5", 's');
HDsnprintf(sf_name, sizeof(sf_name), super_name, fname);
+ /* Verify that the file is accessible */
+ if(H5Fis_accessible(sf_name, H5P_DEFAULT) != FALSE)
+ return -1;
+
H5E_BEGIN_TRY {
file = H5Fopen(sf_name, H5F_ACC_RDWR, H5P_DEFAULT);
} H5E_END_TRY;
@@ -1031,6 +1081,10 @@ test_multi(void)
if(test_multi_opens(filename) < 0)
TEST_ERROR;
+ /* Verify that the file is an HDF5 file */
+ if(H5Fis_accessible(filename, fapl) != TRUE)
+ TEST_ERROR;
+
/* Reopen the file */
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
TEST_ERROR;
@@ -1232,6 +1286,10 @@ test_multi_compat(void)
sprintf(newname_r, "%s-%c.h5", FILENAME[9], 'r');
h5_make_local_copy(filename_r, newname_r);
+ /* Verify that the file is accessible */
+ if(H5Fis_accessible(newname, fapl) != TRUE)
+ TEST_ERROR;
+
/* Reopen the file for read only. Verify 1.8 library can open file
* created with 1.6 library. */
if((file=H5Fopen(newname, H5F_ACC_RDONLY, fapl)) < 0)
@@ -1367,10 +1425,6 @@ test_log(void)
if(H5FD_LOG != H5Pget_driver(access_fapl))
TEST_ERROR;
- /* ...and close the property list */
- if(H5Pclose(access_fapl) < 0)
- TEST_ERROR;
-
/* Check file handle API */
if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0)
TEST_ERROR;
@@ -1390,6 +1444,14 @@ test_log(void)
if(H5Fclose(file) < 0)
TEST_ERROR;
+ /* Verify that the file is accessible with log vfd */
+ if(H5Fis_accessible(filename, access_fapl) != TRUE)
+ TEST_ERROR;
+
+ /* ...and close the property list */
+ if(H5Pclose(access_fapl) < 0)
+ TEST_ERROR;
+
h5_cleanup(FILENAME, fapl);
PASSED();
return 0;
@@ -1445,10 +1507,6 @@ test_stdio(void)
if(H5FD_STDIO != H5Pget_driver(access_fapl))
TEST_ERROR;
- /* ...and close the property list */
- if(H5Pclose(access_fapl) < 0)
- TEST_ERROR;
-
/* Check file handle API */
if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0)
TEST_ERROR;
@@ -1468,6 +1526,14 @@ test_stdio(void)
if(H5Fclose(file) < 0)
TEST_ERROR;
+ /* Verify that the file is accessible with stdio vfd */
+ if(H5Fis_accessible(filename, access_fapl) != TRUE)
+ TEST_ERROR;
+
+ /* ...and close the property list */
+ if(H5Pclose(access_fapl) < 0)
+ TEST_ERROR;
+
h5_cleanup(FILENAME, fapl);
PASSED();
return 0;
@@ -1535,10 +1601,6 @@ test_windows(void)
if(H5FD_WINDOWS!= H5Pget_driver(access_fapl))
TEST_ERROR;
- /* ...and close the property list */
- if(H5Pclose(access_fapl) < 0)
- TEST_ERROR;
-
/* Check file handle API */
if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0)
TEST_ERROR;
@@ -1558,6 +1620,14 @@ test_windows(void)
if(H5Fclose(file) < 0)
TEST_ERROR;
+ /* Verify that the file is accessible with windows vfd */
+ if(H5Fis_accessible(filename, access_fapl) != TRUE)
+ TEST_ERROR;
+
+ /* ...and close the property list */
+ if(H5Pclose(access_fapl) < 0)
+ TEST_ERROR;
+
h5_cleanup(FILENAME, fapl);
PASSED();
return 0;