diff options
author | Quincey Koziol <koziol@lbl.gov> | 2020-11-30 19:54:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-30 19:54:44 (GMT) |
commit | cadd6db431e2664e6dd3f2460639a27d21c6c8a9 (patch) | |
tree | 79bad4f1b2615f8662499a6d986e89514894acf8 /src/H5F.c | |
parent | c256612e0950f3389249aa3a151d66ce01704d89 (diff) | |
download | hdf5-cadd6db431e2664e6dd3f2460639a27d21c6c8a9.zip hdf5-cadd6db431e2664e6dd3f2460639a27d21c6c8a9.tar.gz hdf5-cadd6db431e2664e6dd3f2460639a27d21c6c8a9.tar.bz2 |
Move API routines for VOL objects to main source file. (#133)
Diffstat (limited to 'src/H5F.c')
-rw-r--r-- | src/H5F.c | 115 |
1 files changed, 115 insertions, 0 deletions
@@ -771,6 +771,121 @@ done: } /* end H5Fdelete() */ /*------------------------------------------------------------------------- + * Function: H5Fmount + * + * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and + * NAME using mount properties PLIST_ID. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) +{ + H5VL_object_t *loc_vol_obj = NULL; /* Parent object */ + H5VL_object_t *child_vol_obj = NULL; /* Child object */ + H5I_type_t loc_type; /* ID type of location */ + H5I_type_t child_type; /* ID type of child */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id); + + /* Check arguments */ + loc_type = H5I_get_type(loc_id); + if (H5I_FILE != loc_type && H5I_GROUP != loc_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") + child_type = H5I_get_type(child_id); + if (H5I_FILE != child_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "child_id parameter not a file ID") + if (H5P_DEFAULT == plist_id) + plist_id = H5P_FILE_MOUNT_DEFAULT; + else if (TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "plist_id is not a file mount property list ID") + + /* Set up collective metadata if appropriate */ + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") + + /* Get the location object */ + if (NULL == (loc_vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") + + /* Get the child object */ + if (NULL == (child_vol_obj = (H5VL_object_t *)H5I_object(child_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get child object") + + /* Check if both objects are associated with the same VOL connector */ + if (loc_vol_obj->connector->cls->value != child_vol_obj->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL connector") + + /* Perform the mount operation */ + if (H5VL_file_specific(loc_vol_obj, H5VL_FILE_MOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + (int)loc_type, name, child_vol_obj->data, plist_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Fmount() */ + +/*------------------------------------------------------------------------- + * Function: H5Funmount + * + * Purpose: Given a mount point, dissassociate the mount point's file + * from the file mounted there. Do not close either file. + * + * The mount point can either be the group in the parent or the + * root group of the mounted file (both groups have the same + * name). If the mount point was opened before the mount then + * it's the group in the parent, but if it was opened after the + * mount then it's the root group of the child. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Funmount(hid_t loc_id, const char *name) +{ + H5VL_object_t *vol_obj = NULL; /* Parent object */ + H5I_type_t loc_type; /* ID type of location */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*s", loc_id, name); + + /* Check arguments */ + loc_type = H5I_get_type(loc_id); + if (H5I_FILE != loc_type && H5I_GROUP != loc_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") + + /* Set up collective metadata if appropriate */ + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") + + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") + + /* Perform the unmount operation */ + if (H5VL_file_specific(vol_obj, H5VL_FILE_UNMOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + (int)loc_type, name) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Funmount() */ + +/*------------------------------------------------------------------------- * Function: H5Freopen * * Purpose: Reopen a file. The new file handle which is returned points |