summaryrefslogtreecommitdiffstats
path: root/src/H5FDdirect.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5FDdirect.c')
-rw-r--r--src/H5FDdirect.c84
1 files changed, 60 insertions, 24 deletions
diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c
index 7cca09f..8c5001c 100644
--- a/src/H5FDdirect.c
+++ b/src/H5FDdirect.c
@@ -120,6 +120,8 @@ typedef struct H5FD_direct_t {
/* Prototypes */
static herr_t H5FD__direct_term(void);
+static herr_t H5FD__direct_populate_config(size_t boundary, size_t block_size, size_t cbuf_size,
+ H5FD_direct_fapl_t *fa_out);
static void * H5FD__direct_fapl_get(H5FD_t *file);
static void * H5FD__direct_fapl_copy(const void *_old_fa);
static H5FD_t *H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr);
@@ -140,6 +142,7 @@ static herr_t H5FD__direct_unlock(H5FD_t *_file);
static herr_t H5FD__direct_delete(const char *filename, hid_t fapl_id);
static const H5FD_class_t H5FD_direct_g = {
+ H5FD_DIRECT_VALUE, /* value */
"direct", /* name */
MAXADDR, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
@@ -200,7 +203,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")))
@@ -296,28 +299,10 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu
if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
- HDmemset(&fa, 0, sizeof(H5FD_direct_fapl_t));
- if (boundary != 0)
- fa.mboundary = boundary;
- else
- fa.mboundary = MBOUNDARY_DEF;
- if (block_size != 0)
- fa.fbsize = block_size;
- else
- fa.fbsize = FBSIZE_DEF;
- if (cbuf_size != 0)
- fa.cbsize = cbuf_size;
- else
- fa.cbsize = CBSIZE_DEF;
-
- /* Set the default to be true for data alignment */
- fa.must_align = TRUE;
-
- /* Copy buffer size must be a multiple of file block size */
- if (fa.cbsize % fa.fbsize != 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "copy buffer size must be a multiple of block size")
+ if (H5FD__direct_populate_config(boundary, block_size, cbuf_size, &fa) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't initialize driver configuration info")
- ret_value = H5P_set_driver(plist, H5FD_DIRECT, &fa);
+ ret_value = H5P_set_driver(plist, H5FD_DIRECT, &fa, NULL);
done:
FUNC_LEAVE_API(ret_value)
@@ -367,6 +352,53 @@ done:
} /* end H5Pget_fapl_direct() */
/*-------------------------------------------------------------------------
+ * Function: H5FD__direct_populate_config
+ *
+ * Purpose: Populates a H5FD_direct_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__direct_populate_config(size_t boundary, size_t block_size, size_t cbuf_size, H5FD_direct_fapl_t *fa_out)
+{
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_STATIC
+
+ HDassert(fa_out);
+
+ HDmemset(fa_out, 0, sizeof(H5FD_direct_fapl_t));
+
+ if (boundary != 0)
+ fa_out->mboundary = boundary;
+ else
+ fa_out->mboundary = MBOUNDARY_DEF;
+
+ if (block_size != 0)
+ fa_out->fbsize = block_size;
+ else
+ fa_out->fbsize = FBSIZE_DEF;
+
+ if (cbuf_size != 0)
+ fa_out->cbsize = cbuf_size;
+ else
+ fa_out->cbsize = CBSIZE_DEF;
+
+ /* Set the default to be true for data alignment */
+ fa_out->must_align = TRUE;
+
+ /* Copy buffer size must be a multiple of file block size */
+ if (fa_out->cbsize % fa_out->fbsize != 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "copy buffer size must be a multiple of block size")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD__direct_populate_config() */
+
+/*-------------------------------------------------------------------------
* Function: H5FD__direct_fapl_get
*
* Purpose: Returns a file access property list which indicates how the
@@ -450,6 +482,7 @@ H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad
int fd = (-1);
H5FD_direct_t * file = NULL;
const H5FD_direct_fapl_t *fa;
+ H5FD_direct_fapl_t default_fa;
#ifdef H5_HAVE_WIN32_API
HFILE filehandle;
struct _BY_HANDLE_FILE_INFORMATION fileinfo;
@@ -498,8 +531,11 @@ H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad
/* Get the driver specific information */
if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
- if (NULL == (fa = (const H5FD_direct_fapl_t *)H5P_peek_driver_info(plist)))
- HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info")
+ if (NULL == (fa = (const H5FD_direct_fapl_t *)H5P_peek_driver_info(plist))) {
+ if (H5FD__direct_populate_config(0, 0, 0, &default_fa) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, NULL, "can't initialize driver configuration info")
+ fa = &default_fa;
+ }
file->fd = fd;
H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t);