Build afsio on Windows; remove many warnings
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 6 Oct 2009 15:03:27 +0000 (11:03 -0400)
committerDerrick Brashear <shadow|account-1000005@unknown>
Wed, 7 Oct 2009 19:34:39 +0000 (12:34 -0700)
With this commit afsio builds on Windows.   It will not work
until the VIOC_FS_CMD OSD extension is implemented in the
Windows Cache Manager.

Required changes:

  * Export ugen_ClientInit from libafsauthent.dll

  * Fix util_GetInt64 and util_GetUInt64 to return afs_int32
    instead of afs_int64 since it is just returning success
    or error

  * Define VIOC_FS_CMD for Windows even though it isn't implemented

LICENSE BSD

Reviewed-on: http://gerrit.openafs.org/587
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/WINNT/afsd/NTMakefile
src/WINNT/afsd/afsio.rc [new file with mode: 0644]
src/WINNT/afsd/smb_iocons.h
src/libafsauthent/afsauthent.def
src/util/afsutil_prototypes.h
src/util/volparse.c
src/venus/afsio.c

index 3097fbb..77c242f 100644 (file)
@@ -165,6 +165,11 @@ CMDBGOBJS=$(OUT)\cmdebug.obj
 $(CMDBGOBJS): $(AFSROOT)\src\venus\cmdebug.c
        $(C2OBJ) -DAFS_PTHREAD_ENV /Fo$@ $**
 
+AFSIOOBJS=$(OUT)\afsio.obj
+
+$(AFSIOOBJS): $(AFSROOT)\src\venus\afsio.c
+       $(C2OBJ) -DAFS_PTHREAD_ENV /Fo$@ $**
+
 SLOBJS=$(OUT)\symlink.obj $(OUT)\fs_utils.obj
 
 ILIBDIR = $(DESTDIR)\lib
@@ -302,7 +307,10 @@ install: install_headers install_objs $(CONF_DLLFILE) \
         $(EXEDIR)\afsdacl.exe \
        $(LOGON_DLLFILE) \
        $(EXEDIR)\afsshare.exe \
-       $(DESTDIR)\bin\kpasswd.exe $(EXEDIR)\cmdebug.exe $(EXEDIR)\afscpcc.exe
+       $(DESTDIR)\bin\kpasswd.exe \
+        $(EXEDIR)\cmdebug.exe \
+        $(EXEDIR)\afscpcc.exe \
+        $(EXEDIR)\afsio.exe
 
 install_libutils: install_headers $(CONF_DLLFILE) \
        $(EXEDIR)\klog.exe \
@@ -351,6 +359,11 @@ EXELIBS2 = \
        $(DESTDIR)\lib\libosi.lib \
        $(DESTDIR)\lib\libafsconf.lib
 
+EXELIBS3 = \
+       $(DESTDIR)\lib\afs\afscmd.lib \
+       $(DESTDIR)\lib\afsrxkad.lib
+
+
 # klog.exe
 $(EXEDIR)\klog.exe: $(OUT)\cklog.obj $(OUT)\klog.res $(EXELIBS)
        $(EXECONLINK) dnsapi.lib mpr.lib iphlpapi.lib shell32.lib
@@ -444,6 +457,14 @@ $(EXEDIR)\cmdebug.exe: $(CMDBGOBJS) $(OUT)\cmdebug.res $(EXELIBS2)
         $(CODESIGN_USERLAND)
         $(SYMSTORE_IMPORT)
 
+# afsio.exe
+$(EXEDIR)\afsio.exe: $(AFSIOOBJS) $(OUT)\afsio.res $(RXOBJS) $(AFSD_EXELIBS) $(EXELIBS3)
+       $(EXECONLINK)  $(RXOBJS) $(AFSD_EXELIBS) $(EXELIBS3) dnsapi.lib mpr.lib iphlpapi.lib shell32.lib rpcrt4.lib
+        $(_VC_MANIFEST_EMBED_EXE)
+       $(EXEPREP)
+        $(CODESIGN_USERLAND)
+        $(SYMSTORE_IMPORT)
+
 # symlink.exe
 $(EXEDIR)\symlink.exe: $(SLOBJS) $(OUT)\symlink.res  $(EXELIBS)
        $(EXECONLINK) dnsapi.lib mpr.lib iphlpapi.lib shell32.lib
