summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1997-08-04 16:19:57 (GMT)
committerRobb Matzke <matzke@llnl.gov>1997-08-04 16:19:57 (GMT)
commit6a3cb617d3aa57f439065118fbc68afcb1465a54 (patch)
treeb9062c04a678e7615a437afe04fc7ca86f06efc7 /src/H5F.c
parent5cc4d0dcde9fb0f5a941c90a1de9ab964d09a163 (diff)
downloadhdf5-6a3cb617d3aa57f439065118fbc68afcb1465a54.zip
hdf5-6a3cb617d3aa57f439065118fbc68afcb1465a54.tar.gz
hdf5-6a3cb617d3aa57f439065118fbc68afcb1465a54.tar.bz2
[svn-r12] ./src/H5AC.c
Fails sooner if the type of object requested doesn't match the type of object cached. ./src/H5B.c ./src/H5Bprivate.h ./src/H5Fprivate.h ./src/H5G.c ./src/H5Gnode.c ./src/H5Gprivate.h ./src/H5H.c ./src/H5Hprivate.h Changed lots of `H5*_HDR_SIZE' macros to `H5*_SIZEOF_HDR' to make things more consistent. Added H5*_SIZEOF_MAGIC macros. Added debugging functions to some of the packages. ./src/H5F.c Fixed a bug with reading past the end of a buffer. ./src/H5Tproto.h Added prototypes for H5Tadd_field() and H5Tget_fields(). ./src/debug.c Low-level file debugging program. ./src/Makefile Builds `debug' as one of the main targets. The target is called `debug_hdf5' so it doesn't conflict with the `debug' target that was already there. But the executable is called `debug'.
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c98
1 files changed, 96 insertions, 2 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 7a43ca9..8e37967 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -584,6 +584,7 @@ hatom_t H5Fopen(const char *filename, uintn flags, hatom_t access_temp)
haddr_t curr_off=0; /* The current offset to check in the file */
size_t file_len=0; /* The length of the file we are checking */
hatom_t ret_value = FAIL;
+ size_t variable_size; /*size of the variable part of the bb */
FUNC_ENTER(H5F_mask, ID_H5Fopen, H5F_init_interface, FAIL);
@@ -670,9 +671,9 @@ hatom_t H5Fopen(const char *filename, uintn flags, hatom_t access_temp)
/* Read in the fixed-size part of the boot-block */
if(H5F_READ(new_file->file_handle,temp_buf,16)==FAIL)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL);
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL);
- /* Decode the boot block */
+ /* Decode fixed-size part of the boot block */
p=temp_buf;
new_file->file_create_parms.bootblock_ver=*p++; /* Decode Boot-block version # */
new_file->file_create_parms.smallobject_ver=*p++; /* Decode Small-Object Heap version # */
@@ -684,6 +685,17 @@ hatom_t H5Fopen(const char *filename, uintn flags, hatom_t access_temp)
p++; /* Decode the reserved byte :-) */
UINT32DECODE(p,new_file->file_create_parms.btree_page_size); /* Decode the B-Tree page size */
UINT32DECODE(p,new_file->consist_flags); /* Decode File-Consistancy flags */
+
+ /* Read the variable-size part of the boot-block */
+ variable_size = H5F_SIZEOF_OFFSET(new_file) + /*offset of global small-object heap*/
+ H5F_SIZEOF_OFFSET(new_file) + /*offset of global free list*/
+ H5F_SIZEOF_SIZE(new_file) + /*logical size of HDF5 file*/
+ H5G_SIZEOF_ENTRY(new_file); /*root symbol table entry*/
+ if (H5F_READ(new_file->file_handle, temp_buf, variable_size)<0)
+ HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL);
+
+ /* Decode the variable-size part of the boot block */
+ p = temp_buf;
H5F_decode_offset(new_file,p,new_file->smallobj_off); /* Decode offset of global small-object heap */
H5F_decode_offset(new_file,p,new_file->freespace_off); /* Decode offset of global free-space heap */
H5F_decode_length(new_file,p,new_file->logical_len); /* Decode logical length of file */
@@ -846,3 +858,85 @@ H5F_block_write (hdf5_file_t *f, haddr_t addr, size_t size, void *buf)
PABLO_TRACE_OFF(H5F_mask, ID_H5F_block_write);
return SUCCEED;
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_debug
+ *
+ * Purpose: Prints a file header to the specified stream. Each line
+ * is indented and the field name occupies the specified width
+ * number of characters.
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * robb@maya.nuance.com
+ * Aug 1 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent,
+ intn fwidth)
+{
+ fprintf (stream, "%*sFile Boot Block...\n", indent, "");
+
+ fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Directory:",
+ f->dir);
+ fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "File name:",
+ f->filename);
+ fprintf (stream, "%*s%-*s 0x%08x\n", indent, "", fwidth,
+ "Permissions",
+ (unsigned)(f->acc_perm));
+ fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Reference count:",
+ (unsigned)(f->ref_count));
+ fprintf (stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth,
+ "Consistency flags:",
+ (unsigned long)(f->consist_flags));
+ fprintf (stream, "%*s%-*s %ld\n", indent, "", fwidth,
+ "Small object heap address:",
+ (long)(f->smallobj_off));
+ fprintf (stream, "%*s%-*s %ld\n", indent, "", fwidth,
+ "Free list address:",
+ (long)(f->freespace_off));
+ fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Logical file length:",
+ (unsigned long)(f->logical_len));
+ fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Size of user block:",
+ (unsigned long)(f->file_create_parms.userblock_size));
+ fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Size of file size_t type:",
+ (unsigned)(f->file_create_parms.offset_size));
+ fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Size of file off_t type:",
+ (unsigned)(f->file_create_parms.length_size));
+ fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Bytes per B-tree page:",
+ (unsigned)(f->file_create_parms.btree_page_size));
+ fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Boot block version number:",
+ (unsigned)(f->file_create_parms.bootblock_ver));
+ fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Small object heap version number:",
+ (unsigned)(f->file_create_parms.smallobject_ver));
+ fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Free list version number:",
+ (unsigned)(f->file_create_parms.freespace_ver));
+ fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Object directory version number:",
+ (unsigned)(f->file_create_parms.objectdir_ver));
+ fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Shared header version number:",
+ (unsigned)(f->file_create_parms.sharedheader_ver));
+
+
+ return 0;
+}