Whamcloud - gitweb
LU-17895 lnet: Validate input for lnetctl import
[fs/lustre-release.git] / lustre / tests / reads.c
index 6e58f8b..9b1e98e 100644 (file)
@@ -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.
  *
  * 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
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lustre/tests/reads.c
  *
@@ -57,10 +50,7 @@ static void usage(void)
 {
        printf("reads: read random or stride chunks of a file.\n");
        printf("Usage:\n\n");
-       printf("reads -f <filename> -s <filesize> -b <buffersize>"
-              "-a <adjacent reads> [-v] [-h] [-C] [-l <stride_length> ] "
-              "[ -o <stride_offset> ] [-S <seed>] [-n <iterations>]"
-              "[-w <width>] [-t <timelimit>]\n");
+       printf("reads -f <filename> -s <filesize> -b <buffersize> -a <adjacent reads> [-v] [-h] [-C] [-l <stride_length> ] [ -o <stride_offset> ] [-S <seed>] [-n <iterations>][-w <width>] [-t <timelimit>]\n");
 }
 
 enum {
@@ -130,7 +120,7 @@ int main(int argc, char **argv)
                        usage();
                        return RR_PARSE;
                case 'v':
-                       verbosity ++;
+                       verbosity++;
                        break;
                case 'f':
                        fname = strdup(optarg);
@@ -138,7 +128,8 @@ int main(int argc, char **argv)
                case 's':
                        size = strtol(optarg, &term, 0);
                        if (term == optarg) {
-                               fprintf (stderr, "Can't parse size %s\n", optarg);
+                               fprintf(stderr, "Can't parse size %s\n",
+                                       optarg);
                                usage();
                                return RR_SET;
                        }
@@ -146,7 +137,8 @@ int main(int argc, char **argv)
                case 'b':
                        bsize = strtol(optarg, &term, 0);
                        if (term == optarg) {
-                               fprintf (stderr, "Can't parse bsize %s\n", optarg);
+                               fprintf(stderr, "Can't parse bsize %s\n",
+                                       optarg);
                                usage();
                                return RR_SET;
                        }
@@ -154,7 +146,8 @@ int main(int argc, char **argv)
                case 'a':
                        ad = (int)strtol(optarg, &term, 0);
                        if (term == optarg) {
-                               fprintf (stderr, "Can't parse ad %s\n", optarg);
+                               fprintf(stderr, "Can't parse ad %s\n",
+                                       optarg);
                                usage();
                                return RR_SET;
                        }
@@ -165,7 +158,8 @@ int main(int argc, char **argv)
                case 'S':
                        seed = strtol(optarg, &term, 0);
                        if (term == optarg) {
-                               fprintf (stderr, "Can't parse seed %s\n", optarg);
+                               fprintf(stderr, "Can't parse seed %s\n",
+                                       optarg);
                                usage();
                                return RR_SET;
                        }
@@ -173,7 +167,8 @@ int main(int argc, char **argv)
                case 'n':
                        iterations = strtol(optarg, &term, 0);
                        if (term == optarg) {
-                               fprintf (stderr, "Can't parse seed %s\n", optarg);
+                               fprintf(stderr, "Can't parse seed %s\n",
+                                       optarg);
                                usage();
                                return RR_SET;
                        }
@@ -183,23 +178,26 @@ int main(int argc, char **argv)
                case 't':
                        timelimit = strtol(optarg, &term, 0);
                        if (term == optarg) {
-                               fprintf (stderr, "Can't parse seed %s\n", optarg);
+                               fprintf(stderr, "Can't parse seed %s\n",
+                                       optarg);
                                usage();
                                return RR_SET;
                        }
                        break;
-                case 'l':
-                        stride_length = strtol(optarg, &term, 0);
+               case 'l':
+                       stride_length = strtol(optarg, &term, 0);
                        if (term == optarg) {
-                               fprintf (stderr, "Can't parse seed %s\n", optarg);
+                               fprintf(stderr, "Can't parse seed %s\n",
+                                       optarg);
                                usage();
                                return RR_SET;
                        }
-                       break;
+                       break;
                case 'o':
                        stride_offset = strtol(optarg, &term, 0);
                        if (term == optarg) {
-                               fprintf (stderr, "Can't parse seed %s\n", optarg);
+                               fprintf(stderr, "Can't parse seed %s\n",
+                                       optarg);
                                usage();
                                return RR_SET;
                        }
@@ -207,7 +205,8 @@ int main(int argc, char **argv)
                case 'w':
                        width = (int)strtol(optarg, &term, 0);
                        if (term == optarg) {
-                               fprintf (stderr, "Can't parse seed %s\n", optarg);
+                               fprintf(stderr, "Can't parse seed %s\n",
+                                       optarg);
                                usage();
                                return RR_SET;
                        }
@@ -256,12 +255,12 @@ int main(int argc, char **argv)
                srand(seed);
        gettimeofday(&start, NULL);
        timelimit += start.tv_sec;
-       for (i = 0; !iterations || i < iterations; i ++) {
+       for (i = 0; !iterations || i < iterations; i++) {
                unsigned long block_nr;
                int j;
 
-               if (stride_length) 
-                       block_nr = (unsigned long)(i*stride_length + 
+               if (stride_length)
+                       block_nr = (unsigned long)(i*stride_length +
                                                   stride_offset) % nblocks;
                else
                        block_nr = (unsigned long)((double)nblocks*rand()/