X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fllverfs.c;h=87c9a9c28db08b4b226f3ed894ec0ec94f167af1;hb=1fc1660d7648ea10c100a8bb5b10df15cdddb3d4;hp=953f342980ae92bf8361fc5c912800df7476d816;hpb=e3a7c58aebafce40323db54bf6056029e5af4a70;p=fs%2Flustre-release.git diff --git a/lustre/utils/llverfs.c b/lustre/utils/llverfs.c index 953f342..87c9a9c 100644 --- a/lustre/utils/llverfs.c +++ b/lustre/utils/llverfs.c @@ -27,7 +27,7 @@ * 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/ @@ -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);