Detect attribute creation order tracking setting

When opening an existing file for NC_WRITE access,
check whether the file was created originally with
attribute creation order tracking disabled and if
so, use that setting for subsequent attribute creation.

Also check the `mode` passed in to the open call
in case application is explicitly disabling the
attribute creation order tracking with the NC_NOATTRCREORD flag.
This commit is contained in:
Greg Sjaardema 2021-08-12 13:22:49 -06:00
parent a611f19b32
commit 3ce6df07ba

View File

@ -756,6 +756,10 @@ nc4_open_file(const char *path, int mode, void* parameters, int ncid)
if ((mode & NC_WRITE) == 0)
nc4_info->no_write = NC_TRUE;
if ((mode & NC_WRITE) && (mode & NC_NOATTCREORD)) {
nc4_info->no_attr_create_order = NC_TRUE;
}
if(nc4_info->mem.inmemory && nc4_info->mem.diskless)
BAIL(NC_EINTERNAL);
@ -900,6 +904,19 @@ nc4_open_file(const char *path, int mode, void* parameters, int ncid)
BAIL(NC_EHDFERR);
}
/* Get the file creation property list to check for attribute ordering */
{
hid_t pid;
unsigned int crt_order_flags;
if ((pid = H5Fget_create_plist(h5->hdfid)) < 0)
BAIL(NC_EHDFERR);
if (H5Pget_attr_creation_order(pid, &crt_order_flags) < 0)
BAIL(NC_EHDFERR);
if (!(crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
nc4_info->no_attr_create_order = NC_TRUE;
}
}
/* Now read in all the metadata. Some types and dimscale
* information may be difficult to resolve here, if, for example, a
* dataset of user-defined type is encountered before the