X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;ds=sidebyside;f=lustre%2Futils%2Fllverfs.c;h=7af885e530ff27c134e4f4d2b539e45c788ccc60;hb=9ccaefdb8ae9cacc1b471689672bd08d497831dc;hp=0ecf8f26646db2226ff3eea03e7995e6117faac6;hpb=64f0f965dc80556739a3f86c15c0bb158b6289a2;p=fs%2Flustre-release.git diff --git a/lustre/utils/llverfs.c b/lustre/utils/llverfs.c index 0ecf8f2..7af885e 100644 --- a/lustre/utils/llverfs.c +++ b/lustre/utils/llverfs.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. @@ -28,6 +26,8 @@ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2011, Whamcloud, Inc. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -527,6 +527,7 @@ static int dir_write(char *chunk_buf, size_t chunksize, 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)) @@ -545,7 +546,8 @@ static int dir_write(char *chunk_buf, size_t chunksize, 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 */ @@ -553,7 +555,8 @@ static int dir_write(char *chunk_buf, size_t chunksize, 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)) @@ -575,7 +578,8 @@ static int dir_write(char *chunk_buf, size_t chunksize, fprintf(stderr, "\n%s: mkdir %s : %s\n", progname, tempdir, strerror(errno)); - return 1; + rc = 1; + goto out; } } dir_num++; @@ -600,8 +604,10 @@ static int dir_write(char *chunk_buf, size_t chunksize, 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; } @@ -618,7 +624,6 @@ static int dir_write(char *chunk_buf, size_t chunksize, progname, filecount, strerror(errno)); } } - fclose(countfile); if (verbose) { verbose++; @@ -628,7 +633,10 @@ static int dir_write(char *chunk_buf, size_t chunksize, verbose--; } - return 0; +out: + fclose(countfile); + + return rc; } /* @@ -861,7 +869,8 @@ guess: 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);