-/* -*- 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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, Whamcloud, Inc.
+ * Copyright (c) 2011, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
struct timeval start_time;
unsigned long long total_bytes;
unsigned long long curr_bytes = 0;
+ int rc = 0;
#ifdef HAVE_EXT2FS_EXT2FS_H
if (!full && fsetflags(testdir, EXT2_TOPDIR_FL))
fflush(countfile) != 0) {
fprintf(stderr, "\n%s: writing %s failed :%s\n",
progname, filecount, strerror(errno));
- return 6;
+ rc = 6;
+ goto out;
}
/* calculate total bytes that need to be written */
if (total_bytes <= 0) {
fprintf(stderr, "\n%s: unable to calculate total bytes\n",
progname);
- return 7;
+ rc = 7;
+ goto out;
}
if (!full && (dir_num != 0))
fprintf(stderr, "\n%s: mkdir %s : %s\n",
progname, tempdir,
strerror(errno));
- return 1;
+ rc = 1;
+ goto out;
}
}
dir_num++;
time_st, inode_st, tempfile);
close(fd);
if (ret < 0) {
- if (ret != -ENOSPC)
- return 1;
+ if (ret != -ENOSPC) {
+ rc = 1;
+ goto out;
+ }
curr_bytes = total_bytes;
break;
}
progname, filecount, strerror(errno));
}
}
- fclose(countfile);
if (verbose) {
verbose++;
verbose--;
}
- return 0;
+out:
+ fclose(countfile);
+
+ return rc;
}
/*
fprintf(stderr, "Memory allocation failed for chunk_buf\n");
return 4;
}
- sprintf(filecount, "%s/%s.filecount", testdir, progname);
+ snprintf(filecount, sizeof(filecount), "%s/%s.filecount",
+ testdir, progname);
if (writeoption) {
(void)mkdir(testdir, dirmode);