summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-10-07 15:27:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-10-07 15:27:30 (GMT)
commit36ac2a176955ce29d1bbf7db0c29cee6fd5ecedb (patch)
tree1dbda3be345320fe0b2c20c2219530befe2d6269 /src
parent134a692a8365ab5f196155298b6b601889c80a32 (diff)
downloadhdf5-36ac2a176955ce29d1bbf7db0c29cee6fd5ecedb.zip
hdf5-36ac2a176955ce29d1bbf7db0c29cee6fd5ecedb.tar.gz
hdf5-36ac2a176955ce29d1bbf7db0c29cee6fd5ecedb.tar.bz2
[svn-r7562] Purpose:
Feature add Description: Add a few new fields to the H5G_stat_t structure, to allow more information about the object header to be retrieved. Platforms tested: FreeBSD 4.9 (sleipnir) h5committest
Diffstat (limited to 'src')
-rw-r--r--src/H5G.c5
-rw-r--r--src/H5Gpublic.h2
-rw-r--r--src/H5O.c61
-rw-r--r--src/H5Oprivate.h1
-rw-r--r--src/H5Opublic.h9
5 files changed, 76 insertions, 2 deletions
diff --git a/src/H5G.c b/src/H5G.c
index 5be0110..7bd23af 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -2558,7 +2558,6 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link,
statbuf->objno[1] = 0;
#endif
statbuf->nlink = H5O_link (&obj_ent, 0, dxpl_id);
- statbuf->type = H5G_LINK;
if (NULL==H5O_read(&obj_ent, H5O_MTIME_ID, 0, &(statbuf->mtime), dxpl_id)) {
H5E_clear();
if (NULL==H5O_read(&obj_ent, H5O_MTIME_NEW_ID, 0, &(statbuf->mtime), dxpl_id)) {
@@ -2568,6 +2567,10 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link,
}
statbuf->type = H5G_get_type(&obj_ent, dxpl_id);
H5E_clear(); /*clear errors resulting from checking type*/
+
+ /* Get object header information */
+ if(H5O_get_info(&obj_ent, &(statbuf->ohdr), dxpl_id)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object header information")
}
/* Common code to retrieve the file's fileno */
diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h
index c131520..3d74704 100644
--- a/src/H5Gpublic.h
+++ b/src/H5Gpublic.h
@@ -33,6 +33,7 @@
#include "H5public.h"
#include "H5Ipublic.h"
+#include "H5Opublic.h"
#ifdef __cplusplus
extern "C" {
@@ -93,6 +94,7 @@ typedef struct H5G_stat_t {
#endif /*H5_WANT_H5_V1_4_COMPAT*/
time_t mtime; /*modification time */
size_t linklen; /*symbolic link value length */
+ H5O_stat_t ohdr; /* Object header information */
} H5G_stat_t;
#define H5G_SAME_LOC 0
diff --git a/src/H5O.c b/src/H5O.c
index c6049f5..259557e 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -3264,6 +3264,67 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5O_get_info
+ *
+ * Purpose: Retrieve information about an object header
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Oct 7 2003
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_get_info(H5G_entry_t *ent, H5O_stat_t *ostat, hid_t dxpl_id)
+{
+ H5O_t *oh=NULL; /* Object header information */
+ H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
+ hsize_t total_size; /* Total amount of space used in file */
+ hsize_t free_space; /* Free space in object header */
+ unsigned u; /* Local index variable */
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5O_get_info,FAIL);
+
+ /* Check args */
+ assert (ent);
+ assert (ostat);
+
+ /* Get the object header information */
+ if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
+
+ /* Iterate over all the messages, accumulating the total size & free space */
+ total_size=H5O_SIZEOF_HDR(ent->file);
+ free_space=0;
+ for (u = 0, curr_msg=&oh->mesg[0]; u < oh->nmesgs; u++,curr_msg++) {
+ /* Accumulate the size for this message */
+ total_size+= H5O_SIZEOF_MSGHDR(ent->file) + curr_msg->raw_size;
+
+ /* Check for this message being free space */
+ if (H5O_NULL_ID == curr_msg->type->id)
+ free_space+= H5O_SIZEOF_MSGHDR(ent->file) + curr_msg->raw_size;
+ } /* end for */
+
+ /* Set the information for this object header */
+ ostat->size=total_size;
+ ostat->free=free_space;
+ ostat->nmesgs=oh->nmesgs;
+ ostat->nchunks=oh->nchunks;
+
+done:
+ if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE)<0)
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+
+ FUNC_LEAVE_NOAPI(ret_value);
+} /* end H5O_get_info() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_debug_id
*
* Purpose: Act as a proxy for calling the 'debug' method for a
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index fcd4e8d..4219a46 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -231,6 +231,7 @@ H5_DLL void *H5O_copy(hid_t type_id, const void *mesg, void *dst);
H5_DLL size_t H5O_raw_size(hid_t type_id, H5F_t *f, const void *mesg);
H5_DLL herr_t H5O_get_share(hid_t type_id, H5F_t *f, const void *mesg, H5O_shared_t *share);
H5_DLL herr_t H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr);
+H5_DLL herr_t H5O_get_info(H5G_entry_t *ent, H5O_stat_t *ostat, hid_t dxpl_id);
H5_DLL herr_t H5O_debug_id(hid_t type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth);
H5_DLL herr_t H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent,
int fwidth);
diff --git a/src/H5Opublic.h b/src/H5Opublic.h
index 59d117d..e71ff9c 100644
--- a/src/H5Opublic.h
+++ b/src/H5Opublic.h
@@ -14,7 +14,7 @@
/*-------------------------------------------------------------------------
*
- * Created: H5Oproto.h
+ * Created: H5Opublic.h
* Aug 5 1997
* Robb Matzke <matzke@llnl.gov>
*
@@ -31,6 +31,13 @@
/* Public headers needed by this file */
#include "H5public.h"
+typedef struct H5O_stat_t {
+ hsize_t size; /* Total size of object header in file */
+ hsize_t free; /* Free space within object header */
+ unsigned nmesgs; /* Number of object header messages */
+ unsigned nchunks; /* Number of object header chunks */
+} H5O_stat_t;
+
#ifdef __cplusplus
extern "C" {
#endif