diff options
25 files changed, 148 insertions, 56 deletions
diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 3ba294d..f262c4b 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -172,6 +172,7 @@ H5G_obj_create(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, lnk.type = H5L_TYPE_HARD; lnk.corder = 0; lnk.corder_valid = linfo->track_corder; + lnk.cset = H5T_CSET_ASCII; lnk.name = &null_char; link_size = H5O_msg_size_f(f, gcpl_id, H5O_LINK_ID, &lnk, (size_t)ginfo->est_name_len); HDassert(link_size); @@ -677,8 +677,6 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id, /* Initialize version-specific fields */ if(oh->version > H5O_VERSION_1) { - uint64_t tent_oh_size; /* Tentative size of object header */ - /* Initialize all time fields with current time, if we are storing them */ if(oh->flags & H5O_HDR_STORE_TIMES) oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now(); diff --git a/src/H5Olink.c b/src/H5Olink.c index 94e07ab..655e35a 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -81,7 +81,17 @@ const H5O_msg_class_t H5O_MSG_LINK[1] = {{ #define H5O_LINK_VERSION 1 /* Flags for link flag encoding */ -#define H5O_LINK_FLAG_HAS_CORDER 0x01 +#define H5O_LINK_NAME_SIZE 0x03 /* 2-bit field for size of name length */ +#define H5O_LINK_STORE_CORDER 0x04 /* Whether to store creation index */ +#define H5O_LINK_STORE_LINK_TYPE 0x08 /* Whether to store non-default link type */ +#define H5O_LINK_STORE_NAME_CSET 0x10 /* Whether to store non-default name character set */ +#define H5O_LINK_ALL_FLAGS (H5O_LINK_NAME_SIZE | H5O_LINK_STORE_CORDER | H5O_LINK_STORE_LINK_TYPE | H5O_LINK_STORE_NAME_CSET) + +/* Individual definitions of name size values */ +#define H5O_LINK_NAME_1 0x00 /* Use 1-byte value for name length */ +#define H5O_LINK_NAME_2 0x01 /* Use 2-byte value for name length */ +#define H5O_LINK_NAME_4 0x02 /* Use 4-byte value for name length */ +#define H5O_LINK_NAME_8 0x03 /* Use 8-byte value for name length */ /* Declare a free list to manage the H5O_link_t struct */ H5FL_DEFINE_STATIC(H5O_link_t); @@ -128,14 +138,21 @@ H5O_link_decode(H5F_t *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_flags, /* Get the encoding flags for the link */ link_flags = *p++; - - /* Get the type of the link */ - lnk->type = *p++; - if(lnk->type < H5L_TYPE_HARD || lnk->type > H5L_TYPE_MAX) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad link type") + if(link_flags & ~H5O_LINK_ALL_FLAGS) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad flag value for message") + + /* Check for non-default link type */ + if(link_flags & H5O_LINK_STORE_LINK_TYPE) { + /* Get the type of the link */ + lnk->type = *p++; + if(lnk->type < H5L_TYPE_HARD || lnk->type > H5L_TYPE_MAX) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad link type") + } /* end if */ + else + lnk->type = H5L_TYPE_HARD; /* Get the link creation time from the file */ - if(link_flags & H5O_LINK_FLAG_HAS_CORDER) { + if(link_flags & H5O_LINK_STORE_CORDER) { INT64DECODE(p, lnk->corder) lnk->corder_valid = TRUE; } /* end if */ @@ -144,15 +161,41 @@ H5O_link_decode(H5F_t *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_flags, lnk->corder_valid = FALSE; } /* end else */ - /* Get the link name's character set */ - lnk->cset = (H5T_cset_t)*p++; - if(lnk->cset < H5T_CSET_ASCII || lnk->cset > H5T_CSET_UTF8) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad cset type") + /* Check for non-default name character set */ + if(link_flags & H5O_LINK_STORE_NAME_CSET) { + /* Get the link name's character set */ + lnk->cset = (H5T_cset_t)*p++; + if(lnk->cset < H5T_CSET_ASCII || lnk->cset > H5T_CSET_UTF8) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad cset type") + } /* end if */ + else + lnk->cset = H5T_CSET_ASCII; - /* Get the link's name */ - UINT32DECODE(p, len) + /* Get the length of the link's name */ + switch(link_flags & H5O_LINK_NAME_SIZE) { + case 0: /* 1 byte size */ + len = *p++; + break; + + case 1: /* 2 byte size */ + UINT16DECODE(p, len); + break; + + case 2: /* 4 byte size */ + UINT32DECODE(p, len); + break; + + case 3: /* 8 byte size */ + UINT64DECODE(p, len); + break; + + default: + HDassert(0 && "bad size for name"); + } /* end switch */ if(len == 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "invalid name length") + + /* Get the link's name */ if(NULL == (lnk->name = H5MM_malloc(len + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDmemcpy(lnk->name, p, len); @@ -232,9 +275,9 @@ done: static herr_t H5O_link_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void *_mesg) { - const H5O_link_t *lnk = (const H5O_link_t *) _mesg; - size_t len; /* Length of a string in the message */ - unsigned char link_flags; /* Flags for encoding link info */ + const H5O_link_t *lnk = (const H5O_link_t *) _mesg; + uint64_t len; /* Length of a string in the message */ + unsigned char link_flags; /* Flags for encoding link info */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_link_encode) @@ -243,28 +286,63 @@ H5O_link_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void HDassert(p); HDassert(lnk); + /* Get length of link's name */ + len = (uint64_t)HDstrlen(lnk->name); + HDassert(len > 0); + /* encode */ *p++ = H5O_LINK_VERSION; /* The encoding flags for the link */ - link_flags = lnk->corder_valid ? H5O_LINK_FLAG_HAS_CORDER : 0; + if(len > 4294967295) + link_flags = H5O_LINK_NAME_8; + else if(len > 65535) + link_flags = H5O_LINK_NAME_4; + else if(len > 255) + link_flags = H5O_LINK_NAME_2; + else + link_flags = H5O_LINK_NAME_1; + link_flags |= lnk->corder_valid ? H5O_LINK_STORE_CORDER : 0; + link_flags |= (lnk->type != H5L_TYPE_HARD) ? H5O_LINK_STORE_LINK_TYPE : 0; + link_flags |= (lnk->cset != H5T_CSET_ASCII) ? H5O_LINK_STORE_NAME_CSET : 0; *p++ = link_flags; - /* Store the type of the link */ - *p++ = lnk->type; + /* Store the type of a non-default link */ + if(link_flags & H5O_LINK_STORE_LINK_TYPE) + *p++ = lnk->type; /* Store the link creation order in the file, if its valid */ if(lnk->corder_valid) INT64ENCODE(p, lnk->corder) - /* Store the link name's character set */ - *p++ = (uint8_t)lnk->cset; + /* Store a non-default link name character set */ + if(link_flags & H5O_LINK_STORE_NAME_CSET) + *p++ = (uint8_t)lnk->cset; + + /* Store the link name's length */ + switch(link_flags & H5O_LINK_NAME_SIZE) { + case 0: /* 1 byte size */ + *p++ = len; + break; + + case 1: /* 2 byte size */ + UINT16ENCODE(p, len); + break; + + case 2: /* 4 byte size */ + UINT32ENCODE(p, len); + break; + + case 3: /* 8 byte size */ + UINT64ENCODE(p, len); + break; + + default: + HDassert(0 && "bad size for name"); + } /* end switch */ /* Store the link's name */ - len = HDstrlen(lnk->name); - HDassert(len > 0); - UINT32ENCODE(p, (uint32_t)len) - HDmemcpy(p, lnk->name, len); + HDmemcpy(p, lnk->name, (size_t)len); p += len; /* Store the appropriate information for each type of link */ @@ -279,7 +357,7 @@ H5O_link_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void len = (uint16_t)HDstrlen(lnk->u.soft.name); HDassert(len > 0); UINT16ENCODE(p, len) - HDmemcpy(p, lnk->u.soft.name, len); + HDmemcpy(p, lnk->u.soft.name, (size_t)len); p += len; break; @@ -292,7 +370,7 @@ H5O_link_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void UINT16ENCODE(p, len) if(len > 0) { - HDmemcpy(p, lnk->u.ud.udata, len); + HDmemcpy(p, lnk->u.ud.udata, (size_t)len); p+=len; } break; @@ -382,18 +460,33 @@ static size_t H5O_link_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg) { const H5O_link_t *lnk = (const H5O_link_t *)_mesg; + uint64_t name_len; /* Length of name */ + size_t name_size; /* Size of encoded name length */ size_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_link_size) + /* Get name's length */ + name_len = (uint64_t)HDstrlen(lnk->name); + + /* Determine correct value for name size bits */ + if(name_len > 4294967295) + name_size = 8; + else if(name_len > 65535) + name_size = 4; + else if(name_len > 255) + name_size = 2; + else + name_size = 1; + /* Set return value */ ret_value = 1 + /* Version */ 1 + /* Link encoding flags */ - 1 + /* Link type */ + (lnk->type != H5L_TYPE_HARD ? 1 : 0) + /* Link type */ (lnk->corder_valid ? 8 : 0) + /* Creation order */ - 1 + /* Character set */ - 4 + /* Name length */ - HDstrlen(lnk->name); /* Name */ + (lnk->cset != H5T_CSET_ASCII ? 1 : 0) + /* Character set */ + name_size + /* Name length */ + name_len; /* Name */ /* Add the appropriate length for each type of link */ switch(lnk->type) { diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 17532e0..0eed076 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -89,10 +89,10 @@ #define H5O_CRT_OHDR_FLAGS_DEF H5O_HDR_STORE_TIMES /* Object header status flag definitions */ -#define H5O_HDR_CHUNK0_1 0x00 -#define H5O_HDR_CHUNK0_2 0x01 -#define H5O_HDR_CHUNK0_4 0x02 -#define H5O_HDR_CHUNK0_8 0x03 +#define H5O_HDR_CHUNK0_1 0x00 /* Use 1-byte value for chunk #0 size */ +#define H5O_HDR_CHUNK0_2 0x01 /* Use 2-byte value for chunk #0 size */ +#define H5O_HDR_CHUNK0_4 0x02 /* Use 4-byte value for chunk #0 size */ +#define H5O_HDR_CHUNK0_8 0x03 /* Use 8-byte value for chunk #0 size */ /* * Size of object header prefix. diff --git a/test/be_extlink1.h5 b/test/be_extlink1.h5 Binary files differindex d8838f9..fa63f95 100644 --- a/test/be_extlink1.h5 +++ b/test/be_extlink1.h5 diff --git a/test/be_extlink2.h5 b/test/be_extlink2.h5 Binary files differindex ba60adc..5956047 100644 --- a/test/be_extlink2.h5 +++ b/test/be_extlink2.h5 diff --git a/test/le_extlink1.h5 b/test/le_extlink1.h5 Binary files differindex 07298b0..f7bbba9 100644 --- a/test/le_extlink1.h5 +++ b/test/le_extlink1.h5 diff --git a/test/le_extlink2.h5 b/test/le_extlink2.h5 Binary files differindex ba60adc..5956047 100644 --- a/test/le_extlink2.h5 +++ b/test/le_extlink2.h5 diff --git a/test/stab.c b/test/stab.c index 8ec79eb..adf9803 100644 --- a/test/stab.c +++ b/test/stab.c @@ -427,9 +427,9 @@ lifecycle(hid_t fapl) /* Check that the object header is only one chunk and the space has been allocated correctly */ if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR #ifdef H5_HAVE_LARGE_HSIZET - if(obj_stat.ohdr.size != 183) TEST_ERROR -#else /* H5_HAVE_LARGE_HSIZET */ if(obj_stat.ohdr.size != 163) TEST_ERROR +#else /* H5_HAVE_LARGE_HSIZET */ + if(obj_stat.ohdr.size != 143) TEST_ERROR #endif /* H5_HAVE_LARGE_HSIZET */ if(obj_stat.ohdr.free != 0) TEST_ERROR if(obj_stat.ohdr.nmesgs != 6) TEST_ERROR @@ -453,11 +453,11 @@ lifecycle(hid_t fapl) /* Check that the object header is still one chunk and the space has been allocated correctly */ if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR #ifdef H5_HAVE_LARGE_HSIZET - if(obj_stat.ohdr.size != 183) TEST_ERROR -#else /* H5_HAVE_LARGE_HSIZET */ if(obj_stat.ohdr.size != 163) TEST_ERROR +#else /* H5_HAVE_LARGE_HSIZET */ + if(obj_stat.ohdr.size != 143) TEST_ERROR #endif /* H5_HAVE_LARGE_HSIZET */ - if(obj_stat.ohdr.free != 112) TEST_ERROR + if(obj_stat.ohdr.free != 92) TEST_ERROR if(obj_stat.ohdr.nmesgs != 3) TEST_ERROR if(obj_stat.ohdr.nchunks != 1) TEST_ERROR diff --git a/tools/testfiles/h5diff_types.h5 b/tools/testfiles/h5diff_types.h5 Binary files differindex fd75f34..d5ff2f7 100644 --- a/tools/testfiles/h5diff_types.h5 +++ b/tools/testfiles/h5diff_types.h5 diff --git a/tools/testfiles/h5mkgrp_nested_latest.ls b/tools/testfiles/h5mkgrp_nested_latest.ls index f256b84..320e19d 100644 --- a/tools/testfiles/h5mkgrp_nested_latest.ls +++ b/tools/testfiles/h5mkgrp_nested_latest.ls @@ -3,10 +3,10 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_nested_latest.h5' ############################# Opened "../testfiles/h5mkgrp_nested_latest.h5" with sec2 driver. /one Group - Location: 1:406 + Location: 1:366 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX /one/two Group - Location: 1:227 + Location: 1:207 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX diff --git a/tools/testfiles/h5mkgrp_nested_mult_latest.ls b/tools/testfiles/h5mkgrp_nested_mult_latest.ls index 9a08774..c3a4cf1 100644 --- a/tools/testfiles/h5mkgrp_nested_mult_latest.ls +++ b/tools/testfiles/h5mkgrp_nested_mult_latest.ls @@ -3,18 +3,18 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_nested_mult_latest.h5' ############################# Opened "../testfiles/h5mkgrp_nested_mult_latest.h5" with sec2 driver. /one Group - Location: 1:406 + Location: 1:366 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX /one/two Group - Location: 1:227 + Location: 1:207 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX /three Group - Location: 1:764 + Location: 1:684 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX /three/four Group - Location: 1:585 + Location: 1:525 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX diff --git a/tools/testfiles/h5mkgrp_several_latest.ls b/tools/testfiles/h5mkgrp_several_latest.ls index f5d62e0..f43e6c2 100644 --- a/tools/testfiles/h5mkgrp_several_latest.ls +++ b/tools/testfiles/h5mkgrp_several_latest.ls @@ -3,10 +3,10 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_several_latest.h5' ############################# Opened "../testfiles/h5mkgrp_several_latest.h5" with sec2 driver. /one Group - Location: 1:227 + Location: 1:207 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX /two Group - Location: 1:406 + Location: 1:366 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX diff --git a/tools/testfiles/h5mkgrp_single_latest.ls b/tools/testfiles/h5mkgrp_single_latest.ls index 6ecc9ca..72901cf 100644 --- a/tools/testfiles/h5mkgrp_single_latest.ls +++ b/tools/testfiles/h5mkgrp_single_latest.ls @@ -3,6 +3,6 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_single_latest.h5' ############################# Opened "../testfiles/h5mkgrp_single_latest.h5" with sec2 driver. /latest Group - Location: 1:227 + Location: 1:207 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX diff --git a/tools/testfiles/h5repack_objs.h5 b/tools/testfiles/h5repack_objs.h5 Binary files differindex 509de91..d6b9e81 100644 --- a/tools/testfiles/h5repack_objs.h5 +++ b/tools/testfiles/h5repack_objs.h5 diff --git a/tools/testfiles/tall-2A.h5.xml b/tools/testfiles/tall-2A.h5.xml index 60daa12..e0da42c 100644 --- a/tools/testfiles/tall-2A.h5.xml +++ b/tools/testfiles/tall-2A.h5.xml @@ -134,7 +134,7 @@ Expected output for 'h5dump --xml -A tall.h5' </hdf5:Group> </hdf5:Group> <hdf5:Group Name="g2" OBJ-XID="xid_1848" H5Path="/g2" Parents="xid_96" H5ParentPaths="/" > - <hdf5:Dataset Name="dset2.1" OBJ-XID="xid_9024" H5Path= "/g2/dset2.1" Parents="xid_1848" H5ParentPaths="/g2"> + <hdf5:Dataset Name="dset2.1" OBJ-XID="xid_9000" H5Path= "/g2/dset2.1" Parents="xid_1848" H5ParentPaths="/g2"> <hdf5:StorageLayout> <hdf5:ContiguousLayout/> </hdf5:StorageLayout> @@ -157,7 +157,7 @@ Expected output for 'h5dump --xml -A tall.h5' <hdf5:NoData/> </hdf5:Data> </hdf5:Dataset> - <hdf5:Dataset Name="dset2.2" OBJ-XID="xid_9624" H5Path= "/g2/dset2.2" Parents="xid_1848" H5ParentPaths="/g2"> + <hdf5:Dataset Name="dset2.2" OBJ-XID="xid_9600" H5Path= "/g2/dset2.2" Parents="xid_1848" H5ParentPaths="/g2"> <hdf5:StorageLayout> <hdf5:ContiguousLayout/> </hdf5:StorageLayout> diff --git a/tools/testfiles/tall.h5 b/tools/testfiles/tall.h5 Binary files differindex aff18d8..acd0693 100644 --- a/tools/testfiles/tall.h5 +++ b/tools/testfiles/tall.h5 diff --git a/tools/testfiles/tall.h5.xml b/tools/testfiles/tall.h5.xml index aec74d7..2027474 100644 --- a/tools/testfiles/tall.h5.xml +++ b/tools/testfiles/tall.h5.xml @@ -147,7 +147,7 @@ Expected output for 'h5dump --xml tall.h5' </hdf5:Group> </hdf5:Group> <hdf5:Group Name="g2" OBJ-XID="xid_1848" H5Path="/g2" Parents="xid_96" H5ParentPaths="/" > - <hdf5:Dataset Name="dset2.1" OBJ-XID="xid_9024" H5Path= "/g2/dset2.1" Parents="xid_1848" H5ParentPaths="/g2"> + <hdf5:Dataset Name="dset2.1" OBJ-XID="xid_9000" H5Path= "/g2/dset2.1" Parents="xid_1848" H5ParentPaths="/g2"> <hdf5:StorageLayout> <hdf5:ContiguousLayout/> </hdf5:StorageLayout> @@ -172,7 +172,7 @@ Expected output for 'h5dump --xml tall.h5' </hdf5:DataFromFile> </hdf5:Data> </hdf5:Dataset> - <hdf5:Dataset Name="dset2.2" OBJ-XID="xid_9624" H5Path= "/g2/dset2.2" Parents="xid_1848" H5ParentPaths="/g2"> + <hdf5:Dataset Name="dset2.2" OBJ-XID="xid_9600" H5Path= "/g2/dset2.2" Parents="xid_1848" H5ParentPaths="/g2"> <hdf5:StorageLayout> <hdf5:ContiguousLayout/> </hdf5:StorageLayout> diff --git a/tools/testfiles/tcontents.ddl b/tools/testfiles/tcontents.ddl index 74805c3..5665746 100644 --- a/tools/testfiles/tcontents.ddl +++ b/tools/testfiles/tcontents.ddl @@ -3,7 +3,7 @@ Expected output for 'h5dump -n tfcontents1.h5' ############################# HDF5 "tfcontents1.h5" { FILE_CONTENTS { - datatype /#7290 + datatype /#5648 dataset /dset dataset /dset3 -> /dset dataset /dset4 -> /dset diff --git a/tools/testfiles/textlink.h5 b/tools/testfiles/textlink.h5 Binary files differindex d767a41..701df6b 100644 --- a/tools/testfiles/textlink.h5 +++ b/tools/testfiles/textlink.h5 diff --git a/tools/testfiles/tfcontents1.h5 b/tools/testfiles/tfcontents1.h5 Binary files differindex 508b504..8c6ad11 100644 --- a/tools/testfiles/tfcontents1.h5 +++ b/tools/testfiles/tfcontents1.h5 diff --git a/tools/testfiles/tmany.h5 b/tools/testfiles/tmany.h5 Binary files differindex 7297842..b19cf42 100644 --- a/tools/testfiles/tmany.h5 +++ b/tools/testfiles/tmany.h5 diff --git a/tools/testfiles/tudlink.h5 b/tools/testfiles/tudlink.h5 Binary files differindex b182a1f..ea2d80b 100644 --- a/tools/testfiles/tudlink.h5 +++ b/tools/testfiles/tudlink.h5 diff --git a/tools/testfiles/twithub.h5 b/tools/testfiles/twithub.h5 Binary files differindex 40f81c6..860af95 100644 --- a/tools/testfiles/twithub.h5 +++ b/tools/testfiles/twithub.h5 diff --git a/tools/testfiles/twithub513.h5 b/tools/testfiles/twithub513.h5 Binary files differindex 3981219..01d1b0c 100644 --- a/tools/testfiles/twithub513.h5 +++ b/tools/testfiles/twithub513.h5 |