4 Copyright (C) Andrew Tridgell 1999-2004
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 /* This file links against either fileio.c to do operations against a
22 local filesystem (making dbench), or sockio.c to issue SMB-like
23 command packets over a socket (making tbench).
25 So, the pattern of operations and the control structure is the same
26 for both benchmarks, but the operations performed are different.
31 #define ival(s) strtol(s, NULL, 0)
34 /* run a test that simulates an approximate netbench client load */
35 void child_run(struct child_struct *child, const char *loadfile)
40 char **sparams, **params;
45 FILE *f = fopen(loadfile, "r");
46 pid_t parent = getppid();
47 extern double targetrate;
51 asprintf(&cname,"client%d", child->id);
53 sparams = calloc(20, sizeof(char *));
55 sparams[i] = malloc(100);
61 while (fgets(line, sizeof(line)-1, f)) {
64 if (child->done || kill(parent, 0) == -1) {
70 line[strlen(line)-1] = 0;
72 all_string_sub(line,"client1", cname);
73 all_string_sub(line,"\\", "/");
74 all_string_sub(line," /", " ");
78 i<19 && next_token(&p, params[i], " ");
83 if (i < 2 || params[0][0] == '#') continue;
85 if (!strncmp(params[0],"SMB", 3)) {
86 printf("ERROR: You are using a dbench 1 load file\n");
90 if (i > 0 && isdigit(params[0][0])) {
91 double targett = strtod(params[0], NULL);
92 if (targetrate != 0) {
93 nb_target_rate(child, targetrate);
95 nb_time_delay(child, targett);
101 if (strncmp(params[i-1], "NT_STATUS_", 10) != 0 &&
102 strncmp(params[i-1], "0x", 2) != 0) {
103 printf("Badly formed status at line %d\n", child->line);
116 if (i>1 && params[1][0] == '/') {
117 asprintf(&fname, "%s%s", child->directory, params[1]);
119 if (i>2 && params[2][0] == '/') {
120 asprintf(&fname2, "%s%s", child->directory, params[2]);
123 status = params[i-1];
125 if (!strcmp(params[0],"NTCreateX")) {
126 nb_createx(child, fname, ival(params[2]), ival(params[3]),
127 ival(params[4]), status);
128 } else if (!strcmp(params[0],"Close")) {
129 nb_close(child, ival(params[1]), status);
130 } else if (!strcmp(params[0],"Rename")) {
131 nb_rename(child, fname, fname2, status);
132 } else if (!strcmp(params[0],"Unlink")) {
133 nb_unlink(child, fname, ival(params[2]), status);
134 } else if (!strcmp(params[0],"Deltree")) {
135 nb_deltree(child, fname);
136 } else if (!strcmp(params[0],"Rmdir")) {
137 nb_rmdir(child, fname, status);
138 } else if (!strcmp(params[0],"Mkdir")) {
139 nb_mkdir(child, fname, status);
140 } else if (!strcmp(params[0],"QUERY_PATH_INFORMATION")) {
141 nb_qpathinfo(child, fname, ival(params[2]), status);
142 } else if (!strcmp(params[0],"QUERY_FILE_INFORMATION")) {
143 nb_qfileinfo(child, ival(params[1]), ival(params[2]), status);
144 } else if (!strcmp(params[0],"QUERY_FS_INFORMATION")) {
145 nb_qfsinfo(child, ival(params[1]), status);
146 } else if (!strcmp(params[0],"SET_FILE_INFORMATION")) {
147 nb_sfileinfo(child, ival(params[1]), ival(params[2]), status);
148 } else if (!strcmp(params[0],"FIND_FIRST")) {
149 nb_findfirst(child, fname, ival(params[2]),
150 ival(params[3]), ival(params[4]), status);
151 } else if (!strcmp(params[0],"WriteX")) {
152 nb_writex(child, ival(params[1]),
153 ival(params[2]), ival(params[3]), ival(params[4]),
155 } else if (!strcmp(params[0],"LockX")) {
156 nb_lockx(child, ival(params[1]),
157 ival(params[2]), ival(params[3]), status);
158 } else if (!strcmp(params[0],"UnlockX")) {
159 nb_unlockx(child, ival(params[1]),
160 ival(params[2]), ival(params[3]), status);
161 } else if (!strcmp(params[0],"ReadX")) {
162 nb_readx(child, ival(params[1]),
163 ival(params[2]), ival(params[3]), ival(params[4]),
165 } else if (!strcmp(params[0],"Flush")) {
166 nb_flush(child, ival(params[1]), status);
167 } else if (!strcmp(params[0],"Sleep")) {
168 nb_sleep(child, ival(params[1]), status);
170 printf("[%d] Unknown operation %s\n", child->line, params[0]);