3 Copyright (C) Andrew Tridgell 1999
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /* This file links against either fileio.c to do operations against a
21 local filesystem (making dbench), or sockio.c to issue SMB-like
22 command packets over a socket (making tbench).
24 So, the pattern of operations and the control structure is the same
25 for both benchmarks, but the operations performed are different.
32 char *client_filename = "client.txt";
35 static int sigsegv(int sig)
38 printf("segv at line %d\n", line_count);
39 sprintf(line, "/usr/X11R6/bin/xterm -e gdb /proc/%d/exe %d",
46 FILE * open_client_dump(void)
50 if ((f = fopen(client_filename, "rt")) != NULL)
54 "dbench: error opening %s: %s", client_filename,
60 void child_run(int client)
69 signal(SIGSEGV, sigsegv);
71 sprintf(cname,"CLIENT%d", client);
73 f = open_client_dump();
80 while (fgets(line, sizeof(line)-1, f)) {
83 line[strlen(line)-1] = 0;
85 all_string_sub(line,"CLIENT1", cname);
86 all_string_sub(line,"\\", "/");
87 all_string_sub(line," /", " ");
89 for (i=0;i<20;i++) params[i] = "";
91 /* parse the command parameters */
92 params[0] = strtok(line," ");
94 while (params[i]) params[++i] = strtok(NULL," ");
100 if (strcmp(params[1],"REQUEST") == 0) {
101 if (!strcmp(params[0],"SMBopenX")) {
102 strcpy(fname, params[5]);
103 } else if (!strcmp(params[0],"SMBclose")) {
104 nb_close(atoi(params[3]));
105 } else if (!strcmp(params[0],"SMBmkdir")) {
107 } else if (!strcmp(params[0],"CREATE")) {
108 nb_create(params[3], atoi(params[5]));
109 } else if (!strcmp(params[0],"SMBrmdir")) {
111 } else if (!strcmp(params[0],"SMBunlink")) {
112 strcpy(fname, params[3]);
113 } else if (!strcmp(params[0],"SMBmv")) {
114 nb_rename(params[3], params[5]);
115 } else if (!strcmp(params[0],"SMBgetatr")) {
116 strcpy(fname, params[3]);
117 } else if (!strcmp(params[0],"SMBwrite")) {
118 nb_write(atoi(params[3]),
119 atoi(params[5]), atoi(params[7]));
120 } else if (!strcmp(params[0],"SMBwritebraw")) {
121 nb_write(atoi(params[3]),
122 atoi(params[7]), atoi(params[5]));
123 } else if (!strcmp(params[0],"SMBreadbraw")) {
124 nb_read(atoi(params[3]),
125 atoi(params[7]), atoi(params[5]));
126 } else if (!strcmp(params[0],"SMBread")) {
127 nb_read(atoi(params[3]),
128 atoi(params[5]), atoi(params[7]));
131 if (!strcmp(params[0],"SMBopenX")) {
132 if (!strncmp(params[2], "ERR", 3)) continue;
133 nb_open(fname, atoi(params[3]), atoi(params[5]));
134 } else if (!strcmp(params[0],"SMBgetatr")) {
135 if (!strncmp(params[2], "ERR", 3)) continue;
136 nb_stat(fname, atoi(params[3]));
137 } else if (!strcmp(params[0],"SMBunlink")) {
138 if (!strncmp(params[2], "ERR", 3)) continue;
145 sprintf(fname,"CLIENTS/CLIENT%d", client);