Whamcloud - gitweb
LU-183 replace osd with osd* in proc paths
[fs/lustre-release.git] / lustre / tests / iopentest1.c
index 25ad401..8fd7254 100644 (file)
@@ -1,3 +1,39 @@
+/* -*- 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, 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.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2003, 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.
+ */
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -33,16 +69,24 @@ static char *get_iname(char *fname, const char *mtpt)
         CHECK_IT(iname, "malloc() failed");
 
         fd = open(fname, O_CREAT, 0644);
-        CHECK_IT(fd >= 0 || errno == EISDIR, "open(fname) failed");
+        if (fd < 0 && errno != EISDIR) {
+                fprintf(stderr, "%s:%d: open(%s) failed: %s\n", __FILE__,
+                        __LINE__, fname, strerror(errno));
+                exit(1);
+        }
 
         if (fd >= 0)
                 close(fd);
 
         rc = stat(fname, &buf);
-        CHECK_IT(rc == 0, "stat(fname) failed");
+        if (rc != 0) {
+                fprintf(stderr, "%s:%d: stat(%s) failed: %s\n", __FILE__,
+                        __LINE__, fname, strerror(errno));
+                exit(1);
+        }
 
         rc = snprintf(iname, INAME_LEN,
-                      "%s/__iopen__/%lu", mtpt, buf.st_ino);
+                      "%s/__iopen__/%lu", mtpt, (unsigned long)buf.st_ino);
         CHECK_SNPRINTF(rc, INAME_LEN);
 
         return iname;
@@ -67,16 +111,23 @@ int main(int argc, char *argv[])
         mtpt  = argv[2];
 
         iname = get_iname(fname, mtpt);
-        i=10000;
-        printf("%s:started...\n",argv[0]);
-        do {
+        printf("%s:started...\n", argv[0]);
+        for (i = 0; i < 10000; i++) {
                 rc = stat(fname, &buf);
-                CHECK_IT(rc == 0, "stat(fname) failed");
-               
+                if (rc != 0) {
+                        fprintf(stderr, "%s:%d: stat(%s) failed: %s\n",
+                                __FILE__, __LINE__, fname, strerror(errno));
+                        exit(1);
+                }
+
                 rc = stat(iname, &buf);
-                CHECK_IT(rc == 0, "stat(iname) failed");
-                i--;
-        } while (i>=1);
+                if (rc != 0) {
+                        fprintf(stderr, "%s:%d: stat(%s) failed: %s\n",
+                                __FILE__, __LINE__, iname, strerror(errno));
+                        exit(1);
+                }
+        }
+        printf("%s:finished...\n", argv[0]);
 
         return 0;
 }