From owner-svn-src-user@freebsd.org Wed Dec 30 07:59:59 2015 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E0FFA5545A for ; Wed, 30 Dec 2015 07:59:59 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1978914A5; Wed, 30 Dec 2015 07:59:59 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tBU7xw4f076059; Wed, 30 Dec 2015 07:59:58 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tBU7xwbK076058; Wed, 30 Dec 2015 07:59:58 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201512300759.tBU7xwbK076058@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Wed, 30 Dec 2015 07:59:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r292904 - user/pho/stress2/tools X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Dec 2015 07:59:59 -0000 Author: pho Date: Wed Dec 30 07:59:58 2015 New Revision: 292904 URL: https://svnweb.freebsd.org/changeset/base/292904 Log: Add option "a" for random size writes. Clean up test while here. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/tools/fstool.c Modified: user/pho/stress2/tools/fstool.c ============================================================================== --- user/pho/stress2/tools/fstool.c Wed Dec 30 03:43:25 2015 (r292903) +++ user/pho/stress2/tools/fstool.c Wed Dec 30 07:59:58 2015 (r292904) @@ -28,23 +28,23 @@ #include __FBSDID("$FreeBSD$"); -#include +#include +#include +#include #include -#include +#include + +#include +#include #include #include -#include -#include -#include -#include #include -#include - +#include static int files = 5; static int fs = 1024; +static int max, rnd; static char *buffer; -static int max; void error(char *op, char* arg, char* file, int line) { @@ -54,19 +54,22 @@ error(char *op, char* arg, char* file, i void mkDir(char *path, int level) { - int fd, j; + int fd, j, len; char newPath[MAXPATHLEN + 1]; char file[128]; if (mkdir(path, 0770) == -1) { error("mkdir", path, __FILE__, __LINE__); - fprintf(stderr, "length(path) = %d\n", strlen(path)); + fprintf(stderr, "length(path) = %d\n", (int)strlen(path)); fprintf(stderr, ") level = %d\n", level); exit(2); } chdir(path); + len = fs; for (j = 0; j < files; j++) { + if (rnd) + len = arc4random() % fs + 1; sprintf(file,"f%05d", j); if ((fd = creat(file, 0660)) == -1) { if (errno != EINTR) { @@ -74,7 +77,7 @@ mkDir(char *path, int level) { break; } } - if (write(fd, buffer, fs) != fs) + if (write(fd, buffer, len) != len) err(1, "%d: write(%s), %s:%d", level, file, __FILE__, __LINE__); if (fd != -1 && close(fd) == -1) @@ -104,7 +107,6 @@ void rmDir(char *path, int level) { char newPath[10]; - if (level < max) { sprintf(newPath,"d%d", level+1); rmDir(newPath, level+1); @@ -138,14 +140,17 @@ rmDir2(char *path, int level) { int main(int argc, char **argv) { + pid_t pid; int c, levels = 1, leave = 0; char path[128], rpath[128] = ""; char ch = 0; extern char *optarg; - pid_t pid; - while ((c = getopt(argc, argv, "ln:r:f:s:")) != -1) + while ((c = getopt(argc, argv, "aln:r:f:s:")) != -1) switch (c) { + case 'a': + rnd = 1; + break; case 'l': leave = 1; break; @@ -192,5 +197,6 @@ main(int argc, char **argv) mkDir(path, 1); if (leave == 0) rmDir(path, 1); } - return 0; + + return (0); }