summaryrefslogtreecommitdiffstats
path: root/src/H5FDcore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5FDcore.c')
-rw-r--r--src/H5FDcore.c78
1 files changed, 73 insertions, 5 deletions
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index 5fe845c..7ae89c6 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -148,8 +148,11 @@ static herr_t H5FD__core_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD__core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD__core_lock(H5FD_t *_file, hbool_t rw);
static herr_t H5FD__core_unlock(H5FD_t *_file);
+static herr_t H5FD__core_delete(const char *filename, hid_t fapl_id);
+static inline const H5FD_core_fapl_t *H5FD__core_get_default_config(void);
static const H5FD_class_t H5FD_core_g = {
+ H5FD_CORE_VALUE, /* value */
"core", /* name */
MAXADDR, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
@@ -185,10 +188,16 @@ static const H5FD_class_t H5FD_core_g = {
H5FD__core_truncate, /* truncate */
H5FD__core_lock, /* lock */
H5FD__core_unlock, /* unlock */
+ H5FD__core_delete, /* del */
NULL, /* ctl */
H5FD_FLMAP_DICHOTOMY /* fl_map */
};
+/* Default configurations, if none provided */
+static const H5FD_core_fapl_t H5FD_core_default_config_g = {H5_MB, TRUE, H5FD_CORE_WRITE_TRACKING_FLAG,
+ H5FD_CORE_WRITE_TRACKING_PAGE_SIZE};
+static const H5FD_core_fapl_t H5FD_core_default_paged_config_g = {H5_MB, TRUE, TRUE, (size_t)4096};
+
/* Define a free list to manage the region type */
H5FL_DEFINE(H5FD_core_region_t);
@@ -411,6 +420,32 @@ done:
} /* end H5FD__core_write_to_bstore() */
/*-------------------------------------------------------------------------
+ * Function: H5FD__core_get_default_config
+ *
+ * Purpose: Retrieves a default configuration for this VFD when no
+ * configuration information has been provided.
+ *
+ * Return: Valid Core VFD configuration information pointer (can't
+ * fail)
+ *
+ *-------------------------------------------------------------------------
+ */
+static inline const H5FD_core_fapl_t *
+H5FD__core_get_default_config(void)
+{
+ char *driver = HDgetenv(HDF5_DRIVER);
+
+ if (driver) {
+ if (!HDstrcmp(driver, "core"))
+ return &H5FD_core_default_config_g;
+ else if (!HDstrcmp(driver, "core_paged"))
+ return &H5FD_core_default_paged_config_g;
+ }
+
+ return &H5FD_core_default_config_g;
+} /* end H5FD__core_get_default_config() */
+
+/*-------------------------------------------------------------------------
* Function: H5FD__init_package
*
* Purpose: Initializes any interface-specific data or routines.
@@ -428,7 +463,7 @@ H5FD__init_package(void)
FUNC_ENTER_STATIC
/* Check the use disabled file locks environment variable */
- lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING");
+ lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING);
if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT"))
ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */
else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1")))
@@ -531,7 +566,7 @@ H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size)
if (H5FD_CORE != H5P_peek_driver(plist))
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver")
if (NULL == (old_fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist)))
- HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info")
+ old_fa = H5FD__core_get_default_config();
/* Set VFD info values */
HDmemset(&fa, 0, sizeof(H5FD_core_fapl_t));
@@ -541,7 +576,7 @@ H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size)
fa.page_size = page_size;
/* Set the property values & the driver for the FAPL */
- if (H5P_set_driver(plist, H5FD_CORE, &fa) < 0)
+ if (H5P_set_driver(plist, H5FD_CORE, &fa, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD as driver")
done:
@@ -625,7 +660,7 @@ H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store)
fa.page_size = H5FD_CORE_WRITE_TRACKING_PAGE_SIZE;
/* Set the property values & the driver for the FAPL */
- if (H5P_set_driver(plist, H5FD_CORE, &fa) < 0)
+ if (H5P_set_driver(plist, H5FD_CORE, &fa, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD as driver")
done:
@@ -750,7 +785,7 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr
if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
if (NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist)))
- HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info")
+ fa = H5FD__core_get_default_config();
/* Build the open flags */
o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY;
@@ -1713,3 +1748,36 @@ H5FD__core_unlock(H5FD_t *_file)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__core_unlock() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD__core_delete
+ *
+ * Purpose: Delete a file
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD__core_delete(const char *filename, hid_t fapl_id)
+{
+ const H5FD_core_fapl_t *fa = NULL;
+ H5P_genplist_t * plist; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ HDassert(filename);
+
+ if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
+ if (NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist)))
+ fa = H5FD__core_get_default_config();
+
+ if (fa->backing_store)
+ if (HDremove(filename) < 0)
+ HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete file")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD__core_delete() */