Whamcloud - gitweb
LU-6245 tests: remove libcfs.h from test applications
[fs/lustre-release.git] / lustre / tests / rwv.c
index 96856e9..1bcca57 100644 (file)
@@ -1,5 +1,36 @@
-/* -*- 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.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, 2014 Intel Corporation.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/tests/rwv.c
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 
-#include <liblustre.h>
-#include <lnet/lnetctl.h>
-#include <obd.h>
-#include <lustre_lib.h>
-#include <obd_lov.h>
-#include <lustre/liblustreapi.h>
+#include <lustre/lustreapi.h>
 
 #define ACT_NONE        0
 #define ACT_READ        1
@@ -148,13 +174,15 @@ int main(int argc, char** argv)
                 iv->iov_len = strtoul(argv[optind++], &end, 0);
                 if (*end) {
                         printf("Error iov size\n");
-                        GOTO(out, rc = 1);
+                       rc = 1;
+                       goto out;
                 }
                 iv->iov_base = mmap(NULL, iv->iov_len, PROT_READ | PROT_WRITE,
                                     MAP_PRIVATE | MAP_ANON, 0, 0);
                 if (iv->iov_base == MAP_FAILED) {
                         printf("No memory %s\n", strerror(errno));
-                        GOTO(out, rc = 1);
+                       rc = 1;
+                       goto out;
                 }
                 if (act & ACT_WRITE)
                         memset(iv->iov_base, pad, iv->iov_len);
@@ -169,7 +197,8 @@ int main(int argc, char** argv)
 
         if ((act & ACT_SEEK) && (lseek64(fd, offset, SEEK_SET) < 0)) {
                 printf("Cannot seek %s\n", strerror(errno));
-                GOTO(out, rc == 1);
+               rc = 1;
+               goto out;
         }
 
         if (act & ACT_WRITE) {
@@ -177,19 +206,23 @@ int main(int argc, char** argv)
                 if (rc != len) {
                         printf("Write error: %s (rc = %d, len = %ld)\n",
                                 strerror(errno), rc, len);
-                        GOTO(out, rc = 1);
+                       rc = 1;
+                       goto out;
                 }
         } else if (act & ACT_READ) {
                 rc = readv(fd, iov, iovcnt);
                 if (rc != len) {
                         printf("Read error: %s rc = %d\n", strerror(errno), rc);
-                        GOTO(out, rc = 1);
+                       rc = 1;
+                       goto out;
                 }
 
                 /* It should return zeroed buf if the read hits hole.*/
                 if (((act & ACT_READHOLE) || (act & ACT_VERIFY)) &&
-                    data_verify(iov, iovcnt, pad))
-                        GOTO(out, rc = 1);
+                   data_verify(iov, iovcnt, pad)) {
+                       rc = 1;
+                       goto out;
+               }
         }
 
         rc = 0;