summaryrefslogtreecommitdiffstats
path: root/tools/src/h5ls/h5ls.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src/h5ls/h5ls.c')
-rw-r--r--tools/src/h5ls/h5ls.c74
1 files changed, 57 insertions, 17 deletions
diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c
index 765ab63..f2401b2 100644
--- a/tools/src/h5ls/h5ls.c
+++ b/tools/src/h5ls/h5ls.c
@@ -96,7 +96,7 @@ static h5tool_format_t ls_dataformat = {
0, /*skip_first */
0, /*obj_hidefileno */
- "-%lu:"H5_PRINTF_HADDR_FMT, /*obj_format */
+ "-%lu:%" PRIuHADDR, /*obj_format */
0, /*dset_hidefileno */
"DSET-%s ", /*dset_format */
@@ -121,6 +121,7 @@ typedef struct {
/* Command-line switches */
static int verbose_g = 0; /* lots of extra output */
static int width_g = 80; /* output width in characters */
+static hbool_t vfd_swmr_poll_g = FALSE; /* poll for changes using VFD SWMR */
static hbool_t address_g = FALSE; /* print raw data addresses */
static hbool_t data_g = FALSE; /* display dataset values? */
static hbool_t label_g = FALSE; /* label compound values? */
@@ -171,6 +172,7 @@ usage (void)
{
FLUSHSTREAM(rawoutstream);
PRINTVALSTREAM(rawoutstream, "usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...]\n");
+ PRINTVALSTREAM(rawoutstream, " h5ls [OPTIONS] --poll file\n");
PRINTVALSTREAM(rawoutstream, " OPTIONS\n");
PRINTVALSTREAM(rawoutstream, " -h, -?, --help Print a usage message and exit\n");
PRINTVALSTREAM(rawoutstream, " -a, --address Print raw data address. If dataset is contiguous, address\n");
@@ -201,6 +203,7 @@ usage (void)
PRINTVALSTREAM(rawoutstream, " -f, --full Print full path names instead of base names\n");
PRINTVALSTREAM(rawoutstream, " -g, --group Show information about a group, not its contents\n");
PRINTVALSTREAM(rawoutstream, " -l, --label Label members of compound datasets\n");
+ PRINTVALSTREAM(rawoutstream, " -p, --poll Continuously re-read and re-display the input file using VFD SWMR\n");
PRINTVALSTREAM(rawoutstream, " -r, --recursive List all groups recursively, avoiding cycles\n");
PRINTVALSTREAM(rawoutstream, " -s, --string Print 1-byte integer datasets as ASCII\n");
PRINTVALSTREAM(rawoutstream, " -S, --simple Use a machine-readable output format\n");
@@ -1643,6 +1646,8 @@ dump_dataset_values(hid_t dset)
ctx.need_prefix = TRUE;
ctx.cur_column = (size_t)curr_pos;
+ if (vfd_swmr_poll_g)
+ H5Drefresh(dset);
if (H5Tget_class(f_type) == H5T_REFERENCE) {
H5TOOLS_DEBUG("reference class type");
if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) && !H5Tequal(f_type, H5T_STD_REF_OBJ)) {
@@ -2850,11 +2855,12 @@ main(int argc, const char *argv[])
char *fname = NULL, *oname = NULL, *x;
const char *s = NULL;
char *rest;
- int argno;
+ int argno, times;
static char root_name[] = "/";
char drivername[50];
const char *preferred_driver = NULL;
int err_exit = 0;
+ uint64_t poll_nanosecs = 1000;
hid_t fapl_id = H5P_DEFAULT;
H5E_auto2_t func;
H5E_auto2_t tools_func;
@@ -2946,8 +2952,20 @@ main(int argc, const char *argv[])
}
else if (!HDstrcmp(argv[argno], "--full")) {
fullname_g = TRUE;
- }
- else if (!HDstrcmp(argv[argno], "--group")) {
+ } else if(!HDstrncmp(argv[argno], "--poll=", strlen("--poll="))) {
+ int nscanned = 0, rc;
+ uint64_t poll_millisecs;
+ rc = sscanf(argv[argno], "--poll=%" SCNu64 "%n", &poll_millisecs,
+ &nscanned);
+ if (rc != 1 || argv[argno][nscanned] != '\0') {
+ usage();
+ leave(EXIT_FAILURE);
+ }
+ poll_nanosecs = poll_millisecs * 1000000;
+ vfd_swmr_poll_g = TRUE;
+ } else if(!HDstrcmp(argv[argno], "--poll")) {
+ vfd_swmr_poll_g = TRUE;
+ } else if (!HDstrcmp(argv[argno], "--group")) {
grp_literal_g = TRUE;
}
else if (!HDstrcmp(argv[argno], "--label")) {
@@ -3119,6 +3137,10 @@ main(int argc, const char *argv[])
label_g = TRUE;
break;
+ case 'p': /* --poll */
+ vfd_swmr_poll_g = TRUE;
+ break;
+
case 'r': /* --recursive */
recursive_g = TRUE;
fullname_g = TRUE;
@@ -3165,6 +3187,10 @@ main(int argc, const char *argv[])
leave(EXIT_FAILURE);
} /* end if */
+ if (vfd_swmr_poll_g && argc > 1 + argno) {
+ HDfprintf(rawerrorstream, "Error: -p / --poll is limited to only one file[/OBJECT]\n\n");
+ leave(EXIT_FAILURE);
+ }
/* Check for conflicting arguments */
if (!is_valid_args()) {
usage();
@@ -3232,6 +3258,10 @@ main(int argc, const char *argv[])
symlink_trav_t symlink_list;
size_t u;
+ if (vfd_swmr_poll_g) {
+ preferred_driver = "swmr";
+ }
+
fname = HDstrdup(argv[argno++]);
oname = NULL;
file_id = H5I_INVALID_HID;
@@ -3244,8 +3274,8 @@ main(int argc, const char *argv[])
if (verbose_g)
PRINTSTREAM(rawoutstream, "Opened \"%s\" with %s driver.\n", fname, drivername);
break; /*success*/
- } /* end if */
-
+ } else if (vfd_swmr_poll_g)
+ break;
/* Shorten the file name; lengthen the object name */
x = oname;
oname = HDstrrchr(fname, '/');
@@ -3323,18 +3353,28 @@ main(int argc, const char *argv[])
else
li.type = H5L_TYPE_HARD;
- /* Open the object and display it's information */
- if (li.type == H5L_TYPE_HARD) {
- if (visit_obj(file_id, oname, &iter) < 0) {
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- leave(EXIT_FAILURE);
+ for (times = 0; vfd_swmr_poll_g || times < 1; times++) {
+ if (vfd_swmr_poll_g) {
+ int i;
+ for (i = 0; i < 3; i++)
+ printf("\n");
}
- } /* end if(li.type == H5L_TYPE_HARD) */
- else {
- /* Specified name is not for object -- list that link */
- /* Use file_id ID for root group ID */
- iter.gid = file_id;
- list_lnk(oname, &li, &iter);
+ /* Open the object and display it's information */
+ if (li.type == H5L_TYPE_HARD) {
+ if (visit_obj(file_id, oname, &iter) < 0) {
+ H5Eset_auto2(H5E_DEFAULT, func, edata);
+ leave(EXIT_FAILURE);
+ }
+ } /* end if(li.type == H5L_TYPE_HARD) */
+ else {
+ /* Specified name is not for object -- list that link */
+ /* Use file_id ID for root group ID */
+ iter.gid = file_id;
+ list_lnk(oname, &li, &iter);
+ }
+#if 1
+ H5_nanosleep(poll_nanosecs);
+#endif
}
H5Fclose(file_id);
HDfree(fname);