summaryrefslogtreecommitdiffstats
path: root/src/H5G.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1997-08-13 15:36:47 (GMT)
committerRobb Matzke <matzke@llnl.gov>1997-08-13 15:36:47 (GMT)
commit5cae95154903ecd6564f0712e42168892df17b7d (patch)
treeffc18b449e49921bbe15cb7a02c6b2f0785f3324 /src/H5G.c
parent46ef9d9c266b704ba93ed55296ed2ebab600a2a4 (diff)
downloadhdf5-5cae95154903ecd6564f0712e42168892df17b7d.zip
hdf5-5cae95154903ecd6564f0712e42168892df17b7d.tar.gz
hdf5-5cae95154903ecd6564f0712e42168892df17b7d.tar.bz2
[svn-r27] ./src/H5B.c
./src/H5Bprivate.h The B-tree K value comes from a combination of the B-tree subclass and the file. ./src/H5C.c ./src/H5F.c ./src/hdf5lims.h ./src/hdf5type.h Removed the B-tree size parameter and added an array of B-tree K values. Also added symbol table node K value. ./src/H5Eprivate.h ./src/H5Eproto.h Added H5E_LINK for errors involving link counts. ./src/H5G.c Inserting something into a directory with H5G_insert() increments the link count in the object header. The root object should always have a link count of at least 1. ./src/H5Gnode.c ./src/H5Gprivate.h The symbol table node K value comes from the file instead of being a constant. ./src/H5Olink.c Added an assert(), fixed a hard-link bug.
Diffstat (limited to 'src/H5G.c')
-rw-r--r--src/H5G.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/H5G.c b/src/H5G.c
index 45aada7..f6cbb9b 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -279,6 +279,7 @@ H5G_mkroot (hdf5_file_t *f, size_t size_hint)
H5O_name_t name; /*object name message */
H5G_entry_t root; /*old root entry */
const char *root_name=NULL; /*name of old root object */
+ intn nlinks; /*number of links */
FUNC_ENTER (H5G_mkroot, NULL, FAIL);
@@ -310,9 +311,19 @@ H5G_mkroot (hdf5_file_t *f, size_t size_hint)
}
/*
- * Insert the old root object.
+ * Increase the link count for the root symbol table!
+ */
+ nlinks = H5O_link (f, f->root_sym->header, f->root_sym, 1);
+ assert (1==nlinks);
+
+ /*
+ * Insert the old root object. It should already have a link count
+ * of 1.
*/
if (root_name) {
+ nlinks = H5O_link (f, root.header, &root, 0);
+ assert (1==nlinks);
+
if (H5G_stab_insert (f, f->root_sym, root_name, &root)) {
/* can't insert old root object in new root directory */
H5O_reset (H5O_NAME, &name);
@@ -472,6 +483,9 @@ H5G_find (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent,
* ('/') since that is a special case. If NAME is the root
* symbol table entry, then this function will return failure.
*
+ * Inserting an object entry into the symbol table increments
+ * the link counter for that object.
+ *
* Return: Success: SUCCEED with optional DIR_ENT initialized with
* the symbol table entry for the directory
* which contains the new ENT.
@@ -532,6 +546,11 @@ H5G_insert (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent,
}
}
+ /* increment the link count */
+ if (H5O_link (f, ent->header, ent, 1)<0) {
+ HRETURN_ERROR (H5E_DIRECTORY, H5E_LINK, FAIL); /*can't increase linkage*/
+ }
+
/* insert entry into parent */
if (H5G_stab_insert (f, dir_ent, rest, ent)<0) {
HRETURN_ERROR (H5E_DIRECTORY, H5E_CANTINIT, FAIL); /*can't insert*/
@@ -668,8 +687,12 @@ H5G_stab_new (hdf5_file_t *f, H5G_entry_t *self, size_t init)
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL);
}
- /* Create symbol table object header with a single link */
- if ((addr = H5O_new (f, 1, 4+2*H5F_SIZEOF_OFFSET(f)))<0) {
+ /*
+ * Create symbol table object header. It has a zero link count
+ * since nothing refers to it yet. The link count will be
+ * incremented if the object is added to the directory hierarchy.
+ */
+ if ((addr = H5O_new (f, 0, 4+2*H5F_SIZEOF_OFFSET(f)))<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL);
}
@@ -839,6 +862,8 @@ H5G_stab_insert (hdf5_file_t *f, H5G_entry_t *self, const char *name,
HRETURN_ERROR (H5E_SYM, H5E_CANTINSERT, FAIL);
}
+ /* update the name offset in the entry */
+ ent->name_off = udata.entry.name_off;
FUNC_LEAVE (SUCCEED);
}