This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
+#include "torture/proto.h"
#define MAX_FILES 1000
extern int line_count;
extern int nbio_id;
static int nprocs;
+static struct timeval nb_start;
static struct {
int fd;
if (!children[i].done) num_clients++;
}
- printf("%4d %8d %.2f MB/sec\r", num_clients, lines/nprocs, 1.0e-6 * nbio_total() / end_timer());
+ printf("%4d %8d %.2f MB/sec\r",
+ num_clients, lines/nprocs,
+ 1.0e-6 * nbio_total() / timeval_elapsed(&nb_start));
signal(SIGALRM, nb_alarm);
alarm(1);
printf("segv at line %d\n", line_count);
slprintf(line, sizeof(line), "/usr/X11R6/bin/xterm -e gdb /proc/%d/exe %d",
(int)getpid(), (int)getpid());
- system(line);
+ if (system(line) == -1) {
+ printf("system() failed\n");
+ }
exit(1);
}
{
signal(SIGSEGV, sigsegv);
c = cli;
- start_timer();
+ nb_start = timeval_current();
children[nbio_id].done = 0;
}
void nb_unlink(const char *fname)
{
- if (!cli_unlink(c, fname)) {
+ if (!NT_STATUS_IS_OK(cli_unlink(c, fname, aSYSTEM | aHIDDEN))) {
#if NBDEBUG
printf("(%d) unlink %s failed (%s)\n",
line_count, fname, cli_errstr(c));
void nb_createx(const char *fname,
unsigned create_options, unsigned create_disposition, int handle)
{
- int fd, i;
+ uint16_t fd = (uint16_t)-1;
+ int i;
+ NTSTATUS status;
uint32 desired_access;
if (create_options & FILE_DIRECTORY_FILE) {
desired_access = FILE_READ_DATA | FILE_WRITE_DATA;
}
- fd = cli_nt_create_full(c, fname, 0,
+ status = cli_ntcreate(c, fname, 0,
desired_access,
0x0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
create_disposition,
- create_options, 0);
- if (fd == -1 && handle != -1) {
- printf("ERROR: cli_nt_create_full failed for %s - %s\n",
+ create_options, 0, &fd);
+ if (!NT_STATUS_IS_OK(status) && handle != -1) {
+ printf("ERROR: cli_ntcreate failed for %s - %s\n",
fname, cli_errstr(c));
exit(1);
}
- if (fd != -1 && handle == -1) {
- printf("ERROR: cli_nt_create_full succeeded for %s\n", fname);
+ if (NT_STATUS_IS_OK(status) && handle == -1) {
+ printf("ERROR: cli_ntcreate succeeded for %s\n", fname);
exit(1);
}
- if (fd == -1) return;
+ if (fd == (uint16_t)-1) return;
for (i=0;i<MAX_FILES;i++) {
if (ftable[i].handle == 0) break;
{
int i;
i = find_handle(handle);
- if (!cli_close(c, ftable[i].fd)) {
+ if (!NT_STATUS_IS_OK(cli_close(c, ftable[i].fd))) {
printf("(%d) close failed on handle %d\n", line_count, handle);
exit(1);
}
void nb_rmdir(const char *fname)
{
- if (!cli_rmdir(c, fname)) {
+ if (!NT_STATUS_IS_OK(cli_rmdir(c, fname))) {
printf("ERROR: rmdir %s failed (%s)\n",
fname, cli_errstr(c));
exit(1);
void nb_rename(const char *oldname, const char *newname)
{
- if (!cli_rename(c, oldname, newname)) {
+ if (!NT_STATUS_IS_OK(cli_rename(c, oldname, newname))) {
printf("ERROR: rename %s %s failed (%s)\n",
oldname, newname, cli_errstr(c));
exit(1);
n = SMB_STRDUP(name);
n[strlen(n)-1] = 0;
- asprintf(&s, "%s%s", n, finfo->name);
+ if (asprintf(&s, "%s%s", n, finfo->name) == -1) {
+ printf("asprintf failed\n");
+ return;
+ }
if (finfo->mode & aDIR) {
char *s2;
- asprintf(&s2, "%s\\*", s);
+ if (asprintf(&s2, "%s\\*", s) == -1) {
+ printf("asprintf failed\n");
+ return;
+ }
cli_list(c, s2, aDIR, delete_fn, NULL);
nb_rmdir(s);
} else {
void nb_deltree(const char *dname)
{
char *mask;
- asprintf(&mask, "%s\\*", dname);
+ if (asprintf(&mask, "%s\\*", dname) == -1) {
+ printf("asprintf failed\n");
+ return;
+ }
total_deleted = 0;
cli_list(c, mask, aDIR, delete_fn, NULL);