summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@koziol.gov>2019-04-12 03:22:21 (GMT)
committerQuincey Koziol <koziol@koziol.gov>2019-04-12 03:22:21 (GMT)
commit2eac0fccbc0fa1a38364ab5cb818483379a2668b (patch)
treee542cd31e7e4dba03c9e81e7923c6cfa1959032d
parent52276f3713eec584044bc72d4724507848cfeba0 (diff)
downloadhdf5-2eac0fccbc0fa1a38364ab5cb818483379a2668b.zip
hdf5-2eac0fccbc0fa1a38364ab5cb818483379a2668b.tar.gz
hdf5-2eac0fccbc0fa1a38364ab5cb818483379a2668b.tar.bz2
Add H5Fget_fileno() API routine.
-rw-r--r--src/H5F.c35
-rw-r--r--src/H5Fpublic.h1
-rw-r--r--src/H5VLnative_file.c13
-rw-r--r--src/H5VLpublic.h1
-rw-r--r--test/tfile.c24
5 files changed, 74 insertions, 0 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 9df8140..e873652 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -921,6 +921,41 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5Fget_fileno
+ *
+ * Purpose: Public API to retrieve the file's 'file number' that uniquely
+ * identifies each open file.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fget_fileno(hid_t file_id, unsigned long *fileno)
+{
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_API(FAIL)
+
+ /* If no fileno pointer was passed in, exit quietly */
+ if(fileno) {
+ H5VL_object_t *vol_obj; /* File info */
+
+ /* Get the internal file structure */
+ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* Get the flags */
+ if((ret_value = H5VL_file_get(vol_obj, H5VL_FILE_GET_FILENO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fileno)) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file's 'file number'")
+ } /* end if */
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Fget_fileno() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Fget_freespace
*
* Purpose: Retrieves the amount of free space in the file.
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index 8274654..52f1ee2 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -236,6 +236,7 @@ H5_DLL herr_t H5Fclose(hid_t file_id);
H5_DLL hid_t H5Fget_create_plist(hid_t file_id);
H5_DLL hid_t H5Fget_access_plist(hid_t file_id);
H5_DLL herr_t H5Fget_intent(hid_t file_id, unsigned *intent);
+H5_DLL herr_t H5Fget_fileno(hid_t file_id, unsigned long *fileno);
H5_DLL ssize_t H5Fget_obj_count(hid_t file_id, unsigned types);
H5_DLL ssize_t H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *obj_id_list);
H5_DLL herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle);
diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c
index 624cd30..8903911 100644
--- a/src/H5VLnative_file.c
+++ b/src/H5VLnative_file.c
@@ -228,6 +228,19 @@ H5VL__native_file_get(void *obj, H5VL_file_get_t get_type,
break;
}
+ /* H5Fget_fileno */
+ case H5VL_FILE_GET_FILENO:
+ {
+ unsigned long *fileno = HDva_arg(arguments, unsigned long *);
+ unsigned long my_fileno = 0;
+
+ f = (H5F_t *)obj;
+ H5F_GET_FILENO(f, my_fileno);
+ *fileno = my_fileno; /* sigh */
+
+ break;
+ }
+
/* H5Fget_name */
case H5VL_FILE_GET_NAME:
{
diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h
index cf6246b..da31a97 100644
--- a/src/H5VLpublic.h
+++ b/src/H5VLpublic.h
@@ -114,6 +114,7 @@ typedef enum H5VL_file_get_t {
H5VL_FILE_GET_FAPL, /* file access property list */
H5VL_FILE_GET_FCPL, /* file creation property list */
H5VL_FILE_GET_INTENT, /* file intent */
+ H5VL_FILE_GET_FILENO, /* file number */
H5VL_FILE_GET_NAME, /* file name */
H5VL_FILE_GET_OBJ_COUNT, /* object count in file */
H5VL_FILE_GET_OBJ_IDS /* object ids in file */
diff --git a/test/tfile.c b/test/tfile.c
index 430bc85..acf2bd6 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -1921,6 +1921,7 @@ test_file_open_overlap(void)
hid_t sid;
ssize_t nobjs; /* # of open objects */
unsigned intent;
+ unsigned long fileno1, fileno2; /* File number */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -1939,6 +1940,19 @@ test_file_open_overlap(void)
CHECK(ret, FAIL, "H5Fget_intent");
VERIFY(intent, H5F_ACC_RDWR, "H5Fget_intent");
+ /* Check the file numbers */
+ fileno1 = 0;
+ ret = H5Fget_fileno(fid1, &fileno1);
+ CHECK(ret, FAIL, "H5Fget_fileno");
+ fileno2 = 0;
+ ret = H5Fget_fileno(fid2, &fileno2);
+ CHECK(ret, FAIL, "H5Fget_fileno");
+ VERIFY(fileno1, fileno2, "H5Fget_fileno");
+
+ /* Check that a file number pointer of NULL is ignored */
+ ret = H5Fget_fileno(fid1, NULL);
+ CHECK(ret, FAIL, "H5Fget_fileno");
+
/* Create a group in file */
gid = H5Gcreate2(fid1, GROUP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(gid, FAIL, "H5Gcreate2");
@@ -2652,6 +2666,7 @@ test_userblock_file_size(void)
hid_t fcpl2_id;
hsize_t dims[2] = {3, 4};
hsize_t filesize1, filesize2, filesize;
+ unsigned long fileno1, fileno2; /* File number */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -2669,6 +2684,15 @@ test_userblock_file_size(void)
file2_id = H5Fcreate(FILE2, H5F_ACC_TRUNC, fcpl2_id, H5P_DEFAULT);
CHECK(file2_id, FAIL, "H5Fcreate");
+ /* Check the file numbers */
+ fileno1 = 0;
+ ret = H5Fget_fileno(file1_id, &fileno1);
+ CHECK(ret, FAIL, "H5Fget_fileno");
+ fileno2 = 0;
+ ret = H5Fget_fileno(file2_id, &fileno2);
+ CHECK(ret, FAIL, "H5Fget_fileno");
+ CHECK(fileno1, fileno2, "H5Fget_fileno");
+
/* Create groups */
group1_id = H5Gcreate2(file1_id, GROUP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(group1_id, FAIL, "H5Gcreate2");