diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2012-03-12 21:50:25 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2012-03-12 21:50:25 (GMT) |
commit | 90ec386c958859b73bc050eafa7d525df9dd618c (patch) | |
tree | cee070045fb0d2b1d0dacb9be421ca4198e27592 /src | |
parent | c7b3e19329bb9f417b397d945c20b27c56a7420f (diff) | |
download | hdf5-90ec386c958859b73bc050eafa7d525df9dd618c.zip hdf5-90ec386c958859b73bc050eafa7d525df9dd618c.tar.gz hdf5-90ec386c958859b73bc050eafa7d525df9dd618c.tar.bz2 |
[svn-r22056] - fix several bugs in id management
- update test cases that get the H5F_t struct to use H5I_object_verify instead of H5I_object because of the higher user level ID that is introduced
- add some workarounds to take into consideration that the high level ID is not used everywhere at the moment
- add a routine that translates from low level ids to high level ids
Diffstat (limited to 'src')
-rw-r--r-- | src/H5F.c | 69 | ||||
-rw-r--r-- | src/H5Fpkg.h | 2 | ||||
-rw-r--r-- | src/H5I.c | 182 | ||||
-rw-r--r-- | src/H5Iprivate.h | 1 | ||||
-rw-r--r-- | src/H5VL.c | 2 | ||||
-rw-r--r-- | src/H5VLnative.c | 37 | ||||
-rw-r--r-- | src/H5VLnative.h | 5 |
7 files changed, 192 insertions, 106 deletions
@@ -323,7 +323,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver") if(H5P_set(new_plist, H5F_ACS_FILE_DRV_ID_NAME, &(f->shared->lf->driver_id)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver ID") -#if 0 +#if 1 /* Increment the reference count on the VOL ID and insert it into the property list */ if(H5I_inc_ref(f->vol_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VOL") @@ -1337,6 +1337,10 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") + /* Store the VOL id in the file struct */ + if(H5P_get(a_plist, H5F_ACS_VOL_ID_NAME, &(file->vol_id)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin ID") + /* * Decide the file close degree. If it's the first time to open the * file, set the degree to access property list value; if it's the @@ -1440,15 +1444,6 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") /* - * Adjust bit flags by turning on the creation bit and making sure that - * the EXCL or TRUNC bit is set. All newly-created files are opened for - * reading and writing. - */ - if (0==(flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) - flags |= H5F_ACC_EXCL; /*default*/ - flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; - - /* * Create a new file or truncate an existing file. */ if((ret_value = H5VL_create(filename, flags, fcpl_id, fapl_id)) < 0) @@ -2022,13 +2017,26 @@ H5F_get_id(H5F_t *file, hbool_t app_ref) HDassert(file); if(file->file_id == -1) { + H5I_t *uid_info; /* user id structure */ /* Get an atom for the file */ if((file->file_id = H5I_register(H5I_FILE, file, app_ref)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") + + /* Create a new id that points to a struct that holds the file id and the VOL id */ + if(NULL == (uid_info = H5FL_MALLOC(H5I_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + uid_info->obj_id = file->file_id; + uid_info->vol_id = file->vol_id; + if((H5I_register(H5I_UID, uid_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") } else { /* Increment reference count on atom. */ if(H5I_inc_ref(file->file_id, app_ref) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") + + /* Increment reference count on upper level ID. */ + if(H5I_inc_ref_uid(file->file_id, app_ref) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing user ID failed") } /* end else */ ret_value = file->file_id; @@ -2671,11 +2679,44 @@ H5Fget_name(hid_t uid, char *name/*out*/, size_t size) FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "ixz", uid, name, size); - argv[0] = &ret_value; - argv[1] = &size; - if(H5VL_get(uid, H5F_GET_NAME, (void *)name, 2, argv) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file name") + /* MSC - temp fix to handle later when all user level ids are of type UID */ + if (H5I_UID == H5I_get_type(uid)) { + argv[0] = &ret_value; + argv[1] = &size; + if(H5VL_get(uid, H5F_GET_NAME, (void *)name, 2, argv) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file name") + } + else { + H5F_t *f; /* Top file in mount hierarchy */ + size_t len; + /* For file IDs, get the file object directly */ + /* (This prevents the H5G_loc() call from returning the file pointer for + * the top file in a mount hierarchy) + */ + if(H5I_get_type(uid) == H5I_FILE ) { + if(NULL == (f = (H5F_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + } /* end if */ + else { + H5G_loc_t loc; /* Object location */ + + /* Get symbol table entry */ + if(H5G_loc(uid, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID") + f = loc.oloc->file; + } /* end else */ + len = HDstrlen(H5F_OPEN_NAME(f)); + + if(name) { + HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); + if(len >= size) + name[size-1]='\0'; + } /* end if */ + + /* Set return value */ + ret_value = (ssize_t)len; + } done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_name() */ diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 5c6223b..bb6cc4e 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -274,7 +274,7 @@ struct H5F_t { hbool_t closing; /* File is in the process of being closed */ struct H5F_t *parent; /* Parent file that this file is mounted to */ unsigned nmounts; /* Number of children mounted to this file */ - //hid_t vol_id; /* id of the vol plugin used to open the file */ + hid_t vol_id; /* id of the vol plugin used to open the file */ //H5VL_class_t vol_cls; /* class of the VOL plugin */ }; @@ -978,18 +978,13 @@ done: *------------------------------------------------------------------------- */ void * -H5Iobject_verify(hid_t uid, H5I_type_t id_type) +H5Iobject_verify(hid_t id, H5I_type_t id_type) { - H5I_t *uid_info; /* user id structure */ - hid_t id; void * ret_value; /* Return value */ FUNC_ENTER_API(NULL) - /* Check arguments */ - if(uid < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") - +#if 0 if (H5I_UID == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") @@ -998,6 +993,7 @@ H5Iobject_verify(hid_t uid, H5I_type_t id_type) else { id = uid; } +#endif if(H5I_IS_LIB_TYPE(id_type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") @@ -1031,12 +1027,19 @@ void * H5I_object_verify(hid_t id, H5I_type_t id_type) { H5I_id_info_t *id_ptr = NULL; /*ptr to the new atom */ + H5I_t *uid_info; /* user id structure */ void *ret_value = NULL; /*return value */ FUNC_ENTER_NOAPI(NULL) HDassert(id_type >= 1 && id_type < H5I_next_type); + if (H5I_UID == H5I_get_type(id) && H5I_UID != id_type) { + if(NULL == (uid_info = (H5I_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + id = uid_info->obj_id; + } + /* Verify that the type of the ID is correct & lookup the ID */ if(id_type == H5I_TYPE(id) && NULL != (id_ptr = H5I_find_id(id))) { /* Get the object pointer to return */ @@ -1148,18 +1151,13 @@ done: *------------------------------------------------------------------------- */ void * -H5Iremove_verify(hid_t uid, H5I_type_t id_type) +H5Iremove_verify(hid_t id, H5I_type_t id_type) { - H5I_t *uid_info; /* user id structure */ - hid_t id; void * ret_value; /* Return value */ FUNC_ENTER_API(NULL) - /* Check arguments */ - if(uid < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") - +#if 0 if (H5I_UID == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") @@ -1168,6 +1166,7 @@ H5Iremove_verify(hid_t uid, H5I_type_t id_type) else { id = uid; } +#endif if(H5I_IS_LIB_TYPE(id_type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") @@ -1305,7 +1304,6 @@ int H5Idec_ref(hid_t uid) { H5I_t *uid_info; /* user id structure */ - hid_t id; int ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1318,20 +1316,18 @@ H5Idec_ref(hid_t uid) if (H5I_UID == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - id = uid_info->obj_id; + + if((ret_value = H5I_dec_app_ref(uid_info->obj_id)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") + + if((ret_value = H5I_dec_app_ref(uid)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") } else { - id = uid; + /* Do actual decrement operation */ + if((ret_value = H5I_dec_app_ref(uid)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") } - - /* Check arguments */ - if(id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") - - /* Do actual decrement operation */ - if((ret_value = H5I_dec_app_ref(id)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") - done: FUNC_LEAVE_API(ret_value) } /* end H5Idec_ref() */ @@ -1523,11 +1519,10 @@ int H5Iinc_ref(hid_t uid) { H5I_t *uid_info; /* user id structure */ - hid_t id; int ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("Is", "i", id); + H5TRACE1("Is", "i", uid); /* Check arguments */ if(uid < 0) @@ -1536,19 +1531,20 @@ H5Iinc_ref(hid_t uid) if (H5I_UID == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - id = uid_info->obj_id; + + if((ret_value = H5I_inc_ref(uid_info->obj_id, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count") + + if((ret_value = H5I_inc_ref(uid, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count") } else { - id = uid; + /* Do actual increment operation */ + if((ret_value = H5I_inc_ref(uid, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count") } - /* Check arguments */ - if(id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") - /* Do actual increment operation */ - if((ret_value = H5I_inc_ref(id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count") done: FUNC_LEAVE_API(ret_value) @@ -1627,19 +1623,18 @@ done: *------------------------------------------------------------------------- */ int -H5Iget_ref(hid_t uid) +H5Iget_ref(hid_t id) { - H5I_t *uid_info; /* user id structure */ - hid_t id; int ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("Is", "i", uid); + H5TRACE1("Is", "i", id); /* Check arguments */ - if(uid < 0) + if(id < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") +#if 0 if (H5I_UID == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") @@ -1652,7 +1647,7 @@ H5Iget_ref(hid_t uid) /* Check arguments */ if(id < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") - +#endif /* Do actual retrieve operation */ if((ret_value = H5I_get_ref(id, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") @@ -1979,18 +1974,15 @@ done: *------------------------------------------------------------------------- */ htri_t -H5Iis_valid(hid_t uid) +H5Iis_valid(hid_t id) { H5I_id_info_t *id_ptr; /* ptr to the ID */ - H5I_t *uid_info; /* user id structure */ - hid_t id; htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("t", "i", uid); + H5TRACE1("t", "i", id); - id = uid; - /* +#if 0 if (H5I_UID == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") @@ -1999,10 +1991,7 @@ H5Iis_valid(hid_t uid) else { id = uid; } - - if(id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") - */ +#endif /* Find the ID */ if (NULL == (id_ptr = H5I_find_id(id))) @@ -2091,8 +2080,8 @@ H5I_search(H5I_type_t type, H5I_search_func_t func, void *key, hbool_t app_ref) H5I_id_type_t *type_ptr; /*ptr to the type */ void *ret_value = NULL; /*return value */ - FUNC_ENTER_NOAPI(NULL) - + FUNC_ENTER_NOAPI(NULL +) /* Check arguments */ if(type <= H5I_BADID || type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid type number") @@ -2274,15 +2263,12 @@ H5Iget_file_id(hid_t uid) else { id = uid; } - + if((ret_value = H5I_get_file_id(id, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID") - if (H5I_replace_with_uids (&ret_value, 1) <= 0) + if (H5I_replace_with_uids (&ret_value, 1) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID") - /* Increment reference count on atom. */ - if(H5I_inc_ref(ret_value, TRUE) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") done: FUNC_LEAVE_API(ret_value) @@ -2318,6 +2304,10 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) if(H5I_inc_ref(obj_id, app_ref) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") + /* Increment reference count on upper level ID. */ + if(H5I_inc_ref_uid(obj_id, app_ref) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing user ID failed") + /* Set return value */ ret_value = obj_id; } /* end if */ @@ -2339,8 +2329,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_get_file_id() */ - - /*------------------------------------------------------------------------- * Function: H5I_replace_with_uids @@ -2356,7 +2344,7 @@ done: *------------------------------------------------------------------------- */ int -H5I_replace_with_uids(hid_t *oid_list, ssize_t num_ids) +H5I_replace_with_uids(hid_t *old_list, ssize_t num_ids) { ssize_t j; int ret_value = 0; /* Return value */ @@ -2364,11 +2352,13 @@ H5I_replace_with_uids(hid_t *oid_list, ssize_t num_ids) FUNC_ENTER_NOAPI(FAIL) for (j=0 ; j<num_ids ; j++) { - H5I_id_type_t *type_ptr; /*ptr to the type */ + H5I_id_type_t *type_ptr; /*ptr to the type */ hbool_t replaced = FALSE; - if (H5I_FILE != H5I_get_type(oid_list[j])) + if (H5I_FILE != H5I_get_type(old_list[j])) { + ret_value ++; continue; + } type_ptr = H5I_id_type_list_g[H5I_UID]; @@ -2377,9 +2367,9 @@ H5I_replace_with_uids(hid_t *oid_list, ssize_t num_ids) /* Only iterate through hash table if there are IDs in group */ if(type_ptr->ids > 0) { - H5I_id_info_t *id_ptr; /*ptr to the new ID */ + H5I_id_info_t *id_ptr; /*ptr to the new ID */ H5I_t *uid_info; /* user id structure */ - unsigned i; /*counter */ + unsigned i; /*counter */ /* Start at the beginning of the array */ for(i = 0; i < type_ptr->hash_size; i++) { @@ -2387,8 +2377,8 @@ H5I_replace_with_uids(hid_t *oid_list, ssize_t num_ids) while(id_ptr) { if(NULL == (uid_info = (H5I_t *)H5I_object(id_ptr->id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if (uid_info->obj_id == oid_list[j]) { - oid_list[j] = id_ptr->id; + if (uid_info->obj_id == old_list[j]) { + old_list[j] = id_ptr->id; ret_value ++; replaced = TRUE; break; @@ -2398,7 +2388,7 @@ H5I_replace_with_uids(hid_t *oid_list, ssize_t num_ids) if (replaced) break; } /* end for */ - } /* end if */ + } /* end if */ } done: FUNC_LEAVE_NOAPI(ret_value) @@ -2406,6 +2396,60 @@ done: /*------------------------------------------------------------------------- + * Function: H5I_inc_ref_uid + * + * Purpose: change the ids used by the HDF5 libraries to the UIDs that + * are provided to the user + * + * Return: How many IDs were replaced. + * + * Programmer: Mohamad Chaarawi + * Feb 2012 + * + *------------------------------------------------------------------------- + */ +int +H5I_inc_ref_uid(hid_t fid, hbool_t app_ref) +{ + H5I_id_type_t *type_ptr; /*ptr to the type */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + type_ptr = H5I_id_type_list_g[H5I_UID]; + + if(type_ptr == NULL || type_ptr->count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + + /* Only iterate through hash table if there are IDs in group */ + if(type_ptr->ids > 0) { + H5I_id_info_t *id_ptr; /*ptr to the new ID */ + H5I_t *uid_info; /* user id structure */ + unsigned i; /*counter */ + + /* Start at the beginning of the array */ + for(i = 0; i < type_ptr->hash_size; i++) { + id_ptr = type_ptr->id_list[i]; + while(id_ptr) { + if(NULL == (uid_info = (H5I_t *)H5I_object(id_ptr->id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if (uid_info->obj_id == fid) { + /* Increment reference count on atom. */ + if((ret_value = H5I_inc_ref(id_ptr->id, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") + HGOTO_DONE(ret_value) + } + id_ptr = id_ptr->next; + } /* end while */ + } /* end for */ + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_inc_ref_uid() */ + + +/*------------------------------------------------------------------------- * Function: H5I_debug * * Purpose: Dump the contents of a type to stderr for debugging. diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 6ffc3c9..bc2f354 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -81,5 +81,6 @@ H5_DLL int H5I_inc_type_ref(H5I_type_t type); H5_DLL herr_t H5I_dec_type_ref(H5I_type_t type); H5_DLL int H5I_get_type_ref(H5I_type_t type); H5_DLL herr_t H5I_replace_with_uids(hid_t *oid_list, ssize_t num_ids); +H5_DLL int H5I_inc_ref_uid(hid_t fid, hbool_t app_ref); #endif /* _H5Iprivate_H */ @@ -692,7 +692,7 @@ H5VL_flush(hid_t uid, H5F_scope_t scope) /* Check/fix arguments. */ if(H5I_UID != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 08f62d3..e3b998a 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -46,12 +46,8 @@ static hid_t H5VL_NATIVE_g = 0; /* Prototypes */ -static hid_t H5VL_native_open(const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id, hid_t dxpl_id); -static herr_t H5VL_native_close(hid_t fid); -static hid_t H5VL_native_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); -static herr_t H5VL_native_flush(hid_t fid, H5F_scope_t scope); -static herr_t H5VL_native_get(hid_t file_id, H5VL_file_get_t get_type, void *data, int argc, void **argv); +static herr_t H5VL_native_get(hid_t file_id, H5VL_file_get_t get_type, + void *data, int argc, void **argv); static herr_t H5VL_native_term(void); static const H5VL_class_t H5VL_native_g = { @@ -226,7 +222,7 @@ done: * *------------------------------------------------------------------------- */ -static hid_t +hid_t H5VL_native_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id) { @@ -273,7 +269,7 @@ done: * *------------------------------------------------------------------------- */ -static hid_t +hid_t H5VL_native_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { H5F_t *new_file; /* file struct */ @@ -281,6 +277,15 @@ H5VL_native_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_i FUNC_ENTER_NOAPI_NOINIT + /* + * Adjust bit flags by turning on the creation bit and making sure that + * the EXCL or TRUNC bit is set. All newly-created files are opened for + * reading and writing. + */ + if (0==(flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) + flags |= H5F_ACC_EXCL; /*default*/ + flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; + /* Create the file */ if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id, H5AC_dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file") @@ -313,7 +318,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5VL_native_close(hid_t file_id) { int nref; @@ -367,7 +372,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5VL_native_flush(hid_t object_id, H5F_scope_t scope) { H5F_t *f = NULL; /* File to flush */ @@ -461,7 +466,7 @@ H5VL_native_flush(hid_t object_id, H5F_scope_t scope) /* Call the flush routine for mounted file hierarchies */ if(H5F_flush_mounts(f, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") - } /* end if */ + } /* end if */ else { /* Call the flush routine, for this file */ if(H5F_flush(f, H5AC_dxpl_id, FALSE) < 0) @@ -633,16 +638,6 @@ H5VL_native_get(hid_t obj_id, H5VL_file_get_t get_type, void *data, int argc, vo ret = (ssize_t)len; break; } - /* H5Fget_ */ - case H5F_GET_OBJ_COUNT: - { - break; - } - /* H5Fget_create_plist */ - case H5F_GET_OBJ_IDS: - { - break; - } /* H5Fget_vfd_handle */ case H5F_GET_VFD_HANDLE: { diff --git a/src/H5VLnative.h b/src/H5VLnative.h index 36177ed..ab4dd20 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -30,6 +30,11 @@ extern "C" { H5_DLL hid_t H5VL_native_init(void); H5_DLL herr_t H5Pset_fapl_native(hid_t fapl_id); +H5_DLL hid_t H5VL_native_open(const char *name, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, hid_t dxpl_id); +H5_DLL herr_t H5VL_native_close(hid_t fid); +H5_DLL hid_t H5VL_native_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +H5_DLL herr_t H5VL_native_flush(hid_t fid, H5F_scope_t scope); #ifdef __cplusplus } |