diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2018-02-21 11:55:20 +0100 |
---|---|---|
committer | Eryu Guan <eguan@redhat.com> | 2018-02-22 15:44:30 +0800 |
commit | b8b56f24d917fef2ab8400a7bc645844cbd777d6 (patch) | |
tree | ddaf828ffa09c7d04b49971deadc2dbb250b4330 | |
parent | 69eb6281a9d37110364bd08476599efb3a996440 (diff) | |
download | xfstests-dev-b8b56f24d917fef2ab8400a7bc645844cbd777d6.tar.gz |
fsx: Fix -P errors
When -P is used, report the correct *.fsxgood filename in
report_failure and fix the default *.fsxops filename.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
-rw-r--r-- | ltp/fsx.c | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -121,6 +121,7 @@ char *bname; /* basename of our test file */ char *logdev; /* -i flag */ char *logid; /* -j flag */ char dname[1024]; /* -P flag */ +char goodfile[1024]; int dirpath = 0; /* -P flag */ int fd; /* fd for our test file */ @@ -510,8 +511,8 @@ report_failure(int status) if (good_buf) { save_buffer(good_buf, file_size, fsxgoodfd); prt("Correct content saved for comparison\n"); - prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n", - fname, fname); + prt("(maybe hexdump \"%s\" vs \"%s\")\n", + fname, goodfile); } close(fsxgoodfd); } @@ -1864,12 +1865,10 @@ main(int argc, char **argv) { int i, style, ch; char *endp, *tmp; - char goodfile[1024]; char logfile[1024]; struct stat statbuf; int o_flags = O_RDWR|O_CREAT|O_TRUNC; - goodfile[0] = 0; logfile[0] = 0; dname[0] = 0; @@ -2027,10 +2026,6 @@ main(int argc, char **argv) strncpy(dname, optarg, sizeof(dname)); strcat(dname, "/"); dirpath = strlen(dname); - - strncpy(goodfile, dname, sizeof(goodfile)); - strncpy(logfile, dname, sizeof(logfile)); - strncpy(opsfile, dname, sizeof(logfile)); break; case 'R': mapped_reads = 0; @@ -2124,24 +2119,28 @@ main(int argc, char **argv) } } #endif - strncat(goodfile, dirpath ? bname : fname, 256); - strcat (goodfile, ".fsxgood"); + + if (dirpath) { + snprintf(goodfile, sizeof(goodfile), "%s%s.fsxgood", dname, bname); + snprintf(logfile, sizeof(logfile), "%s%s.fsxlog", dname, bname); + if (!*opsfile) + snprintf(opsfile, sizeof(opsfile), "%s%s.fsxops", dname, bname); + } else { + snprintf(goodfile, sizeof(goodfile), "%s.fsxgood", fname); + snprintf(logfile, sizeof(logfile), "%s.fsxlog", fname); + if (!*opsfile) + snprintf(opsfile, sizeof(opsfile), "%s.fsxops", fname); + } fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666); if (fsxgoodfd < 0) { prterr(goodfile); exit(92); } - strncat(logfile, dirpath ? bname : fname, 256); - strcat (logfile, ".fsxlog"); fsxlogf = fopen(logfile, "w"); if (fsxlogf == NULL) { prterr(logfile); exit(93); } - if (!*opsfile) { - strncat(opsfile, dirpath ? bname : fname, 256); - strcat(opsfile, ".fsxops"); - } unlink(opsfile); if (replayops) { |