Commit c405a6bb authored by Philip Carns's avatar Philip Carns

add darshan-convert option to filter output to a specific file


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/branches/darshan-parser-file-list@752 3b7491f3-a168-0410-bf4b-c445ed680a29
parent f470e1e1
...@@ -28,22 +28,28 @@ int usage (char *exename) ...@@ -28,22 +28,28 @@ int usage (char *exename)
fprintf(stderr, " --obfuscate Obfuscate items in the log.\n"); fprintf(stderr, " --obfuscate Obfuscate items in the log.\n");
fprintf(stderr, " --key <key> Key to use when obfuscating.\n"); fprintf(stderr, " --key <key> Key to use when obfuscating.\n");
fprintf(stderr, " --annotate <string> Additional metadata to add.\n"); fprintf(stderr, " --annotate <string> Additional metadata to add.\n");
fprintf(stderr, " --file <hash> Limit output to specified (hashed) file only.\n");
exit(1); exit(1);
} }
void parse_args (int argc, char **argv, char **infile, char **outfile, void parse_args (int argc, char **argv, char **infile, char **outfile,
int *obfuscate, int *key, char **annotate) int *obfuscate, int *key, char **annotate, uint64_t* hash)
{ {
int index; int index;
int ret;
static struct option long_opts[] = static struct option long_opts[] =
{ {
{"annotate", 1, NULL, 'a'}, {"annotate", 1, NULL, 'a'},
{"obfuscate", 0, NULL, 'o'}, {"obfuscate", 0, NULL, 'o'},
{"key", 1, NULL, 'k'}, {"key", 1, NULL, 'k'},
{"file", 1, NULL, 'f'},
{"help", 0, NULL, 0} {"help", 0, NULL, 0}
}; };
*hash = 0;
while(1) while(1)
{ {
int c = getopt_long(argc, argv, "", long_opts, &index); int c = getopt_long(argc, argv, "", long_opts, &index);
...@@ -61,6 +67,11 @@ void parse_args (int argc, char **argv, char **infile, char **outfile, ...@@ -61,6 +67,11 @@ void parse_args (int argc, char **argv, char **infile, char **outfile,
case 'k': case 'k':
*key = atoi(optarg); *key = atoi(optarg);
break; break;
case 'f':
ret = sscanf(optarg, "%" PRIu64, hash);
if(ret != 1)
usage(argv[0]);
break;
case 0: case 0:
case '?': case '?':
default: default:
...@@ -151,8 +162,9 @@ int main(int argc, char **argv) ...@@ -151,8 +162,9 @@ int main(int argc, char **argv)
int obfuscate = 0; int obfuscate = 0;
int key = 0; int key = 0;
char *annotation = NULL; char *annotation = NULL;
uint64_t hash;
parse_args(argc, argv, &infile_name, &outfile_name, &obfuscate, &key, &annotation); parse_args(argc, argv, &infile_name, &outfile_name, &obfuscate, &key, &annotation, &hash);
infile = darshan_log_open(infile_name, "r"); infile = darshan_log_open(infile_name, "r");
if(!infile) if(!infile)
...@@ -252,13 +264,16 @@ int main(int argc, char **argv) ...@@ -252,13 +264,16 @@ int main(int argc, char **argv)
if(cp_file.rank != -1) if(cp_file.rank != -1)
last_rank = cp_file.rank; last_rank = cp_file.rank;
if (obfuscate) obfuscate_file(key, &cp_file); if(!hash || hash == cp_file.hash)
ret = darshan_log_putfile(outfile, &job, &cp_file);
if (ret < 0)
{ {
fprintf(stderr, "Error: failed to write file record.\n"); if (obfuscate) obfuscate_file(key, &cp_file);
break;
ret = darshan_log_putfile(outfile, &job, &cp_file);
if (ret < 0)
{
fprintf(stderr, "Error: failed to write file record.\n");
break;
}
} }
} while((ret = darshan_log_getfile(infile, &job, &cp_file)) == 1); } while((ret = darshan_log_getfile(infile, &job, &cp_file)) == 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment