From 811418887df505b9012a96802aa3dc3281b302e7 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 6 Oct 2009 11:03:27 -0400 Subject: [PATCH] Build afsio on Windows; remove many warnings 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 Tested-by: Jeffrey Altman Tested-by: Derrick Brashear Reviewed-by: Derrick Brashear --- src/WINNT/afsd/NTMakefile | 23 ++++++++- src/WINNT/afsd/afsio.rc | 17 +++++++ src/WINNT/afsd/smb_iocons.h | 1 + src/libafsauthent/afsauthent.def | 1 + src/util/afsutil_prototypes.h | 4 +- src/util/volparse.c | 4 +- src/venus/afsio.c | 85 +++++++++++++++++++------------- 7 files changed, 95 insertions(+), 40 deletions(-) create mode 100644 src/WINNT/afsd/afsio.rc diff --git a/src/WINNT/afsd/NTMakefile b/src/WINNT/afsd/NTMakefile index 3097fbb00..77c242f88 100644 --- a/src/WINNT/afsd/NTMakefile +++ b/src/WINNT/afsd/NTMakefile @@ -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 index 000000000..c1a5dbfaa --- /dev/null +++ b/src/WINNT/afsd/afsio.rc @@ -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" diff --git a/src/WINNT/afsd/smb_iocons.h b/src/WINNT/afsd/smb_iocons.h index d0601977a..9ecb13970 100644 --- a/src/WINNT/afsd/smb_iocons.h +++ b/src/WINNT/afsd/smb_iocons.h @@ -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 diff --git a/src/libafsauthent/afsauthent.def b/src/libafsauthent/afsauthent.def index cd33f9f62..16844ffe7 100644 --- a/src/libafsauthent/afsauthent.def +++ b/src/libafsauthent/afsauthent.def @@ -139,3 +139,4 @@ EXPORTS ubik_PR_UpdateEntry @137 ubik_PR_ListEntries @138 ubik_PR_ListSuperGroups @139 + ugen_ClientInit @140 diff --git a/src/util/afsutil_prototypes.h b/src/util/afsutil_prototypes.h index a05a64ea5..2e948bfc3 100644 --- a/src/util/afsutil_prototypes.h +++ b/src/util/afsutil_prototypes.h @@ -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 */ diff --git a/src/util/volparse.c b/src/util/volparse.c index cb969357b..43f1181b4 100644 --- a/src/util/volparse.c +++ b/src/util/volparse.c @@ -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; diff --git a/src/venus/afsio.c b/src/venus/afsio.c index 94bde8f46..129bc3180 100644 --- a/src/venus/afsio.c +++ b/src/venus/afsio.c @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -34,7 +35,17 @@ #include #include #ifdef AFS_NT40_ENV +#include +#include +#define _CRT_RAND_S +#include +#include #include +#include +#include +#include +#include +#include #else #include #include @@ -45,10 +56,15 @@ #include #include #include +#include +#include +#include +#include +#include +#define FSINT_COMMON_XG 1 #endif #include #include -#include #include #include #include @@ -57,10 +73,7 @@ #include #include #include -#include #include -#define FSINT_COMMON_XG 1 -#include #include #include #include @@ -68,7 +81,6 @@ #include #include #include -#include #include #include #ifdef HAVE_DIRENT_H @@ -77,8 +89,6 @@ #ifdef HAVE_DIRECT_H #include #endif -#include -#include #ifdef AFS_DARWIN_ENV #include #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; -- 2.39.5