X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fwrite_time_limit.c;h=0988f54c355ed578de841b2ab57017101501ad92;hb=41d99c4902836b7265db946dfa49cf99381f0db4;hp=56493eaae03c14cb16b9ec6ce28b0351bed6cfa6;hpb=0f8dca08a4f68cba82c2c822998ecc309d3b7aaf;p=fs%2Flustre-release.git diff --git a/lustre/tests/write_time_limit.c b/lustre/tests/write_time_limit.c index 56493ea..0988f54 100644 --- a/lustre/tests/write_time_limit.c +++ b/lustre/tests/write_time_limit.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -17,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 */ @@ -31,7 +25,6 @@ */ /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. */ /* for O_DIRECT */ @@ -63,59 +56,62 @@ void catch_alarm(int sig) int main(int argc, char **argv) { - char *file; - unsigned char buf[BUFFERSIZE]; - int fd, i, rc; + char *file; + unsigned char buf[BUFFERSIZE]; + int fd, i, rc; unsigned int test_time; - mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH; - if (argc != 3) { - printf("Invalid number of arguments.\n"); - printf("Usage %s \n", argv[0]); - return -1; - } + mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH; + + if (argc != 3) { + printf("Invalid number of arguments.\n"); + printf("Usage %s \n", argv[0]); + return -1; + } - file = argv[1]; - test_time = atoi(argv[2]); + file = argv[1]; + test_time = atoi(argv[2]); /* Establish a handler for SIGALRM signals. */ signal(SIGALRM, catch_alarm); - /* Set an alarm to go off in a little while. */ - alarm(test_time); + /* Set an alarm to go off in a little while. */ + alarm(test_time); - fd = open(file, O_RDWR|O_TRUNC|O_CREAT|O_SYNC|O_LARGEFILE, mode); - if (fd < 0) { - fprintf(stderr, "Error: Cannot open file named "); - perror(file); - return -1; - } + fd = open(file, O_RDWR | O_TRUNC | O_CREAT | O_SYNC | O_LARGEFILE, + mode); + if (fd < 0) { + fprintf(stderr, "Error: Cannot open file named "); + perror(file); + return -1; + } - memset(buf, 1, BUFFERSIZE); + memset(buf, 1, BUFFERSIZE); while (keep_going) { - for (i = 0; i < 1024; i++) { - rc = write(fd, buf, BUFFERSIZE); + for (i = 0; i < 1024; i++) { + rc = write(fd, buf, BUFFERSIZE); if (rc < 0) { - fprintf(stderr, "Error: Write error "); - perror(file); + fprintf(stderr, "Error: Write error "); + perror(file); exit(-1); - } else if (rc != BUFFERSIZE) { - fprintf(stderr, "Error: Ddidn't write all data \n"); + } else if (rc != BUFFERSIZE) { + fprintf(stderr, + "Error: Ddidn't write all data\n"); } - } + } - if (ftruncate(fd, 0) < 0) { - fprintf(stderr, "Error: Truncate error "); - perror(file); + if (ftruncate(fd, 0) < 0) { + fprintf(stderr, "Error: Truncate error "); + perror(file); exit(-1); - } - } + } + } - if (close(fd) < 0) { - fprintf(stderr, "Error: Cannot close "); - perror(file); - return -1; - } + if (close(fd) < 0) { + fprintf(stderr, "Error: Cannot close "); + perror(file); + return -1; + } - return 0; + return 0; }