windows-torture-test-20060625
authorDave Tanner <dtanner@mit.edu>
Sun, 25 Jun 2006 20:50:37 +0000 (20:50 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 25 Jun 2006 20:50:37 +0000 (20:50 +0000)
Torture Test

29 files changed:
src/WINNT/tests/torture/DumpAfsLog/DumpAfsLog.c [new file with mode: 0644]
src/WINNT/tests/torture/DumpAfsLog/DumpAfsLog.dsp [new file with mode: 0644]
src/WINNT/tests/torture/DumpAfsLog/DumpAfsLog.dsw [new file with mode: 0644]
src/WINNT/tests/torture/DumpAfsLog/Makefile.src [new file with mode: 0644]
src/WINNT/tests/torture/Source/Makefile.src [new file with mode: 0644]
src/WINNT/tests/torture/Source/ResolveLocker.c [new file with mode: 0644]
src/WINNT/tests/torture/Source/WinThreads.c [new file with mode: 0644]
src/WINNT/tests/torture/Source/WinTorture.c [new file with mode: 0644]
src/WINNT/tests/torture/Source/nbio.c [new file with mode: 0644]
src/WINNT/tests/torture/Source/output.c [new file with mode: 0644]
src/WINNT/tests/torture/StopStressTest/Makefile.src [new file with mode: 0644]
src/WINNT/tests/torture/StopStressTest/StopStressTest.c [new file with mode: 0644]
src/WINNT/tests/torture/StopStressTest/StopStressTest.dsp [new file with mode: 0644]
src/WINNT/tests/torture/StopStressTest/StopStressTest.dsw [new file with mode: 0644]
src/WINNT/tests/torture/Stress/Makefile.src [new file with mode: 0644]
src/WINNT/tests/torture/Stress/StdAfx.h [new file with mode: 0644]
src/WINNT/tests/torture/Stress/Stress.c [new file with mode: 0644]
src/WINNT/tests/torture/Stress/Stress.dsp [new file with mode: 0644]
src/WINNT/tests/torture/Stress/Stress.dsw [new file with mode: 0644]
src/WINNT/tests/torture/WinTorture_VC6/wintorture.dsp [new file with mode: 0644]
src/WINNT/tests/torture/WinTorture_VC6/wintorture.dsw [new file with mode: 0644]
src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.dsp [new file with mode: 0644]
src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.dsw [new file with mode: 0644]
src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.ncb [new file with mode: 0644]
src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.vcproj [new file with mode: 0644]
src/WINNT/tests/torture/include/ResolveLocker.h [new file with mode: 0644]
src/WINNT/tests/torture/include/common.h [new file with mode: 0644]
src/WINNT/tests/torture/include/includes.h [new file with mode: 0644]
src/WINNT/tests/torture/include/proto.h [new file with mode: 0644]

diff --git a/src/WINNT/tests/torture/DumpAfsLog/DumpAfsLog.c b/src/WINNT/tests/torture/DumpAfsLog/DumpAfsLog.c
new file mode 100644 (file)
index 0000000..ff0888c
--- /dev/null
@@ -0,0 +1,258 @@
+// Stress.cpp : Defines the entry point for the console application.
+//
+
+#include <windows.h>
+#include <stdio.h>
+#include <time.h>
+#include <stdio.h>
+#include <io.h>
+
+void usage(void);
+int  GetConsoleInput(HANDLE hStdin);
+
+int main(int argc, char* argv[])
+{
+    int     i;
+    int     Count;
+    int     SecondsDelay;
+    int     SecondsToRun;
+    int     NewSessionDeadlock;
+    int     NewSessionDeadlockCount;
+    int     SecondsToDelay;
+    int     MiniDump;
+    int     rc;
+    char    HostName[512];
+    char    LogName[512];
+    char    command[512];
+    char    WorkingDirectory[512];
+    char    LoggingDrive[512];
+    char    EnvVariable[512];
+//    char    Buffer[512];
+//    char    FileName[32];
+//    char    *pPtr;
+    time_t  StartTime;
+//    FILE    *fp;
+    HANDLE  hStdin; 
+
+
+    Count = 0;
+    SecondsDelay = 15;
+    NewSessionDeadlock = 0;
+    SecondsToRun = 30 * 60;
+    memset(HostName, '\0', sizeof(HostName));
+    memset(command, '\0', sizeof(command));
+    strcpy(LoggingDrive, "C");
+    MiniDump = 0;
+
+    for (i = 0; i < argc; i++)
+    {
+        if (!stricmp(argv[i], "-e"))
+        {
+            MiniDump = 1;
+        }
+        if (!stricmp(argv[i], "-s"))
+        {
+            SecondsDelay = atoi(argv[i+1]);
+        }
+        if (!stricmp(argv[i], "-h"))
+        {
+            strcpy(HostName, argv[i+1]);
+        }
+        if (!stricmp(argv[i], "-d"))
+        {
+            strcpy(LoggingDrive, argv[i+1]);
+            if (strlen(LoggingDrive) == 1)
+                strcat(LoggingDrive,":");
+        }
+        if (!stricmp(argv[i], "-m"))
+        {
+            SecondsToRun = atoi(argv[i+1]) * 60;
+        }
+        if (!stricmp(argv[i], "-n"))
+        {
+            NewSessionDeadlock = 1;
+            NewSessionDeadlockCount = atoi(argv[i+1]);
+            if (NewSessionDeadlockCount == 0)
+                NewSessionDeadlockCount = 20;
+        }
+        if (!stricmp(argv[i], "-?") || !stricmp(argv[i], "/?") || 
+            !stricmp(argv[i], "?") || !stricmp(argv[i], "help"))
+        {
+             usage();
+             exit(1);
+        }
+    }
+
+    hStdin = GetStdHandle(STD_INPUT_HANDLE);
+
+    sprintf(command, "fs trace -on");
+    rc = system(command);
+    sprintf(command, "fs trace -reset");
+    rc = system(command);
+
+    GetCurrentDirectory(sizeof(WorkingDirectory), WorkingDirectory);
+    if (WorkingDirectory[0] != LoggingDrive[0])
+        WorkingDirectory[0] = LoggingDrive[0];
+    sprintf(command, "rmdir /Q /S %s\\DumpAfsLogDir", WorkingDirectory);
+    rc = system(command);
+    sprintf(LogName, "%s\\DumpAfsLogDir", WorkingDirectory);
+    sprintf(command, "mkdir %s\\DumpAfsLogDir", WorkingDirectory);
+    rc = system(command);
+
+    time(&StartTime);
+    SecondsToRun += StartTime;
+    while (1)
+    {
+        if (MiniDump)
+        {
+            printf("\n");
+            sprintf(command, "fs minidump");
+            rc = system(command);
+            ExpandEnvironmentStrings("%windir%", EnvVariable, sizeof(EnvVariable));
+            strcat(EnvVariable, "\\TEMP\\afsd.dmp");
+            sprintf(command, "copy /Y %s %s\\DumpAfsLogDir", EnvVariable, WorkingDirectory);
+            printf("%s\n", command);
+            rc = system(command);
+            sprintf(command, "rename %s\\DumpAfsLogDir\\afsd.dmp afsd_%05d.dmp", WorkingDirectory, Count);
+            printf("%s\n", command);
+            rc = system(command);
+        }
+
+        printf("\n");
+        sprintf(command, "fs trace -dump");
+        rc = system(command);
+        ExpandEnvironmentStrings("%windir%", EnvVariable, sizeof(EnvVariable));
+        strcat(EnvVariable, "\\TEMP\\afsd.log");
+        sprintf(command, "copy /Y %s %s\\DumpAfsLogDir", EnvVariable, WorkingDirectory);
+        printf("%s\n", command);
+        rc = system(command);
+//        sprintf(command, "crlf.pl -d %s\\DumpAfsLogDir\\afsd.log", WorkingDirectory);
+//        printf("%s\n", command);
+//        rc = system(command);
+        sprintf(command, "rename %s\\DumpAfsLogDir\\afsd.log afsd_%05d.log", WorkingDirectory, Count);
+        printf("%s\n\n", command);
+        rc = system(command);
+/*
+        if (strlen(HostName) != 0)
+        {
+            sprintf(command, "cmdebug %s -long | grep refcnt > %s\\DumpAfsLogDir\\refcnt_%05d.log",
+                    HostName, WorkingDirectory, Count);
+            printf("%s\n", command);
+            rc = system(command);
+        }
+        sprintf(FileName, "%s\\DumpAfsLogDir\\afsd_%05d.log", WorkingDirectory, Count);
+
+        if (NewSessionDeadlock)
+        {
+            fp = fopen(FileName, "r");
+            if (fp != NULL)
+            {
+                while (fgets(Buffer, 512, fp))
+                {
+//                  if (pPtr = strstr(Buffer, "RecordRacingRevoke"))
+//                  {
+//                      if (pPtr = strstr(Buffer, "activeCalls "))
+//                      {
+//                          pPtr += strlen("activeCalls ");
+//                          if (atoi(pPtr) > 0)
+//                          {
+//                              SetEvent(ShutDownEventHandle);
+//                              break;
+//                          }
+//                      }
+//                  }
+                    if (pPtr = strstr(Buffer, "New Session lsn "))
+                    {
+                        printf("%s", Buffer);
+                        pPtr += strlen("New Session lsn "   );
+                        if (atoi(pPtr) > NewSessionDeadlockCount)
+                        {
+                            break;
+                        }
+                    }
+//                  if (pPtr = strstr(Buffer, "Racing revoke scp"))
+//                  {
+//                      SetEvent(ShutDownEventHandle);
+//                      break;
+//                  }
+                }
+
+            }
+            fclose(fp);
+        }
+*/
+        ++Count;
+        time(&StartTime);
+        if (StartTime > (time_t)SecondsToRun)
+            break;
+        printf("Type Q to stop DumpAfsLog\n");
+        SecondsToDelay = StartTime + SecondsDelay;
+        while (1)
+        {
+            time(&StartTime);
+            if (StartTime > (time_t)SecondsToDelay)
+                break;
+            rc = GetConsoleInput(hStdin);
+            Sleep(500);
+        }
+        rc = GetConsoleInput(hStdin);
+    }
+
+    sprintf(command, "fs trace -off");
+    rc = system(command);
+       return(0);
+
+}
+
+void usage(void)
+{
+
+    printf("usage: wintorture [options]\n");
+    printf("where options can be:\n");
+    printf("\t-d <drive> Local drive letter where to place log files\n");
+    printf("\t-e         Enable fs minidump\n");
+    printf("\t-h <host>  Local host name.  Used to run cmdebug\n");
+    printf("\t-m <min>   Number of minutes to run this program\n");
+//    printf("\t-n <num>  Stop processing on \"New Session lsn XX\" deadlock\n");
+    printf("\t-s <sec>   Seconds delay between dumping AFS logs\n");
+    printf("\t            15 seconds delay is the default\n");
+}
+
+int GetConsoleInput(HANDLE hStdin)
+{
+    INPUT_RECORD    InputRecord[128];
+    DWORD           InputRecordCount;
+    BOOL            rc;
+    int             i;
+    int             RetCode;
+    char            ReadChar;
+
+    InputRecordCount = 0;
+    RetCode = 0;
+    if (!(rc = PeekConsoleInput(hStdin, InputRecord, 128, &InputRecordCount)))
+        return(0);
+    if (InputRecordCount == 0)
+        return(0);
+    rc = ReadConsoleInput(hStdin, InputRecord, 128, &InputRecordCount);
+    for (i = 0; i < (int)InputRecordCount; i++) 
+    {
+        switch(InputRecord[i].EventType) 
+        { 
+            case KEY_EVENT:
+                if (InputRecord[i].Event.KeyEvent.bKeyDown)
+                {
+                    ReadChar = InputRecord[i].Event.KeyEvent.uChar.AsciiChar;
+                    if ((ReadChar == 'q') || (ReadChar == 'Q'))
+                    {
+                        printf("Stop request received\n");
+                        exit(0);
+                    }
+                }
+                break; 
+            default: 
+                break; 
+        }
+    }
+    return(RetCode);
+}
+
diff --git a/src/WINNT/tests/torture/DumpAfsLog/DumpAfsLog.dsp b/src/WINNT/tests/torture/DumpAfsLog/DumpAfsLog.dsp
new file mode 100644 (file)
index 0000000..9635c64
--- /dev/null
@@ -0,0 +1,88 @@
+# Microsoft Developer Studio Project File - Name="DumpAfsLog" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=DumpAfsLog - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "DumpAfsLog.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "DumpAfsLog.mak" CFG="DumpAfsLog - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "DumpAfsLog - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "DumpAfsLog - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "DumpAfsLog - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF  "$(CFG)" == "DumpAfsLog - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "DumpAfsLog - Win32 Release"
+# Name "DumpAfsLog - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\DumpAfsLog.c
+# End Source File
+# End Target
+# End Project
diff --git a/src/WINNT/tests/torture/DumpAfsLog/DumpAfsLog.dsw b/src/WINNT/tests/torture/DumpAfsLog/DumpAfsLog.dsw
new file mode 100644 (file)
index 0000000..e6b6cd8
--- /dev/null
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "DumpAfsLog"=".\DumpAfsLog.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/src/WINNT/tests/torture/DumpAfsLog/Makefile.src b/src/WINNT/tests/torture/DumpAfsLog/Makefile.src
new file mode 100644 (file)
index 0000000..011ecb7
--- /dev/null
@@ -0,0 +1,25 @@
+NAME=DumpAfsLog
+TARGETTYPE=EXE
+TARGETSS=console
+
+OBJS= \
+       $(O)\DumpAfsLog.obj
+
+
+#INCLUDES=$(O);$(MOIRABASE)\include;$(MOIRABASE)\mmc;$(PISMERE)\athena\auth\krb4\include;$(PISMERE)\athena\wshelper\include;$(PISMERE)\athena\auth\krb5\src\include;$(PISMERE)\athena\auth\krb5\src\include\krb5;$(PISMERE)\athena\auth\krb5\src\lib;$(PISMERE)\athena\auth\krb5\src\lib\krb5\asn.1;$(PISMERE)\athena\auth\krb5\src\krb524;$(PISMERE)\athena\auth\krb5\src\lib\krb5\krb
+#LIB_PATHS = $(PISMERE)\athena\auth\krb4\krbv4\krbdll\$(O);$(PISMERE)\athena\wshelper\wshelper\$(O);$(MOIRABASE)\util\et\$(O);$(MOIRABASE)\lib\$(O);$(PISMERE)\athena\auth\krb5\src\lib\krb5\$(O);$(PISMERE)\target\lib\$(T)
+
+
+USE_DEFAULTLIB=1
+
+LIBS= wsock32.lib advapi32.lib user32.lib \
+      dnsapi.lib oleaut32.lib \
+      ole32.lib wldap32.lib
+
+
+USE_LIBC_DLL=1
+
+#####
+
+
+
diff --git a/src/WINNT/tests/torture/Source/Makefile.src b/src/WINNT/tests/torture/Source/Makefile.src
new file mode 100644 (file)
index 0000000..3c0e00a
--- /dev/null
@@ -0,0 +1,32 @@
+NAME=WinTorture
+TARGETTYPE=EXE
+TARGETSS=console
+
+OBJS= \
+       $(O)\nbio.obj \
+       $(O)\output.obj \
+       $(O)\ResolveLocker.obj \
+       $(O)\WinThreads.obj \
+       $(O)\WinTorture.obj \
+
+
+INCLUDES=..\include; \
+       $(PISMERE)\athena\wshelper\include; \
+       $(PISMERE)\athena\util\locker\lib
+
+!ifdef NODEBUG
+LIB_PATHS=$(PISMERE)\target\lib\i386\rel
+!else
+LIB_PATHS=$(PISMERE)\target\lib\i386\dbg
+!endif
+
+USE_DEFAULTLIB=1
+
+LIBS=krbv4w32.lib oncrpc.lib Kernel32.lib Psapi.lib wshelp32.lib locker.lib athdir.lib Ws2_32.lib Mpr.lib oleaut32.lib Advapi32.lib ole32.lib User32.lib
+USE_LIBC_DLL=1
+C_DEFINE=-DHAVE_HESOID 
+
+#####
+
+
+
diff --git a/src/WINNT/tests/torture/Source/ResolveLocker.c b/src/WINNT/tests/torture/Source/ResolveLocker.c
new file mode 100644 (file)
index 0000000..7b9934c
--- /dev/null
@@ -0,0 +1,154 @@
+/* 
+ * MODULE: locker.c.
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
+ *
+ * Description: functions used by add, attach, detach, and shell extensions
+ */
+#ifdef HAVE_HESOID
+
+#ifdef _WIN32_WINNT
+    #undef _WIN32_WINNT
+#endif
+
+#define _WIN32_WINNT 0x0500
+
+#include <windows.h>
+#include <stdio.h>
+#include <hesiod.h>
+#include <locker.h>
+
+
+char **ResolveHesName(char *locker);
+void GetLockerInfo(char *Locker, char *Path);
+
+int  ResolveLocker(USER_OPTIONS *attachOption)
+{
+    char    HostName[128];
+    char    path[2048];
+    char    MountDir[2048];
+    char    ReparseDir[MAX_PATH];
+    char    AccessMode[16];
+    char    temp[4096];
+    char    FileSystem[16];
+    int     i;
+
+    memset(path, '\0', sizeof(path));
+    if (!stricmp(attachOption->type, "locker"))
+    {
+        GetLockerInfo(attachOption->Locker, path);
+        if (strlen(path) == 0)
+        {
+            return(FALSE);
+        }
+        memset(MountDir, 0, sizeof(MountDir));
+        memset(AccessMode, 0, sizeof(AccessMode));
+        memset(ReparseDir, 0, sizeof(ReparseDir));
+        memset(temp, 0, sizeof(temp));
+        sscanf(path, "%s %s", FileSystem, temp);
+
+        if (!strcmp(FileSystem, "AFS"))
+        {
+            sprintf(attachOption->SubMount, "\\\\afs\\%s", attachOption->Locker);
+            for (i = 0; i < (int)strlen(attachOption->SubMount); i++)
+            {
+                if (attachOption->SubMount[i] == '/')
+                    attachOption->SubMount[i] = '\\';
+            }
+            strcpy(attachOption->type, "AFS");
+            return(TRUE);
+        }
+        else if (!strcmp(FileSystem, "NFS"))
+        {
+            if (strlen(attachOption->SubMount) != 0)
+            {
+                return(FALSE);
+            }
+            if (sscanf(path, "%s %s %s %s %s", FileSystem, temp, HostName,
+                       AccessMode, ReparseDir) != 5)
+            {
+                return(FALSE);
+            }
+            sprintf(attachOption->SubMount, "\\\\%s%s", HostName, temp);
+            for (i = 0; i < (int)strlen(attachOption->SubMount); i++)
+            {
+                if (attachOption->SubMount[i] == '/')
+                    attachOption->SubMount[i] = '\\';
+            }
+            strcpy(attachOption->FileType, "NFS");
+            return(TRUE);
+        }
+        else
+        {
+            return(FALSE);
+        }
+    }
+    else
+    {
+        return(FALSE);
+    }
+
+//    rc = resource_mount(attachOption, addtoPath, addtoFront, appName,
+//                        MountDir, HostName, FileSystem);
+    return(TRUE);
+}
+
+void GetLockerInfo(char *Locker, char *Path)
+{
+    char**  cpp;
+    char    cWeight[3];
+    char    cPath[256];
+    int     i;
+    int     last_weight;
+
+    cpp = NULL;
+    cpp = ResolveHesName(Locker);
+
+    if (cpp != NULL)
+    {
+        memset(cWeight, 0, sizeof(cWeight));
+        memset(cPath, 0, sizeof(cPath));
+        last_weight = 1000;
+        i = 0;
+        while (cpp[i] != NULL)
+        {
+            memset(cPath, '\0', sizeof(cPath));
+            if (sscanf(cpp[i], "%*s %s", cPath))
+            {
+                if (strnicmp(cpp[i], "AFS", strlen("AFS")) == 0)
+                {
+                    memset(cWeight, '\0', sizeof(cWeight));
+                    if (sscanf(cpp[i], "%*s %*s %*s %*s %s", cWeight))
+                    {
+                        if (atoi(cWeight) < last_weight)
+                        {
+                            strcpy(Path, cpp[i]);
+                            last_weight = (int)atoi(cWeight);
+                        }
+                    }
+                    else
+                        strcpy(Path, cpp[i]);
+                    }
+                if (strnicmp(cpp[i], "NFS", strlen("NFS")) == 0)
+                    strcpy(Path, cpp[i]);
+            }
+            ++i;
+        }
+    }
+    return;
+}
+
+char **ResolveHesName(char *locker)
+{
+    char   type[16];
+    char** cpp;
+    strcpy(type, "filsys");
+
+    cpp = NULL;
+    cpp = hes_resolve(locker, type);
+
+    return cpp;
+}
+#endif /*HAVE_HESOID */
\ No newline at end of file
diff --git a/src/WINNT/tests/torture/Source/WinThreads.c b/src/WINNT/tests/torture/Source/WinThreads.c
new file mode 100644 (file)
index 0000000..5e3e154
--- /dev/null
@@ -0,0 +1,604 @@
+#include <windows.h>
+#include <includes.h>
+#include "common.h"
+#ifdef HAVE_HESOID
+    #include "ResolveLocker.h"
+    int ResolveLocker(USER_OPTIONS *attachOption);
+#endif
+#ifdef HAVE_AFS_SOURCE
+    #include <smb_iocons.h>
+    #include <afsint.h>
+    #include <pioctl_nt.h>
+#else
+    #define VIOCGETVOLSTAT  0x7
+    #define afs_int32   int
+
+    struct VolumeStatus {
+           afs_int32 Vid;
+           afs_int32 ParentId;
+           char Online;
+           char InService;
+           char Blessed;
+           char NeedsSalvage;
+           afs_int32 Type;
+           afs_int32 MinQuota;
+           afs_int32 MaxQuota;
+           afs_int32 BlocksInUse;
+           afs_int32 PartBlocksAvail;
+           afs_int32 PartMaxBlocks;
+    };
+
+    typedef struct VolumeStatus VolumeStatus;
+
+    typedef struct ViceIoctl {
+           long in_size;
+            long out_size;
+            void *in;
+           void *out;
+    } viceIoctl_t;
+#endif
+long pioctl(char *pathp, long opcode, struct ViceIoctl *blob, int follow);
+
+#define MAX_PARAMS 20
+#define ival(s) strtol(s, NULL, 0)
+#define AFSDLL "afsauthent.dll"
+
+#define WINTORTURE_ASFDLL_ONLINE        1
+#define WINTORTURE_ASFDLL_OFFLINE       2
+#define WINTORTURE_ASFDLL_NOTFOUND      3
+#define WINTORTURE_ASFPIOCTL_NOTFOUND   4
+
+extern int verbose;
+
+extern void EndSecondTime(int cmd);
+extern void StartSecondTime(int cmd);
+extern void LogMessage(int ProcessNumber, char *HostName, char *FileName, char *message, int LogID);
+extern void LogStats(char *FileName, int ToLog, int Iteration,  int NumberOfProcesses, int NumberOfThreads,
+                     char *HostName, int ProcessNumber, struct cmd_struct ThreadCommandInfo[],
+                     char *CommandLine, char *TargetDirectory);
+extern void SubstituteString(char *s,const char *pattern,const char *insert, size_t len);
+
+int  IsOnline(char *strPath);
+BOOL run_netbench(int client, char *ClientTxt, char *PathToSecondDir);
+
+HANDLE  MutexHandle;
+HANDLE  FileMutexHandle;
+HANDLE  ShutDownEventHandle;
+HANDLE  PauseEventHandle;
+HANDLE  ContinueEventHandle;
+HANDLE  OSMutexHandle;
+
+__declspec( thread ) int    AfsTrace;
+__declspec( thread ) int    CurrentLoop;
+__declspec( thread ) int    ProcessNumber = 0;
+__declspec( thread ) int    LogID = 0;
+__declspec( thread ) int    LineCount = 0;
+__declspec( thread ) int    *pThreadStatus;
+__declspec( thread ) DWORD  TickCount1,TickCount2, MilliTickStart;
+__declspec( thread ) char   *IoBuffer = NULL;
+__declspec( thread ) char   AfsLocker[256];
+__declspec( thread ) char   OriginalAfsLocker[256];
+__declspec( thread ) char   HostName[256];
+__declspec( thread ) struct cmd_struct ThreadCommandInfo[CMD_MAX_CMD + 1];
+__declspec( thread ) FTABLE ftable[MAX_FILES];
+__declspec( thread ) HANDLE hWinEventHandle;
+__declspec( thread ) EXIT_STATUS *pExitStatus;
+__declspec( thread ) DWORD  LastKnownError;
+
+
+DWORD WINAPI StressTestThread(LPVOID lpThreadParameter)
+{
+    int         j;
+    int         rc;
+    int         count;
+    int         BufferSize;
+    int         ProcessID;
+    char        EventName[64];
+    char        FileName[256];
+    char        CommandLine[512];
+    char        TargetDirectory[512];
+    char        WorkingDirectory[512];
+    char        ClientText[128];
+    char        PathToSecondDir[256];
+    char        temp[256];
+    BOOL        PrintStats;
+    PARAMETERLIST *pParameterList;
+    struct cmd_struct *WinCommandInfo;
+
+    pParameterList = (PARAMETERLIST *)lpThreadParameter;
+    pThreadStatus = pParameterList->pThreadStatus;
+    BufferSize = pParameterList->BufferSize;
+    ProcessNumber = pParameterList->ProcessNumber;
+    PrintStats = pParameterList->PrintStats;
+    CurrentLoop = pParameterList->CurrentLoop;
+    ProcessID = pParameterList->ProcessID;
+    LogID = pParameterList->LogID;
+    AfsTrace = pParameterList->AfsTrace;
+    pExitStatus = pParameterList->pExitStatus;
+    strcpy(TargetDirectory, pParameterList->TargetDirectory);
+    strcpy(CommandLine, pParameterList->CommandLine);
+    strcpy(ClientText, pParameterList->ClientText);
+    strcpy(PathToSecondDir, pParameterList->PathToSecondDir);
+    strcpy(AfsLocker, pParameterList->AfsLocker);
+    strcpy(HostName, pParameterList->HostName);
+    WinCommandInfo = ( struct cmd_struct *)pParameterList->CommandInfo;
+
+    sprintf(EventName, "%d%sEvent%05d", ProcessID, HostName, ProcessNumber);
+    hWinEventHandle = OpenEvent(EVENT_ALL_ACCESS, TRUE, EventName);
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    GetCurrentDirectory(sizeof(WorkingDirectory), WorkingDirectory);
+    sprintf(temp, "%s\\log%05d\\%s", WorkingDirectory, LogID, HostName);
+    CreateDirectory(temp, NULL);
+
+
+    memset(ftable, '\0', sizeof(ftable[0]) * MAX_FILES);
+    IoBuffer = malloc(BufferSize);
+    if (!IoBuffer)
+    {
+        strcpy(pExitStatus->Reason, "Unable to allocate buffer");
+        pExitStatus->ExitStatus = 1;
+        SetEvent(hWinEventHandle);
+        ExitThread(1);
+    }
+
+    ShutDownEventHandle = CreateEvent(NULL, TRUE, FALSE, "AfsShutdownEvent");
+    PauseEventHandle = CreateEvent(NULL, TRUE, FALSE, "AfsPauseEvent");
+    ContinueEventHandle = CreateEvent(NULL, TRUE, FALSE, "AfsContinueEvent");
+    OSMutexHandle = CreateMutex(NULL, FALSE, "WinTortureOSMutex");
+    MutexHandle = CreateMutex(NULL, FALSE, "WinTortureMutex");
+
+    strcpy(OriginalAfsLocker, AfsLocker);
+
+    while (1)
+    {
+        LastKnownError = 0;
+        for (j = 0; j <= CMD_MAX_CMD; j++)
+            {
+                WinCommandInfo[j].count = 0;
+                WinCommandInfo[j].min_sec = 0;
+                WinCommandInfo[j].max_sec = 0;
+                WinCommandInfo[j].MilliSeconds = 0;
+                WinCommandInfo[j].total_sec = 0;
+                WinCommandInfo[j].total_sum_of_squares = 0;
+                WinCommandInfo[j].ErrorCount = 0;
+                WinCommandInfo[j].ErrorTime = 0;
+                ThreadCommandInfo[j].count = 0;
+                ThreadCommandInfo[j].min_sec = 1000;
+                ThreadCommandInfo[j].max_sec = 0;
+                ThreadCommandInfo[j].MilliSeconds = 0;
+                ThreadCommandInfo[j].total_sec = 0;
+                ThreadCommandInfo[j].total_sum_of_squares = 0;
+                ThreadCommandInfo[j].ErrorCount = 0;
+                ThreadCommandInfo[j].ErrorTime = 0;
+            }
+
+        run_netbench(ProcessNumber, ClientText, PathToSecondDir);
+        if (LastKnownError != ERROR_NETNAME_DELETED)
+            break;
+        sprintf(temp, "entered error %d processing\n", LastKnownError);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+
+        count = strlen(pExitStatus->Reason);
+        if (count != 0)
+            memset(pExitStatus->Reason, '\0', count);
+        pExitStatus->ExitStatus = 0;
+        (*pThreadStatus) = 1;
+        count = 0;
+        
+        while ((rc = IsOnline(OriginalAfsLocker)) != WINTORTURE_ASFDLL_ONLINE)
+        {
+            if ((count > 3) || (rc == WINTORTURE_ASFDLL_NOTFOUND) || (rc == WINTORTURE_ASFPIOCTL_NOTFOUND))
+            {
+                LastKnownError = 0;
+                strcpy(temp, "AFS client appears to be off-line\n");
+                strcpy(pExitStatus->Reason, temp);
+                pExitStatus->ExitStatus = 1;
+                (*pThreadStatus) = 0;
+                printf("%s", temp);
+                LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+                strcpy(temp, "Stress test is terminating\n");
+                printf(temp);
+                LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+                break;
+            }
+            strcpy(temp, "AFS is online, sleeping 10 seconds before continuing\n");
+            LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+            ++count;
+            Sleep(10 * 1000);
+        }
+        sprintf(temp, "leaving error %d processing\n", LastKnownError);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        if (count > 3)
+            break;
+    }
+    free(IoBuffer);
+
+    for (j = 0; j <= CMD_MAX_CMD; j++)
+    {
+        WinCommandInfo[j].count += ThreadCommandInfo[j].count;
+        WinCommandInfo[j].min_sec += ThreadCommandInfo[j].min_sec;
+        WinCommandInfo[j].max_sec += ThreadCommandInfo[j].max_sec;
+        WinCommandInfo[j].total_sec += ThreadCommandInfo[j].total_sec;
+        WinCommandInfo[j].total_sum_of_squares += ThreadCommandInfo[j].total_sum_of_squares;
+        WinCommandInfo[j].ErrorCount += ThreadCommandInfo[j].ErrorCount;
+        WinCommandInfo[j].ErrorTime += ThreadCommandInfo[j].ErrorTime;
+    }
+
+    memset(WorkingDirectory, '\0', sizeof(WorkingDirectory));
+    GetCurrentDirectory(sizeof(WorkingDirectory), WorkingDirectory);
+    sprintf(FileName, "%s\\log%05d\\%s\\Thread_%05d_Stats.log", WorkingDirectory, LogID, HostName, ProcessNumber);
+
+    if (PrintStats)
+    {
+        WaitForSingleObject(MutexHandle, 4 * 1000);
+        LogStats(FileName, 0, CurrentLoop, 0, 0, HostName, ProcessNumber, ThreadCommandInfo, CommandLine, TargetDirectory);
+        ReleaseMutex(MutexHandle);
+    }
+
+    LogStats(FileName, 1, CurrentLoop, 0, 0, HostName, ProcessNumber, ThreadCommandInfo,CommandLine, TargetDirectory);
+
+    SetEvent(hWinEventHandle);
+    CloseHandle(hWinEventHandle);
+//    CloseHandle(OSMutexHandle);
+//    CloseHandle(MutexHandle);
+
+    ExitThread(0);
+    return(0);
+}
+
+BOOL run_netbench(int client, char *ClientText, char *PathToSecondDir)
+{
+    pstring line;
+    pstring line1;
+    char    cname[20];
+    char    *params[MAX_PARAMS];
+    char    temp[256];
+    char    FileName[256];
+    char    *pPtr;
+    int     rc;
+    int     i;
+    int     IncreaseBy;
+    BOOL    correct = TRUE;
+    DWORD   dwFlags = 0;
+    DWORD   NumberOfBytes;
+    DWORD   TotalBytesRead;
+    HANDLE  hFile;
+    enum    states bm_state;
+    CRITICAL_SECTION CriticalSection;
+
+
+    InitializeCriticalSection(&CriticalSection);
+
+    sprintf(cname, "client%d", client);
+
+    sprintf(temp, "Started Iteration %d\n", CurrentLoop);
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+    sprintf(temp, "Thread %d started\n", ProcessNumber);
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+
+    hFile = CreateFile(ClientText, GENERIC_READ | STANDARD_RIGHTS_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 
+
+    if (hFile == INVALID_HANDLE_VALUE) 
+    {
+        perror(ClientText);
+        return(-1);
+    }
+
+    StartSecondTime(CMD_NONAFS);
+    TotalBytesRead = 0;
+    while (1)
+    {
+        memset(line, '\0', sizeof(line));
+        NumberOfBytes = 0;
+        rc = ReadFile(hFile, line, 128, &NumberOfBytes, NULL);
+        if (rc && NumberOfBytes == 0)
+            break;
+        pPtr = strchr(line, '\n');
+        IncreaseBy = 0;
+        if (pPtr != NULL)
+        {
+            IncreaseBy += 1;
+            (*pPtr) = '\0';
+            if ((*(pPtr - 1)) == '\r')
+            {
+                IncreaseBy += 1;
+                (*(pPtr - 1)) = '\0';
+            }
+        }
+        TotalBytesRead += (strlen(line) + IncreaseBy);
+        SetFilePointer(hFile, TotalBytesRead, 0, FILE_BEGIN);
+        strcpy(line1, line);
+        if (rc = WaitForSingleObject(PauseEventHandle, 0) == WAIT_OBJECT_0)
+        {
+            strcpy(temp, "AFS suspend request received\n");
+            sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+            LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+            while (WaitForSingleObject(ContinueEventHandle, 5000) == WAIT_TIMEOUT);
+            strcpy(temp, "AFS continue request received\n");
+            sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+            LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        }
+        if (rc = WaitForSingleObject(ShutDownEventHandle, 0) == WAIT_OBJECT_0)
+        {
+            strcpy(temp, "AFS shutdown request received\n");
+            sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+            LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+            break;
+        }
+        LineCount++;
+        if (strlen(line) == 0)
+            continue;
+        if (line[0] == '#')
+            continue;
+        /*printf("[%d] %s\n", LineCount, line);*/
+
+        for (i = 0; i < MAX_PARAMS; i++)
+            params[i] = NULL;
+
+        SubstituteString(line,"client1", cname, sizeof(line));
+        sprintf(temp, "%s%05d", HostName, LogID);
+        SubstituteString(line,"clients", temp, sizeof(line));
+        SubstituteString(line,"\\\\afs\\locker", AfsLocker, sizeof(line));
+        if (strlen(PathToSecondDir) != 0)
+               SubstituteString(line,"\\\\afs\\lcolby", PathToSecondDir, sizeof(line));
+
+        if (verbose)
+        {
+            EnterCriticalSection(&CriticalSection);
+            printf("Thread%05d - %-6d - %s\n", ProcessNumber, LineCount, line);
+            LeaveCriticalSection(&CriticalSection);
+        }
+
+        pPtr = line;
+        i = 0;
+        while (pPtr != NULL)
+        {
+            if ((*pPtr) == ' ')
+            {
+                (*pPtr) = '\0';
+                ++pPtr;
+                continue;
+            }
+            params[i] = pPtr;
+            ++i;
+            pPtr = strstr(pPtr, " ");
+            if (pPtr != NULL)
+            {
+                (*pPtr) = '\0';
+                ++pPtr;
+            }
+            
+        }
+
+        params[i] = "";
+
+        if (i < 1) 
+            continue;
+
+        if (!strncmp(params[0],"SMB", 3)) 
+        {
+            printf("ERROR: You are using a dbench 1 load file\n");
+            if (GetHandleInformation((HANDLE)hWinEventHandle, &dwFlags))
+                break;
+               }
+        if (!strcmp(params[0], "BM_SETUP"))
+        {
+            bm_state = BM_SETUP;
+        } 
+        else if (!strcmp(params[0], "BM_WARMUP"))
+        {
+            bm_state = BM_WARMUP;
+        } 
+        else if (!strcmp(params[0], "BM_MEASURE"))
+        {
+            bm_state = BM_MEASURE;
+            if (verbose)
+                fprintf(stderr, "setting state to BM_MEASURE\n");
+        } 
+        else if (!strcmp(params[0],"RECONNECT")) 
+        {
+            if (verbose)
+                fprintf(stderr, "Reconnecting ...\n");
+        } 
+        else if (!strcmp(params[0], "SYNC"))
+        {
+            int length = atoi(params[1]), st = 0;
+            if (verbose)
+                fprintf(stderr, "Syncing for %d seconds\n", length);
+        } 
+        else if (!strcmp(params[0],"NTCreateX")) 
+        {
+            if (nb_createx(params[1], ival(params[2]), ival(params[3]), ival(params[4])) == -1)
+                break;
+        } 
+        else if (!stricmp(params[0],"SetLocker"))
+        {
+            if (nb_SetLocker(params[1]) == -1)
+                break;
+        } 
+        else if (!stricmp(params[0],"Xrmdir")) 
+        {
+            if (nb_Xrmdir(params[1], params[2]) == -1)
+                break;
+        } 
+        else if (!stricmp(params[0],"Mkdir")) 
+        {
+            if (nb_Mkdir(params[1]) == -1)
+                break;
+        } 
+        else if (!stricmp(params[0],"Attach")) 
+        {
+            if (nb_Attach(params[1], params[2]) == -1)
+                break;
+        } 
+        else if (!stricmp(params[0],"Detach")) 
+        {
+            if (nb_Detach(params[1], params[2]) == -1)
+                break;
+        } 
+        else if (!stricmp(params[0],"CreateFile")) 
+        {
+            if (nb_CreateFile(params[1], atol(params[2])) == -1)
+                break;
+        } 
+        else if (!stricmp(params[0],"CopyFiles")) 
+        {
+            if (nb_CopyFile(params[1], params[2]) == -1)
+                break;
+        } 
+        else if (!stricmp(params[0],"DeleteFiles")) 
+        {
+            if (nb_DeleteFile(params[1]) == -1)
+                break;
+        } 
+        else if (!stricmp(params[0],"Move")) 
+        {
+            if (nb_Move(params[1], params[2]) == -1)
+                break;
+        } 
+        else if (!stricmp(params[0],"Xcopy")) 
+        {
+            if (nb_xcopy(params[1], params[2]) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"Close")) 
+        {
+            if (nb_close(ival(params[1])) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"Rename")) 
+        {
+            if (nb_rename(params[1], params[2]) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"Unlink")) 
+        {
+            if (nb_unlink(params[1]) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"Deltree"))
+        {
+            if (nb_deltree(params[1]) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"Rmdir")) 
+        {
+            if (nb_rmdir(params[1]) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"QUERY_PATH_INFORMATION"))
+        {
+            if (nb_qpathinfo(params[1], ival(params[2])) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"QUERY_FILE_INFORMATION")) 
+        {
+            if (nb_qfileinfo(ival(params[1])) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"QUERY_FS_INFORMATION")) 
+        {
+            if (nb_qfsinfo(ival(params[1])) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"FIND_FIRST")) 
+        {
+            if (nb_findfirst(params[1]) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"WriteX")) 
+        {
+            if (nb_writex(ival(params[1]), ival(params[2]), ival(params[3]), ival(params[4])) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"ReadX")) 
+        {
+            if (nb_readx(ival(params[1]), ival(params[2]), ival(params[3]), ival(params[4])) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"Flush")) 
+        {
+            if (nb_flush(ival(params[1])) == -1)
+                break;
+        } 
+        else if (!strcmp(params[0],"LockingX")) 
+        {
+            if (nb_lock(ival(params[1]), ival(params[2]), ival(params[3]), ival(params[4]),
+                        (unsigned char)ival(params[5]), ival(params[6])) == -1)
+                break;
+        } 
+        else 
+        {
+            printf("Unknown operation %s\n", params[0]);
+            printf("Line read = %s\n", line1);
+            break;
+        }
+    }
+    CloseHandle(hFile);
+
+//    nb_cleanup(cname);
+
+    EndSecondTime(CMD_NONAFS);
+
+    for (i = 0; i < MAX_FILES; i++) 
+    {
+        if (ftable[i].handle > 0)
+            nb_close(ftable[i].handle);
+    }
+
+       DeleteCriticalSection(&CriticalSection);
+
+    return(correct);
+}
+
+typedef long ( __cdecl  *PPIOCTL)(char *pathp, long opcode, struct ViceIoctl *blobp, int follow);
+
+int IsOnline(char *strPath)
+{
+    int     bret;
+    char    space[2048];
+    int     code;
+    int     rc;
+    struct  ViceIoctl blob;
+    struct  VolumeStatus *status;
+    PPIOCTL ppioctl;
+    HINSTANCE hAfsDll;
+
+    rc = WaitForSingleObject(OSMutexHandle, 5 * 1000);
+    bret = FALSE;
+    hAfsDll = NULL;
+    hAfsDll = LoadLibrary(AFSDLL);
+    if (hAfsDll)
+    {
+        ppioctl = NULL;
+        ppioctl = (PPIOCTL)GetProcAddress(hAfsDll, "pioctl");
+        if (ppioctl != NULL)
+        {
+            blob.in_size = 0;
+            blob.out_size = sizeof(space);
+            blob.out = space;
+            if (!(code = ppioctl(strPath, VIOCGETVOLSTAT, &blob, 1)))
+            {
+                bret = WINTORTURE_ASFDLL_ONLINE;
+                status = (VolumeStatus *)space;
+                if (!status->Online || !status->InService || !status->Blessed || status->NeedsSalvage)
+                    bret = WINTORTURE_ASFDLL_OFFLINE;
+            }
+        }
+        else
+            bret = WINTORTURE_ASFPIOCTL_NOTFOUND;
+
+        FreeLibrary(hAfsDll);
+        hAfsDll = NULL;
+    }
+    else
+        bret = WINTORTURE_ASFDLL_NOTFOUND;
+
+    if (rc == WAIT_OBJECT_0)
+        ReleaseMutex(OSMutexHandle);
+    return(bret);
+}
+
diff --git a/src/WINNT/tests/torture/Source/WinTorture.c b/src/WINNT/tests/torture/Source/WinTorture.c
new file mode 100644 (file)
index 0000000..444f808
--- /dev/null
@@ -0,0 +1,921 @@
+//#define _WIN32_WINNT 0x0500
+//#include <windows.h>
+
+#include "includes.h"
+#include <Psapi.h>
+#include "common.h"
+#ifdef HAVE_HESOID
+    #include "ResolveLocker.h"
+    extern int ResolveLocker(USER_OPTIONS *attachOption);
+    extern void GetLockerInfo(char *Locker, char *Path);
+#endif /* HAVE_HESOID */
+
+#define MAX_THREADS 100
+
+int opterr = 1;
+int optind = 1;
+int optopt;
+int optreset;
+char *optarg;
+
+extern void LogStats(char *FileName, int ToLog, int Iteration,  int NumberOfProcesses, int NumberOfThreads, 
+                     char *HostName, int ProcessNumber, struct cmd_struct CommandInfo[],
+                     char *CommandLine, char *TargetDirectory);
+extern int UpdateMasterLog(char *FileName, struct cmd_struct CommandInfo[]);
+extern int BuildMasterStatLog(char *FileName, char *MoveFileName, int NumberOfProcesses, 
+                              int NumberOfThreads, char *CommandLine, int LoopCount, 
+                              char *TargetDirectory, int ProcessNumber);
+extern void LogMessage(int ProcessNumber, char *HostName, char *FileName, char *message, int LogID);
+
+DWORD WINAPI StressTestThread(LPVOID lpThreadParameter);
+int   getopt(int, char**, char*);
+DWORD FindProcessCount(char *ProcessName, HANDLE JobHandle);
+void  show_results(char *CommandLine, char *TargetDirectory, struct cmd_struct CommandInfo[], 
+                   char *HostName, int NumberOfThreads, int CurrentLoop, int LogID);
+
+char    *ClientText = "streamfiles.txt";
+char    PathToSecondDir[256];
+int     ThreadStatus[MAX_HANDLES];
+int     verbose;
+int     BufferSize = 256*1024;
+int     UseLocker = 0;
+//int     UseUnicode = 0;
+int     EndOnError;
+int     AfsTrace;
+int     ChronLog;
+BOOL    PrintStats;
+HANDLE  MutexHandle;
+HANDLE  FileMutexHandle;
+HANDLE  ChronMutexHandle;
+HANDLE  OSMutexHandle;
+HANDLE  ShutDownEventHandle;
+HANDLE  PauseEventHandle;
+HANDLE  ContinueEventHandle;
+EXIT_STATUS ExitStatus[MAX_HANDLES];
+
+double create_procs(char *Hostname, char *CommandLine, char *TargetDirectory, 
+                    char *AfsLocker, char *Locker, char *HostName, 
+                    int NumberOfThreads, int CurrentLoop, int LogID)
+{
+    int     i;
+    int     status;
+    int     count;
+    int     ProcessID;
+    char    EventName[512];
+    HANDLE  hEventHandle[MAX_HANDLES];
+    HANDLE  hThreadHandle[MAX_HANDLES];
+    DWORD   dwThreadID[MAX_HANDLES];
+    struct cmd_struct *CommandInfo;
+    CRITICAL_SECTION CriticalSection;
+    PARAMETERLIST    *pParameterList[MAX_HANDLES];
+#ifdef HAVE_HESOID
+    USER_OPTIONS     attachOption;
+#endif
+
+    InitializeCriticalSection(&CriticalSection); 
+    for (i = 0; i < MAX_HANDLES; i++)
+    {
+        hEventHandle[i] = NULL;
+        hThreadHandle[i] = NULL;
+        pParameterList[i] = NULL;
+        dwThreadID[i] = 0;
+    }
+
+    count = 0;
+    CommandInfo = calloc(1, sizeof(struct cmd_struct) * (CMD_MAX_CMD + 1) * NumberOfThreads);
+    ProcessID = getpid();
+
+    for (i = 0; i < NumberOfThreads; i++) 
+    {
+        if (EndOnError)
+        {
+            if (ThreadStatus[count] == 0)
+                continue;
+        }
+        sprintf(EventName, "%d%sEvent%05d", ProcessID, HostName, count);
+        hEventHandle[count] = CreateEvent(NULL, FALSE, FALSE, EventName);
+        if (hEventHandle[count] == NULL)
+            continue;
+        ResetEvent(hEventHandle[count]);
+        
+        pParameterList[count] = calloc(1, sizeof(PARAMETERLIST));
+        pParameterList[count]->ProcessNumber = count;
+        pParameterList[count]->CommandInfo = (struct cmd_struct *)(CommandInfo + (i * (CMD_MAX_CMD + 1)));
+        pParameterList[count]->BufferSize = BufferSize;
+        pParameterList[count]->PrintStats = PrintStats;
+        pParameterList[count]->CurrentLoop = CurrentLoop;
+        pParameterList[count]->AfsTrace = AfsTrace;
+        pParameterList[count]->TargetDirectory = TargetDirectory;
+        pParameterList[count]->pExitStatus = &ExitStatus[i];
+        pParameterList[count]->pThreadStatus = &ThreadStatus[i];
+        pParameterList[count]->CommandLine = CommandLine;
+        pParameterList[count]->ClientText = ClientText;
+        pParameterList[count]->PathToSecondDir = PathToSecondDir;
+        pParameterList[count]->AfsLocker = AfsLocker;
+        pParameterList[count]->HostName = HostName;
+        pParameterList[count]->ProcessID = ProcessID;;
+        pParameterList[count]->LogID = LogID;;
+
+        ThreadStatus[count] = 0;
+        hThreadHandle[count] = CreateThread(NULL, 0, &StressTestThread, (LPVOID)pParameterList[count], CREATE_SUSPENDED, &dwThreadID[count]);
+        if (hThreadHandle[count] != NULL)
+        {
+            ResumeThread(hThreadHandle[count]);
+            ThreadStatus[count] = 1;
+            ++count;
+        }
+        else
+        {
+            CloseHandle(hEventHandle[count]);
+            if (pParameterList[count] != NULL)
+                free(pParameterList[count]);
+            pParameterList[count] = NULL;
+            hThreadHandle[count] = NULL;
+            hEventHandle[count] = NULL;
+        }
+    }
+
+    count = 0;
+    for (i = 0; i < MAX_HANDLES; i++)
+    {
+        if (hEventHandle[i] != NULL)
+            ++count;
+    }
+#ifdef HAVE_HESOID
+    if (UseLocker)
+    {
+        int          rc;
+
+        memset(&attachOption, '\0', sizeof(attachOption));
+        strcpy(attachOption.Locker, Locker);
+        strcpy(attachOption.type, "locker");
+        if (rc = ResolveLocker(&attachOption))
+        {
+            if (!stricmp(attachOption.type, "AFS"))
+            {
+                printf("Unable to attach locker %s - AFS is not supported\n", Locker);
+                exit(1);
+            }
+            strcpy(AfsLocker, attachOption.SubMount);
+            memset(&attachOption, '\0', sizeof(attachOption));
+            strcpy(attachOption.Locker, Locker);
+            strcpy(attachOption.type, "locker");
+            if (rc = attach(attachOption, 0, 0, Locker))
+            {
+                printf("Unable to attach locker %s\n", Locker);
+                exit(1);
+            }
+        }
+    }
+#endif /* HAVE_HESOID */
+
+    status = WaitForMultipleObjects(count, hEventHandle, TRUE, INFINITE);
+    for (i = 0; i < MAX_HANDLES; i++)
+    {
+        if (hEventHandle[i] != NULL)
+            CloseHandle(hEventHandle[i]);
+        if (pParameterList[i] != NULL)
+            free(pParameterList[i]);
+        pParameterList[i] = NULL;
+        hEventHandle[i] = NULL;
+    }
+
+    for (i = 0; i < NumberOfThreads; i++)
+    {
+        char    FileName[128];
+        char    temp[512];
+
+        if (strlen(ExitStatus[i].Reason))
+        {
+            sprintf(temp, "Thread %0d exited with reason: %s", i, ExitStatus[i].Reason);
+        }
+        else
+        {
+            sprintf(temp, "Thread %0d completed\n", i);
+        }
+        if (verbose)
+            printf("%s", temp);
+        sprintf(FileName, "Thread_%05d.log", i);
+        LogMessage(i, HostName, FileName, temp, LogID);
+        sprintf(temp, "Ended Iteration %0d\n\n", CurrentLoop);
+        LogMessage(i, HostName, FileName, temp, LogID);
+        CloseHandle(hEventHandle[i]);
+    }
+    show_results(CommandLine, TargetDirectory, CommandInfo, HostName, NumberOfThreads, CurrentLoop, LogID);
+    free(CommandInfo);
+    DeleteCriticalSection(&CriticalSection);
+
+    return(0);
+}
+
+static void usage(void)
+{
+
+    fprintf(stderr, "usage: wintorture [options]\n");
+    fprintf(stderr, "where options can be:\n");
+    fprintf(stderr, "\t-b        Create a chronological log.\n");
+    fprintf(stderr, "\t-c <txt>  Specifies the script txt file to use.\n");
+    fprintf(stderr, "\t-e        End thread processing on an error.\n");
+    fprintf(stderr, "\t-f <name> Target directory name.\n");
+    fprintf(stderr, "\t-i <num>  Number of iterations of the stress test to run.\n");
+    fprintf(stderr, "\t            This option will override the -m option.\n");
+#ifdef HAVE_HESOID
+    fprintf(stderr, "\t-l <path> AFS locker or AFS submount in which to create the target directory.\n");
+#endif /* HAVE_HESOID */
+    fprintf(stderr, "\t-m <num>  The number of minutes to run the stress test.\n");
+    fprintf(stderr, "\t            This option will override the -i option.\n");
+    fprintf(stderr, "\t-n <num>  The number of threads to run.\n");
+    fprintf(stderr, "\t-p <path> UNC path to second directory.\n");
+    fprintf(stderr, "\t-s        Output stats.\n");
+    fprintf(stderr, "\t-t        Do AFS trace logging.\n");
+    fprintf(stderr, "\t-u <UNC>  UNC path to target directory.\n");
+    fprintf(stderr, "\t-v        Turn on verbose mode.\n");
+    fprintf(stderr, "\nNOTE: The switches are not case sensitive.  You\n");
+    fprintf(stderr, "\n      may use either upper or lower case letters.\n\n");
+}
+
+void show_results(char *CommandLine, char *TargetDirectory, struct cmd_struct *CommandInfo, 
+                  char *HostName, int NumberOfThreads, int CurrentLoop, int LogID)
+{
+       struct cmd_struct TotalCommandInfo[CMD_MAX_CMD + 1];
+       int         i;
+    int         j;
+       unsigned    grand_total = 0;
+    char        FileName[256];
+    char        WorkingDirectory[512];
+    struct cmd_struct *FinalCmdInfo;
+
+       for (j = 0; j <= CMD_MAX_CMD; j++) {
+               TotalCommandInfo[j].count = 0;
+               TotalCommandInfo[j].min_sec = 0;
+               TotalCommandInfo[j].max_sec = 0;
+               TotalCommandInfo[j].MilliSeconds = 0;
+               TotalCommandInfo[j].total_sec = 0;
+               TotalCommandInfo[j].total_sum_of_squares = 0;
+               TotalCommandInfo[j].ErrorCount = 0;
+               TotalCommandInfo[j].ErrorTime = 0;
+       }
+
+    memset(ExitStatus, '\0', sizeof(ExitStatus[0]) * MAX_HANDLES);
+
+       for (j = 0; j < NumberOfThreads; j++) 
+    { 
+           FinalCmdInfo = CommandInfo + (j * (CMD_MAX_CMD + 1));
+
+               for (i = 0; i <= CMD_MAX_CMD; i++)
+        {
+                   TotalCommandInfo[i].count += FinalCmdInfo[i].count;
+            TotalCommandInfo[i].total_sec += FinalCmdInfo[i].total_sec; 
+            TotalCommandInfo[i].total_sum_of_squares += FinalCmdInfo[i].total_sum_of_squares; 
+            TotalCommandInfo[i].ErrorCount += FinalCmdInfo[i].ErrorCount; 
+            TotalCommandInfo[i].ErrorTime += FinalCmdInfo[i].ErrorTime; 
+            grand_total += FinalCmdInfo[j].total_sec;
+            if (!TotalCommandInfo[i].min_sec || (TotalCommandInfo[i].min_sec > FinalCmdInfo[i].min_sec))
+                TotalCommandInfo[i].min_sec = FinalCmdInfo[i].min_sec;
+            if (TotalCommandInfo[i].max_sec < FinalCmdInfo[i].max_sec)
+                TotalCommandInfo[i].max_sec = FinalCmdInfo[i].max_sec;
+        }
+       }
+
+
+    memset(WorkingDirectory, '\0', sizeof(WorkingDirectory));
+    GetCurrentDirectory(sizeof(WorkingDirectory), WorkingDirectory);
+    sprintf(FileName, "%s\\log%05d\\%s\\ProcessStats.log", WorkingDirectory, LogID, HostName);
+
+    if (PrintStats)
+        LogStats(FileName, 0, CurrentLoop, 1, NumberOfThreads, HostName, -1, TotalCommandInfo, 
+                 CommandLine, TargetDirectory);
+    LogStats(FileName, 1, CurrentLoop, 1, NumberOfThreads, HostName, -1, TotalCommandInfo, 
+             CommandLine, TargetDirectory);
+
+    sprintf(FileName, "%s\\log%05d\\%s", WorkingDirectory, LogID, "MasterStatLog.log");
+    UpdateMasterLog(FileName, TotalCommandInfo);
+    sprintf(FileName, "%s\\log%05d\\%s\\%s", WorkingDirectory, LogID, HostName, "MasterProcessStatLog.log");
+    UpdateMasterLog(FileName, TotalCommandInfo);
+}
+
+
+int main(int argc, char *argv[])
+{
+    int         i;
+    int         LoopCount;
+    int         SecondsToRun;
+    int         NumberOfIterations;
+    int         StressTestUsed = 0;
+    int         rc;
+    int         opt;
+    int         ErrorState;
+    int         NumberOfProcesses;
+    int         NumberOfThreads;
+    int         IterationCount;
+    int         CurrentLoop = 0;
+    int         LogID;
+    time_t      TotalTime;
+    time_t      StartTime;
+    time_t      EndTime;
+    extern char *optarg;
+    extern int  optind;
+    FILE        *Mfp;
+    FILE        *fp;
+    char        *p;
+    char        tbuffer[10];
+    char        buffer[512];
+    char        FileName[256];
+    char        MoveFileName[256];
+    char        Locker[64];
+    char        command[512];
+    char        DateTime[512];
+    char        WorkingDirectory[512];
+    char        CommandLine[512];
+    char        TargetDirectory[512];
+    char        AfsLocker[256];
+    char        HostName[128];
+    char        JobName[128];
+    SYSTEMTIME  SystemTime;
+    SYSTEMTIME  LocalTime;
+    TIME_ZONE_INFORMATION TimeZoneInformation;
+    HANDLE      ExitMutexHandle;
+    HANDLE      JobHandle;
+
+
+    memset(HostName, '\0', sizeof(HostName));
+    memset(PathToSecondDir, '\0', sizeof(PathToSecondDir));
+    memset(Locker, '\0', sizeof(Locker));
+    SecondsToRun = 0;
+    NumberOfIterations = 0;
+    EndOnError = 0;
+    UseLocker = 0;
+    ChronLog = 0;
+    AfsTrace = 0;
+    verbose = 0;
+    NumberOfThreads = 1;
+    NumberOfProcesses = 1;
+    NumberOfThreads = 1;
+    LogID = 0;
+    PrintStats = FALSE;
+
+    while ((opt = getopt(argc, argv, "A:a:BbC:c:D:d:EeF:f:G:g:I:i:L:l:M:m:N:n:P:p:SsTtU:u:Vv")) != EOF)
+    {
+
+        switch (opt)
+        {
+            case 'a':
+            case 'A':
+                break;
+            case 'b':
+            case 'B':
+                ChronLog = 1;
+                break;
+            case 'c':
+            case 'C':
+                ClientText = optarg;
+                break;
+            case 'd':
+            case 'D':
+                StressTestUsed = 1;
+                NumberOfProcesses = atoi(optarg);
+                break;
+            case 'e':
+            case 'E':
+                EndOnError = 1;
+                break;
+            case 'f':
+            case 'F':
+                strcpy(HostName, optarg);
+                for (i = 0; i < (int)strlen(HostName); i++)
+                {
+                    if ((HostName[i] == '\\') || (HostName[i] == '/'))
+                    {
+                        printf("\nInvalid -F usage...Subdirectories not allowed\n\n");
+                        usage();
+                        exit(1);
+                    }
+                }
+                break;
+            case 'g':
+            case 'G':
+                StressTestUsed = 1;
+                LogID = atoi(optarg);
+                break;
+            case 'i':
+            case 'I':
+                SecondsToRun = 0;
+                NumberOfIterations = atoi(optarg);
+                if (NumberOfIterations < 0)
+                    NumberOfIterations = 0;
+                break;
+#ifdef HAVE_HESOID
+            case 'l':
+            case 'L':
+                strcpy(Locker, optarg);
+                UseLocker = 1;
+                break;
+#endif /* HAVE_HESOID */
+            case 'm':
+            case 'M':
+                NumberOfIterations = 0;
+                SecondsToRun = atoi(optarg) * 60;
+                if (SecondsToRun < 0)
+                    SecondsToRun = 0;
+                break;
+            case 'n':
+            case 'N':
+                NumberOfThreads = atoi(optarg);
+                break;
+            case 'p':
+            case 'P':
+                strcpy(PathToSecondDir, optarg);
+                for(p = PathToSecondDir; *p; p++)
+                {
+                    if(*p == '/')
+                        *p = '\\';
+                }
+                break;
+            case 's':
+            case 'S':
+                PrintStats = TRUE;
+                break;
+            case 't':
+            case 'T':
+                AfsTrace = 1;
+                break;
+            case 'u':
+            case 'U':
+                UseLocker = 0;
+                strcpy(Locker, optarg);
+                break;
+            case 'v':
+            case 'V':
+                verbose = 1;
+                break;
+            default:
+                usage();
+                exit(1);
+                break;
+        }
+    }
+
+    if (strlen(HostName) == 0)
+    {
+        printf("You must use the -f option to specify a target directory\n\n");
+        usage();
+        exit(1);
+    }
+    if (strlen(Locker) == 0)
+    {
+        printf("You must use either the -u or the -l option\n\n");
+        usage();
+        exit(1);
+    }
+
+    memset(CommandLine, '\0', sizeof(CommandLine));
+    for (i = 1; i < argc; i++)
+    {
+        if (StressTestUsed)
+        {
+            if (!stricmp(argv[i], "-f"))
+            {
+                char temp[64];
+
+                strcpy(temp, argv[i + 1]);
+                temp[strlen(temp) - 5] = '\0';
+                strcat(CommandLine, argv[i]);
+                strcat(CommandLine, " ");
+                strcat(CommandLine, temp);
+                strcat(CommandLine, " ");
+                ++i;
+                continue;
+            }
+        }
+        strcat(CommandLine, argv[i]);
+        strcat(CommandLine, " ");
+    }
+
+    argc -= optind;
+    argv += optind;
+
+    if (strlen(Locker) == 0)
+    {
+        usage();
+        exit(1);
+    }
+
+
+    for(p = Locker; *p; p++)
+    {
+        if(*p == '/')
+            *p = '\\';
+    }
+#ifdef HAVE_HESOID
+    if (UseLocker)
+    {
+        char *sPtr;
+
+        sprintf(AfsLocker, "\\\\afs\\%s", Locker);
+        memset(buffer, '\0', sizeof(buffer));
+        GetLockerInfo(Locker, buffer);
+        if (strlen(buffer) != 0)
+        {
+            sPtr = strstr(buffer, "/afs/");
+            sPtr += strlen("/afs/");
+            strcpy(TargetDirectory, sPtr);
+            sPtr = strchr(TargetDirectory, ' ');
+            if (sPtr != NULL)
+                (*sPtr) = '\0';
+            while ((sPtr = strchr(TargetDirectory, '/')) != NULL)
+                (*sPtr) = '\\';
+        }
+        else
+        {
+            strcpy(TargetDirectory, Locker);
+        }
+    }
+    else
+    {
+#endif /* HAVE_HESOID */
+        strcpy(AfsLocker, Locker);
+        if (!strnicmp(Locker, "\\\\afs\\", strlen("\\\\afs\\")))
+            strcpy(TargetDirectory, &Locker[strlen("\\\\afs\\")]);
+        else
+            strcpy(TargetDirectory, Locker);
+#ifdef HAVE_HESOID
+    }
+#endif /* HAVE_HESOID */
+
+
+    TotalTime = 0;
+    LoopCount = 0;
+    CurrentLoop = 0;
+
+    ExitMutexHandle = CreateMutex(NULL, FALSE, "AfsExitEvent");
+    ChronMutexHandle = CreateMutex(NULL, FALSE, "WinTortureChronMutex");
+    MutexHandle = CreateMutex(NULL, FALSE, "WinTortureMutex");
+    FileMutexHandle = CreateMutex(NULL, FALSE, "WinTortureFileMutex");
+    OSMutexHandle = CreateMutex(NULL, FALSE, "WinTortureOSMutex");
+
+    for (i = 0; i < MAX_THREADS; i++)
+    {
+        ThreadStatus[i] = 2;
+    }
+
+    sprintf(JobName, "%s%05d", "JOB", LogID);
+    JobHandle = CreateJobObject(NULL, JobName);
+    rc = AssignProcessToJobObject(JobHandle, GetCurrentProcess());
+
+    GetCurrentDirectory(sizeof(WorkingDirectory), WorkingDirectory);
+    sprintf(FileName, "%s\\log%05d", WorkingDirectory, LogID);
+    CreateDirectory(FileName, NULL);
+    sprintf(FileName, "%s\\test", WorkingDirectory);
+    CreateDirectory(FileName, NULL);
+    if (!StressTestUsed)
+    {
+        sprintf(FileName, "%s\\log%05d\\Chron.log", WorkingDirectory, LogID);
+        DeleteFile(FileName);
+    }
+
+    sprintf(FileName, "%s\\log%05d\\%s", WorkingDirectory, LogID, HostName);
+    sprintf(command, "rmdir /S /Q %s > %s\\test\\test", FileName, WorkingDirectory);
+    system(command);
+
+    ShutDownEventHandle = CreateEvent(NULL, TRUE, FALSE, "AfsShutdownEvent");
+    PauseEventHandle = CreateEvent(NULL, TRUE, FALSE, "AfsPauseEvent");
+    ContinueEventHandle = CreateEvent(NULL, TRUE, FALSE, "AfsContinueEvent");
+
+    IterationCount = 0;
+    time(&StartTime);
+    if ((NumberOfIterations == 0) && (SecondsToRun == 0))
+        NumberOfIterations = 1;
+    else if (SecondsToRun != 0)
+    {
+        SecondsToRun += StartTime;
+    }
+
+    while (1)
+    {
+        if (SecondsToRun != 0)
+        {
+            time(&StartTime);
+            if (StartTime > (time_t)SecondsToRun)
+            {
+                break;
+            }
+        }
+        if (NumberOfIterations != 0)
+        {
+            if (LoopCount >= NumberOfIterations)
+            {
+                break;
+            }
+        }
+        if (rc = WaitForSingleObject(ShutDownEventHandle, 0) == WAIT_OBJECT_0)
+        {
+            break;
+        }
+        ++LoopCount;
+        CurrentLoop = LoopCount;
+
+        _strtime(tbuffer);
+        printf("\nIteration %d started at: %s\n", LoopCount, tbuffer);
+        create_procs(HostName, CommandLine, TargetDirectory, AfsLocker, Locker, 
+                     HostName, NumberOfThreads, CurrentLoop, LogID);
+        _strtime(tbuffer);
+        printf("Iteration %d ended at: %s\n", LoopCount, tbuffer);
+        time(&EndTime);
+        printf("Iteration %d lapse time: %ld seconds\n", LoopCount, EndTime - StartTime);
+        TotalTime += EndTime - StartTime;
+        sprintf(FileName, "%s\\log%05d\\IterationCount", WorkingDirectory, LogID);
+        WaitForSingleObject(MutexHandle, 20 * 1000);
+        if ((fp = fopen(FileName, "r")) != NULL)
+        {
+            fgets(buffer, sizeof(buffer), fp);
+            IterationCount = atoi(buffer);
+            fclose(fp);
+        }
+        ++IterationCount;
+        fp = fopen(FileName, "w");
+        fprintf(fp, "%d\n", IterationCount);
+        fclose(fp);
+        ReleaseMutex(MutexHandle);
+        if (EndOnError)
+        {
+            for (i = 0; i < MAX_THREADS; i++)
+            {
+                if (ThreadStatus[i] == 1)
+                {
+                    break;
+                }
+            }
+            if (i >= MAX_THREADS)
+                break;
+        }
+        ErrorState = 0;
+        for (i = 0; i < MAX_THREADS; i++)
+        {
+            if (ThreadStatus[i] == 0)
+            {
+                ErrorState = 1;
+                ThreadStatus[i] = 1;
+            }
+        }
+        if (ErrorState)
+        {
+            printf("\nSleeping for 3 minutes for error recovery\n\n");
+            Sleep(3 * 60 * 1000);
+        }
+    }
+    if (LoopCount == 0)
+        return(0);
+
+    sprintf(FileName, ".\\log%05d\\%s\\Master.log", LogID, HostName);
+    Mfp = fopen(FileName, "w+");
+    fprintf(Mfp, "Average Iteration Time = %.02f minutes\n\n", ((float)TotalTime/(float)(LoopCount))/60.0);
+    for (i = 0; i < NumberOfThreads; i++)
+    {
+        sprintf(FileName, ".\\log%05d\\%s\\Thread_%05d.log", LogID, HostName, i);
+        fp = fopen(FileName, "r");
+        if (fp != NULL)
+        {
+            fprintf(Mfp, "START OF THREAD %d\n\n", i);
+            while (fgets(buffer, 512, fp) != NULL)
+            {
+                fprintf(Mfp, "%s", buffer);
+            }
+            fclose(fp);
+            fprintf(Mfp, "END OF THREAD %d\n\n", i);
+        }
+    }
+    fclose(Mfp);
+
+    memset(WorkingDirectory, '\0', sizeof(WorkingDirectory));
+    GetCurrentDirectory(sizeof(WorkingDirectory), WorkingDirectory);
+
+    sprintf(FileName, "%s\\log%05d\\%s\\%s", WorkingDirectory, LogID, HostName, "MasterProcessStatLog.log");
+    sprintf(MoveFileName, "%s\\log%05d\\%s\\%s", WorkingDirectory, LogID, HostName, "MasterProcessStatLogRaw.log");
+    BuildMasterStatLog(FileName, MoveFileName, NumberOfProcesses, NumberOfThreads, CommandLine, LoopCount, 
+                       TargetDirectory, -1);
+
+//    sprintf(DateTime, "%s-%04d%02d%02d-%02d%02d%02d", HostName,
+//                                                      LocalTime.wYear, 
+//                                                      LocalTime.wMonth, 
+//                                                      LocalTime.wDay,
+//                                                      LocalTime.wHour,
+//                                                      LocalTime.wMinute,
+//                                                      LocalTime.wSecond);
+//    sprintf(command, "rename %s\\log%05d\\%s %s", WorkingDirectory, LogID, HostName, DateTime);
+//    rc = system(command);
+
+    WaitForSingleObject(ExitMutexHandle, 20 * 1000);
+    Sleep(3 * 1000);
+
+    GetSystemTime(&SystemTime);
+    GetTimeZoneInformation(&TimeZoneInformation);
+    SystemTimeToTzSpecificLocalTime(&TimeZoneInformation, &SystemTime, &LocalTime);
+
+    NumberOfProcesses = 0;
+    sprintf(FileName, "%s\\log%05d\\ProcessCount", WorkingDirectory, LogID);
+    if ((fp = fopen(FileName, "r")) != NULL)
+    {
+        fgets(buffer, sizeof(buffer), fp);
+        NumberOfProcesses = atoi(buffer);
+        fclose(fp);
+    }
+    ++NumberOfProcesses;
+    fp = fopen(FileName, "w");
+    fprintf(fp, "%d\n", NumberOfProcesses);
+    fclose(fp);
+
+    if (FindProcessCount("wintorture.exe", JobHandle) == 1)
+    {
+        NumberOfProcesses = 0;
+        sprintf(FileName, "%s\\log%05d\\ProcessCount", WorkingDirectory, LogID);
+        sprintf(MoveFileName, "%s\\log%05d\\ProcessCountRaw", WorkingDirectory, LogID);
+        if ((fp = fopen(FileName, "r")) != NULL)
+        {
+            fgets(buffer, sizeof(buffer), fp);
+            NumberOfProcesses = atoi(buffer);
+            fclose(fp);
+            MoveFile(FileName, MoveFileName);
+        }
+
+        IterationCount = 0;
+        sprintf(FileName, "%s\\log%05d\\IterationCount", WorkingDirectory, LogID);
+        sprintf(MoveFileName, "%s\\log%05d\\IterationCountRaw", WorkingDirectory, LogID);
+        if ((fp = fopen(FileName, "r")) != NULL)
+        {
+            fgets(buffer, sizeof(buffer), fp);
+            IterationCount = atoi(buffer);
+            fclose(fp);
+            MoveFile(FileName, MoveFileName);
+        }
+
+        sprintf(FileName, "%s\\log%05d\\%s", WorkingDirectory, LogID, "MasterStatLog.log");
+        sprintf(MoveFileName, "%s\\log%05d\\%s", WorkingDirectory, LogID, "MasterStatLogRaw.log");
+        BuildMasterStatLog(FileName, MoveFileName, NumberOfProcesses, NumberOfThreads, 
+                           CommandLine, IterationCount, TargetDirectory, -2);
+        sprintf(DateTime, "%s%05d-%04d%02d%02d-%02d%02d%02d", "log",
+                                                          LogID,
+                                                          LocalTime.wYear, 
+                                                          LocalTime.wMonth, 
+                                                          LocalTime.wDay,
+                                                          LocalTime.wHour,
+                                                          LocalTime.wMinute,
+                                                          LocalTime.wSecond);
+        sprintf(command, "rename %s\\log%05d %s", WorkingDirectory, LogID, DateTime);
+        rc = system(command);
+        ResetEvent(ShutDownEventHandle);
+        ResetEvent(PauseEventHandle);
+        ResetEvent(ContinueEventHandle);
+        CloseHandle(ShutDownEventHandle);
+        CloseHandle(PauseEventHandle);
+        CloseHandle(ContinueEventHandle);
+
+    }
+
+    ReleaseMutex(ExitMutexHandle);
+    CloseHandle(JobHandle);
+    return 0;
+}
+
+int ProcessNameAndID(DWORD processID, char *ProcessName, HANDLE JobHandle)
+{
+    char    szProcessName[1024] = "unknown";
+    char    FileName[1024];
+    char    WorkingDirectory[512];
+    HANDLE  hProcess;
+    int     Count;
+
+    memset(WorkingDirectory, '\0', sizeof(WorkingDirectory));
+    GetCurrentDirectory(sizeof(WorkingDirectory), WorkingDirectory);
+    strcat(WorkingDirectory, "\\");
+    Count = 0;
+    hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);
+    if (hProcess)
+    {
+        HMODULE hMod;
+        DWORD cbNeeded;
+
+        if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded))
+        {
+            memset(szProcessName, '\0', sizeof(szProcessName));
+            GetModuleBaseName(hProcess, hMod, szProcessName, sizeof(szProcessName));
+            if (!stricmp(szProcessName, ProcessName))
+            {
+                memset(FileName, '\0', sizeof(FileName));
+                if (GetModuleFileNameEx(hProcess, hMod, FileName, sizeof(FileName) - 1))
+                {
+                    if (!strnicmp(WorkingDirectory, FileName, strlen(WorkingDirectory)))
+                    {
+                        ++Count;
+                    }
+                }
+            }
+        }
+    }
+    CloseHandle(hProcess);
+    return(Count);
+}
+
+DWORD FindProcessCount(char *ProcessName, HANDLE JobHandle)
+{
+    DWORD       aProcesses[8092];
+    DWORD       cbNeeded;
+    DWORD       cProcesses;
+    int         Count;
+    int         rc;
+    unsigned    int i;
+    JOBOBJECT_BASIC_PROCESS_ID_LIST IdList;
+
+    rc = QueryInformationJobObject(JobHandle, JobObjectBasicProcessIdList, &IdList, sizeof(IdList), NULL);
+    return(IdList.NumberOfAssignedProcesses);
+
+    if (!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))
+        return(1);
+
+    Count = 0;
+    cProcesses = cbNeeded / sizeof(DWORD);
+
+    for (i = 0; i < cProcesses; i++)
+    {
+
+//        Count += ProcessNameAndID(aProcesses[i], ProcessName, JobHandle);
+    }
+
+    return(Count);
+}
+
+char *_progname(char *nargv0)
+{
+    char    *tmp;
+
+    tmp = strrchr(nargv0, '/');
+    if (tmp)
+        tmp++;
+    else
+        tmp = nargv0;
+    return(tmp);
+}
+
+#define BADCH   (int)'?'
+#define BADARG  (int)':'
+#define EMSG    ""
+
+int getopt(int nargc, char *nargv[], char *ostr)
+{
+    static char *__progname = 0;
+    static char *place = EMSG;         /* option letter processing */
+    char *oli;                         /* option letter list index */
+
+    __progname = __progname?__progname:_progname(*nargv);
+
+    if (optreset || !*place)
+    {
+        optreset = 0;
+        if (optind >= nargc || *(place = nargv[optind]) != '-')
+        {
+            place = EMSG;
+            return (-1);
+        }
+        if (place[1] && *++place == '-'        && place[1] == '\0')
+        {
+            ++optind;
+            place = EMSG;
+            return (-1);
+        }
+    }
+    if ((optopt = (int)*place++) == (int)':' || !(oli = strchr(ostr, optopt))) 
+    {
+        if (optopt == (int)'-')
+            return (-1);
+        if (!*place)
+            ++optind;
+        if (opterr && *ostr != ':')
+            (void)fprintf(stderr, "%s: illegal option -- %c\n", __progname, optopt);
+        return (BADCH);
+    }
+    if (*++oli != ':') 
+    {
+        optarg = NULL;
+        if (!*place)
+            ++optind;
+    }
+    else
+    {
+        if (*place)
+            optarg = place;
+        else if (nargc <= ++optind) 
+        {
+            place = EMSG;
+            if (*ostr == ':')
+                return (BADARG);
+            if (opterr)
+                (void)fprintf(stderr, "%s: option requires an argument -- %c\n", __progname, optopt);
+            return (BADCH);
+        }
+        else
+            optarg = nargv[optind];
+        place = EMSG;
+        ++optind;
+    }
+    return (optopt);
+}
diff --git a/src/WINNT/tests/torture/Source/nbio.c b/src/WINNT/tests/torture/Source/nbio.c
new file mode 100644 (file)
index 0000000..f4140d6
--- /dev/null
@@ -0,0 +1,1493 @@
+/* 
+   Unix SMB/CIFS implementation.
+   SMB torture tester
+   Copyright (C) Andrew Tridgell 1997-1998
+   Copyright (C) Richard Sharpe  2002
+   
+   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
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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.
+*/
+
+#include "includes.h"
+#include "common.h"
+
+extern int verbose;
+
+#define off_t DWORD
+
+__declspec( thread ) extern int     ProcessNumber;
+__declspec( thread ) extern int     LineCount;
+__declspec( thread ) extern int     AfsTrace;
+__declspec( thread ) extern int     *pThreadStatus;
+__declspec( thread ) extern int     LogID;
+__declspec( thread ) extern char    *IoBuffer;
+__declspec( thread ) extern char    AfsLocker[256];
+__declspec( thread ) extern char    OriginalAfsLocker[256];
+__declspec( thread ) extern char    HostName[256];
+__declspec( thread ) extern DWORD   TickCount1, TickCount2, MilliTickStart;
+__declspec( thread ) extern FTABLE  ftable[MAX_FILES];
+__declspec( thread ) extern struct  cmd_struct ThreadCommandInfo[CMD_MAX_CMD + 1];
+__declspec( thread ) extern EXIT_STATUS *pExitStatus;
+__declspec( thread ) extern DWORD   LastKnownError;
+extern void LogMessage(int ProcessNumber, char *HostName, char *FileName, char *message, int LogID);
+
+int  CreateObject(const char *fname, uint32 DesiredAccess,
+                  uint32 FileAttributes, uint32 ShareAccess,
+                  uint32 CreateDisposition, uint32 CreateOptions);
+void DumpAFSLog(char * HostName, int LogID);
+int  FindHandle(int handle);
+int  GetFileList(char *Mask, void (*fn)(file_info *, const char *, void *), void *state);
+BOOL GetFileInfo(char *FileName, int fnum, uint16 *mode, size_t *size,
+                       time_t *c_time, time_t *a_time, time_t *m_time, 
+                       time_t *w_time);
+BOOL GetPathInfo(const char *fname, time_t *c_time, time_t *a_time, time_t *m_time, 
+                        size_t *size, uint16 *mode);
+int  LeaveThread(int status, char *Reason, int cmd);
+void StartFirstTimer();
+void EndFirstTimer(int cmd, int Type);
+void StartSecondTime(int cmd);
+void EndSecondTime(int cmd);
+void SubstituteString(char *s,const char *pattern,const char *insert, size_t len);
+int  SystemCall(char *command);
+HANDLE WinFindFirstFile(char *Mask, void **FileData, char *cFileName, int *dwFileAttributes);
+int  WinFindNextFile(HANDLE hFind, void **FileData, char *cFileName, int *dwFileAttributes);
+
+int FindHandle(int handle)
+{
+    int i;
+    for (i=0;i<MAX_FILES;i++)
+    {
+        if (ftable[i].handle == handle)
+            return(i);
+    }
+    if (verbose)
+        printf("(%d) ERROR: handle %d was not found\n", LineCount, handle);
+    return(LeaveThread(1, "", -1));
+}
+
+int nb_unlink(char *fname)
+{
+    int     rc;
+    char    temp[256];
+    char    FileName[128];
+    pstring path;
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+
+    strcpy(path, AfsLocker);
+    strcat(path, fname);
+
+    StartFirstTimer();
+    rc = DeleteFile(path);
+    EndFirstTimer(CMD_UNLINK, 1);
+    if (!rc)
+    {
+        LeaveThread(0, "", CMD_UNLINK);
+        sprintf(temp, "FILE: DeleteFile %s failed\n", fname);
+        if (verbose)
+            printf("%s", temp);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+
+    return(0);
+}
+
+int nb_SetLocker(char *Locker)
+{
+
+    StartFirstTimer();
+    if (strlen(Locker) == 0)
+        strcpy(AfsLocker, OriginalAfsLocker);
+    else
+        strcpy(AfsLocker, Locker);
+    EndFirstTimer(CMD_SETLOCKER, 1);
+    return(0);
+}
+
+int nb_Xrmdir(char *Directory, char *type)
+{
+    DWORD   rc;
+    char    FileName[128];
+    char    command[256];
+    char    NewDirectory[256];
+    char    temp[512];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    if (strlen(Directory) == 0)
+    {
+        return(LeaveThread(1, "rmdir failed no path found\n", CMD_XRMDIR));
+    }
+    strcpy(NewDirectory, Directory);
+    memset(command, '\0', sizeof(command));
+    strcpy(command,"rmdir /Q ");
+    if (!stricmp(type, "all"))
+    {
+        strcat(command, "/S ");
+    }
+    strcat(command, NewDirectory);
+
+    StartFirstTimer();
+    rc = system(command);
+
+    if ((rc) && (rc != 2) && (rc != 3))
+    {
+        EndFirstTimer(CMD_XRMDIR, 0);
+        sprintf(temp, "rmdir failed on %s\n", command);
+        LeaveThread(rc, temp, CMD_XRMDIR);
+        sprintf(temp, "FAILURE: Thread %d - rmdir failed on\n    %s\n", ProcessNumber, command);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    EndFirstTimer(CMD_XRMDIR, 1);
+    return(0);
+}
+
+
+int nb_Mkdir(char *Directory)
+{
+    DWORD   rc;
+    char    FileName[128];
+    char    command[256];
+    char    NewDirectory[256];
+    char    temp[512];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    if (strlen(Directory) == 0)
+    {
+        return(LeaveThread(1, "mkdir failed on no path found\n", CMD_MKDIR));
+    }
+    strcpy(NewDirectory, Directory);
+    memset(command, '\0', sizeof(command));
+    strcpy(command,"mkdir ");
+    strcat(command, NewDirectory);
+
+    StartFirstTimer();
+    rc = system(command);
+
+    if (rc > 1)
+    {
+        EndFirstTimer(CMD_MKDIR, 0);
+        sprintf(temp,  "mkdir failed on %s\n", command);
+        LeaveThread(rc, temp, CMD_MKDIR);
+        sprintf(temp, "ERROR: Thread %d - mkdir failed on\n    %s\n", ProcessNumber, command);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    EndFirstTimer(CMD_MKDIR, 1);
+    return(0);
+}
+
+int nb_Attach(char *Locker, char *Drive)
+{
+    DWORD   rc;
+    char    FileName[128];
+    char    command[512];
+    char    temp[512];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    if (strlen(Locker) == 0)
+    {
+        return(LeaveThread(1, "attach failed no locker found\n", CMD_ATTACH));
+    }
+    memset(command, '\0', sizeof(command));
+    strcpy(command,"attach -q ");
+    rc = 0;
+    if (strlen(Drive) != 0)
+    {
+        sprintf(temp, "-D %s ", Drive);
+        strcat(command, temp);
+    }
+    strcat(command, Locker);
+
+    StartFirstTimer();
+    rc = system(command);
+
+    if (rc)
+    {
+        EndFirstTimer(CMD_ATTACH, 0);
+        sprintf(pExitStatus->Reason, "attach failed on %s\n", command);
+        pExitStatus->ExitStatus = rc;
+        sprintf(temp, "ERROR: Thread %d - attach failed on\n    %s\n", ProcessNumber, command);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+    }
+    EndFirstTimer(CMD_ATTACH, 1);
+    return(0);
+}
+
+int nb_Detach(char *Name, char *type)
+{
+    DWORD   rc;
+    char    FileName[128];
+    char    command[512];
+    char    temp[512];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    memset(command, '\0', sizeof(command));
+    strcpy(command,"detach -q ");
+    rc = 0;
+    if (!stricmp(type, "drive"))
+    {
+        sprintf(temp, "-D %s ", Name);
+        strcat(command, temp);
+    }
+    else if (!stricmp(type, "locker"))
+    {
+        strcat(command, Name);
+    }
+    else
+    {
+        return(LeaveThread(1, "nb_Detach failed unknown type: %s\n", CMD_DETACH));
+    }
+
+    StartFirstTimer();
+    rc = system(command);
+
+    if (rc)
+    {
+        EndFirstTimer(CMD_DETACH, 0);
+        sprintf(temp, "detach failed on %s\n", command);
+        LeaveThread(rc, temp, CMD_DETACH);
+        sprintf(temp, "ERROR: Thread %d - detach failed on\n    %s\n", ProcessNumber, command);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    EndFirstTimer(CMD_DETACH, 1);
+    return(0);
+}
+
+int nb_CreateFile(char *path, DWORD size)
+{
+    char    NewPath[256];
+    char    Buffer[512];
+    char    temp[512];
+    char    FileName[128];
+    HANDLE  fHandle;
+    DWORD   Moved;
+    DWORD   BytesWritten;
+    DWORD   BytesToWrite;
+    BOOL    rc;
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    if (strlen(path) == 0)
+    {
+        return(LeaveThread(1, "nb_DeleteFile failed no path found\n", CMD_CREATEFILE));
+    }
+
+    strcpy(NewPath, path);
+
+    StartFirstTimer();
+    fHandle = CreateFile(NewPath, 
+                         GENERIC_READ | GENERIC_WRITE | STANDARD_RIGHTS_ALL,
+                         FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+                         NULL,
+                         CREATE_ALWAYS,
+                         FILE_ATTRIBUTE_NORMAL,
+                         NULL);
+
+    if (fHandle == INVALID_HANDLE_VALUE)
+    {
+        EndFirstTimer(CMD_CREATEFILE, 0);
+        sprintf(temp, "Create file failed on %s\n", NewPath);
+        LeaveThread(0, "", CMD_CREATEFILE);
+        sprintf(temp, "ERROR: Thread %d - Create file failed on\n    %s\n", ProcessNumber, NewPath);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    EndFirstTimer(CMD_CREATEFILE, 1);
+    Moved = SetFilePointer(fHandle,
+                           size,
+                           NULL,
+                           FILE_BEGIN);
+    memset(Buffer, 'A', sizeof(Buffer));
+    BytesToWrite = sizeof(Buffer);
+    rc = WriteFile(fHandle, Buffer, BytesToWrite, &BytesWritten, NULL);
+
+    FlushFileBuffers(fHandle);
+    CloseHandle(fHandle);
+
+    return(0);
+}
+
+int nb_CopyFile(char *Source, char *Destination)
+{
+    DWORD   rc;
+    char    FileName[128];
+    char    temp[512];
+    char    command[256];
+    char    NewSource[256];
+    char    NewDestination[256];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    if ((strlen(Source) == 0) || (strlen(Destination) == 0))
+    {
+        return(LeaveThread(1, "nb_CopyFile failed to copy files: either source or destination path not found\n", CMD_COPYFILES));
+    }
+    strcpy(NewSource, Source);
+    strcpy(NewDestination, Destination);
+
+    memset(command, '\0', sizeof(command));
+    sprintf(command, "copy /V /Y /B %s %s > .\\test\\%s%d", NewSource, NewDestination, HostName, ProcessNumber);
+
+    StartFirstTimer();
+    rc = system(command);
+
+    if (rc)
+    {
+        EndFirstTimer(CMD_COPYFILES, 0);
+        sprintf(temp, "copy failed on %s\n", command);
+        LeaveThread(rc, temp, CMD_COPYFILES);
+        sprintf(temp, "FAILURE: Thread %d - copy failed on\n    %s\n", ProcessNumber, command);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        if (verbose)
+            printf("%s", temp);
+        return(-1);
+    }
+    EndFirstTimer(CMD_COPYFILES, 1);
+    return(0);
+}
+
+int nb_DeleteFile(char *path)
+{
+    DWORD   rc;
+    char    FileName[128];
+    char    command[256];
+    char    NewPath[256];
+    char    temp[512];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    if (strlen(path) == 0)
+    {
+        return(LeaveThread(1, "nb_DeleteFile failed to delete files: no path found\n", CMD_DELETEFILES));
+    }
+    strcpy(NewPath, path);
+
+    memset(command, '\0', sizeof(command));
+    sprintf(command, "del /Q %s", NewPath);
+
+    StartFirstTimer();
+    rc = system(command);
+
+    if (rc)
+    {
+        EndFirstTimer(CMD_DELETEFILES, 0);
+        sprintf(temp, "del failed on %s\n", NewPath);
+        LeaveThread(rc, temp, CMD_DELETEFILES);
+        sprintf(temp, "ERROR: Thread %d - del failed on\n    %s\n", ProcessNumber, command);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    EndFirstTimer(CMD_DELETEFILES, 1);
+    return(0);
+}
+
+int nb_xcopy(char *Source, char *Destination)
+{
+    DWORD   rc;
+    char    FileName[128];
+    char    temp[512];
+    char    command[256];
+    char    NewSource[256];
+    char    NewDestination[256];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    if ((strlen(Source) == 0) || (strlen(Destination) == 0))
+    {
+        return(LeaveThread(1, "nb_xcopy failed to xcopy: either source or destination is missing\n", CMD_XCOPY));
+    }
+    strcpy(NewSource, Source);
+    strcpy(NewDestination, Destination);
+    memset(command, '\0', sizeof(command));
+    sprintf(command, "xcopy /E /I /V /Y /Q %s %s > .\\test\\%s%d", NewSource, NewDestination, HostName, ProcessNumber);
+
+    StartFirstTimer();
+    rc = SystemCall(command);
+
+    if (rc)
+    {
+        EndFirstTimer(CMD_XCOPY, 0);
+//        sprintf(temp, "xcopy failed on %s\n", command);
+//        LeaveThread(rc, temp, CMD_XCOPY);
+        LeaveThread(0, "", CMD_XCOPY);
+        sprintf(temp, "FAIURE: Thread %d - xcopy failed on\n    %s\n", ProcessNumber, command);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    EndFirstTimer(CMD_XCOPY, 1);
+    return(0);
+}
+
+int nb_Move(char *Source, char *Destination)
+{
+    DWORD   rc;
+    char    command[256];
+    char    FileName[128];
+    char    temp[512];
+    char    NewSource[256];
+    char    NewDestination[256];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    if ((strlen(Source) == 0) || (strlen(Destination) == 0))
+    {
+        return(LeaveThread(1, "nb_Move failed to move: either source or destination is missing\n", CMD_MOVE));
+    }
+    strcpy(NewSource, Source);
+    strcpy(NewDestination, Destination);
+    memset(command, '\0', sizeof(command));
+    sprintf(command, "move /Y %s %s > .\\test\\%s%d", NewSource, NewDestination, HostName, ProcessNumber);
+    StartFirstTimer();
+    rc = system(command);
+
+    if (rc)
+    {
+        EndFirstTimer(CMD_MOVE, 0);
+        sprintf(temp, "move failed on %s\n", command);
+        LeaveThread(rc, temp, CMD_MOVE);
+        sprintf(temp, "FAILURE: Thread %d - move failed on\n    %s\n", ProcessNumber, command);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    EndFirstTimer(CMD_MOVE, 1);
+    return(0);
+}
+
+int nb_createx(char *fname, unsigned create_options, unsigned create_disposition, int handle)
+{
+    int     fd;
+    int     i;
+    uint32  desired_access;
+    char    FileName[128];
+    char    temp[512];
+    pstring path;
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+
+    strcpy(path, AfsLocker);
+    strcat(path, fname);
+    if (create_options & FILE_DIRECTORY_FILE)
+    {
+        desired_access = FILE_READ_DATA;
+    }
+    else
+    {
+        desired_access = FILE_READ_DATA | FILE_WRITE_DATA;
+    }
+
+    StartFirstTimer();
+    fd = CreateObject(path, 
+                        desired_access,
+                        0x0,
+                        FILE_SHARE_READ|FILE_SHARE_WRITE, 
+                        create_disposition, 
+                        create_options);
+
+    if (fd == -1 && handle != -1)
+    {
+        if (create_options & FILE_DIRECTORY_FILE)
+        {
+            int rc;
+
+            rc = GetLastError();
+        if ((rc != ERROR_FILE_NOT_FOUND) && (rc != ERROR_PATH_NOT_FOUND))
+            if (rc != ERROR_ALREADY_EXISTS)
+            {
+                EndFirstTimer(CMD_NTCREATEX, 0);
+                SetLastError(rc);
+                LeaveThread(0, "", CMD_NTCREATEX);
+                sprintf(temp, "Directory: unable to create directory %s\n", path);
+                if (verbose)
+                    printf("%s", temp);
+                LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+                return(-1);
+            }
+            fd = 0;
+        }
+        else
+        {
+            EndFirstTimer(CMD_NTCREATEX, 0);
+            LeaveThread(0, "", CMD_NTCREATEX);
+            sprintf(temp, "File: unable to create file %s\n", path);
+            if (verbose)
+                printf("%s", temp);
+            LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+            return(-1);
+        }
+    }
+
+    EndFirstTimer(CMD_NTCREATEX, 1);
+
+    if (create_options & FILE_DIRECTORY_FILE)
+        fd = 0;
+
+    if (fd != -1 && handle == -1)
+    {
+        if (fd > 1)
+            CloseHandle((HANDLE)fd);
+        nb_unlink(fname);
+        return(0);
+    }
+
+    if (fd == -1 && handle == -1)
+        return(0);
+
+    for (i = 0; i < MAX_FILES; i++) 
+    {
+        if (ftable[i].handle == 0) 
+            break;
+    }
+    if (i == MAX_FILES) 
+    {
+        printf("(%d) file table full for %s\n", LineCount, path);
+        return(LeaveThread(1, "file table is full\n", CMD_NTCREATEX));
+    }
+    ftable[i].handle = handle;
+    ftable[i].fd = fd;
+    if (ftable[i].name) 
+        free(ftable[i].name);
+    ftable[i].name = strdup(path);
+    ftable[i].reads = ftable[i].writes = 0;
+    return(0);
+}
+
+int nb_writex(int handle, int offset, int size, int ret_size)
+{
+    int     i;
+    int     status;
+    char    FileName[128];
+    char    temp[512];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+
+    if (IoBuffer[0] == 0) 
+        memset(IoBuffer, 1, sizeof(IoBuffer));
+
+    if ((i = FindHandle(handle)) == -1)
+        return(-1);
+    StartFirstTimer();
+    status = nb_write(ftable[i].fd, IoBuffer, offset, size);
+
+    if (status != ret_size) 
+    {
+        EndFirstTimer(CMD_WRITEX, 0);
+               LeaveThread(0, "", CMD_WRITEX);
+        if (status == 0)
+            sprintf(temp, "File: %s. wrote %d bytes, got %d bytes\n", ftable[i].name, size, status);
+        if (status == -1)
+            sprintf(temp, "File: %s. On write, cannot set file pointer\n", ftable[i].name);
+        if (verbose)
+            printf("%s", temp);
+        nb_close(handle);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+       }
+    EndFirstTimer(CMD_WRITEX, 1);
+
+    ftable[i].writes++;
+    return(0);
+}
+
+int nb_lock(int handle, int offset, int size, int timeout, unsigned char locktype, NTSTATUS exp)
+{
+/*
+    int         i;
+    NTSTATUS    ret;
+    char        FileName[128];
+    char        temp[512];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+
+    if ((i = FindHandle(handle)) == -1)
+    {
+        LeaveThread(0, "", CMD_LOCKINGX);
+        sprintf(temp, "File unlock: Cannot find handle for %s", ftable[i].name);
+        if (verbose)
+            printf("%s", temp);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+
+    StartFirstTimer();
+    ret = cli_locktype(c, i, offset, size, timeout, locktype);
+
+    if (ret != exp)
+    {
+        EndFirstTimer(CMD_LOCKINGX, 0);
+        LeaveThread(0, "", CMD_LOCKINGX);
+        sprintf(temp, "(%d) ERROR: lock failed on handle %d ofs=%d size=%d timeout= %d exp=%d fd %d errno %d (%s)\n",
+               LineCount, handle, offset, size, timeout, exp, ftable[i].fd, exp, "");
+        sprintf(temp, "File unlock: lock failed %s", ftable[i].name);
+        if (verbose)
+            printf("%s", temp);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    EndFirstTimer(CMD_LOCKINGX, 1);
+*/
+    return(0);
+}
+
+int nb_readx(int handle, int offset, int size, int ret_size)
+{
+    int     i;
+    int     ret;
+    char    FileName[128];
+    char    temp[512];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+
+    if ((i = FindHandle(handle)) == -1)
+        return(-1);
+
+    StartFirstTimer();
+    ret = nb_read(ftable[i].fd, IoBuffer, offset, size);
+
+    if ((ret != size) && (ret != ret_size))
+    {
+        EndFirstTimer(CMD_READX, 0);
+        LeaveThread(0, "", CMD_READX);
+        if (ret == 0)
+            sprintf(temp, "File: read failed on index=%d, offset=%d ReadSize=%d ActualRead=%d handle=%d\n",
+                    handle, offset, size, ret, ftable[i].fd);
+        if (ret == -1)
+            sprintf(temp, "File: %s. On read, cannot set file pointer\n", ftable[i].name);
+        if (verbose)
+            printf("%s", temp);
+        nb_close(handle);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    EndFirstTimer(CMD_READX, 1);
+    ftable[i].reads++;
+    return(0);
+}
+
+int nb_close(int handle)
+{
+    int     i;
+    int     ret;
+    char    FileName[128];
+    char    temp[512];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+
+    if ((i = FindHandle(handle)) == -1)
+        return(0);
+
+    StartFirstTimer();
+    ret = nb_close1(ftable[i].fd); 
+    EndFirstTimer(CMD_CLOSE, ret);
+    if (!ret) 
+    {
+        LeaveThread(0, "", CMD_CLOSE);
+        sprintf(temp, "(%d) close failed on handle %d\n", LineCount, handle);
+        if (verbose)
+            printf("%s", temp);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+
+    ftable[i].handle = 0;
+    ftable[i].fd = 0;
+    if (ftable[i].name) 
+        free(ftable[i].name);
+    ftable[i].name = NULL;
+    return(0);   
+}
+
+int nb_rmdir(char *fname)
+{
+    int     rc;
+    pstring path;
+    char    FileName[128];
+    char    temp[512];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+
+    strcpy(path, AfsLocker);
+    strcat(path, fname);
+
+    StartFirstTimer();
+    rc = RemoveDirectory(path);
+    EndFirstTimer(CMD_RMDIR, rc);
+
+    if (!rc)
+    {
+        LeaveThread(0, "", CMD_RMDIR);
+        sprintf(temp, "Directory: RemoveDirectory %s failed\n", fname);
+        if (verbose)
+            printf("%s", temp);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    return(0);
+}
+
+int nb_rename(char *old, char *New)
+{
+    int     rc;
+    pstring opath;
+    pstring npath;
+    char    FileName[128];
+    char    temp[512];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+
+    strcpy(opath, AfsLocker);
+    strcat(opath, old);
+    strcpy(npath, AfsLocker);
+    strcat(npath, New); 
+
+    StartFirstTimer();
+    rc = MoveFileEx(opath, npath, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
+    EndFirstTimer(CMD_RENAME, rc);
+
+    if (!rc)
+    {
+        LeaveThread(0, "", CMD_RENAME);
+        sprintf(temp, "File: rename %s %s failed\n", old, New);
+        if (verbose)
+            printf("%s", temp);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    return(0);
+}
+
+
+int nb_qpathinfo(char *fname, int Type)
+{
+    pstring path;
+    int     rc;
+    char    FileName[128];
+    char    temp[512];
+static Flag = 0;
+
+    if (Type == 1111)
+        Flag = 1;
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+
+    strcpy(path, AfsLocker);
+    strcat(path, fname);
+
+    StartFirstTimer();
+    rc = GetPathInfo(path, NULL, NULL, NULL, NULL, NULL);
+
+    if (strstr(fname, "~TS"))
+    {
+        if (rc == 0)
+            rc = 1;
+        else
+            rc = 0;
+    }
+
+if (!Flag)
+{
+    if (Type)
+    {
+        if (rc)
+            rc = 0;
+        else
+            rc = 1;
+    }
+    if (!rc)
+    {
+        EndFirstTimer(CMD_QUERY_PATH_INFO, 0);
+        LeaveThread(0, "", CMD_QUERY_PATH_INFO);
+        sprintf(temp, "File: qpathinfo failed for %s\n", path);
+        if (verbose)
+            printf("%s", temp);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+}
+    EndFirstTimer(CMD_QUERY_PATH_INFO, 1);
+    return(0);
+}
+
+int nb_qfileinfo(int fnum)
+{
+    int     i;
+    int     rc;
+    char    FileName[128];
+    char    temp[512];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+
+    if ((i = FindHandle(fnum)) == -1)
+        return(-1);
+
+    StartFirstTimer();
+    rc = GetFileInfo(ftable[i].name, ftable[i].fd, NULL, NULL, NULL, NULL, NULL, NULL);
+
+    if (!rc)
+    {
+        EndFirstTimer(CMD_QUERY_FILE_INFO, 0);
+        LeaveThread(0, "", CMD_QUERY_FILE_INFO);
+        sprintf(temp, "File: qfileinfo failed for %s\n", ftable[i].name);
+        if (verbose)
+            printf("%s", temp);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    EndFirstTimer(CMD_QUERY_FILE_INFO, 1);
+
+    return(0);
+}
+
+int nb_qfsinfo(int level)
+{
+
+//     int     bsize;
+//    int     total;
+//    int     avail;
+    int     rc;
+    char    FileName[128];
+    char    temp[512];
+    char    Path[512];
+    ULARGE_INTEGER FreeBytesAvailable;
+    ULARGE_INTEGER TotalNumberOfBytes;
+    ULARGE_INTEGER TotalNumberOfFreeBytes;
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    sprintf(Path, "%s\\%s%05d", AfsLocker, HostName, LogID);
+
+    StartFirstTimer();
+    rc = GetDiskFreeSpaceEx(Path, &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes);
+//    rc = cli_dskattr(c, &bsize, &total, &avail);
+
+    if (!rc)
+    {
+        EndFirstTimer(CMD_QUERY_FS_INFO, 0);
+        LeaveThread(0, "", CMD_QUERY_FS_INFO);
+        strcpy(temp, "File: Disk free space failed\n");
+        if (verbose)
+            printf("%s", temp);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    EndFirstTimer(CMD_QUERY_FS_INFO, 1);
+
+    return(0);
+}
+
+void find_fn(file_info *finfo, char *name, void *state)
+{
+       /* noop */
+}
+
+int nb_findfirst(char *mask)
+{
+    int     rc;
+    char    FileName[128];
+    char    NewMask[512];
+    char    temp[512];
+
+    if (strstr(mask, "<.JNK"))
+        return(0);
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+
+    strcpy(NewMask, AfsLocker);
+    strcat(NewMask, mask);
+
+    StartFirstTimer();
+    rc = GetFileList(NewMask, (void *)find_fn, NULL);
+
+    if (!rc)
+    {
+        EndFirstTimer(CMD_FIND_FIRST, 0);
+        sprintf(temp, "File: findfirst cannot find for %s\n", mask);
+        if (verbose)
+            printf("%s", temp);
+        LeaveThread(1, temp, CMD_FIND_FIRST);
+        LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+        return(-1);
+    }
+    EndFirstTimer(CMD_FIND_FIRST, 1);
+    return(0);
+}
+
+int nb_flush(int fnum)
+{
+    int i;
+
+    if ((i = FindHandle(fnum)) == -1)
+        return(-1);
+    return(0);
+       /* hmmm, we don't have cli_flush() yet */
+}
+
+static int total_deleted;
+
+void delete_fn(file_info *finfo, const char *name, void *state)
+{
+    int     rc;
+    char    temp[256];
+    char    s[1024];
+    char    FileName[128];
+
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+
+    if (finfo->mode & aDIR) 
+    {
+        char s2[1024];
+        sprintf(s2, "%s\\*", name);
+        GetFileList(s2, delete_fn, NULL);
+        sprintf(s, "%s", &name[strlen(AfsLocker)]);
+        nb_rmdir(s);
+    }
+    else
+    {
+        rc = DeleteFile(name);
+        if (!rc)
+        {
+            LeaveThread(0, "", CMD_UNLINK);
+            sprintf(temp, "FILE: DeleteFile %s failed\n", name);
+            if (verbose)
+                printf("%s", temp);
+            LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+            return;
+        }
+    }
+    return;
+}
+
+int nb_deltree(char *dname)
+{
+    int     rc;
+    char    mask[1024];
+    pstring path;
+
+
+    strcpy(path, AfsLocker);
+    strcat(path, dname);
+    sprintf(mask, "%s\\*", path);
+
+    total_deleted = 0;
+
+    StartFirstTimer();
+    GetFileList(mask, delete_fn, NULL);
+
+//    pstrcpy(path, AfsLocker);
+//    pstrcat(path, dname);
+    rc = RemoveDirectory(path);
+    EndFirstTimer(CMD_DELTREE, rc);
+    if (!rc)
+    {
+        char FileName[256];
+        char temp[128];
+        int  rc;
+
+        rc = GetLastError();
+        if ((rc != ERROR_FILE_NOT_FOUND) && (rc != ERROR_PATH_NOT_FOUND))
+        {
+            SetLastError(rc);
+            LeaveThread(0, "", CMD_DELTREE);
+            sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+            sprintf(temp, "ERROR: Thread %d - Unable to remove %s.\n", ProcessNumber, path);
+            LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+            if (verbose)
+                printf(temp);
+            return(-1);
+        }
+    }
+    return(0);
+}
+
+
+int nb_cleanup(char *cname)
+{
+    char temp[256];
+
+    strcpy(temp, "\\clients\\client1");
+    SubstituteString(temp, "client1", cname, sizeof(temp));
+    SubstituteString(temp, "clients", HostName, sizeof(temp));
+    nb_deltree(temp);
+    return(0);
+}
+
+int LeaveThread(int status, char *Reason, int cmd)
+{
+    char    FileName[256];
+    char    temp[512];
+    DWORD   rc;
+
+    if (cmd != -1)
+        ++ThreadCommandInfo[cmd].ErrorCount;
+
+    if (strlen(Reason) == 0)
+    {
+        if (status == 0)
+            rc = GetLastError();
+        else
+            rc = status;
+        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
+                      NULL,
+                      rc,
+                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                      pExitStatus->Reason,
+                      sizeof(pExitStatus->Reason),
+                      NULL);
+        LastKnownError = rc;
+    }
+    else
+        strcpy(pExitStatus->Reason, Reason);
+
+    if (strlen(pExitStatus->Reason) == 0)
+        strcpy(pExitStatus->Reason, "\n");
+    if (pExitStatus->Reason[strlen(pExitStatus->Reason) - 1] != '\n')
+        strcat(pExitStatus->Reason, "\n");
+    sprintf(FileName, "Thread_%05d.log", ProcessNumber);
+    if (strlen(Reason) == 0)
+        sprintf(temp, "ERROR(%d): Thread %d - (%d) %s", LineCount, ProcessNumber, rc, pExitStatus->Reason);
+    else
+        sprintf(temp, "ERROR(%d): Thread %d - %s", LineCount, ProcessNumber, pExitStatus->Reason);
+    LogMessage(ProcessNumber, HostName, FileName, temp, LogID);
+    if (verbose)
+        printf("%s", temp);
+    pExitStatus->ExitStatus = status;
+    if (AfsTrace)
+        DumpAFSLog(HostName, LogID);
+    (*pThreadStatus) = 0;
+    return(-1);
+}
+
+void StartFirstTimer(void)
+{
+
+    EndSecondTime(CMD_NONAFS);
+    TickCount1 = GetTickCount();
+}
+
+void EndFirstTimer(int cmd, int Type)
+{
+    DWORD   MilliTick;
+    DWORD   cmd_time;
+
+    ThreadCommandInfo[cmd].count++;
+    cmd_time = 0;
+    MilliTick = GetTickCount() - TickCount1;
+    if (MilliTick <= 0)
+    {
+        StartSecondTime(CMD_NONAFS);
+        return;
+    }
+
+    ThreadCommandInfo[cmd].MilliSeconds += MilliTick;
+    while (ThreadCommandInfo[cmd].MilliSeconds > 1000)
+    {
+        ThreadCommandInfo[cmd].MilliSeconds -= 1000;
+        cmd_time += 1;
+    }
+
+    if (cmd_time == 0)
+    {
+        ThreadCommandInfo[cmd].min_sec = cmd_time;
+        StartSecondTime(CMD_NONAFS);
+        return;
+    }
+
+    if (!Type)
+        ThreadCommandInfo[cmd].ErrorTime += cmd_time;
+    else
+    {
+        ThreadCommandInfo[cmd].total_sec += cmd_time;
+        if (cmd_time < (int)ThreadCommandInfo[cmd].min_sec)
+            ThreadCommandInfo[cmd].min_sec = cmd_time;
+        if ((int)ThreadCommandInfo[cmd].max_sec < cmd_time)
+            ThreadCommandInfo[cmd].max_sec = cmd_time;
+    }
+
+    StartSecondTime(CMD_NONAFS);
+}
+
+void StartSecondTime(int cmd)
+{
+
+    TickCount2 = GetTickCount();
+
+}
+
+void EndSecondTime(int cmd)
+{
+    DWORD   MilliTick;
+    DWORD   cmd_time;
+
+    ThreadCommandInfo[cmd].count++;
+    cmd_time = 0;
+    MilliTick = GetTickCount() - TickCount2;
+
+    if (MilliTick <= 0)
+        return;
+
+    ThreadCommandInfo[cmd].MilliSeconds += MilliTick;
+    while (ThreadCommandInfo[cmd].MilliSeconds > 1000)
+    {
+        ThreadCommandInfo[cmd].MilliSeconds -= 1000;
+        cmd_time += 1;
+    }
+    if (cmd_time == 0)
+    {
+        ThreadCommandInfo[cmd].min_sec = cmd_time;
+        return;
+    }
+    if (cmd_time < (int)ThreadCommandInfo[cmd].min_sec)
+        ThreadCommandInfo[cmd].min_sec = cmd_time;
+    if ((int)ThreadCommandInfo[cmd].max_sec < cmd_time)
+        ThreadCommandInfo[cmd].max_sec = cmd_time;
+    ThreadCommandInfo[cmd].total_sec += cmd_time;
+}
+
+
+int SystemCall(char *command)
+{
+    int     rc;
+    char    *argv[6];
+
+    argv[0] = getenv("COMSPEC");
+    argv[1] = "/q";
+    argv[2] = "/c";
+    argv[3] = (char *)command;
+    argv[4] = NULL;
+
+    rc = spawnve(_P_WAIT,argv[0],argv,NULL);
+// != -1 || (errno != ENOENT && errno != EACCES))
+    return(rc);
+}
+
+int CreateObject(const char *fname, uint32 DesiredAccess,
+                uint32 FileAttributes, uint32 ShareAccess,
+                uint32 CreateDisposition, uint32 CreateOptions)
+{
+    int   fd;
+    DWORD dwCreateDisposition = 0;
+    DWORD dwDesiredAccess = 0;
+    DWORD dwShareAccess = 0;
+
+    if (CreateOptions & FILE_DIRECTORY_FILE)
+    {
+        fd = CreateDirectory(fname, NULL);
+        if (fd == 0)
+            fd = -1;
+    }
+    else
+    {
+        dwDesiredAccess = 0;
+        if (DesiredAccess & FILE_READ_DATA)
+            dwDesiredAccess |= GENERIC_READ;
+        if (DesiredAccess & FILE_WRITE_DATA)
+            dwDesiredAccess |= GENERIC_WRITE;
+        dwShareAccess = ShareAccess;
+        dwShareAccess |= FILE_SHARE_DELETE;
+        dwCreateDisposition = OPEN_ALWAYS;
+        if (CreateDisposition == 1)
+            dwCreateDisposition = OPEN_EXISTING;
+        fd = (int)CreateFile(fname, dwDesiredAccess, ShareAccess, NULL, dwCreateDisposition, FILE_ATTRIBUTE_NORMAL, NULL);
+    }
+
+    return(fd);
+}
+
+BOOL nb_close1(int fnum)
+{
+    int dwFlags = 0;
+    int rc = 1;
+
+    if (fnum > 0)
+    {
+        if (rc = GetHandleInformation((HANDLE)fnum, &dwFlags))
+            CloseHandle((HANDLE)fnum);
+    }
+    return(rc);
+}
+
+/****************************************************************************
+  do a directory listing, calling fn on each file found
+  this uses the old SMBsearch interface. It is needed for testing Samba,
+  but should otherwise not be used
+  ****************************************************************************/
+int nb_list_old(const char *Mask, void (*fn)(file_info *, const char *, void *), void *state)
+{
+       int     num_received = 0;
+       pstring mask;
+    char    temp[512];
+    char    cFileName[1024];
+    int     dwFileAttributes;
+    HANDLE  hFind;
+    void    *FileData;
+
+       strcpy(mask,Mask);
+
+
+    if (!strcmp(&mask[strlen(mask)-2], "\"*"))
+    {
+        strcpy(&mask[strlen(mask)-2], "*");
+    }
+    FileData = NULL;
+    dwFileAttributes = 0;
+    memset(cFileName, '\0', sizeof(cFileName));
+    hFind = WinFindFirstFile(mask, &FileData, cFileName, &dwFileAttributes);
+    if (hFind == INVALID_HANDLE_VALUE)
+    {
+        return(0);
+    }
+    mask[strlen(mask) - 1] = '\0';
+    while (1)
+    {
+        if (cFileName[0] != '.')
+        {
+            file_info finfo;
+
+            memset(&finfo, '\0', sizeof(finfo));
+            if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+                finfo.mode = aDIR;
+            strcpy(finfo.name, cFileName);
+            sprintf(temp, "%s%s", mask, cFileName);
+               fn(&finfo, temp, state);
+            ++num_received;
+        }
+        memset(cFileName, '\0', sizeof(cFileName));
+        dwFileAttributes = 0;
+        if (!WinFindNextFile(hFind, &FileData, cFileName, &dwFileAttributes))
+            break;
+    }
+    FindClose(hFind);
+    return(num_received);
+}
+
+
+/****************************************************************************
+  do a directory listing, calling fn on each file found
+  this auto-switches between old and new style
+  ****************************************************************************/
+int GetFileList(char *Mask, void (*fn)(file_info *, const char *, void *), void *state)
+{
+    return(nb_list_old(Mask, fn, state));
+}
+
+HANDLE WinFindFirstFile(char *Mask, void **FileData, char *cFileName, int *dwFileAttributes)
+{
+    HANDLE  rc;
+    static WIN32_FIND_DATAW FileDataW;
+    static WIN32_FIND_DATAA FileDataA;
+
+    memset(&FileDataA, '\0', sizeof(FileDataA));
+    rc = FindFirstFile(Mask, &FileDataA);
+    if (rc != INVALID_HANDLE_VALUE)
+    {
+        (*FileData) = (void *)&FileDataA;
+        (*dwFileAttributes) = FileDataA.dwFileAttributes;
+        strcpy(cFileName, FileDataA.cFileName);
+    }
+
+    return(rc);
+}
+
+int WinFindNextFile(HANDLE hFind, void **FileData, char *cFileName, int *dwFileAttributes)
+{
+    int     rc;
+    WIN32_FIND_DATAA *FileDataA;
+
+    FileDataA = (WIN32_FIND_DATAA *)(*FileData);
+    if (!(rc = FindNextFile(hFind, FileDataA)))
+    {
+        return(rc);
+    }
+    (*dwFileAttributes) = FileDataA->dwFileAttributes;
+    strcpy(cFileName, FileDataA->cFileName);
+
+    return(rc);
+}
+
+void SubstituteString(char *s,const char *pattern,const char *insert, size_t len)
+{
+    char *p;
+    ssize_t ls,lp,li;
+
+    if (!insert || !pattern || !s) return;
+
+    ls = (ssize_t)strlen(s);
+    lp = (ssize_t)strlen(pattern);
+    li = (ssize_t)strlen(insert);
+
+    if (!*pattern) return;
+       
+    while (lp <= ls && (p = strstr(s,pattern)))
+    {
+        if (len && (ls + (li-lp) >= (int)len)) 
+        {
+            break;
+        }
+        if (li != lp) 
+        {
+            memmove(p+li,p+lp,strlen(p+lp)+1);
+        }
+        memcpy(p, insert, li);
+        s = p + li;
+        ls += (li-lp);
+    }
+}
+
+#define CHANGE_TIME(A,B) \
+B.tm_hour = A.wHour; \
+B.tm_sec = A.wSecond; \
+B.tm_min = A.wMinute; \
+B.tm_mon = A.wMonth - 1; \
+B.tm_yday = 0; \
+B.tm_year = A.wYear - 1900; \
+B.tm_wday = A.wDayOfWeek - 1; \
+B.tm_isdst = -1; \
+B.tm_mday = A.wDay;
+
+
+BOOL GetPathInfo(const char *fname, 
+                  time_t *c_time, time_t *a_time, time_t *m_time, 
+                  size_t *size, uint16 *mode)
+{
+    WIN32_FILE_ATTRIBUTE_DATA FileInfo;
+    int         rc;
+    SYSTEMTIME  SystemTime;
+    struct tm   tm_time;
+
+//    rc = WinGetFileAttributesEx(UseUnicode, (char *)fname, &FileInfo);
+    rc = GetFileAttributesEx(fname, GetFileExInfoStandard, &FileInfo);
+    if (rc != 0)
+    {
+        if (c_time)
+        {
+            rc = FileTimeToSystemTime(&FileInfo.ftCreationTime, &SystemTime);
+            CHANGE_TIME(SystemTime, tm_time)
+            (*c_time) = mktime(&tm_time);
+        }
+        if (a_time)
+        {
+            rc = FileTimeToSystemTime(&FileInfo.ftLastAccessTime, &SystemTime);
+            CHANGE_TIME(SystemTime, tm_time)
+            (*a_time) = mktime(&tm_time);
+        }
+        if (m_time)
+        {
+            rc = FileTimeToSystemTime(&FileInfo.ftLastWriteTime, &SystemTime);
+            CHANGE_TIME(SystemTime, tm_time)
+            (*m_time) = mktime(&tm_time);
+        }
+        if (size) 
+        {
+            rc = 1;
+            if (!(FileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+                *size = FileInfo.nFileSizeLow;
+        }
+        if (mode)
+        {
+            rc = 1;
+            (*mode) = 0;
+        }
+    }
+    return(rc);
+}
+
+/****************************************************************************
+send a qfileinfo call
+****************************************************************************/
+BOOL GetFileInfo(char *FileName, int fnum, 
+                   uint16 *mode, size_t *size,
+                   time_t *c_time, time_t *a_time, time_t *m_time, 
+                   time_t *w_time)
+{
+    WIN32_FILE_ATTRIBUTE_DATA FileInfo;
+    int         rc;
+    SYSTEMTIME  SystemTime;
+    struct tm   tm_time;
+
+    rc = GetFileAttributesEx(FileName, GetFileExInfoStandard, &FileInfo);
+    if (rc != 0)
+    {
+        if (c_time)
+        {
+            rc = FileTimeToSystemTime(&FileInfo.ftCreationTime, &SystemTime);
+            CHANGE_TIME(SystemTime, tm_time)
+            (*c_time) = mktime(&tm_time);
+        }
+        if (a_time)
+        {
+            rc = FileTimeToSystemTime(&FileInfo.ftLastAccessTime, &SystemTime);
+            CHANGE_TIME(SystemTime, tm_time)
+            (*a_time) = mktime(&tm_time);
+        }
+        if (m_time)
+        {
+            rc = FileTimeToSystemTime(&FileInfo.ftLastWriteTime, &SystemTime);
+            CHANGE_TIME(SystemTime, tm_time)
+            (*m_time) = mktime(&tm_time);
+        }
+        if (size) 
+        {
+            rc = 0;
+            if (!(FileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+               *size = FileInfo.nFileSizeLow;
+           }
+           if (mode)
+        {
+            rc = 0;
+            (*mode) = 0;
+        }
+    }
+    return(rc);
+}
+
+/****************************************************************************
+  Read size bytes at offset offset using SMBreadX.
+****************************************************************************/
+
+ssize_t nb_read(int fnum, char *IoBuffer, off_t offset, size_t size)
+{
+       ssize_t total = 0;
+    int     rc;
+    DWORD   LowDword;
+
+       if (size == 0) 
+               return(0);
+
+    LowDword = SetFilePointer((HANDLE)fnum, offset, 0, FILE_BEGIN);
+
+    if (LowDword == INVALID_SET_FILE_POINTER)
+        return(-1);
+    rc = ReadFile((HANDLE)fnum, IoBuffer, size, &total, NULL);
+
+    if (!rc)
+        return(rc);
+    return(total);
+}
+
+/****************************************************************************
+  write to a file
+****************************************************************************/
+
+ssize_t nb_write(int fnum, char *IoBuffer, off_t offset, size_t size)
+{
+       int     bwritten = 0;
+    int     rc;
+    DWORD   LowDword;
+
+    LowDword = SetFilePointer((HANDLE)fnum, offset, 0, FILE_BEGIN);
+    if (LowDword == INVALID_SET_FILE_POINTER)
+        return(-1);
+    rc = WriteFile((HANDLE)fnum, IoBuffer, size, &bwritten, NULL);
+
+    if (!rc)
+        return(rc);
+    FlushFileBuffers((HANDLE)fnum);
+    return(bwritten);
+}
diff --git a/src/WINNT/tests/torture/Source/output.c b/src/WINNT/tests/torture/Source/output.c
new file mode 100644 (file)
index 0000000..b7c69dd
--- /dev/null
@@ -0,0 +1,316 @@
+#include <windows.h>
+#include <includes.h>
+#include "common.h"
+
+extern int  ChronLog;
+extern int  CurrentLoop;
+extern HANDLE ChronMutexHandle;
+extern HANDLE MutexHandle;
+extern HANDLE FileMutexHandle;
+
+void LogStats(char *FileName, int ToLog, int Iteration, int NumberOfProcesses, int NumberOfThreads, 
+              char *HostName, int ProcessNumber, struct cmd_struct CommandInfo[],
+              char *CommandLine, char *TargetDirectory)
+{
+       struct cmd_struct TotalCommandInfo[CMD_MAX_CMD + 1];
+       int         i;
+    int         j;
+    int         LineCount;
+       unsigned    grand_total = 0;
+    char        AsciiTime[32];
+    FILE        *fp;
+    struct tm   *newtime;
+    time_t      aclock;
+
+    LineCount = 1;
+    time(&aclock);
+    newtime = localtime(&aclock);
+    strcpy(AsciiTime, asctime(newtime));
+    AsciiTime[strlen(AsciiTime) - 1] = '\0';
+
+    fp = stdout;
+    if (ToLog)
+        fp = fopen(FileName, "a+");
+
+       for (j = 0; j <= CMD_MAX_CMD; j++)
+    {
+               TotalCommandInfo[j].count = 0;
+               TotalCommandInfo[j].min_sec = 0;
+               TotalCommandInfo[j].ErrorTime = 0;
+               TotalCommandInfo[j].max_sec = 0;
+               TotalCommandInfo[j].MilliSeconds = 0;
+               TotalCommandInfo[j].total_sec = 0;
+               TotalCommandInfo[j].total_sum_of_squares = 0;
+               TotalCommandInfo[j].ErrorCount = 0;
+               TotalCommandInfo[j].ErrorTime = 0;
+       }
+
+    for (i = 0; i <= CMD_MAX_CMD; i++)
+    {
+        TotalCommandInfo[i].count += CommandInfo[i].count;
+        TotalCommandInfo[i].total_sec += CommandInfo[i].total_sec; 
+        TotalCommandInfo[i].ErrorCount += CommandInfo[i].ErrorCount; 
+        TotalCommandInfo[i].ErrorTime += CommandInfo[i].ErrorTime; 
+        grand_total += CommandInfo[i].total_sec;
+        if (!TotalCommandInfo[i].min_sec || (TotalCommandInfo[i].min_sec > CommandInfo[i].min_sec))
+            TotalCommandInfo[i].min_sec = CommandInfo[i].min_sec;
+        if (TotalCommandInfo[i].min_sec == 1000)
+            TotalCommandInfo[i].min_sec = 0;
+        if (TotalCommandInfo[i].max_sec < CommandInfo[i].max_sec)
+            TotalCommandInfo[i].max_sec = CommandInfo[i].max_sec;
+    }
+    if (ProcessNumber > -1)
+    {
+       fprintf(fp, "Iteration %d Statistics\n", Iteration);
+        ++LineCount;
+    }
+    else if (ProcessNumber == -1)
+    {
+       fprintf(fp, "Process Statistics for Iteration %d\n", Iteration);
+        ++LineCount;
+    }
+    else if (ProcessNumber == -2)
+    {
+       fprintf(fp, "Test Statistics for all processes - %d Iterations \n", Iteration);
+        ++LineCount;
+    }
+    fprintf(fp, "Date: %s\n", AsciiTime);
+    ++LineCount;
+    fprintf(fp, "Total Time: %d seconds (%4.1f minutes)\n", grand_total, grand_total/60.0);
+    ++LineCount;
+    if ((ProcessNumber == -2) || (ProcessNumber == -1))
+    {
+        fprintf(fp, "Number of Processes: %d\n", NumberOfProcesses);
+        fprintf(fp, "Number of Threads/Process: %d\n", NumberOfThreads);
+        ++LineCount;
+        ++LineCount;
+    }
+
+    if (strlen(TargetDirectory) != 0)
+    {
+        fprintf(fp, "Target directory: %s\n", TargetDirectory);
+        ++LineCount;
+    }
+    if (strlen(CommandLine) != 0)
+    {
+        fprintf(fp, "Command Line: %s\n", CommandLine);
+        ++LineCount;
+    }
+    fprintf(fp, "\n  Command:                          Count  Min Latency Max Latency Ave Latency    Cost      Seconds     Error     Error  \n");
+    fprintf(fp, "                                            (seconds)   (seconds)   (seconds)                           Count    seconds\n");
+    ++LineCount;
+    ++LineCount;
+
+    for (i = LineCount; i < 12; i++)
+        fprintf(fp, "\n");
+
+    for (i = 0; i <= CMD_MAX_CMD; i++)
+    {
+        fprintf(fp, "%-30s   %8d    %8d  %10d  %10.2f   %5.1f%%   %10d  %8d  %8d  %s\n",
+                cmd_names[i].name, 
+                TotalCommandInfo[i].count, 
+                TotalCommandInfo[i].min_sec,
+                TotalCommandInfo[i].max_sec,
+                (TotalCommandInfo[i].count ? (float)TotalCommandInfo[i].total_sec/(float)TotalCommandInfo[i].count : 0),
+                (grand_total ? 100.0*TotalCommandInfo[i].total_sec/grand_total : 0),
+                TotalCommandInfo[i].total_sec,
+                TotalCommandInfo[i].ErrorCount,
+                TotalCommandInfo[i].ErrorTime,
+                cmd_names[i].ms_api);
+    }
+    fprintf(fp, "\n");
+    if (ToLog)
+        fclose(fp);
+}
+
+void LogMessage(int ProcessNumber, char *HostName, char *FileName, char *message, int LogID)
+{
+    char        NewMessage[1024];
+    char        AsciiTime[32];
+    char        NewFileName[256];
+    char        WorkingDirectory[512];
+    FILE        *fp;
+    struct tm   *newtime;
+    time_t      aclock;
+    DWORD       rc;
+
+    if (ChronLog)
+    {
+        while(1)
+        {
+            rc = WaitForSingleObject(ChronMutexHandle, 4 * 1000);
+            if ((rc == WAIT_OBJECT_0) || (rc == WAIT_TIMEOUT))
+                break;
+        }
+    }
+    time(&aclock);
+    newtime = localtime(&aclock);
+    strcpy(AsciiTime, asctime(newtime));
+    AsciiTime[strlen(AsciiTime) - 1] = '\0';
+    GetCurrentDirectory(sizeof(WorkingDirectory), WorkingDirectory);
+    sprintf(NewMessage, "%s - %s", AsciiTime, message);
+    sprintf(NewFileName, "%s\\log%05d\\%s\\%s", WorkingDirectory, LogID, HostName, FileName);
+    fp = fopen(NewFileName, "a+");
+    if (fp != NULL)
+    {
+        fprintf(fp, "%s", NewMessage);
+        fclose(fp);
+    }
+    if (ChronLog)
+    {
+        sprintf(NewMessage, "%s %s:%d- %s", AsciiTime, HostName, ProcessNumber, message);
+        sprintf(NewFileName, "%s\\log%05d\\Chron.log", WorkingDirectory, LogID);
+        fp = fopen(NewFileName, "a+");
+        fprintf(fp, "%s", NewMessage);
+        fclose(fp);
+        ReleaseMutex(ChronMutexHandle);
+    }
+}
+
+void DumpAFSLog(char *HostName, int LogID)
+{
+    char    EnvVariable[512];
+    char    WorkingDirectory[512];
+    char    command[512];
+    int     rc;
+
+    WaitForSingleObject(FileMutexHandle, 4 * 1000);
+    memset(WorkingDirectory, '\0', sizeof(WorkingDirectory));
+    GetCurrentDirectory(sizeof(WorkingDirectory), WorkingDirectory);
+    sprintf(command, "fs trace -dump > .\\test\\%s", HostName);
+    rc = system(command);
+    rc = GetWindowsDirectory(EnvVariable, sizeof(EnvVariable));
+    strcat(EnvVariable, "\\TEMP\\afsd.log");
+    sprintf(command, "move %s %s\\log%05d\\%s > .\\test\\%s", EnvVariable, WorkingDirectory, LogID, HostName, HostName);
+    rc = system(command);
+    sprintf(command, "rename %s\\log%05d\\%s\\afsd.log afsd_%s_iteration%d.log", 
+            WorkingDirectory, LogID, HostName, HostName, CurrentLoop);
+    rc = system(command);
+    ReleaseMutex(FileMutexHandle);
+}
+
+int UpdateMasterLog(char *FileName, struct cmd_struct CommandInfo[])
+{
+    FILE    *fp;
+    char    Buffer[32];
+    int     i;
+    struct cmd_struct TotalCommandInfo[CMD_MAX_CMD + 1];
+
+    WaitForSingleObject(FileMutexHandle, 4 * 1000);
+
+    for (i = 0; i <= CMD_MAX_CMD; i++)
+    {
+        TotalCommandInfo[i].count = 0;
+        TotalCommandInfo[i].min_sec = 0;
+        TotalCommandInfo[i].max_sec = 0;
+        TotalCommandInfo[i].MilliSeconds = 0;
+        TotalCommandInfo[i].total_sec = 0;
+        TotalCommandInfo[i].ErrorCount = 0;
+        TotalCommandInfo[i].ErrorTime = 0;
+        TotalCommandInfo[i].total_sum_of_squares = 0;
+    }
+
+    fp = fopen(FileName, "r");
+    if (fp != NULL)
+    {
+        for (i = 0; i <= CMD_MAX_CMD; i++)
+        {
+            fgets(Buffer, 16, fp);
+            TotalCommandInfo[i].count = atoi(Buffer);
+            fgets(Buffer, 16, fp);
+            TotalCommandInfo[i].min_sec = atoi(Buffer);
+            fgets(Buffer, 16, fp);
+            TotalCommandInfo[i].max_sec = atoi(Buffer);
+            fgets(Buffer, 16, fp);
+            TotalCommandInfo[i].total_sec = atoi(Buffer);
+            fgets(Buffer, 16, fp);
+            TotalCommandInfo[i].total_sum_of_squares = atoi(Buffer);
+            fgets(Buffer, 16, fp);
+            TotalCommandInfo[i].ErrorCount = atoi(Buffer);
+            fgets(Buffer, 16, fp);
+            TotalCommandInfo[i].ErrorTime = atoi(Buffer);
+        }
+        fclose(fp);
+    }
+
+    for (i = 0; i <= CMD_MAX_CMD; i++)
+    {
+        TotalCommandInfo[i].count += CommandInfo[i].count;
+        if (!TotalCommandInfo[i].min_sec || (TotalCommandInfo[i].min_sec > CommandInfo[i].min_sec))
+            TotalCommandInfo[i].min_sec = CommandInfo[i].min_sec;
+        if (TotalCommandInfo[i].max_sec < CommandInfo[i].max_sec)
+            TotalCommandInfo[i].max_sec = CommandInfo[i].max_sec;
+        TotalCommandInfo[i].total_sec += CommandInfo[i].total_sec;
+        TotalCommandInfo[i].total_sum_of_squares += CommandInfo[i].total_sum_of_squares;
+        TotalCommandInfo[i].ErrorCount += CommandInfo[i].ErrorCount;
+        TotalCommandInfo[i].ErrorTime += CommandInfo[i].ErrorTime;
+    }
+
+
+    fp = fopen(FileName, "w");
+    for (i = 0; i <= CMD_MAX_CMD; i++)
+    {
+        fprintf(fp, "%ld\n", TotalCommandInfo[i].count);
+        fprintf(fp, "%ld\n", TotalCommandInfo[i].min_sec);
+        fprintf(fp, "%ld\n", TotalCommandInfo[i].max_sec);
+        fprintf(fp, "%ld\n", TotalCommandInfo[i].total_sec);
+        fprintf(fp, "%ld\n", TotalCommandInfo[i].total_sum_of_squares);
+        fprintf(fp, "%ld\n", TotalCommandInfo[i].ErrorCount);
+        fprintf(fp, "%ld\n", TotalCommandInfo[i].ErrorTime);
+    }
+    fclose(fp);
+    ReleaseMutex(FileMutexHandle);
+    return(0);
+}
+
+int BuildMasterStatLog(char *FileName, char*MoveFileName, int NumberOfProcesses, 
+                       int NumberOfThreads, char *CommandLine, int Iterations, 
+                       char *TargetDirectory, int ProcessNumber)
+{
+    FILE    *fp;
+    char    Buffer[32];
+    int     i;
+    struct cmd_struct TotalCommandInfo[CMD_MAX_CMD + 1];
+
+    for (i = 0; i <= CMD_MAX_CMD; i++)
+    {
+        TotalCommandInfo[i].count = 0;
+        TotalCommandInfo[i].min_sec = 0;
+        TotalCommandInfo[i].MilliSeconds = 0;
+        TotalCommandInfo[i].max_sec = 0;
+        TotalCommandInfo[i].total_sec = 0;
+        TotalCommandInfo[i].total_sum_of_squares = 0;
+        TotalCommandInfo[i].ErrorCount = 0;
+        TotalCommandInfo[i].ErrorTime = 0;
+    }
+
+    fp = fopen(FileName, "r");
+    if (fp != NULL)
+    {
+        for (i = 0; i <= CMD_MAX_CMD; i++)
+        {
+            if (fgets(Buffer, 16, fp) != NULL)
+                TotalCommandInfo[i].count = atoi(Buffer);
+            if (fgets(Buffer, 16, fp) != NULL)
+                TotalCommandInfo[i].min_sec = atoi(Buffer);
+            if (fgets(Buffer, 16, fp) != NULL)
+                TotalCommandInfo[i].max_sec = atoi(Buffer);
+            if (fgets(Buffer, 16, fp) != NULL)
+                TotalCommandInfo[i].total_sec = atoi(Buffer);
+            if (fgets(Buffer, 16, fp) != NULL)
+                TotalCommandInfo[i].total_sum_of_squares = atoi(Buffer);
+            if (fgets(Buffer, 16, fp) != NULL)
+                TotalCommandInfo[i].ErrorCount = atoi(Buffer);
+            if (fgets(Buffer, 16, fp) != NULL)
+                TotalCommandInfo[i].ErrorTime = atoi(Buffer);
+        }
+        fclose(fp);
+        MoveFile(FileName, MoveFileName);
+    }
+    
+    fp = fopen(FileName, "w");
+    fclose(fp);
+    LogStats(FileName, 1, Iterations, NumberOfProcesses, NumberOfThreads, "", ProcessNumber, TotalCommandInfo, 
+             CommandLine, TargetDirectory);
+    return(0);
+}
diff --git a/src/WINNT/tests/torture/StopStressTest/Makefile.src b/src/WINNT/tests/torture/StopStressTest/Makefile.src
new file mode 100644 (file)
index 0000000..5f5a443
--- /dev/null
@@ -0,0 +1,24 @@
+NAME=StopStressTest
+TARGETTYPE=EXE
+TARGETSS=console
+
+OBJS= \
+       $(O)\StopStressTest.obj
+
+
+#INCLUDES=$(O);$(MOIRABASE)\include;$(MOIRABASE)\mmc;$(PISMERE)\athena\auth\krb4\include;$(PISMERE)\athena\wshelper\include;$(PISMERE)\athena\auth\krb5\src\include;$(PISMERE)\athena\auth\krb5\src\include\krb5;$(PISMERE)\athena\auth\krb5\src\lib;$(PISMERE)\athena\auth\krb5\src\lib\krb5\asn.1;$(PISMERE)\athena\auth\krb5\src\krb524;$(PISMERE)\athena\auth\krb5\src\lib\krb5\krb
+#LIB_PATHS = $(PISMERE)\athena\auth\krb4\krbv4\krbdll\$(O);$(PISMERE)\athena\wshelper\wshelper\$(O);$(MOIRABASE)\util\et\$(O);$(MOIRABASE)\lib\$(O);$(PISMERE)\athena\auth\krb5\src\lib\krb5\$(O);$(PISMERE)\target\lib\$(T)
+
+
+USE_DEFAULTLIB=1
+
+#LIBS= wsock32.lib advapi32.lib user32.lib \
+#      dnsapi.lib oleaut32.lib \
+#      ole32.lib wldap32.lib
+
+USE_LIBC_DLL=1
+
+#####
+
+
+
diff --git a/src/WINNT/tests/torture/StopStressTest/StopStressTest.c b/src/WINNT/tests/torture/StopStressTest/StopStressTest.c
new file mode 100644 (file)
index 0000000..905e300
--- /dev/null
@@ -0,0 +1,150 @@
+// Stress.cpp : Defines the entry point for the console application.
+//
+
+#include <windows.h>
+#include <stdio.h>
+#include <time.h>
+#include <stdio.h>
+#include <io.h>
+
+#define SUSPEND_PROCESSING  'p'
+#define CONTINUE_PROCESSING 'c'
+#define END_PROCESSING      'e'
+
+void usage(void);
+int  GetConsoleInput(HANDLE hStdin);
+void ProcessRequest(char RequestType, HANDLE ShutDownEventHandle, HANDLE PauseEventHandle, HANDLE ContinueEventHandle);
+
+int main(int argc, char* argv[])
+{
+    char    Character;
+    HANDLE  ShutDownEventHandle;
+    HANDLE  PauseEventHandle;
+    HANDLE  ContinueEventHandle;
+    HANDLE  hStdin; 
+
+    hStdin = GetStdHandle(STD_INPUT_HANDLE);
+
+
+    ShutDownEventHandle = CreateEvent(NULL, TRUE, FALSE, "AfsShutdownEvent");
+    PauseEventHandle = CreateEvent(NULL, TRUE, FALSE, "AfsPauseEvent");
+    ContinueEventHandle = CreateEvent(NULL, TRUE, FALSE, "AfsContinueEvent");
+
+    while (1)
+    {
+        printf("\nType p to pause the stress test\n");
+        printf("Type c to continue the stress test\n");
+        printf("Type e to end the stress test\n");
+        printf("Type q to quit StopStressTest\n");
+        Character = (char)GetConsoleInput(hStdin);
+
+        if (Character == 'q')
+            break;
+        if ((Character == SUSPEND_PROCESSING) || (Character == END_PROCESSING) || (Character == CONTINUE_PROCESSING))
+            ProcessRequest(Character, ShutDownEventHandle, PauseEventHandle, ContinueEventHandle);
+        else
+            printf("\nInvalid selection....\n");
+
+    }
+
+    CloseHandle(ShutDownEventHandle);
+    CloseHandle(PauseEventHandle);
+    CloseHandle(ContinueEventHandle);
+       return(0);
+
+}
+
+int GetConsoleInput(HANDLE hStdin)
+{
+    INPUT_RECORD    InputRecord[128];
+    DWORD           InputRecordCount;
+    BOOL            rc;
+    int             i;
+    int             RetCode;
+    char            ReadChar;
+
+    InputRecordCount = 0;
+    RetCode = 0;
+    while (1)
+    {
+        rc = ReadConsoleInput(hStdin, InputRecord, 1, &InputRecordCount);
+        if (InputRecord[0].EventType == KEY_EVENT)
+        {
+            if (InputRecord[0].Event.KeyEvent.bKeyDown)
+                break;
+        }
+    }
+    for (i = 0; i < (int)InputRecordCount; i++) 
+    {
+        switch(InputRecord[i].EventType) 
+        { 
+            case KEY_EVENT:
+                if (InputRecord[i].Event.KeyEvent.bKeyDown)
+                {
+                    ReadChar = InputRecord[i].Event.KeyEvent.uChar.AsciiChar;
+                    if ((ReadChar == 'q') || (ReadChar == 'Q'))
+                    {
+                        printf("\nQuit request received\n");
+                        exit(0);
+                    }
+                    else if ((ReadChar == 'c') || (ReadChar == 'C'))
+                    {
+                        printf("\nContinue stress test request received\n");
+                        RetCode = CONTINUE_PROCESSING;
+                    }
+                    else if ((ReadChar == 'p') || (ReadChar == 'P'))
+                    {
+                        printf("\nPause stress test request received\n");
+                        RetCode = SUSPEND_PROCESSING;
+                    }
+                    else if ((ReadChar == 'e') || (ReadChar == 'E'))
+                    {
+                        RetCode = END_PROCESSING;
+                        printf("\nEnd stress test request received\n");
+                    }
+                }
+                break; 
+            default: 
+                break; 
+        }
+    }
+    return(RetCode);
+}
+
+void ProcessRequest(char RequestType, HANDLE ShutDownEventHandle, HANDLE PauseEventHandle, HANDLE ContinueEventHandle)
+{
+    static int LastRequest = 0;
+
+    if (RequestType == CONTINUE_PROCESSING)
+    {
+        if (LastRequest == END_PROCESSING)
+        {
+            printf("Invalid request, all process are currently ending\n");
+            return;
+        }
+        ResetEvent(PauseEventHandle);
+        SetEvent(ContinueEventHandle);
+        printf("Continue processing event has been set\n");
+        LastRequest = RequestType;
+    }
+    if (RequestType == SUSPEND_PROCESSING)
+    {
+        if (LastRequest == END_PROCESSING)
+        {
+            printf("Invalid request, all processes are currently ending\n");
+            return;
+        }
+        ResetEvent(ContinueEventHandle);
+        SetEvent(PauseEventHandle);
+        printf("Suspend processing event has been set\n");
+        LastRequest = RequestType;
+    }
+    else if (RequestType == END_PROCESSING)
+    {
+        SetEvent(ShutDownEventHandle);
+        ResetEvent(PauseEventHandle);
+        SetEvent(ContinueEventHandle);
+        printf("End processing event has been set\n");
+        LastRequest = RequestType;
+    }
+}
diff --git a/src/WINNT/tests/torture/StopStressTest/StopStressTest.dsp b/src/WINNT/tests/torture/StopStressTest/StopStressTest.dsp
new file mode 100644 (file)
index 0000000..6e439b8
--- /dev/null
@@ -0,0 +1,101 @@
+# Microsoft Developer Studio Project File - Name="StopStressTest" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=StopStressTest - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "StopStressTest.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "StopStressTest.mak" CFG="StopStressTest - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "StopStressTest - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "StopStressTest - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "StopStressTest - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF  "$(CFG)" == "StopStressTest - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "StopStressTest - Win32 Release"
+# Name "StopStressTest - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\StopStressTest.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/src/WINNT/tests/torture/StopStressTest/StopStressTest.dsw b/src/WINNT/tests/torture/StopStressTest/StopStressTest.dsw
new file mode 100644 (file)
index 0000000..4a1b354
--- /dev/null
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "StopStressTest"=".\StopStressTest.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/src/WINNT/tests/torture/Stress/Makefile.src b/src/WINNT/tests/torture/Stress/Makefile.src
new file mode 100644 (file)
index 0000000..1db39da
--- /dev/null
@@ -0,0 +1,18 @@
+NAME=Stress
+TARGETTYPE=EXE
+TARGETSS=console
+
+OBJS= \
+       $(O)\Stress.obj
+
+INCLUDES=..\include
+
+USE_DEFAULTLIB=1
+
+USE_LIBC_DLL=1
+C_DEFINE=-DHAVE_HESOID 
+
+#####
+
+
+
diff --git a/src/WINNT/tests/torture/Stress/StdAfx.h b/src/WINNT/tests/torture/Stress/StdAfx.h
new file mode 100644 (file)
index 0000000..7153bcc
--- /dev/null
@@ -0,0 +1,19 @@
+// stdafx.h : include file for standard system include files,
+//  or project specific include files that are used frequently, but
+//      are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__5D9D9966_7D99_435B_82F4_6465EFF7E7E2__INCLUDED_)
+#define AFX_STDAFX_H__5D9D9966_7D99_435B_82F4_6465EFF7E7E2__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+
+// TODO: reference additional headers your program requires here
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__5D9D9966_7D99_435B_82F4_6465EFF7E7E2__INCLUDED_)
diff --git a/src/WINNT/tests/torture/Stress/Stress.c b/src/WINNT/tests/torture/Stress/Stress.c
new file mode 100644 (file)
index 0000000..49702b9
--- /dev/null
@@ -0,0 +1,267 @@
+// Stress.cpp : Defines the entry point for the console application.
+//
+
+#include <windows.h>
+#include <stdio.h>
+
+int opterr = 1;
+int optind = 1;
+int optopt;
+int optreset;
+char *optarg;
+
+int   getopt(int, char**, char*);
+void usage(void);
+
+int main(int argc, char* argv[])
+{
+    int                 i;
+    int                 k;
+    int                 opt;
+    int                 LogID;
+    int                 ProcessCount;
+    int                 SecondsDelay;
+    int                 DirCount;
+    int                 DirFound;
+    char                command[512];
+    char                temp[512];
+    char                TopDirectory[512];
+    char                CurrentDirectory[256];
+    PROCESS_INFORMATION ProcInfo;
+    STARTUPINFO         StartupInfo;
+    HANDLE              hArray[500];
+    WIN32_FIND_DATA     FindFileData;
+    HANDLE              fHandle;
+
+    if (argc < 2)
+    {
+        usage();
+        exit(1);
+    }
+    for (i = 0; i < 500; i++)
+        hArray[i] = NULL;
+
+    LogID = 0;
+    ProcessCount = 0;
+    DirFound = 0;
+    DirCount = 0;
+    SecondsDelay = 0;
+    memset(command, '\0', sizeof(command));
+    memset(TopDirectory, '\0', sizeof(TopDirectory));
+
+    while ((opt = getopt(argc, argv, "A:a:BbC:c:D:d:EeF:f:I:i:L:l:M:m:N:n:P:p:SsTtU:u:Vv")) != EOF)
+    {
+
+        switch (opt)
+        {
+            case 'f':
+            case 'F':
+                DirFound = 1;
+                strcpy(TopDirectory, optarg);
+                break;
+            case 'a':
+            case 'A':
+                SecondsDelay = atoi(optarg);
+                break;
+            case 'd':
+            case 'D':
+                ProcessCount = atoi(optarg);
+            case 'b':
+            case 'B':
+            case 'c':
+            case 'C':
+            case 'e':
+            case 'E':
+            case 'i':
+            case 'I':
+            case 'l':
+            case 'L':
+            case 'm':
+            case 'M':
+            case 'n':
+            case 'N':
+            case 'p':
+            case 'P':
+            case 's':
+            case 'S':
+            case 't':
+            case 'T':
+            case 'u':
+            case 'U':
+            case 'v':
+            case 'V':
+                break;
+            default:
+                usage();
+                exit(1);
+                break;
+        }
+    }
+
+    for (LogID = 0; LogID < 100; LogID++)
+    {
+        sprintf(CurrentDirectory, ".\\Log%05d", LogID);
+        fHandle = FindFirstFile(CurrentDirectory, &FindFileData);
+        if (fHandle == INVALID_HANDLE_VALUE)
+            break;
+        FindClose(fHandle);
+    }
+    if (LogID == 100)
+    {
+        printf("\nUnable to get a LogID.\n");
+        exit(1);
+    }
+
+    if (!DirFound)
+    {
+        printf("\nYou must use the -f switch\n\n");
+        usage();
+        exit(1);
+    }
+    if (!ProcessCount)
+    {
+        printf("\nYou must use the -d switch\n\n");
+        usage();
+        exit(1);
+    }
+    if (ProcessCount > 500)
+    {
+        printf("\nA max of 500 processes allowed\n\n");
+        usage();
+        exit(1);
+    }
+
+    GetStartupInfo(&StartupInfo);
+    memset(&StartupInfo, '\0', sizeof(StartupInfo));
+    for (i = 0; i < ProcessCount; i++)
+    {
+        memset(command, '\0', sizeof(command));
+        for (k = 0; k < argc; k++)
+        {
+            strcat(command, argv[k]);
+            strcat(command, " ");
+            if (!stricmp(argv[k], "-f"))
+            {
+                ++k;
+                memset(temp, '\0', sizeof(temp));
+                sprintf(temp, "%s%05d", argv[k], DirCount);
+                strcat(command, temp);
+                strcat(command, " ");
+                ++DirCount;
+            }
+        }
+        sprintf(temp, " -g %d", LogID);
+        strcat(command, temp);
+        StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
+        StartupInfo.wShowWindow = SW_SHOWMINIMIZED;
+        if (CreateProcess(".\\wintorture.exe", command, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcInfo))
+            hArray[i] = ProcInfo.hProcess;
+        Sleep(SecondsDelay * 1000);
+    }
+
+       return(0);
+
+}
+
+void usage(void)
+{
+
+    printf("usage: stress [options]\n");
+    printf("where options can be:\n");
+    printf("\t-a <sec>  Seconds delay between starting detached processes\n");
+    printf("\t-b        Create a chronological log\n");
+    printf("\t-c <txt>  Specifies the script txt file to use\n");
+    printf("\t-d <num>  Number of detached processes to run\n");
+    printf("\t-e        End thread processing on an error.\n");
+    printf("\t-f <name> Target directory name\n");
+#ifdef HAVE_HESOID
+    printf("\t-l <path> Interpert as an AFS locker or AFS submount\n");
+#endif /* HAVE_HESOID */
+    printf("\t-i <num>  Number of iterations of the stress test to run.\n");
+    printf("\t            This option will override the -m option.\n");
+    printf("\t-m <num>  The number of minutes to run\n");
+    printf("\t-n <num>  The number of threads to run\n");
+    printf("\t-p <path> UNC path to second directory\n");
+    printf("\t-s        Output stats\n");
+    printf("\t-t        Do AFS trace logging\n");
+    printf("\t-u <UNC>  UNC path to target directory\n");
+    printf("\t-v        Turn on verbose mode\n");
+    printf("\nNOTE: The switches are not case sensitive.  You\n");
+    printf("\n      may use either upper or lower case letters.\n\n");
+}
+
+char *_progname(char *nargv0)
+{
+    char    *tmp;
+
+    tmp = strrchr(nargv0, '/');
+    if (tmp)
+        tmp++;
+    else
+        tmp = nargv0;
+    return(tmp);
+}
+
+#define BADCH   (int)'?'
+#define BADARG  (int)':'
+#define EMSG    ""
+
+int getopt(int nargc, char *nargv[], char *ostr)
+{
+    static char *__progname = 0;
+    static char *place = EMSG;         /* option letter processing */
+    char *oli;                         /* option letter list index */
+
+    __progname = __progname?__progname:_progname(*nargv);
+
+    if (optreset || !*place)
+    {
+        optreset = 0;
+        if (optind >= nargc || *(place = nargv[optind]) != '-')
+        {
+            place = EMSG;
+            return (-1);
+        }
+        if (place[1] && *++place == '-'        && place[1] == '\0')
+        {
+            ++optind;
+            place = EMSG;
+            return (-1);
+        }
+    }
+    if ((optopt = (int)*place++) == (int)':' || !(oli = strchr(ostr, optopt))) 
+    {
+        if (optopt == (int)'-')
+            return (-1);
+        if (!*place)
+            ++optind;
+        if (opterr && *ostr != ':')
+            (void)fprintf(stderr, "%s: illegal option -- %c\n", __progname, optopt);
+        return (BADCH);
+    }
+    if (*++oli != ':') 
+    {
+        optarg = NULL;
+        if (!*place)
+            ++optind;
+    }
+    else
+    {
+        if (*place)
+            optarg = place;
+        else if (nargc <= ++optind) 
+        {
+            place = EMSG;
+            if (*ostr == ':')
+                return (BADARG);
+            if (opterr)
+                (void)fprintf(stderr, "%s: option requires an argument -- %c\n", __progname, optopt);
+            return (BADCH);
+        }
+        else
+            optarg = nargv[optind];
+        place = EMSG;
+        ++optind;
+    }
+    return (optopt);
+}
diff --git a/src/WINNT/tests/torture/Stress/Stress.dsp b/src/WINNT/tests/torture/Stress/Stress.dsp
new file mode 100644 (file)
index 0000000..b623cda
--- /dev/null
@@ -0,0 +1,113 @@
+# Microsoft Developer Studio Project File - Name="Stress" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=Stress - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "Stress.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "Stress.mak" CFG="Stress - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "Stress - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "Stress - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "Stress - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX /Yc /Yu
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF  "$(CFG)" == "Stress - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
+# SUBTRACT CPP /YX /Yc /Yu
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "Stress - Win32 Release"
+# Name "Stress - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\Stress.c
+
+!IF  "$(CFG)" == "Stress - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "Stress - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF 
+
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/src/WINNT/tests/torture/Stress/Stress.dsw b/src/WINNT/tests/torture/Stress/Stress.dsw
new file mode 100644 (file)
index 0000000..ed692b4
--- /dev/null
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "Stress"=".\Stress.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/src/WINNT/tests/torture/WinTorture_VC6/wintorture.dsp b/src/WINNT/tests/torture/WinTorture_VC6/wintorture.dsp
new file mode 100644 (file)
index 0000000..82ba8ba
--- /dev/null
@@ -0,0 +1,138 @@
+# Microsoft Developer Studio Project File - Name="wintorture" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=wintorture - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "wintorture.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "wintorture.mak" CFG="wintorture - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "wintorture - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "wintorture - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "wintorture - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /Od /I "..\include" /I "$(PISMERE)\athena\util\locker\lib" /I "$(PISMERE)\athena\wshelper\include" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "HAVE_HESOID" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 Ws2_32.lib Mpr.lib Psapi.lib getopt.lib locker.lib oncrpc.lib athdir.lib krbv4w32.lib wshelp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"$(PISMERE)\target\lib\i386\rel"
+# SUBTRACT LINK32 /pdb:none /nodefaultlib
+
+!ELSEIF  "$(CFG)" == "wintorture - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /vmg /GX /ZI /Od /I "..\include" /I "$(PISMERE)\athena\util\locker\lib" /I "$(PISMERE)\athena\wshelper\include" /I "$(PISMERE)\target\lib\i386\rel" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "HAVE_HESOID" /FR /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 krbv4w32.lib oncrpc.lib Kernel32.lib Psapi.lib wshelp32.lib locker.lib athdir.lib Ws2_32.lib Mpr.lib oleaut32.lib Advapi32.lib ole32.lib User32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"$(PISMERE)\target\lib\i386\dbg"
+# SUBTRACT LINK32 /verbose /nodefaultlib
+
+!ENDIF 
+
+# Begin Target
+
+# Name "wintorture - Win32 Release"
+# Name "wintorture - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\Source\nbio.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\Source\output.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\Source\ResolveLocker.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\Source\WinThreads.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\Source\WinTorture.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\include\common.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\includes.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\proto.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\ResolveLocker.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/src/WINNT/tests/torture/WinTorture_VC6/wintorture.dsw b/src/WINNT/tests/torture/WinTorture_VC6/wintorture.dsw
new file mode 100644 (file)
index 0000000..1269321
--- /dev/null
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "wintorture"=".\wintorture.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.dsp b/src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.dsp
new file mode 100644 (file)
index 0000000..e6ed381
--- /dev/null
@@ -0,0 +1,138 @@
+# Microsoft Developer Studio Project File - Name="wintorture" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=wintorture - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "wintorture.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "wintorture.mak" CFG="wintorture - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "wintorture - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "wintorture - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "wintorture - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /Od /I "..\include" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 Ws2_32.lib Mpr.lib Psapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# SUBTRACT LINK32 /pdb:none /nodefaultlib
+
+!ELSEIF  "$(CFG)" == "wintorture - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /vmg /GX /ZI /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 Kernel32.lib Psapi.lib Ws2_32.lib Mpr.lib oleaut32.lib Advapi32.lib ole32.lib User32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# SUBTRACT LINK32 /verbose /nodefaultlib
+
+!ENDIF 
+
+# Begin Target
+
+# Name "wintorture - Win32 Release"
+# Name "wintorture - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\Source\nbio.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\Source\output.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\Source\ResolveLocker.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\Source\WinThreads.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\Source\WinTorture.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\include\common.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\includes.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\proto.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\ResolveLocker.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.dsw b/src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.dsw
new file mode 100644 (file)
index 0000000..1269321
--- /dev/null
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "wintorture"=".\wintorture.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.ncb b/src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.ncb
new file mode 100644 (file)
index 0000000..948b842
Binary files /dev/null and b/src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.ncb differ
diff --git a/src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.vcproj b/src/WINNT/tests/torture/WinTorture_VC6_withoutHesiod/wintorture.vcproj
new file mode 100644 (file)
index 0000000..17c04da
--- /dev/null
@@ -0,0 +1,346 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="wintorture"
+       ProjectGUID="{AA8BB120-E8EC-4609-8FBA-F36124AA363E}"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory=".\Release"
+                       IntermediateDirectory=".\Release"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Release/wintorture.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="..\include"
+                               PreprocessorDefinitions="WIN32;_CONSOLE"
+                               RuntimeLibrary="2"
+                               PrecompiledHeaderFile=".\Release/wintorture.pch"
+                               AssemblerListingLocation=".\Release/"
+                               ObjectFile=".\Release/"
+                               ProgramDataBaseFileName=".\Release/"
+                               WarningLevel="3"
+                               SuppressStartupBanner="true"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="NDEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="Ws2_32.lib Mpr.lib Psapi.lib odbc32.lib odbccp32.lib"
+                               OutputFile=".\Release/wintorture.exe"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               ProgramDatabaseFile=".\Release/wintorture.pdb"
+                               SubSystem="1"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Release/wintorture.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory=".\Debug"
+                       IntermediateDirectory=".\Debug"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Debug/wintorture.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalOptions="/vmg"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="..\include"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               PrecompiledHeaderFile=".\Debug/wintorture.pch"
+                               AssemblerListingLocation=".\Debug/"
+                               ObjectFile=".\Debug/"
+                               ProgramDataBaseFileName=".\Debug/"
+                               BrowseInformation="1"
+                               WarningLevel="3"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="_DEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="Kernel32.lib Psapi.lib Ws2_32.lib Mpr.lib Advapi32.lib User32.lib"
+                               OutputFile=".\Debug/wintorture.exe"
+                               LinkIncremental="2"
+                               SuppressStartupBanner="true"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile=".\Debug/wintorture.pdb"
+                               SubSystem="1"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Debug/wintorture.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+                       >
+                       <File
+                               RelativePath="..\Source\nbio.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\Source\output.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\Source\ResolveLocker.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\Source\WinThreads.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\Source\WinTorture.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl"
+                       >
+                       <File
+                               RelativePath="..\include\common.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\includes.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\proto.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\ResolveLocker.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+                       >
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/src/WINNT/tests/torture/include/ResolveLocker.h b/src/WINNT/tests/torture/include/ResolveLocker.h
new file mode 100644 (file)
index 0000000..8fdd189
--- /dev/null
@@ -0,0 +1,31 @@
+// Description: public header for the locker library
+
+#ifndef LOCKER_H
+#define LOCKER_H
+
+typedef struct {
+    int     OutputHesResolve;
+    int     MountType;
+    int     UseUnc;
+    int     useHostname;
+    int     AuthReq;
+    int     UnAuth;
+    int     addtoPath;
+    int     deletefromPath;
+    int     ForceDismount;
+    int     OutputToScreen;
+    int     SwitchCount;
+    char    Host[512];
+    char    PassWord[128];
+    char    UserName[128];
+    char    DiskDrive[128];
+    char    Locker[512];
+    char    SubMount[64];
+    char    type[16];
+    char    FileType[8];
+} USER_OPTIONS;
+
+int  attach(USER_OPTIONS attachOption, int addtoPath, int addtoFront, char *appName);
+int detach(USER_OPTIONS detachOption, int DeleteFromPath, char *appName);
+
+#endif
\ No newline at end of file
diff --git a/src/WINNT/tests/torture/include/common.h b/src/WINNT/tests/torture/include/common.h
new file mode 100644 (file)
index 0000000..488a636
--- /dev/null
@@ -0,0 +1,150 @@
+#ifndef _SCOMMON_H_
+#define _SCOMMON_H_
+
+enum states {BM_SETUP, BM_WARMUP, BM_MEASURE};
+
+#define PSTRING_LEN 2048
+#define FSTRING_LEN 512
+
+#define MAX_HANDLES 128
+#define MAX_FILES 1000
+#define ssize_t SSIZE_T
+
+#define aRONLY (1L<<0)         /* 0x01 */
+#define aHIDDEN (1L<<1)                /* 0x02 */
+#define aSYSTEM (1L<<2)                /* 0x04 */
+#define aVOLID (1L<<3)         /* 0x08 */
+#define aDIR (1L<<4)           /* 0x10 */
+#define aARCH (1L<<5)          /* 0x20 */
+
+#define FILE_DIRECTORY_FILE       0x0001
+#define FILE_WRITE_THROUGH        0x0002
+#define FILE_SEQUENTIAL_ONLY      0x0004
+#define FILE_NON_DIRECTORY_FILE   0x0040
+#define FILE_NO_EA_KNOWLEDGE      0x0200
+#define FILE_EIGHT_DOT_THREE_ONLY 0x0400
+#define FILE_RANDOM_ACCESS        0x0800
+#define FILE_DELETE_ON_CLOSE      0x1000
+
+#define CMD_CLOSE           0
+#define CMD_DELTREE         1
+#define CMD_FIND_FIRST      2
+//#define CMD_FLUSH           3
+//#define CMD_LOCKINGX        4
+#define CMD_NTCREATEX       3
+#define CMD_QUERY_FILE_INFO 4
+#define CMD_QUERY_FS_INFO   5
+#define CMD_QUERY_PATH_INFO 6
+#define CMD_READX           7
+#define CMD_RENAME          8
+#define CMD_RMDIR           9
+#define CMD_UNLINK          10
+#define CMD_WRITEX          11
+#define CMD_XCOPY           12 
+#define CMD_DELETEFILES     13 
+#define CMD_COPYFILES       14
+#define CMD_ATTACH          15
+#define CMD_DETACH          16
+#define CMD_MKDIR           17
+#define CMD_XRMDIR          18
+#define CMD_SETLOCKER       19
+#define CMD_CREATEFILE      20
+#define CMD_MOVE            21
+#define CMD_NONAFS          22
+#define CMD_MAX_CMD         23 /* KEEP THIS UP TO DATE! */
+
+typedef DWORD NTSTATUS;
+
+typedef char pstring[PSTRING_LEN];
+typedef char fstring[FSTRING_LEN];
+
+typedef struct file_info
+{
+       DWORD mode;
+       time_t mtime;
+       time_t atime;
+       time_t ctime;
+       pstring name;
+//     char short_name[13*3];
+} file_info;
+
+struct cmd_struct {
+  int   count;
+  int   ErrorCount;
+  DWORD ErrorTime;
+  DWORD MilliSeconds;
+  DWORD min_sec;
+  DWORD max_sec;
+  DWORD total_sec;
+  DWORD total_sum_of_squares;
+};
+
+static struct 
+{
+       char *name; /* name used in results */
+       char *disable_name; /* name used in disable (-d) option */
+       unsigned id; /* cmd id */
+    char *ms_api;
+} cmd_names[] = {
+       {"Close", "CLOSE", CMD_CLOSE, "(CloseHandle)"},
+       {"DelTree", "DELTREE", CMD_DELTREE, "(FindFirstFile/FindNextFile/DeleteFile/RemoveDirectory)"},
+       {"Find First", "FIND_FIRST", CMD_FIND_FIRST, "(FindFirstFile/FindNextFile)"},
+//     {"Flush", "FLUSH", CMD_FLUSH},
+//     {"Locking & X", "LOCKINGX", CMD_LOCKINGX},
+       {"NT Create & X", "NTCREATEX", CMD_NTCREATEX, "(CreateFile/CreateDirectory)"},
+       {"Query File Info", "QUERY_FILE_INFO", CMD_QUERY_FILE_INFO, "(GetFileAttributesEx)"},
+       {"Query File System Info", "QUERY_FS_INFO", CMD_QUERY_FS_INFO, "(GetDiskFreeSpaceEx)"},
+       {"Query Path Info", "QUERY_PATH_INFO", CMD_QUERY_PATH_INFO, "(GetFileAttributesEx)"},
+       {"Read & X", "READX", CMD_READX, "(SetFilePointer/ReadFile)"},
+       {"Rename", "RENAME", CMD_RENAME, "(MoveFileEx)"},
+       {"Rmdir", "RMDIR", CMD_RMDIR, "(RemoveDirectory)"},
+       {"Unlink","UNLINK", CMD_UNLINK, "(DeleteFile)"},
+       {"Write & X", "WRITEX", CMD_WRITEX, "(SetFilePointer/WriteFile/FlushFileBuffers)"},
+    {"CopyEx", "XCOPY", CMD_XCOPY, "(DOS xcopy)"},
+    {"DeleteFiles", "DELETEFILES", CMD_DELETEFILES, "(DOS del)"},
+    {"CopyFiles", "COPYFILES", CMD_COPYFILES, "(DOS copy)"},
+    {"Attach", "ATTACH", CMD_ATTACH, "(M.I.T.)"},
+    {"Detach", "DETACH", CMD_DETACH, "(M.I.T.)"},
+    {"Mkdir", "MKDIR", CMD_MKDIR, "(DOS mkdir)"},
+    {"Xrmdir", "XRMDIR", CMD_XRMDIR, "(DOS rmdir)"},
+    {"SetLocker", "SETLOCKER", CMD_SETLOCKER, "(M.I.T.)"},
+    {"CreateFile", "CREATEFILE", CMD_CREATEFILE, "(CreateFile/SetFilePointer/WriteFile/FlushFileBuffers/CloseHandle)"},
+    {"Move", "MOVE", CMD_MOVE, "(DOS move)"},
+    {"NonAFS", "NonAFS", CMD_NONAFS, ""},
+       {NULL, NULL, 0, NULL}
+};
+
+typedef struct {
+    int     ExitStatus;
+    char    Reason[1024];
+} EXIT_STATUS;
+
+typedef struct {
+        BOOL                PrintStats;
+       BOOL                *child_status_out;
+        int                 AfsTrace;
+        int                 ProcessNumber;
+        int                 BufferSize;
+        int                 CurrentLoop;
+        int                 ProcessID;
+        int                 *pThreadStatus;
+        int                 LogID;
+        struct cmd_struct   *CommandInfo;
+        char                *TargetDirectory;
+        char                *CommandLine;
+        char                *ClientText;
+        char                *PathToSecondDir;
+        char                *AfsLocker;
+        char                *HostName;
+        EXIT_STATUS         *pExitStatus;
+        } PARAMETERLIST;
+
+typedef struct {
+       int fd;
+       int handle;
+    char *name; 
+       int reads, writes;
+} FTABLE;
+
+
+#endif
\ No newline at end of file
diff --git a/src/WINNT/tests/torture/include/includes.h b/src/WINNT/tests/torture/include/includes.h
new file mode 100644 (file)
index 0000000..bdaef16
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef _INCLUDES_H
+#define _INCLUDES_H
+/* 
+   Unix SMB/CIFS implementation.
+   Machine customisation and include handling
+   Copyright (C) Andrew Tridgell 1994-1998
+   Copyright (C) 2002 by Martin Pool <mbp@samba.org>
+   
+   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
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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.
+*/
+
+//#ifndef NO_CONFIG_H /* for some tests */
+//#include "config.h"
+//#endif
+
+//#include "local.h"
+
+#ifndef _WIN32_WINNT   
+#define _WIN32_WINNT 0x0500 
+#endif 
+#include <windows.h>
+#include <io.h>
+#include <stdio.h>
+#include <process.h>
+#include <stdlib.h>
+
+#include <time.h>
+
+#undef HAVE_KRB5
+
+#define uint16 int
+#define uint32 DWORD
+
+#include "proto.h"
+
+#endif /* _INCLUDES_H */
+
diff --git a/src/WINNT/tests/torture/include/proto.h b/src/WINNT/tests/torture/include/proto.h
new file mode 100644 (file)
index 0000000..5a947d1
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef _PROTO_H_
+#define _PROTO_H_
+
+#include <common.h>
+#include <includes.h>
+
+int nb_unlink(char *fname);
+int nb_createx(char *fname, 
+               unsigned create_options, unsigned create_disposition, int handle);
+int nb_SetLocker(char *Locker);
+int nb_Mkdir(char *Directory);
+int nb_Xrmdir(char *Directory, char *type);
+int nb_Attach(char *Locker, char *Drive);
+int nb_Detach(char *Name, char *type);
+int nb_CreateFile(char *path, DWORD Size);
+int nb_CopyFile(char *source, char *destination);
+int nb_DeleteFile(char *fname);
+int nb_Move(char *Source, char *Destination);
+int nb_xcopy(char *Source, char *Destination);
+ssize_t nb_write(int fnum, char *buf, DWORD offset, size_t size);
+int nb_writex(int handle, int offset, int size, int ret_size);
+ssize_t nb_read(int fnum, char *buf, DWORD offset, size_t size);
+int nb_readx(int handle, int offset, int size, int ret_size);
+int nb_close(int handle);
+BOOL nb_close1(int fnum);
+int nb_rmdir(char *fname);
+int nb_rename(char *old, char *new);
+int nb_qpathinfo(char *fname, int Type);
+int nb_qfileinfo(int fnum);
+int nb_qfsinfo(int level);
+int nb_findfirst(char *mask);
+int nb_flush(int fnum);
+int nb_deltree(char *dname);
+int nb_cleanup(char *cname);
+int nb_lock(int handle, int offset, int size, int timeout, unsigned char locktype, NTSTATUS exp);
+
+#endif /*  _PROTO_H_  */