diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5G.c | 5 | ||||
-rw-r--r-- | src/H5Gpublic.h | 2 | ||||
-rw-r--r-- | src/H5O.c | 61 | ||||
-rw-r--r-- | src/H5Oprivate.h | 1 | ||||
-rw-r--r-- | src/H5Opublic.h | 9 |
5 files changed, 76 insertions, 2 deletions
@@ -2539,7 +2539,6 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link, /* Some other type of object */ statbuf->objno = obj_ent.header; 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(NULL); if (NULL==H5O_read(&obj_ent, H5O_MTIME_NEW_ID, 0, &(statbuf->mtime), dxpl_id)) { @@ -2549,6 +2548,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(NULL); /*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 2a37fef..c907f5e 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" { @@ -77,6 +78,7 @@ typedef struct H5G_stat_t { H5G_obj_t type; /*basic object type */ 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 @@ -3279,6 +3279,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, H5AC_READ))) + 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 bcd2e5b..78f8c0e 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -234,6 +234,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 |