X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Ftests%2Futime.c;h=4295e5a01f3f2232ac61691aeaea0fb3d7acc098;hp=0c84ef8b5860c278ee2b65e0aeab5af41a380e09;hb=1d3c585194a907addbe8be7a884cc28d51db4b48;hpb=e3a7c58aebafce40323db54bf6056029e5af4a70 diff --git a/lustre/tests/utime.c b/lustre/tests/utime.c index 0c84ef8..4295e5a 100644 --- a/lustre/tests/utime.c +++ b/lustre/tests/utime.c @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -29,7 +25,6 @@ */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. * * lustre/tests/utime.c * @@ -57,26 +52,27 @@ int main(int argc, char *argv[]) { long before_mknod, after_mknod; const char *prog = argv[0]; - const char *filename = argv[1]; - char *secname = NULL; - struct utimbuf utb; + const char *filename = argv[1]; + char *secname = NULL; + struct utimbuf utb; struct stat st, st2; int rc; - int c; - - while ((c = getopt(argc, argv, "s:")) != -1) { - switch(c) { - case 's': - secname = optarg; - break; - default: - usage(argv[0]); - } - } + int c; + + while ((c = getopt(argc, argv, "s:")) != -1) { + switch (c) { + case 's': + secname = optarg; + break; + default: + usage(argv[0]); + } + } if (optind + 1 > argc) usage(argv[0]); - /* Adjust the before time back one second, because the kernel's + /* + * Adjust the before time back one second, because the kernel's * CURRENT_TIME (lockless clock reading, used to set inode times) * may drift against the do_gettimeofday() time (TSC-corrected and * locked clock reading, used to return timestamps to user space). @@ -99,40 +95,42 @@ int main(int argc, char *argv[]) } if (st.st_mtime < before_mknod || st.st_mtime > after_mknod) { - fprintf(stderr, "%s: bad mknod(%s) times %lu <= %lu <= " - "%lu false\n", prog, filename, before_mknod, - st.st_mtime, after_mknod); + fprintf(stderr, + "%s: bad mknod(%s) times %lu <= %lu <= %lu false\n", + prog, filename, before_mknod, st.st_mtime, + after_mknod); return 4; } printf("%s: good mknod times %lu%s <= %lu <= %lu for %s\n", - prog, before_mknod, before_mknod == st.st_mtime ? "*":"", + prog, before_mknod, + before_mknod == st.st_mtime ? "*" : "", st.st_mtime, after_mknod, filename); - if (secname) { - sleep(1); - rc = stat(secname, &st2); - if (rc) { - fprintf(stderr, "%s: stat(%s) failed: rc %d: " - "%s\n", prog, secname, errno, - strerror(errno)); - return 5; - } - - if (st2.st_mtime < before_mknod || - st2.st_mtime > after_mknod) { - fprintf(stderr, "%s: bad mknod(%s) times %lu " - " <= %lu <= %lu false\n", prog, - filename, before_mknod, st2.st_mtime, - after_mknod); - return 6; - } - - printf("%s: good mknod times %lu%s <= %lu <= %lu " - "for %s\n", prog, before_mknod, - before_mknod == st.st_mtime ? "*":"", - st2.st_mtime, after_mknod, secname); - } + if (secname) { + sleep(1); + rc = stat(secname, &st2); + if (rc) { + fprintf(stderr, + "%s: stat(%s) failed: rc %d: %s\n", + prog, secname, errno, strerror(errno)); + return 5; + } + + if (st2.st_mtime < before_mknod || + st2.st_mtime > after_mknod) { + fprintf(stderr, + "%s: bad mknod(%s) times %lu <= %lu <= %lu false\n", + prog, filename, before_mknod, + st2.st_mtime, after_mknod); + return 6; + } + + printf("%s: good mknod times %lu%s <= %lu <= %lu for %s\n", + prog, before_mknod, + before_mknod == st.st_mtime ? "*" : "", + st2.st_mtime, after_mknod, secname); + } } utb.actime = 200000; @@ -143,7 +141,7 @@ int main(int argc, char *argv[]) prog, filename, errno, strerror(errno)); return 7; } - + rc = stat(filename, &st); if (rc) { fprintf(stderr, "%s: second stat(%s) failed: rc %d: %s\n", @@ -151,13 +149,13 @@ int main(int argc, char *argv[]) return 8; } - if (st.st_mtime != utb.modtime ) { + if (st.st_mtime != utb.modtime) { fprintf(stderr, "%s: bad utime mtime(%s) %lu should be %lu\n", prog, filename, st.st_mtime, utb.modtime); return 9; } - if (st.st_atime != utb.actime ) { + if (st.st_atime != utb.actime) { fprintf(stderr, "%s: bad utime atime(%s) %lu should be %lu\n", prog, filename, st.st_atime, utb.actime); return 10; @@ -166,32 +164,32 @@ int main(int argc, char *argv[]) printf("%s: good utime mtimes %lu, atime %lu\n", prog, utb.modtime, utb.actime); - if (secname == NULL) - return 0; - - /* Checking that times in past get updated on another client. */ + if (!secname) + return 0; + + /* Checking that times in past get updated on another client. */ rc = stat(secname, &st2); - if (rc) { + if (rc) { fprintf(stderr, "%s: second stat(%s) failed: rc %d: %s\n", prog, secname, errno, strerror(errno)); return 12; } if (st2.st_mtime != st.st_mtime) { - fprintf(stderr, "%s: not synced mtime(%s) between clients: " - "%lu should be %lu\n", prog, secname, - st2.st_mtime, st.st_mtime); + fprintf(stderr, + "%s: not synced mtime(%s) between clients: %lu should be %lu\n", + prog, secname, st2.st_mtime, st.st_mtime); return 13; } if (st2.st_ctime != st.st_ctime) { - fprintf(stderr, "%s: not synced ctime(%s) between clients: " - "%lu should be %lu\n", prog, secname, - st2.st_ctime, st.st_ctime); + fprintf(stderr, + "%s: not synced ctime(%s) between clients: %lu should be %lu\n", + prog, secname, st2.st_ctime, st.st_ctime); return 14; } - - printf("%s: updated times for %s\n", prog, secname); - + + printf("%s: updated times for %s\n", prog, secname); + return 0; }