diff --git a/src/WINNT/afsd/afsio.rc b/src/WINNT/afsd/afsio.rc
new file mode 100644 (file)
index 0000000..c1a5dbf
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2000, International Business Machines Corporation and others.
+ * All Rights Reserved.
+ * 
+ * This software has been released under the terms of the IBM Public
+ * License.  For details, see the LICENSE file in the top-level source
+ * directory or online at http://www.openafs.org/dl/license10.html
+ */
+
+/* Define VERSIONINFO resource */
+
+#define  AFS_VERINFO_FILE_DESCRIPTION "AFS Input Output Command"
+#define AFS_VERINFO_NAME "afsio"
+#define AFS_VERINFO_FILENAME "afsio.exe"
+
+#include "AFS_component_version_number.h"
+#include "..\..\config\NTVersioninfo.rc"
index d060197..9ecb139 100644 (file)
@@ -97,6 +97,7 @@ struct sbstruct {
 #define VIOC_UNICODECTL                 0x33
 #define VIOC_SETOWNER                   0x34
 #define VIOC_SETGROUP                   0x35
+#define VIOC_FS_CMD                     0x36
 
 #define VIOC_VOLSTAT_TEST               0x3F
 
index cd33f9f..16844ff 100644 (file)
@@ -139,3 +139,4 @@ EXPORTS
         ubik_PR_UpdateEntry                            @137
         ubik_PR_ListEntries                            @138
         ubik_PR_ListSuperGroups                                @139
+        ugen_ClientInit                                 @140
index a05a64e..2e948bf 100644 (file)
@@ -201,8 +201,8 @@ extern afs_int32 volutil_PartitionName2_r(afs_int32 part, char *tbuffer, size_t
 extern char *volutil_PartitionName(int avalue);
 extern afs_int32 util_GetInt32(register char *as, afs_int32 * aval);
 extern afs_uint32 util_GetUInt32(register char *as, afs_uint32 * aval);
-extern afs_int64 util_GetInt64(char *as, afs_int64 * aval);
-extern afs_uint64 util_GetUInt64(char *as, afs_uint64 * aval);
+extern afs_int32 util_GetInt64(char *as, afs_int64 * aval);
+extern afs_uint32 util_GetUInt64(char *as, afs_uint64 * aval);
 extern afs_int32 util_GetHumanInt32(register char *as, afs_int32 * aval);
 
 /* winsock_nt.c */
index cb96935..43f1181 100644 (file)
@@ -342,7 +342,7 @@ util_GetHumanInt32(register char *as, afs_int32 * aval)
     return 0;
 }
 
-afs_int64
+afs_int32
 util_GetInt64(char *as, afs_int64 * aval)
 {
     afs_int64 total;
@@ -392,7 +392,7 @@ util_GetInt64(char *as, afs_int64 * aval)
     return 0;
 }
 
-afs_uint64
+afs_uint32
 util_GetUInt64(char *as, afs_uint64 * aval)
 {
     afs_uint64 total;
index 94bde8f..129bc31 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <afsconfig.h>
 #include <afs/param.h>
+#include <afs/stds.h>
 
 #include <stdio.h>
 #include <setjmp.h>
 #include <string.h>
 #include <ctype.h>
 #ifdef AFS_NT40_ENV
+#include <windows.h>
+#include <winsock2.h>
+#define _CRT_RAND_S
+#include <stdlib.h>
+#include <process.h>
 #include <fcntl.h>
+#include <io.h>
+#include <afs/smb_iocons.h>
+#include <afs/afsd.h>
+#include <afs/cm_ioctl.h>
+#include <afs/pioctl_nt.h>
 #else
 #include <sys/param.h>
 #include <sys/file.h>
 #include <netdb.h>
 #include <string.h>
 #include <fcntl.h>
+#include <pwd.h>
+#include <afs/venus.h>
+#include <sys/time.h>
+#include <netdb.h>
+#include <afs/afsint.h>
+#define FSINT_COMMON_XG 1
 #endif
 #include <sys/stat.h>
 #include <errno.h>
-#include <pwd.h>
 #include <signal.h>
 #include <afs/vice.h>
 #include <afs/cmd.h>
 #include <afs/afsutil.h>
 #include <rx/rx.h>
 #include <rx/xdr.h>
-#include <afs/venus.h>
 #include <afs/afscbint.h>
-#define FSINT_COMMON_XG 1
-#include <afs/afsint.h>
 #include <afs/vldbint.h>
 #include <afs/vlserver.h>
 #include <afs/volser.h>
@@ -68,7 +81,6 @@
 #include <afs/dir.h>
 #include <afs/nfs.h>
 #include <afs/ihandle.h>
-#include <afs/namei_ops.h>
 #include <afs/vnode.h>
 #include <afs/com_err.h>
 #ifdef HAVE_DIRENT_H
@@ -77,8 +89,6 @@
 #ifdef HAVE_DIRECT_H
 #include <direct.h>
 #endif
-#include <sys/time.h>
-#include <netdb.h>
 #ifdef AFS_DARWIN_ENV
 #include <sys/malloc.h>
 #else
@@ -176,8 +186,8 @@ struct FsCmdOutputs PioctlOutputs;
 void
 printDatarate(void)
 {
-    seconds = now.tv_sec + now.tv_usec *.000001
-       -opentime.tv_sec - opentime.tv_usec *.000001;
+    seconds = (float)(now.tv_sec + now.tv_usec *.000001
+       -opentime.tv_sec - opentime.tv_usec *.000001);
     if ((seconds - oldseconds) > 30.) {
        afs_int64 tmp;
        tmp = xfered - oldxfered;
@@ -614,7 +624,7 @@ InitializeCBService(void)
 #define LWP_STACK_SIZE (16 * 1024)
     afs_int32 code;
 #ifdef AFS_PTHREAD_ENV
-    pthread_t CBservicePid, parentPid;
+    pthread_t CBservicePid;
     pthread_attr_t tattr;
 #else
     PROCESS CBServiceLWP_ID, parentPid;
@@ -643,8 +653,13 @@ InitializeCBService(void)
     srand48(getpid());
     InitialCBPort = RESTOOL_CBPORT + lrand48() % 1000;
 #else /* AFS_HPUX_ENV */
+#if defined AFS_NT40_ENV
+    srand(_getpid());
+    InitialCBPort = RESTOOL_CBPORT + rand() % 1000;
+#else /* AFS_NT40_ENV */
     srand(getpid());
     InitialCBPort = RESTOOL_CBPORT + rand() % 1000;
+#endif /* AFS_NT40_ENV */
 #endif /* AFS_HPUX_ENV */
 #endif /* AFS_AIX_ENV || AFS_SUN_ENV || AFS_OSF_ENV || AFS_SGI_ENV */
 
@@ -1019,8 +1034,8 @@ readFile(struct cmd_syndesc *as, void *unused)
 #endif /* NO_AFS_CLIENT */
         gettimeofday(&opentime, &Timezone);
        if (verbose) {
-            seconds = opentime.tv_sec + opentime.tv_usec *.000001
-               -starttime.tv_sec - starttime.tv_usec *.000001;
+            seconds = (float)(opentime.tv_sec + opentime.tv_usec *.000001
+               -starttime.tv_sec - starttime.tv_usec *.000001);
            fprintf(stderr,"Startup to find the file took %.3f sec.\n",
                    seconds);
        }
@@ -1034,9 +1049,9 @@ readFile(struct cmd_syndesc *as, void *unused)
             tcall = rx_NewCall(RXConn);
             code = StartAFS_FetchData64 (tcall, &Fid, Pos, Len);
             if (code == RXGEN_OPCODE) {
-               afs_uint32 tmpPos,  tmpLen;
-               tmpPos = Pos; tmpLen = Len;
-                code = StartAFS_FetchData (tcall, &Fid, Pos, Len);
+               afs_int32 tmpPos,  tmpLen;
+               tmpPos = (afs_int32)Pos; tmpLen = (afs_int32)Len;
+                code = StartAFS_FetchData (tcall, &Fid, tmpPos, tmpLen);
                bytes = rx_Read(tcall, (char *)&low, sizeof(afs_int32));
                length = ntohl(low);
                if (bytes != 4) code = -3;
@@ -1062,7 +1077,7 @@ readFile(struct cmd_syndesc *as, void *unused)
            if (length > bufflen)
                len = bufflen;
            else
-               len = length;
+               len = (afs_int32) length;
            buf = (char *)malloc(len);
            if (!buf) {
                fprintf(stderr, "couldn't allocate buffer\n");
@@ -1072,7 +1087,7 @@ readFile(struct cmd_syndesc *as, void *unused)
                if (length > bufflen)
                    len = bufflen;
                else
-                   len = length;
+                   len = (afs_int32) length;
                bytes = rx_Read(tcall, (char *) buf, len);
                if (bytes != len) {
                    code = -3;
@@ -1116,8 +1131,8 @@ readFile(struct cmd_syndesc *as, void *unused)
                    htonl(md5int[2]), htonl(md5int[3]), p);
         }
        if(verbose) {
-            seconds = readtime.tv_sec + readtime.tv_usec *.000001
-               -opentime.tv_sec - opentime.tv_usec *.000001;
+            seconds = (float)(readtime.tv_sec + readtime.tv_usec *.000001
+               -opentime.tv_sec - opentime.tv_usec *.000001);
             fprintf(stderr,"Transfer of %llu bytes took %.3f sec.\n",
                    xfered, seconds);
             datarate = (xfered >> 20) / seconds;
@@ -1148,7 +1163,7 @@ writeFile(struct cmd_syndesc *as, void *unused)
     afs_int64 Pos;
     afs_int64 length, Len, synthlength = 0, offset = 0;
     u_char vnode = 0;
-    int bytes;
+    afs_int64 bytes;
     int worstCode = 0;
     int append = 0;
     int synthesize = 0;
@@ -1240,17 +1255,17 @@ writeFile(struct cmd_syndesc *as, void *unused)
        memset(tbuf, 0, sizeof(struct wbuf));
        tbuf->buflen = BUFFLEN;
        if (synthesize) {
-           afs_int32 ll, l = tbuf->buflen;
+           afs_int64 ll, l = tbuf->buflen;
            if (l > synthlength)
                l = synthlength;
            for (ll = 0; ll < l; ll += 4096) {
                 sprintf(&tbuf->buf[ll],"Offset (0x%x, 0x%x)\n",
-                       (unsigned int)(offset >> 32),
-                       (unsigned int)(offset & 0xffffffff) + ll);
+                       (unsigned int)((offset + ll) >> 32),
+                       (unsigned int)((offset + ll) & 0xffffffff));
            }
            offset += l;
            synthlength -= l;
-           tbuf->used = l;
+           tbuf->used = (afs_int32)l;
        } else
            tbuf->used = read(0, &tbuf->buf, tbuf->buflen);
        if (!tbuf->used) {
@@ -1265,8 +1280,8 @@ writeFile(struct cmd_syndesc *as, void *unused)
     }
     gettimeofday(&opentime, &Timezone);
     if (verbose) {
-        seconds = opentime.tv_sec + opentime.tv_usec *.000001
-           -starttime.tv_sec - starttime.tv_usec *.000001;
+        seconds = (float) (opentime.tv_sec + opentime.tv_usec *.000001
+           -starttime.tv_sec - starttime.tv_usec *.000001);
         fprintf(stderr,"Startup to find the file took %.3f sec.\n",
                seconds);
     }
@@ -1279,8 +1294,8 @@ writeFile(struct cmd_syndesc *as, void *unused)
         code = StartAFS_StoreData64 (tcall, &Fid, &InStatus, Pos, Len, Pos+Len);
         if (code == RXGEN_OPCODE) {
            afs_uint32 tmpLen, tmpPos;
-           tmpPos = Pos;
-           tmpLen = Len;
+           tmpPos = (afs_int32) Pos;
+           tmpLen = (afs_int32) Len;
            if (Pos+Len > 0x7fffffff) {
                fprintf(stderr,"AFS fileserver does not support files >= 2 GB\n");
                return EFBIG;
@@ -1340,17 +1355,17 @@ writeFile(struct cmd_syndesc *as, void *unused)
             for (tbuf = bufchain; tbuf; tbuf=tbuf->next) {
                tbuf->offset = 0;
                if (synthesize) {
-                   afs_int32 ll, l = tbuf->buflen;
+                   afs_int64 ll, l = tbuf->buflen;
                    if (l > synthlength)
                        l = synthlength;
                    for (ll = 0; ll < l; ll += 4096) {
-                     sprintf(&tbuf->buf[ll],"Offset (0x%x, 0x%x)\n",
-                             (unsigned int)(offset >> 32),
-                             (unsigned int)(offset & 0xffffffff) + ll);
+                       sprintf(&tbuf->buf[ll],"Offset (0x%x, 0x%x)\n",
+                               (unsigned int)((offset + ll) >> 32),
+                               (unsigned int)((offset + ll) & 0xffffffff));
                    }
                    offset += l;
                    synthlength -= l;
-                   tbuf->used = l;
+                   tbuf->used = (afs_int32) l;
                } else
                    tbuf->used = read(0, &tbuf->buf, tbuf->buflen);
                if (!tbuf->used)
@@ -1366,8 +1381,8 @@ writeFile(struct cmd_syndesc *as, void *unused)
     if (worstCode) {
        fprintf(stderr,"%s failed with code %d\n", as->name, worstCode);
     } else if(verbose) {
-        seconds = writetime.tv_sec + writetime.tv_usec *.000001
-           -opentime.tv_sec - opentime.tv_usec *.000001;
+        seconds = (float) (writetime.tv_sec + writetime.tv_usec *.000001
+           -opentime.tv_sec - opentime.tv_usec *.000001);
         fprintf(stderr,"Transfer of %llu bytes took %.3f sec.\n",
                xfered, seconds);
         datarate = (xfered >> 20) / seconds;