summaryrefslogtreecommitdiffstats
path: root/src/H5Fint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Fint.c')
-rw-r--r--src/H5Fint.c72
1 files changed, 37 insertions, 35 deletions
diff --git a/src/H5Fint.c b/src/H5Fint.c
index e1be2b6..c2d3e77 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -2360,11 +2360,11 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5F_delete(const char *filename, hid_t fapl_id)
+H5F__delete(const char *filename, hid_t fapl_id)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_PACKAGE
HDassert(filename);
@@ -2374,7 +2374,7 @@ H5F_delete(const char *filename, hid_t fapl_id)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5F_delete() */
+} /* end H5F__delete() */
/*-------------------------------------------------------------------------
* Function: H5F_try_close
@@ -3109,27 +3109,28 @@ done:
/*-------------------------------------------------------------------------
* Function: H5F__get_file_image
*
- * Purpose: Private version of H5Fget_file_image
+ * Purpose: Private version of H5Fget_file_image, returns bytes copied/
+ * number of bytes needed in *image_len.
+ *
+ * Return: SUCCEED/FAIL
*
- * Return: Success: Bytes copied / number of bytes needed.
- * Failure: -1
*-------------------------------------------------------------------------
*/
-ssize_t
-H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len)
+herr_t
+H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len, size_t *image_len)
{
- H5FD_t *fd_ptr; /* file driver */
- haddr_t eoa; /* End of file address */
- ssize_t ret_value = -1; /* Return value */
+ H5FD_t *fd_ptr; /* file driver */
+ haddr_t eoa; /* End of file address */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Check args */
if (!file || !file->shared || !file->shared->lf)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "file_id yields invalid file pointer")
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file_id yields invalid file pointer")
fd_ptr = file->shared->lf;
if (!fd_ptr->cls)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "fd_ptr yields invalid class pointer")
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "fd_ptr yields invalid class pointer")
/* the address space used by the split and multi file drivers is not
* a good fit for this call. Since the plan is to depreciate these
@@ -3150,7 +3151,7 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len)
* JRM -- 11/11/22
*/
if (HDstrcmp(fd_ptr->cls->name, "multi") == 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "Not supported for multi file driver.")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Not supported for multi file driver.")
/* While the family file driver is conceptually fully compatible
* with the get file image operation, it sets a file driver message
@@ -3158,7 +3159,7 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len)
* driver other than the family file driver. Needless to say, this
* rather defeats the purpose of the get file image operation.
*
- * While this problem is quire solvable, the required time and
+ * While this problem is quite solvable, the required time and
* resources are lacking at present. Hence, for now, we don't
* allow the get file image operation to be perfomed on files
* opened with the family file driver.
@@ -3172,30 +3173,24 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len)
* JRM -- 12/21/11
*/
if (HDstrcmp(fd_ptr->cls->name, "family") == 0)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "Not supported for family file driver.")
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "Not supported for family file driver.")
/* Go get the actual file size */
if (HADDR_UNDEF == (eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT)))
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file size")
-
- /* set ret_value = to eoa -- will overwrite this if appropriate */
- ret_value = (ssize_t)eoa;
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size")
- /* test to see if a buffer was provided -- if not, we are done */
+ /* Test to see if a buffer was provided */
if (buf_ptr != NULL) {
- size_t space_needed; /* size of file image */
unsigned tmp, tmp_size;
/* Check for buffer too small */
if ((haddr_t)buf_len < eoa)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "supplied buffer too small")
-
- space_needed = (size_t)eoa;
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "supplied buffer too small")
- /* read in the file image */
+ /* Read in the file image */
/* (Note compensation for base address addition in internal routine) */
- if (H5FD_read(fd_ptr, H5FD_MEM_DEFAULT, 0, space_needed, buf_ptr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_READERROR, (-1), "file image read request failed")
+ if (H5FD_read(fd_ptr, H5FD_MEM_DEFAULT, 0, (size_t)eoa, buf_ptr) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "file image read request failed")
/* Offset to "status_flags" in the superblock */
tmp = H5F_SUPER_STATUS_FLAGS_OFF(file->shared->sblock->super_vers);
@@ -3207,6 +3202,9 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len)
HDmemset((uint8_t *)buf_ptr + tmp, 0, tmp_size);
} /* end if */
+ /* Set *image_len = to EOA */
+ *image_len = (size_t)eoa;
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F__get_file_image() */
@@ -3902,11 +3900,12 @@ done:
hid_t
H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref)
{
- void * vol_obj_file = NULL; /* File object pointer */
- H5VL_loc_params_t loc_params; /* Location parameters */
- hid_t file_id = H5I_INVALID_HID; /* File ID for object */
- hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
+ void * vol_obj_file = NULL; /* File object pointer */
+ H5VL_object_get_args_t vol_cb_args; /* Arguments to VOL callback */
+ H5VL_loc_params_t loc_params; /* Location parameters */
+ hid_t file_id = H5I_INVALID_HID; /* File ID for object */
+ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_NOAPI(H5I_INVALID_HID)
@@ -3914,9 +3913,12 @@ H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref)
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = obj_type;
+ /* Set up VOL callback arguments */
+ vol_cb_args.op_type = H5VL_OBJECT_GET_FILE;
+ vol_cb_args.args.get_file.file = &vol_obj_file;
+
/* Retrieve VOL file from object */
- if (H5VL_object_get(vol_obj, &loc_params, H5VL_OBJECT_GET_FILE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL,
- &vol_obj_file) < 0)
+ if (H5VL_object_get(vol_obj, &loc_params, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file from object")
/* Check if the file's ID already exists */