Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sudheer Chunduri
darshan
Commits
d4413b4e
Commit
d4413b4e
authored
Jan 04, 2016
by
Shane Snyder
Browse files
better error handling for opening old log files
parent
86533a49
Changes
1
Hide whitespace changes
Inline
Side-by-side
darshan-util/darshan-logutils.c
View file @
d4413b4e
...
...
@@ -133,6 +133,7 @@ darshan_fd darshan_log_open(const char *name)
ret
=
darshan_log_getheader
(
tmp_fd
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error: failed to read darshan log file header.
\n
"
);
close
(
tmp_fd
->
state
->
fildes
);
free
(
tmp_fd
->
state
);
free
(
tmp_fd
);
...
...
@@ -845,6 +846,30 @@ static int darshan_log_getheader(darshan_fd fd)
return
(
-
1
);
}
/* read the version number so we know how to process this log */
ret
=
darshan_log_read
(
fd
,
&
fd
->
version
,
8
);
if
(
ret
<
8
)
{
fprintf
(
stderr
,
"Error: invalid log file (failed to read version).
\n
"
);
return
(
-
1
);
}
/* other log file versions can be detected and handled here */
if
(
strcmp
(
fd
->
version
,
"3.00"
))
{
fprintf
(
stderr
,
"Error: incompatible darshan file.
\n
"
);
fprintf
(
stderr
,
"Error: expected version %s
\n
"
,
DARSHAN_LOG_VERSION
);
return
(
-
1
);
}
/* seek back so we can read the entire header */
ret
=
darshan_log_seek
(
fd
,
0
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error: unable to seek in darshan log file.
\n
"
);
return
(
-
1
);
}
/* read uncompressed header from log file */
ret
=
darshan_log_read
(
fd
,
&
header
,
sizeof
(
header
));
if
(
ret
!=
sizeof
(
header
))
...
...
@@ -853,9 +878,6 @@ static int darshan_log_getheader(darshan_fd fd)
return
(
-
1
);
}
/* save the version string */
strncpy
(
fd
->
version
,
header
.
version_string
,
8
);
if
(
header
.
magic_nr
==
DARSHAN_MAGIC_NR
)
{
/* no byte swapping needed, this file is in host format already */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment