summaryrefslogtreecommitdiffstats
path: root/src/H5FDsplitter.c
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2021-09-29 18:28:12 (GMT)
committerGitHub <noreply@github.com>2021-09-29 18:28:12 (GMT)
commit3da0802c40d58759995916bf9d0880e19f0af44d (patch)
tree809ada78cec1cbaaf6ec2ace5b4429a56d0f6574 /src/H5FDsplitter.c
parent0fa5836cc5f037dd9f2cdd7f9a1051ddcc1c9ad0 (diff)
downloadhdf5-3da0802c40d58759995916bf9d0880e19f0af44d.zip
hdf5-3da0802c40d58759995916bf9d0880e19f0af44d.tar.gz
hdf5-3da0802c40d58759995916bf9d0880e19f0af44d.tar.bz2
VFD plugins (#602)
* Implement support for loading of Virtual File Drivers as plugins Fix plugin caching for VOL connector and VFD plugins Fix plugin iteration to skip paths that can't be opened * Enable dynamic loading of VFDs with HDF5_DRIVER environment variable * Temporarily disable error reporting during H5F_open double file open * Default to using HDstat in h5_get_file_size for unknown VFDs * Use macros for some environment variables that HDF5 interprets * Update "null" and "ctl testing" VFDs
Diffstat (limited to 'src/H5FDsplitter.c')
-rw-r--r--src/H5FDsplitter.c355
1 files changed, 293 insertions, 62 deletions
diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c
index 3113e8b..321973e 100644
--- a/src/H5FDsplitter.c
+++ b/src/H5FDsplitter.c
@@ -104,6 +104,10 @@ static int H5FD__copy_plist(hid_t fapl_id, hid_t *id_out_ptr);
/* Prototypes */
static herr_t H5FD__splitter_term(void);
+static herr_t H5FD__splitter_populate_config(H5FD_splitter_vfd_config_t *vfd_config,
+ H5FD_splitter_fapl_t * fapl_out);
+static herr_t H5FD__splitter_get_default_wo_path(char *new_path, size_t new_path_len,
+ const char *base_filename);
static hsize_t H5FD__splitter_sb_size(H5FD_t *_file);
static herr_t H5FD__splitter_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/);
static herr_t H5FD__splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf);
@@ -129,10 +133,12 @@ static herr_t H5FD__splitter_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closin
static herr_t H5FD__splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD__splitter_lock(H5FD_t *_file, hbool_t rw);
static herr_t H5FD__splitter_unlock(H5FD_t *_file);
+static herr_t H5FD__splitter_delete(const char *filename, hid_t fapl_id);
static herr_t H5FD__splitter_ctl(H5FD_t *_file, uint64_t op_code, uint64_t flags, const void *input,
void **output);
static const H5FD_class_t H5FD_splitter_g = {
+ H5FD_SPLITTER_VALUE, /* value */
"splitter", /* name */
MAXADDR, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
@@ -140,7 +146,7 @@ static const H5FD_class_t H5FD_splitter_g = {
H5FD__splitter_sb_size, /* sb_size */
H5FD__splitter_sb_encode, /* sb_encode */
H5FD__splitter_sb_decode, /* sb_decode */
- sizeof(H5FD_splitter_fapl_t), /* fapl_size */
+ sizeof(H5FD_splitter_fapl_t), /* fapl_size */
H5FD__splitter_fapl_get, /* fapl_get */
H5FD__splitter_fapl_copy, /* fapl_copy */
H5FD__splitter_fapl_free, /* fapl_free */
@@ -151,7 +157,7 @@ static const H5FD_class_t H5FD_splitter_g = {
H5FD__splitter_close, /* close */
H5FD__splitter_cmp, /* cmp */
H5FD__splitter_query, /* query */
- H5FD__splitter_get_type_map, /* get_type_map */
+ H5FD__splitter_get_type_map, /* get_type_map */
H5FD__splitter_alloc, /* alloc */
H5FD__splitter_free, /* free */
H5FD__splitter_get_eoa, /* get_eoa */
@@ -164,7 +170,7 @@ static const H5FD_class_t H5FD_splitter_g = {
H5FD__splitter_truncate, /* truncate */
H5FD__splitter_lock, /* lock */
H5FD__splitter_unlock, /* unlock */
- NULL, /* del */
+ H5FD__splitter_delete, /* del */
H5FD__splitter_ctl, /* ctl */
H5FD_FLMAP_DICHOTOMY /* fl_map */
};
@@ -312,57 +318,14 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config)
if (NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid property list")
- /* Make sure that the W/O channel supports write-only capability.
- * Some drivers (e.g. family or multi) do revision of the superblock
- * in-memory, causing problems in that channel.
- * Uses the feature flag H5FD_FEAT_DEFAULT_VFD_COMPATIBLE as the
- * determining attribute.
- */
- if (H5P_DEFAULT != vfd_config->wo_fapl_id) {
- H5FD_class_t * wo_driver = NULL;
- H5FD_driver_prop_t wo_driver_prop;
- H5P_genplist_t * wo_plist_ptr = NULL;
- unsigned long wo_driver_flags = 0;
-
- wo_plist_ptr = (H5P_genplist_t *)H5I_object(vfd_config->wo_fapl_id);
- if (NULL == wo_plist_ptr)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
- if (H5P_peek(wo_plist_ptr, H5F_ACS_FILE_DRV_NAME, &wo_driver_prop) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID & info")
- wo_driver = (H5FD_class_t *)H5I_object(wo_driver_prop.driver_id);
- if (NULL == wo_driver)
- HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid driver ID in file access property list")
- if (H5FD_driver_query(wo_driver, &wo_driver_flags) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't query VFD flags")
- if (0 == (H5FD_FEAT_DEFAULT_VFD_COMPATIBLE & wo_driver_flags))
- HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unsuitable W/O driver")
- } /* end if W/O VFD is non-default */
-
info = H5FL_CALLOC(H5FD_splitter_fapl_t);
if (NULL == info)
HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate file access property list struct")
- info->ignore_wo_errs = vfd_config->ignore_wo_errs;
- HDstrncpy(info->wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX + 1);
- info->wo_path[H5FD_SPLITTER_PATH_MAX] = '\0';
- HDstrncpy(info->log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX + 1);
- info->log_file_path[H5FD_SPLITTER_PATH_MAX] = '\0';
- info->rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */
- info->wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */
-
- /* Set non-default channel FAPL IDs in splitter configuration info */
- if (H5P_DEFAULT != vfd_config->rw_fapl_id) {
- if (FALSE == H5P_isa_class(vfd_config->rw_fapl_id, H5P_FILE_ACCESS))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list")
- info->rw_fapl_id = vfd_config->rw_fapl_id;
- }
- if (H5P_DEFAULT != vfd_config->wo_fapl_id) {
- if (FALSE == H5P_isa_class(vfd_config->wo_fapl_id, H5P_FILE_ACCESS))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list")
- info->wo_fapl_id = vfd_config->wo_fapl_id;
- }
+ if (H5FD__splitter_populate_config(vfd_config, info) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't setup driver configuration")
- ret_value = H5P_set_driver(plist_ptr, H5FD_SPLITTER, info);
+ ret_value = H5P_set_driver(plist_ptr, H5FD_SPLITTER, info, NULL);
done:
if (info)
@@ -386,9 +349,10 @@ done:
herr_t
H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config /*out*/)
{
- const H5FD_splitter_fapl_t *fapl_ptr = NULL;
- H5P_genplist_t * plist_ptr = NULL;
- herr_t ret_value = SUCCEED;
+ const H5FD_splitter_fapl_t *fapl_ptr = NULL;
+ H5FD_splitter_fapl_t * default_fapl = NULL;
+ H5P_genplist_t * plist_ptr = NULL;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "ix", fapl_id, config);
@@ -414,8 +378,14 @@ H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config /*out*/)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
if (H5FD_SPLITTER != H5P_peek_driver(plist_ptr))
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver")
- if (NULL == (fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr)))
- HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unable to get specific-driver info")
+ fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr);
+ if (NULL == fapl_ptr) {
+ if (NULL == (default_fapl = H5FL_CALLOC(H5FD_splitter_fapl_t)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate file access property list struct")
+ if (H5FD__splitter_populate_config(NULL, default_fapl) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't initialize driver configuration info")
+ fapl_ptr = default_fapl;
+ }
HDstrncpy(config->wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX + 1);
HDstrncpy(config->log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX + 1);
@@ -428,10 +398,188 @@ H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config /*out*/)
HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't copy W/O FAPL");
done:
+ if (default_fapl)
+ H5FL_FREE(H5FD_splitter_fapl_t, default_fapl);
+
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_fapl_splitter() */
/*-------------------------------------------------------------------------
+ * Function: H5FD__splitter_populate_config
+ *
+ * Purpose: Populates a H5FD_splitter_fapl_t structure with the provided
+ * values, supplying defaults where values are not provided.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD__splitter_populate_config(H5FD_splitter_vfd_config_t *vfd_config, H5FD_splitter_fapl_t *fapl_out)
+{
+ H5P_genplist_t *def_plist;
+ H5P_genplist_t *plist;
+ hbool_t free_config = FALSE;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_STATIC
+
+ HDassert(fapl_out);
+
+ HDmemset(fapl_out, 0, sizeof(H5FD_splitter_fapl_t));
+
+ if (!vfd_config) {
+ vfd_config = H5MM_calloc(sizeof(H5FD_splitter_vfd_config_t));
+ if (NULL == vfd_config)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate file access property list struct")
+
+ vfd_config->magic = H5FD_SPLITTER_MAGIC;
+ vfd_config->version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
+ vfd_config->rw_fapl_id = H5P_DEFAULT;
+ vfd_config->wo_fapl_id = H5P_DEFAULT;
+
+ free_config = TRUE;
+ }
+
+ /* Make sure that the W/O channel supports write-only capability.
+ * Some drivers (e.g. family or multi) do revision of the superblock
+ * in-memory, causing problems in that channel.
+ * Uses the feature flag H5FD_FEAT_DEFAULT_VFD_COMPATIBLE as the
+ * determining attribute.
+ */
+ if (H5P_DEFAULT != vfd_config->wo_fapl_id) {
+ H5FD_class_t * wo_driver = NULL;
+ H5FD_driver_prop_t wo_driver_prop;
+ H5P_genplist_t * wo_plist_ptr = NULL;
+ unsigned long wo_driver_flags = 0;
+
+ wo_plist_ptr = (H5P_genplist_t *)H5I_object(vfd_config->wo_fapl_id);
+ if (NULL == wo_plist_ptr)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
+ if (H5P_peek(wo_plist_ptr, H5F_ACS_FILE_DRV_NAME, &wo_driver_prop) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID & info")
+ wo_driver = (H5FD_class_t *)H5I_object(wo_driver_prop.driver_id);
+ if (NULL == wo_driver)
+ HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid driver ID in file access property list")
+ if (H5FD_driver_query(wo_driver, &wo_driver_flags) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't query VFD flags")
+ if (0 == (H5FD_FEAT_DEFAULT_VFD_COMPATIBLE & wo_driver_flags))
+ HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unsuitable W/O driver")
+ } /* end if W/O VFD is non-default */
+
+ fapl_out->ignore_wo_errs = vfd_config->ignore_wo_errs;
+ HDstrncpy(fapl_out->wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX + 1);
+ fapl_out->wo_path[H5FD_SPLITTER_PATH_MAX] = '\0';
+ HDstrncpy(fapl_out->log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX + 1);
+ fapl_out->log_file_path[H5FD_SPLITTER_PATH_MAX] = '\0';
+ fapl_out->rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */
+ fapl_out->wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */
+
+ if (NULL == (def_plist = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
+
+ /* Set non-default channel FAPL IDs in splitter configuration info */
+ if (H5P_DEFAULT != vfd_config->rw_fapl_id) {
+ if (FALSE == H5P_isa_class(vfd_config->rw_fapl_id, H5P_FILE_ACCESS))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list")
+ fapl_out->rw_fapl_id = vfd_config->rw_fapl_id;
+ }
+ else {
+ /* Use copy of default file access property list for R/W channel FAPL ID.
+ * The Sec2 driver is explicitly set on the FAPL ID, as the default
+ * driver might have been replaced with the Splitter VFD, which
+ * would cause recursion badness.
+ */
+ if ((fapl_out->rw_fapl_id = H5P_copy_plist(def_plist, FALSE)) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTCOPY, FAIL, "can't copy property list")
+ if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_out->rw_fapl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
+ if (H5P_set_driver_by_value(plist, H5_VFD_SEC2, NULL, TRUE) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set default driver on R/W channel FAPL")
+ }
+ if (H5P_DEFAULT != vfd_config->wo_fapl_id) {
+ if (FALSE == H5P_isa_class(vfd_config->wo_fapl_id, H5P_FILE_ACCESS))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list")
+ fapl_out->wo_fapl_id = vfd_config->wo_fapl_id;
+ }
+ else {
+ /* Use copy of default file access property list for W/O channel FAPL ID.
+ * The Sec2 driver is explicitly set on the FAPL ID, as the default
+ * driver might have been replaced with the Splitter VFD, which
+ * would cause recursion badness.
+ */
+ if ((fapl_out->wo_fapl_id = H5P_copy_plist(def_plist, FALSE)) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTCOPY, FAIL, "can't copy property list")
+ if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_out->wo_fapl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
+ if (H5P_set_driver_by_value(plist, H5_VFD_SEC2, NULL, TRUE) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set default driver on R/W channel FAPL")
+ }
+
+done:
+ if (free_config && vfd_config)
+ H5MM_free(vfd_config);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD__splitter_populate_config() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD__splitter_get_default_wo_path
+ *
+ * Purpose: Given a base filename, returns a default filename for the
+ * W/O channel file by appending '_wo' to the base file name.
+ *
+ * Return: Non-negative on Success/Negative on Failure
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD__splitter_get_default_wo_path(char *new_path, size_t new_path_len, const char *base_filename)
+{
+ const char *suffix = "_wo";
+ size_t old_filename_len = 0;
+ char * file_extension = NULL;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_STATIC
+
+ HDassert(new_path);
+ HDassert(base_filename);
+
+ /* Check that output buffer can hold base filename + `_wo` suffix */
+ old_filename_len = HDstrlen(base_filename);
+ if (old_filename_len > H5FD_SPLITTER_PATH_MAX - HDstrlen(suffix) - 1)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "filename exceeds max length")
+
+ /* Determine if filename contains a ".h5" extension. */
+ if ((file_extension = strstr(base_filename, ".h5"))) {
+ /* Insert the suffix between the filename and ".h5" extension. */
+ HDstrcpy(new_path, base_filename);
+ file_extension = strstr(new_path, ".h5");
+ HDsprintf(file_extension, "%s%s", suffix, ".h5");
+ }
+ else if ((file_extension = strrchr(base_filename, '.'))) {
+ char *new_extension_loc = NULL;
+
+ /* If the filename doesn't contain a ".h5" extension, but contains
+ * AN extension, just insert the suffix before that extension.
+ */
+ HDstrcpy(new_path, base_filename);
+ new_extension_loc = strrchr(new_path, '.');
+ HDsprintf(new_extension_loc, "%s%s", suffix, file_extension);
+ }
+ else {
+ /* If the filename doesn't contain an extension at all, just insert
+ * the suffix at the end of the filename.
+ */
+ HDsnprintf(new_path, new_path_len, "%s%s", base_filename, suffix);
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD__splitter_get_default_wo_path() */
+
+/*-------------------------------------------------------------------------
* Function: H5FD__splitter_flush
*
* Purpose: Flushes all data to disk for both channels.
@@ -658,10 +806,11 @@ done:
static H5FD_t *
H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, haddr_t maxaddr)
{
- H5FD_splitter_t * file_ptr = NULL; /* Splitter VFD info */
- const H5FD_splitter_fapl_t *fapl_ptr = NULL; /* Driver-specific property list */
- H5P_genplist_t * plist_ptr = NULL;
- H5FD_t * ret_value = NULL;
+ H5FD_splitter_t * file_ptr = NULL; /* Splitter VFD info */
+ const H5FD_splitter_fapl_t *fapl_ptr = NULL; /* Driver-specific property list */
+ H5FD_splitter_fapl_t * default_fapl = NULL;
+ H5P_genplist_t * plist_ptr = NULL;
+ H5FD_t * ret_value = NULL;
FUNC_ENTER_STATIC
@@ -674,8 +823,7 @@ H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, ha
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr")
if (ADDR_OVERFLOW(maxaddr))
HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr")
- if ((H5P_FILE_ACCESS_DEFAULT == splitter_fapl_id) || (H5FD_SPLITTER != H5Pget_driver(splitter_fapl_id)))
- /* presupposes that H5P_FILE_ACCESS_DEFAULT is not a splitter */
+ if (H5FD_SPLITTER != H5Pget_driver(splitter_fapl_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "driver is not splitter")
file_ptr = (H5FD_splitter_t *)H5FL_CALLOC(H5FD_splitter_t);
@@ -689,8 +837,20 @@ H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, ha
if (NULL == plist_ptr)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr);
- if (NULL == fapl_ptr)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get VFL driver info")
+ if (NULL == fapl_ptr) {
+ if (NULL == (default_fapl = H5FL_CALLOC(H5FD_splitter_fapl_t)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate file access property list struct")
+ if (H5FD__splitter_populate_config(NULL, default_fapl) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, NULL, "can't initialize driver configuration info")
+
+ /* If W/O path is not set, use base filename with '_wo' suffix */
+ if (*default_fapl->wo_path == '\0')
+ if (H5FD__splitter_get_default_wo_path(default_fapl->wo_path, H5FD_SPLITTER_PATH_MAX + 1, name) <
+ 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, NULL, "can't generate default filename for W/O channel")
+
+ fapl_ptr = default_fapl;
+ }
/* Copy simpler info */
HDstrncpy(file_ptr->fa.wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX + 1);
@@ -726,6 +886,9 @@ H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, ha
ret_value = (H5FD_t *)file_ptr;
done:
+ if (default_fapl)
+ H5FL_FREE(H5FD_splitter_fapl_t, default_fapl);
+
if (NULL == ret_value) {
if (file_ptr) {
if (H5I_INVALID_HID != file_ptr->fa.rw_fapl_id)
@@ -1339,6 +1502,74 @@ done:
} /* end H5FD__splitter_free() */
/*-------------------------------------------------------------------------
+ * Function: H5FD__splitter_delete
+ *
+ * Purpose: Delete a file
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD__splitter_delete(const char *filename, hid_t fapl_id)
+{
+ const H5FD_splitter_fapl_t *fapl_ptr = NULL;
+ H5FD_splitter_fapl_t * default_fapl = NULL;
+ H5P_genplist_t * plist;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_STATIC
+
+ HDassert(filename);
+
+ /* Get the driver info */
+ if (H5P_FILE_ACCESS_DEFAULT == fapl_id) {
+ if (NULL == (default_fapl = H5FL_CALLOC(H5FD_splitter_fapl_t)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate file access property list struct")
+ if (H5FD__splitter_populate_config(NULL, default_fapl) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't initialize driver configuration info")
+
+ /* If W/O path is not set, use base filename with '_wo' suffix */
+ if (*default_fapl->wo_path == '\0')
+ if (H5FD__splitter_get_default_wo_path(default_fapl->wo_path, H5FD_SPLITTER_PATH_MAX + 1,
+ filename) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't generate default filename for W/O channel")
+
+ fapl_ptr = default_fapl;
+ }
+ else {
+ 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 == (fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist))) {
+ if (NULL == (default_fapl = H5FL_CALLOC(H5FD_splitter_fapl_t)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL,
+ "unable to allocate file access property list struct")
+ if (H5FD__splitter_populate_config(NULL, default_fapl) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't initialize driver configuration info")
+
+ /* If W/O path is not set, use base filename with '_wo' suffix */
+ if (*default_fapl->wo_path == '\0')
+ if (H5FD__splitter_get_default_wo_path(default_fapl->wo_path, H5FD_SPLITTER_PATH_MAX + 1,
+ filename) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't generate default filename for W/O channel")
+
+ fapl_ptr = default_fapl;
+ }
+ }
+
+ if (H5FDdelete(filename, fapl_ptr->rw_fapl_id) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete file")
+ if (H5FDdelete(fapl_ptr->wo_path, fapl_ptr->wo_fapl_id) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete W/O channel file")
+
+done:
+ if (default_fapl)
+ H5FL_FREE(H5FD_splitter_fapl_t, default_fapl);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+}
+
+/*-------------------------------------------------------------------------
* Function: H5FD__splitter_log_error
*
* Purpose: Log an error from the W/O channel appropriately.