[Pvfs2-cvs] commit by sampson in pvfs2/src/client/windows/client-service: dokan-interface.c fs.c fs.h service-main.c

CVS commit program cvs at parl.clemson.edu
Sat Dec 18 14:31:51 EST 2010


Update of /projects/cvsroot/pvfs2/src/client/windows/client-service
In directory parlweb1:/tmp/cvs-serv28251/src/client/windows/client-service

Modified Files:
      Tag: windows-client
	dokan-interface.c fs.c fs.h service-main.c 
Log Message:
Coding Windows client


Index: dokan-interface.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/windows/client-service/Attic/dokan-interface.c,v
diff -p -u -r1.1.2.8 -r1.1.2.9
--- dokan-interface.c	16 Dec 2010 23:01:00 -0000	1.1.2.8
+++ dokan-interface.c	18 Dec 2010 19:31:51 -0000	1.1.2.9
@@ -10,19 +10,55 @@
 #include "str-utils.h"
 #include "fs.h"
 
+FILE *g_DebugFile = NULL;
 BOOL g_UseStdErr;
 BOOL g_DebugMode;
 
-#define PVFS2_DOKAN_CHECKFLAG(val, flag) if (val&flag) { DbgPrint("\t" #flag "\n"); }
+#define DEBUG_FLAG(val, flag) if (val&flag) { DbgPrint("   "#flag"\n"); }
 
 /* TODO */
-#define MALLOC_CHECK(ptr)
+#define MALLOC_CHECK(ptr)   if (ptr == NULL) \
+                                return -ERROR_NOT_ENOUGH_MEMORY
+
+#define DEBUG_PATH(path)   DbgPrint("   resolved path: %s\n", path)
+
+static void DbgInit()
+{
+    char temp_path[MAX_PATH];
+    int ret;
+
+    ret = GetTempPath(MAX_PATH, temp_path);
+    if (ret != 0)
+    {
+        strcat(temp_path, "pvfs.log");
+
+        g_DebugFile = fopen(temp_path, "w");
+    }
+
+#if 0
+    char temp_path[MAX_PATH], temp_file[MAX_PATH];
+    int err;
+
+    /* Create log in temporary directory */
+    err = GetTempPath(MAX_PATH, temp_path);
+    if (err != 0)
+    {
+        err = GetTempFileName(temp_path, "OFS", 0, temp_file);
+        if (err != 0) 
+        {
+            g_DebugFile = fopen(temp_file, "w");
+        }
+    }
+#endif
+
+}
 
 static void DbgPrint(LPCSTR format, ...)
 {
     if (g_DebugMode) 
     {
         char buffer[512];
+        SYSTEMTIME sys_time;
     
         va_list argp;
         va_start(argp, format);
@@ -36,9 +72,27 @@ static void DbgPrint(LPCSTR format, ...)
         {
             OutputDebugString(buffer);
         }
+
+        /* log to file */
+        if (g_DebugFile != NULL)
+        {
+            GetLocalTime(&sys_time);
+            fprintf(g_DebugFile, "[%d-%02d-%02d %02d:%02d:%02d.%03d] (%u) %s", 
+                    sys_time.wYear, sys_time.wMonth, sys_time.wDay, 
+                    sys_time.wHour, sys_time.wMinute, sys_time.wSecond, sys_time.wMilliseconds,
+                    GetThreadId(GetCurrentThread()),
+                    buffer);
+            fflush(g_DebugFile);
+        }
     }
 }
 
+static void DbgClose()
+{
+    if (g_DebugFile != NULL)
+        fclose(g_DebugFile);
+}
+
 static char RootDirectory[MAX_PATH] = "C:";
 
 static void
@@ -70,7 +124,8 @@ static char *convert_wstring(const wchar
     /* allocate buffer */
     mb_size = ret;
     mbstr = (char *) malloc(mb_size);
-    MALLOC_CHECK(mbstr);
+    if (mbstr == NULL)
+        return NULL;
 
     /* convert string */
     err = wcstombs_s(&ret, mbstr, mb_size, wcstr, wcslen(wcstr));
@@ -104,7 +159,8 @@ static wchar_t *convert_mbstring(const c
 
     w_size = ret;
     wstr = (wchar_t *) malloc(w_size * sizeof(wchar_t));
-    MALLOC_CHECK(wstr);
+    if (wstr == NULL)
+        return NULL;
 
     /* convert string */
     err = mbstowcs_s(&ret, wstr, w_size, mbstr, strlen(mbstr));
@@ -124,7 +180,7 @@ static wchar_t *convert_mbstring(const c
 
 /* convert PVFS time to Windows FILETIME 
    (from MSDN Knowledgebase) */
-void convert_time(time_t t, LPFILETIME pft)
+static void convert_pvfstime(time_t t, LPFILETIME pft)
 {
     LONGLONG ll;
 
@@ -134,8 +190,19 @@ void convert_time(time_t t, LPFILETIME p
 }
 
 
-static int
-PVFS2_Dokan_create_file(
+static void convert_filetime(LPFILETIME pft, PVFS_time *t)
+{
+    LONGLONG ll;
+
+    ll = (LONGLONG) pft->dwHighDateTime << 32;
+    ll |= pft->dwLowDateTime;
+    ll -= 116444736000000000;
+    *t = ll / 10000000LL;
+}
+
+
+static int __stdcall
+PVFS_Dokan_create_file(
     LPCWSTR          FileName,
     DWORD            AccessMode,
     DWORD            ShareMode,
@@ -144,13 +211,12 @@ PVFS2_Dokan_create_file(
     PDOKAN_FILE_INFO DokanFileInfo)
 {
     char *local_path, *fs_path;
-    DWORD fileAttr;
     int ret, found, err;
     PVFS_handle handle;
     PVFS_sys_attr attr;
 
 
-    DbgPrint("CreateFile : %S\n", FileName);
+    DbgPrint("CreateFile: %S\n", FileName);
     
     if (CreationDisposition == CREATE_NEW)
         DbgPrint("\tCREATE_NEW\n");
@@ -172,32 +238,32 @@ PVFS2_Dokan_create_file(
 
     DbgPrint("\tShareMode = 0x%x\n", ShareMode);
 
-    PVFS2_DOKAN_CHECKFLAG(ShareMode, FILE_SHARE_READ);
-    PVFS2_DOKAN_CHECKFLAG(ShareMode, FILE_SHARE_WRITE);
-    PVFS2_DOKAN_CHECKFLAG(ShareMode, FILE_SHARE_DELETE);
+    DEBUG_FLAG(ShareMode, FILE_SHARE_READ);
+    DEBUG_FLAG(ShareMode, FILE_SHARE_WRITE);
+    DEBUG_FLAG(ShareMode, FILE_SHARE_DELETE);
 
     DbgPrint("\tAccessMode = 0x%x\n", AccessMode);
 
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, GENERIC_READ);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, GENERIC_WRITE);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, GENERIC_EXECUTE);
+    DEBUG_FLAG(AccessMode, GENERIC_READ);
+    DEBUG_FLAG(AccessMode, GENERIC_WRITE);
+    DEBUG_FLAG(AccessMode, GENERIC_EXECUTE);
     
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, DELETE);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, FILE_READ_DATA);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, FILE_READ_ATTRIBUTES);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, FILE_READ_EA);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, READ_CONTROL);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, FILE_WRITE_DATA);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, FILE_WRITE_ATTRIBUTES);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, FILE_WRITE_EA);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, FILE_APPEND_DATA);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, WRITE_DAC);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, WRITE_OWNER);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, SYNCHRONIZE);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, FILE_EXECUTE);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, STANDARD_RIGHTS_READ);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, STANDARD_RIGHTS_WRITE);
-    PVFS2_DOKAN_CHECKFLAG(AccessMode, STANDARD_RIGHTS_EXECUTE);
+    DEBUG_FLAG(AccessMode, DELETE);
+    DEBUG_FLAG(AccessMode, FILE_READ_DATA);
+    DEBUG_FLAG(AccessMode, FILE_READ_ATTRIBUTES);
+    DEBUG_FLAG(AccessMode, FILE_READ_EA);
+    DEBUG_FLAG(AccessMode, READ_CONTROL);
+    DEBUG_FLAG(AccessMode, FILE_WRITE_DATA);
+    DEBUG_FLAG(AccessMode, FILE_WRITE_ATTRIBUTES);
+    DEBUG_FLAG(AccessMode, FILE_WRITE_EA);
+    DEBUG_FLAG(AccessMode, FILE_APPEND_DATA);
+    DEBUG_FLAG(AccessMode, WRITE_DAC);
+    DEBUG_FLAG(AccessMode, WRITE_OWNER);
+    DEBUG_FLAG(AccessMode, SYNCHRONIZE);
+    DEBUG_FLAG(AccessMode, FILE_EXECUTE);
+    DEBUG_FLAG(AccessMode, STANDARD_RIGHTS_READ);
+    DEBUG_FLAG(AccessMode, STANDARD_RIGHTS_WRITE);
+    DEBUG_FLAG(AccessMode, STANDARD_RIGHTS_EXECUTE);
 
     // When filePath is a directory, needs to change the flag so that the file can be opened.
     /*
@@ -207,37 +273,36 @@ PVFS2_Dokan_create_file(
         //AccessMode = 0;
     }
     */
-    DbgPrint("\tFlagsAndAttributes = 0x%x\n", FlagsAndAttributes);
-
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_ATTRIBUTE_ARCHIVE);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_ATTRIBUTE_ENCRYPTED);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_ATTRIBUTE_HIDDEN);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_ATTRIBUTE_NORMAL);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_ATTRIBUTE_OFFLINE);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_ATTRIBUTE_READONLY);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_ATTRIBUTE_SYSTEM);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_ATTRIBUTE_TEMPORARY);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_FLAG_WRITE_THROUGH);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_FLAG_OVERLAPPED);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_FLAG_NO_BUFFERING);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_FLAG_RANDOM_ACCESS);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_FLAG_SEQUENTIAL_SCAN);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_FLAG_DELETE_ON_CLOSE);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_FLAG_BACKUP_SEMANTICS);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_FLAG_POSIX_SEMANTICS);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_FLAG_OPEN_REPARSE_POINT);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, FILE_FLAG_OPEN_NO_RECALL);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, SECURITY_ANONYMOUS);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, SECURITY_IDENTIFICATION);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, SECURITY_IMPERSONATION);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, SECURITY_DELEGATION);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, SECURITY_CONTEXT_TRACKING);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, SECURITY_EFFECTIVE_ONLY);
-    PVFS2_DOKAN_CHECKFLAG(FlagsAndAttributes, SECURITY_SQOS_PRESENT);
+    DbgPrint("   FlagsAndAttributes = 0x%x\n", FlagsAndAttributes);
 
-    DbgPrint("\n");
+    DEBUG_FLAG(FlagsAndAttributes, FILE_ATTRIBUTE_ARCHIVE);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_ATTRIBUTE_ENCRYPTED);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_ATTRIBUTE_HIDDEN);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_ATTRIBUTE_NORMAL);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_ATTRIBUTE_OFFLINE);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_ATTRIBUTE_READONLY);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_ATTRIBUTE_SYSTEM);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_ATTRIBUTE_TEMPORARY);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_FLAG_WRITE_THROUGH);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_FLAG_OVERLAPPED);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_FLAG_NO_BUFFERING);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_FLAG_RANDOM_ACCESS);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_FLAG_SEQUENTIAL_SCAN);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_FLAG_DELETE_ON_CLOSE);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_FLAG_BACKUP_SEMANTICS);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_FLAG_POSIX_SEMANTICS);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_FLAG_OPEN_REPARSE_POINT);
+    DEBUG_FLAG(FlagsAndAttributes, FILE_FLAG_OPEN_NO_RECALL);
+    DEBUG_FLAG(FlagsAndAttributes, SECURITY_ANONYMOUS);
+    DEBUG_FLAG(FlagsAndAttributes, SECURITY_IDENTIFICATION);
+    DEBUG_FLAG(FlagsAndAttributes, SECURITY_IMPERSONATION);
+    DEBUG_FLAG(FlagsAndAttributes, SECURITY_DELEGATION);
+    DEBUG_FLAG(FlagsAndAttributes, SECURITY_CONTEXT_TRACKING);
+    DEBUG_FLAG(FlagsAndAttributes, SECURITY_EFFECTIVE_ONLY);
+    DEBUG_FLAG(FlagsAndAttributes, SECURITY_SQOS_PRESENT);
 
+    /* convert from Unicode */
     local_path = convert_wstring(FileName);
     if (local_path == NULL)
     {
@@ -254,9 +319,14 @@ PVFS2_Dokan_create_file(
         return -1;
     }
 
+    DEBUG_PATH(fs_path);
+
     /* look up the file */
     found = 0;
     ret = fs_lookup(fs_path, &handle);    
+
+    DbgPrint("   fs_lookup returns: %d\n", ret);
+
     if (ret == -PVFS_ENOENT)
     {
         found = 0;
@@ -317,7 +387,7 @@ PVFS2_Dokan_create_file(
         }
     }
 
-    DbgPrint("Return code: %d\n", ret);
+    DbgPrint("    fs_create/fs_truncate returns: %d\n", ret);
 
     switch (ret)
     {
@@ -326,7 +396,7 @@ PVFS2_Dokan_create_file(
         /* save the file handle in context */
         DokanFileInfo->Context = handle;
 
-        DbgPrint("Context: %llx\n", DokanFileInfo->Context);
+        DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
 
         /* determine whether this is a directory */
         ret = fs_getattr(fs_path, &attr);
@@ -350,13 +420,15 @@ PVFS2_Dokan_create_file(
 
     free(local_path);
     free(fs_path);
+
+    DbgPrint("CreateFile exit: %d\n", err);
         
     return err;
 }
 
 
-static int
-PVFS2_Dokan_create_directory(
+static int __stdcall
+PVFS_Dokan_create_directory(
     LPCWSTR          FileName,
     PDOKAN_FILE_INFO DokanFileInfo)
 {
@@ -364,7 +436,7 @@ PVFS2_Dokan_create_directory(
     int ret, err;
     PVFS_handle handle;
 
-    DbgPrint("CreateDirectory : %S\n", FileName);
+    DbgPrint("CreateDirectory: %S\n", FileName);
 
     local_path = convert_wstring(FileName);
     if (local_path == NULL)
@@ -383,8 +455,12 @@ PVFS2_Dokan_create_directory(
         return -1;
     }
 
+    DEBUG_PATH(fs_path);
+
     ret = fs_mkdir(fs_path, &handle);
 
+    DbgPrint("   fs_mkdir returns: %d\n", ret);
+
     switch (ret)
     {
     case 0: 
@@ -405,12 +481,14 @@ PVFS2_Dokan_create_directory(
     free(local_path);
     free(fs_path);
 
+    DbgPrint("CreateDirectory exit: %d\n", err);
+
     return err;
 }
 
 
-static int
-PVFS2_Dokan_open_directory(
+static int __stdcall
+PVFS_Dokan_open_directory(
     LPCWSTR          FileName,
     PDOKAN_FILE_INFO DokanFileInfo)
 {
@@ -419,7 +497,7 @@ PVFS2_Dokan_open_directory(
     PVFS_handle handle;
     PVFS_sys_attr attr;
 
-    DbgPrint("OpenDirectory : %S\n", FileName);
+    DbgPrint("OpenDirectory: %S\n", FileName);
 
     /* convert from Unicode */
     local_path = convert_wstring(FileName);
@@ -439,12 +517,17 @@ PVFS2_Dokan_open_directory(
         return -1;
     }
 
+    DEBUG_PATH(fs_path);
+
     /* lookup the file */
     ret = fs_lookup(fs_path, &handle);    
 
+    DbgPrint("   fs_lookup returns: %d\n", ret);
+
     if (ret == 0)
     {
         ret = fs_getattr(fs_path, &attr);
+        DbgPrint("   fs_getattr returns: %d\n", ret);
         if (ret == 0)
         {
             if (!(attr.objtype & PVFS_TYPE_DIRECTORY))
@@ -473,13 +556,15 @@ PVFS2_Dokan_open_directory(
 
     free(local_path);
     free(fs_path);
+
+    DbgPrint("OpenDirectory exit: %d\n", err);
     
     return err;
 }
 
 
-static int
-PVFS2_Dokan_close_file(
+static int __stdcall
+PVFS_Dokan_close_file(
     LPCWSTR          FileName,
     PDOKAN_FILE_INFO DokanFileInfo)
 {
@@ -490,12 +575,14 @@ PVFS2_Dokan_close_file(
        Simply clear the handle and return success */
     DokanFileInfo->Context = 0;
 
+    DbgPrint("CloseFile exit: %d\n", 0);
+
     return 0;
 }
 
 
-static int
-PVFS2_Dokan_cleanup(
+static int __stdcall
+PVFS_Dokan_cleanup(
     LPCWSTR          FileName,
     PDOKAN_FILE_INFO DokanFileInfo)
 {
@@ -518,12 +605,14 @@ PVFS2_Dokan_cleanup(
         return -1;
     }
 
+    DbgPrint("Cleanup exit: %d\n", 0);
+
     return 0;
 }
 
 
-static int
-PVFS2_Dokan_read_file(
+static int __stdcall
+PVFS_Dokan_read_file(
     LPCWSTR          FileName,
     LPVOID           Buffer,
     DWORD            BufferLength,
@@ -537,6 +626,11 @@ PVFS2_Dokan_read_file(
     DbgPrint("ReadFile: %S\n", FileName);
     DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
 
+    if (FileName == NULL || wcslen(FileName) == 0 ||
+        Buffer == NULL || BufferLength == 0 || 
+        ReadLength == 0)
+        return -1;
+
     /* convert from Unicode */
     local_path = convert_wstring(FileName);
     if (local_path == NULL)
@@ -554,11 +648,13 @@ PVFS2_Dokan_read_file(
         free(fs_path);
         return -1;
     }
+
+    DEBUG_PATH(fs_path);
     
     /* perform the read operation */
-    ret = fs_read(fs_path, Buffer, BufferLength, Offset, (size_t *) ReadLength);
+    ret = fs_read(fs_path, Buffer, BufferLength, Offset, (PVFS_size *) ReadLength);
 
-    DbgPrint("   fs_read returns %d\n", ret);
+    DbgPrint("   fs_read returns: %d\n", ret);
 
     switch (ret)
     {
@@ -569,12 +665,14 @@ PVFS2_Dokan_read_file(
         err = -1;
     }
 
+    DbgPrint("ReadFile exit: %d\n", err);
+
     return err;
 }
 
 
-static int
-PVFS2_Dokan_write_file(
+static int __stdcall
+PVFS_Dokan_write_file(
     LPCWSTR          FileName,
     LPCVOID          Buffer,
     DWORD            NumberOfBytesToWrite,
@@ -605,12 +703,14 @@ PVFS2_Dokan_write_file(
         free(fs_path);
         return -1;
     }
+
+    DEBUG_PATH(fs_path);
     
     /* perform the read operation */
     ret = fs_write(fs_path, (void *) Buffer, NumberOfBytesToWrite, Offset, 
-                   (size_t *) NumberOfBytesWritten);
+                   (PVFS_size *) NumberOfBytesWritten);
 
-    DbgPrint("   fs_write returns %d\n", ret);
+    DbgPrint("   fs_write returns: %d\n", ret);
 
     switch (ret)
     {
@@ -621,19 +721,21 @@ PVFS2_Dokan_write_file(
         err = -1;
     }
 
+    DbgPrint("WriteFile exit: %d\n", err);
+
     return err;
 }
 
 
-static int
-PVFS2_Dokan_flush_file_buffers(
+static int __stdcall
+PVFS_Dokan_flush_file_buffers(
     LPCWSTR          FileName,
     PDOKAN_FILE_INFO DokanFileInfo)
 {
     char *local_path, *fs_path;
     int ret, err;
 
-    DbgPrint("FlushFileBuffers : %S\n", FileName);
+    DbgPrint("FlushFileBuffers: %S\n", FileName);
     DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
 
     /* convert from Unicode */
@@ -654,10 +756,12 @@ PVFS2_Dokan_flush_file_buffers(
         return -1;
     }
 
+    DEBUG_PATH(fs_path);
+
     /* flush the file */
     ret = fs_flush(fs_path);
 
-    DbgPrint("   fs_flush returns %d\n", ret);
+    DbgPrint("   fs_flush returns: %d\n", ret);
 
     switch (ret)
     {
@@ -671,12 +775,14 @@ PVFS2_Dokan_flush_file_buffers(
     free(fs_path);
     free(local_path);
 
+    DbgPrint("FlushFileBuffers exit: %d\n", err);
+
     return err;
 }
 
 
-static int
-PVFS2_Dokan_get_file_information(
+static int __stdcall
+PVFS_Dokan_get_file_information(
     LPCWSTR                      FileName,
     LPBY_HANDLE_FILE_INFORMATION HandleFileInformation,
     PDOKAN_FILE_INFO             DokanFileInfo)
@@ -685,7 +791,7 @@ PVFS2_Dokan_get_file_information(
     int ret, err;
     PVFS_sys_attr attr;
 
-    DbgPrint("GetFileInfo : %S\n", FileName);
+    DbgPrint("GetFileInfo: %S\n", FileName);
     DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
 
     /* convert from Unicode */
@@ -706,9 +812,13 @@ PVFS2_Dokan_get_file_information(
         return -1;
     }
 
+    DEBUG_PATH(fs_path);
+
     /* get file attributes */
     ret = fs_getattr(fs_path, &attr);
 
+    DbgPrint("   fs_getattr returns: %d\n", ret);
+
     if (ret == 0)
     {
         /* convert to Windows attributes */
@@ -737,9 +847,9 @@ PVFS2_Dokan_get_file_information(
             HandleFileInformation->dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
         
         /* file times */
-        convert_time(attr.ctime, &HandleFileInformation->ftCreationTime);
-        convert_time(attr.atime, &HandleFileInformation->ftLastAccessTime);
-        convert_time(attr.mtime, &HandleFileInformation->ftLastWriteTime);
+        convert_pvfstime(attr.ctime, &HandleFileInformation->ftCreationTime);
+        convert_pvfstime(attr.atime, &HandleFileInformation->ftLastAccessTime);
+        convert_pvfstime(attr.mtime, &HandleFileInformation->ftLastWriteTime);
 
         /* file size */
         HandleFileInformation->nFileSizeHigh = (attr.size & 0x7FFFFFFF00000000LL) >> 32;
@@ -759,23 +869,23 @@ PVFS2_Dokan_get_file_information(
     cleanup_string(local_path);
     free(fs_path);
 
-    DbgPrint("   fs_getattr returns %d\n", ret);
+    DbgPrint("GetFileInfo exit: %d\n", err);
 
     return err;
 }
 
 
-static int
-PVFS2_Dokan_set_file_attributes(
+static int __stdcall
+PVFS_Dokan_set_file_attributes(
     LPCWSTR          FileName,
     DWORD            FileAttributes,
     PDOKAN_FILE_INFO DokanFileInfo)
 {
-    char *local_path, *fs_path, *filename;
+    char *local_path, *fs_path;
     int ret, err;
     PVFS_sys_attr attr;
 
-    DbgPrint("SetFileAttributes : %S\n", FileName);
+    DbgPrint("SetFileAttributes: %S\n", FileName);
     DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
 
     /* convert from Unicode */
@@ -796,23 +906,46 @@ PVFS2_Dokan_set_file_attributes(
         return -1;
     }
 
+    DEBUG_PATH(fs_path);
+
     /* convert attributes to PVFS */
     ret = fs_getattr(fs_path, &attr);
-    if (ret != 0)
+
+    DbgPrint("   fs_getattr returns: %d\n", ret);
+
+    if (ret == 0)
     {
         if (FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
-            attr.objtype |= PVFS_TYPE_DIRECTORY;
+            attr.objtype = PVFS_TYPE_DIRECTORY;
+        else if (FileAttributes & FILE_ATTRIBUTE_NORMAL)
+            attr.objtype = PVFS_TYPE_DATAFILE;
+        if (FileAttributes & FILE_ATTRIBUTE_READONLY)
+            /* TODO: permissions */ ;
+
+        ret = fs_setattr(fs_path, &attr);
+
+        DbgPrint("   fs_setattr returns: %d\n", ret);
+    }
 
+    switch (ret)
+    {
+    case 0: 
+        err = 0;
+        break;
+    default:
+        err = -1;
     }
 
+    free(fs_path);
+    cleanup_string(local_path);
 
     DbgPrint("SetFileAttributes exit: %d\n", err);
-    return 0;
+    return err;
 }
 
 
-static int
-PVFS2_Dokan_find_files(
+static int __stdcall
+PVFS_Dokan_find_files(
     LPCWSTR          FileName,
     PFillFindData    FillFindData, // function pointer
     PDOKAN_FILE_INFO DokanFileInfo)
@@ -820,13 +953,12 @@ PVFS2_Dokan_find_files(
     char *local_path, *fs_path;
     char filename[PVFS_NAME_MAX];
     int ret, err, count = 0;
-    PVFS_sys_attr attr;
     PVFS_ds_position token;
     WIN32_FIND_DATAW find_data;
     wchar_t *wfilename;
     BY_HANDLE_FILE_INFORMATION hfile_info;
     
-    DbgPrint("FindFiles : %S\n", FileName);
+    DbgPrint("FindFiles: %S\n", FileName);
     DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
 
     /* convert from Unicode */
@@ -843,6 +975,8 @@ PVFS2_Dokan_find_files(
     if (ret != 0)
         goto find_files_exit;
 
+    DEBUG_PATH(fs_path);
+
     /* find the first file */
     ret = fs_find_first_file(fs_path, &token, filename, PVFS_NAME_MAX);
     if (ret != 0)
@@ -855,7 +989,7 @@ PVFS2_Dokan_find_files(
         /* get file information */
         memset(&find_data, 0, sizeof(WIN32_FIND_DATAW));
         wfilename = convert_mbstring(filename);
-        ret = PVFS2_Dokan_get_file_information(wfilename, &hfile_info, DokanFileInfo);
+        ret = PVFS_Dokan_get_file_information(wfilename, &hfile_info, DokanFileInfo);
         if (ret != 0) 
         {
             cleanup_string(wfilename);
@@ -886,7 +1020,9 @@ PVFS2_Dokan_find_files(
             goto find_files_exit;
     }
 
-find_files_exit:
+find_files_exit:    
+
+    DbgPrint("   fs_find_xxx_file returns: %d\n", ret);
 
     cleanup_string(local_path);
     free(fs_path);
@@ -909,12 +1045,12 @@ find_files_exit:
 }
 
 
-static int
-PVFS2_Dokan_delete_file(
+static int __stdcall
+PVFS_Dokan_delete_file(
     LPCWSTR          FileName,
     PDOKAN_FILE_INFO DokanFileInfo)
 {
-    DbgPrint("DeleteFile : %S\n", FileName);
+    DbgPrint("DeleteFile: %S\n", FileName);
     DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
     
     /*** TODO ***/
@@ -925,12 +1061,12 @@ PVFS2_Dokan_delete_file(
 }
 
 
-static int
-PVFS2_Dokan_delete_directory(
+static int __stdcall
+PVFS_Dokan_delete_directory(
     LPCWSTR          FileName,
     PDOKAN_FILE_INFO DokanFileInfo)
 {
-    DbgPrint("DeleteDirectory : %S\n", FileName);
+    DbgPrint("DeleteDirectory: %S\n", FileName);
     DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
 
     /*** TODO ***/
@@ -969,14 +1105,14 @@ PVFS2_Dokan_delete_directory(
 }
 
 
-static int
-PVFS2_Dokan_move_file(
+static int __stdcall
+PVFS_Dokan_move_file(
     LPCWSTR          FileName, // existing file name
     LPCWSTR          NewFileName,
     BOOL             ReplaceIfExisting,
     PDOKAN_FILE_INFO DokanFileInfo)
 {
-    DbgPrint("MoveFile : %S -> %S\n", FileName, NewFileName);
+    DbgPrint("MoveFile: %S -> %S\n", FileName, NewFileName);
     DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
 
     /*** TODO ***/
@@ -1007,14 +1143,14 @@ PVFS2_Dokan_move_file(
     return 0;
 }
 
-static int
-PVFS2_Dokan_lock_file(
+static int __stdcall
+PVFS_Dokan_lock_file(
     LPCWSTR          FileName,
     LONGLONG         ByteOffset,
     LONGLONG         Length,
     PDOKAN_FILE_INFO DokanFileInfo)
 {
-    DbgPrint("LockFile : %S\n", FileName);
+    DbgPrint("LockFile: %S\n", FileName);
     DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
 
     /* PVFS does not currently have a locking mechanism */
@@ -1025,16 +1161,12 @@ PVFS2_Dokan_lock_file(
 }
 
 
-static int
-PVFS2_Dokan_set_end_of_file(
+static int __stdcall
+PVFS_Dokan_set_end_of_file(
     LPCWSTR                FileName,
     LONGLONG            ByteOffset,
     PDOKAN_FILE_INFO    DokanFileInfo)
 {
-    char            filePath[MAX_PATH];
-    HANDLE            handle;
-    LARGE_INTEGER    offset;
-
     DbgPrint("SetEndOfFile %S\n", FileName);
     DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
 
@@ -1046,8 +1178,8 @@ PVFS2_Dokan_set_end_of_file(
 }
 
 
-static int
-PVFS2_Dokan_set_allocation_size(
+static int __stdcall
+PVFS_Dokan_set_allocation_size(
     LPCWSTR          FileName,
     LONGLONG         AllocSize,
     PDOKAN_FILE_INFO DokanFileInfo)
@@ -1063,80 +1195,98 @@ PVFS2_Dokan_set_allocation_size(
 }
 
 
+static int __stdcall
+PVFS_Dokan_set_file_time(
+    LPCWSTR          FileName,
+    CONST FILETIME*  CreationTime,
+    CONST FILETIME*  LastAccessTime,
+    CONST FILETIME*  LastWriteTime,
+    PDOKAN_FILE_INFO DokanFileInfo)
+{
+    char *local_path, *fs_path;
+    int ret, err;
+    PVFS_sys_attr attr;
 
+    DbgPrint("SetFileTime: %S\n", FileName);
+    DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
 
-static int
-PVFS2_Dokan_set_file_time(
-    LPCWSTR                FileName,
-    CONST FILETIME*        CreationTime,
-    CONST FILETIME*        LastAccessTime,
-    CONST FILETIME*        LastWriteTime,
-    PDOKAN_FILE_INFO    DokanFileInfo)
-{
-    char    filePath[MAX_PATH];
-    HANDLE    handle;
+    /* convert from Unicode */
+    local_path = convert_wstring(FileName);
+    if (local_path == NULL)
+    {
+        return -ERROR_INVALID_DATA;
+    }
 
-    GetFilePath(filePath, FileName);
+    /* resolve the path */
+    fs_path = (char *) malloc(MAX_PATH);
+    MALLOC_CHECK(fs_path);
+    ret = fs_resolve_path(local_path, fs_path, MAX_PATH);
+    if (ret != 0)
+    {
+        free(local_path);
+        free(fs_path);
+        return -1;
+    }
 
-    DbgPrint("SetFileTime %s\n", filePath);
+    DEBUG_PATH(fs_path);
 
-    handle = (HANDLE)DokanFileInfo->Context;
+    /* convert times to PVFS */
+    ret = fs_getattr(fs_path, &attr);
 
-    if (!handle || handle == INVALID_HANDLE_VALUE) {
-        DbgPrint("\tinvalid handle\n\n");
-        return -1;
+    DbgPrint("   fs_getattr returns: %d\n", ret);
+
+    if (ret == 0)
+    {
+        convert_filetime(CreationTime, &attr.ctime);
+        convert_filetime(LastAccessTime, &attr.atime);
+        convert_filetime(LastWriteTime, &attr.mtime);
+
+        ret = fs_setattr(fs_path, &attr);        
+
+        DbgPrint("   fs_setattr returns: %d\n", ret);
     }
 
-    if (!SetFileTime(handle, CreationTime, LastAccessTime, LastWriteTime)) {
-        DWORD error = GetLastError();
-        DbgPrint("\terror code = %d\n\n", error);
-        return error * -1;
+    switch (ret)
+    {
+    case 0:
+        err = 0;
+        break;
+    default:
+        err = -1;
     }
 
-    DbgPrint("\n");
-    return 0;
+    DbgPrint("SetFileTime exit: %d (%d)\n", err, ret);
+
+    return err;
 }
 
-static int
-PVFS2_Dokan_unlock_file(
-    LPCWSTR                FileName,
-    LONGLONG            ByteOffset,
-    LONGLONG            Length,
-    PDOKAN_FILE_INFO    DokanFileInfo)
+
+static int __stdcall
+PVFS_Dokan_unlock_file(
+    LPCWSTR          FileName,
+    LONGLONG         ByteOffset,
+    LONGLONG         Length,
+    PDOKAN_FILE_INFO DokanFileInfo)
 {
-    char    filePath[MAX_PATH];
-    HANDLE    handle;
-    LARGE_INTEGER    length;
-    LARGE_INTEGER    offset;
-
-    GetFilePath(filePath, FileName);
-
-    DbgPrint("UnlockFile %s\n", filePath);
-
-    handle = (HANDLE)DokanFileInfo->Context;
-    if (!handle || handle == INVALID_HANDLE_VALUE) {
-        DbgPrint("\tinvalid handle\n\n");
-        return -1;
-    }
+    DbgPrint("UnLockFile: %S\n", FileName);
+    DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
 
-    length.QuadPart = Length;
-    offset.QuadPart = ByteOffset;
+    /* PVFS does not currently have a locking mechanism */
 
-    if (UnlockFile(handle, offset.HighPart, offset.LowPart, length.HighPart, length.LowPart)) {
-        DbgPrint("\tsuccess\n\n");
-        return 0;
-    } else {
-        DbgPrint("\tfail\n\n");
-        return -1;
-    }
+    DbgPrint("UnLockFile exit: %d\n", 0);
+
+    return 0;
 }
 
 
-static int
-PVFS2_Dokan_unmount(
+static int __stdcall
+PVFS_Dokan_unmount(
     PDOKAN_FILE_INFO    DokanFileInfo)
 {
     DbgPrint("Unmount\n");
+    DbgPrint("   Context: %llx\n", DokanFileInfo->Context);
+    DbgPrint("Unmount exit: %d\n", 0);
+
     return 0;
 }
 
@@ -1145,9 +1295,9 @@ int __cdecl dokan_loop()
 
     int status;
     PDOKAN_OPERATIONS dokanOperations =
-            (PDOKAN_OPERATIONS)malloc(sizeof(DOKAN_OPERATIONS));
+            (PDOKAN_OPERATIONS) malloc(sizeof(DOKAN_OPERATIONS));
     PDOKAN_OPTIONS dokanOptions =
-            (PDOKAN_OPTIONS)malloc(sizeof(DOKAN_OPTIONS));
+            (PDOKAN_OPTIONS) malloc(sizeof(DOKAN_OPTIONS));
 
 #ifdef _DEBUG
     g_DebugMode = g_UseStdErr = TRUE;
@@ -1158,6 +1308,8 @@ int __cdecl dokan_loop()
     ZeroMemory(dokanOptions, sizeof(DOKAN_OPTIONS));
     dokanOptions->ThreadCount = 0; /* use default */
 
+    DbgInit();
+
     if (g_DebugMode)
         dokanOptions->Options |= DOKAN_OPTION_DEBUG;
     if (g_UseStdErr)
@@ -1165,64 +1317,70 @@ int __cdecl dokan_loop()
 
     dokanOptions->Options |= DOKAN_OPTION_KEEP_ALIVE;
 
-    /* Hard coded M: for now */
-    dokanOptions->DriveLetter = L'M';
+    /* Hard coded for now */
+    dokanOptions->DriveLetter = L'Z';
 
     /* assign file operations */
     ZeroMemory(dokanOperations, sizeof(DOKAN_OPERATIONS));
-    dokanOperations->CreateFile = PVFS2_Dokan_create_file;
-    dokanOperations->OpenDirectory = PVFS2_Dokan_open_directory;
-    dokanOperations->CreateDirectory = PVFS2_Dokan_create_directory;
-    dokanOperations->Cleanup = PVFS2_Dokan_cleanup;
-    dokanOperations->CloseFile = PVFS2_Dokan_close_file;
-    dokanOperations->ReadFile = PVFS2_Dokan_read_file;
-    dokanOperations->WriteFile = PVFS2_Dokan_write_file;
-    dokanOperations->FlushFileBuffers = PVFS2_Dokan_flush_file_buffers;
-    dokanOperations->GetFileInformation = PVFS2_Dokan_get_file_information;
-    dokanOperations->FindFiles = PVFS2_Dokan_find_files;
+    dokanOperations->CreateFile = PVFS_Dokan_create_file;
+    dokanOperations->OpenDirectory = PVFS_Dokan_open_directory;
+    dokanOperations->CreateDirectory = PVFS_Dokan_create_directory;
+    dokanOperations->Cleanup = PVFS_Dokan_cleanup;
+    dokanOperations->CloseFile = PVFS_Dokan_close_file;
+    dokanOperations->ReadFile = PVFS_Dokan_read_file;
+    dokanOperations->WriteFile = PVFS_Dokan_write_file;
+    dokanOperations->FlushFileBuffers = PVFS_Dokan_flush_file_buffers;
+    dokanOperations->GetFileInformation = PVFS_Dokan_get_file_information;
+    dokanOperations->FindFiles = PVFS_Dokan_find_files;
     dokanOperations->FindFilesWithPattern = NULL;
-    dokanOperations->SetFileAttributes = PVFS2_Dokan_set_file_attributes;
-    dokanOperations->SetFileTime = PVFS2_Dokan_set_file_time;
-    dokanOperations->DeleteFile = PVFS2_Dokan_delete_file;
-    dokanOperations->DeleteDirectory = PVFS2_Dokan_delete_directory;
-    dokanOperations->MoveFile = PVFS2_Dokan_move_file;
-    dokanOperations->SetEndOfFile = PVFS2_Dokan_set_end_of_file;
-    dokanOperations->SetAllocationSize = PVFS2_Dokan_set_allocation_size;
-    dokanOperations->LockFile = PVFS2_Dokan_lock_file;
-    dokanOperations->UnlockFile = PVFS2_Dokan_unlock_file;
+    dokanOperations->SetFileAttributes = PVFS_Dokan_set_file_attributes;
+    dokanOperations->SetFileTime = PVFS_Dokan_set_file_time;
+    dokanOperations->DeleteFile = PVFS_Dokan_delete_file;
+    dokanOperations->DeleteDirectory = PVFS_Dokan_delete_directory;
+    dokanOperations->MoveFile = PVFS_Dokan_move_file;
+    dokanOperations->SetEndOfFile = PVFS_Dokan_set_end_of_file;
+    dokanOperations->SetAllocationSize = PVFS_Dokan_set_allocation_size;
+    dokanOperations->LockFile = PVFS_Dokan_lock_file;
+    dokanOperations->UnlockFile = PVFS_Dokan_unlock_file;
     dokanOperations->GetDiskFreeSpace = NULL;
     dokanOperations->GetVolumeInformation = NULL;
-    dokanOperations->Unmount = PVFS2_Dokan_unmount;
+    dokanOperations->Unmount = PVFS_Dokan_unmount;
+
+    DbgPrint("Entering DokanMain\n");
 
     /* TODO: dokan loops until termination */
     status = DokanMain(dokanOptions, dokanOperations);
 
+    DbgPrint("Exited DokanMain\n");
+
     switch (status) {
         case DOKAN_SUCCESS:
-            fprintf(stderr, "Success\n");
+            DbgPrint("Success\n");
             break;
         case DOKAN_ERROR:
-            fprintf(stderr, "Error\n");
+            DbgPrint("Error\n");
             break;
         case DOKAN_DRIVE_LETTER_ERROR:
-            fprintf(stderr, "Bad Drive letter\n");
+            DbgPrint("Bad Drive letter\n");
             break;
         case DOKAN_DRIVER_INSTALL_ERROR:
-            fprintf(stderr, "Can't install driver\n");
+            DbgPrint("Can't install driver\n");
             break;
         case DOKAN_START_ERROR:
-            fprintf(stderr, "Driver something wrong\n");
+            DbgPrint("Driver something wrong\n");
             break;
         case DOKAN_MOUNT_ERROR:
-            fprintf(stderr, "Can't assign a drive letter\n");
+            DbgPrint("Can't assign a drive letter\n");
             break;
         default:
-            fprintf(stderr, "Unknown error: %d\n", status);
+            DbgPrint("Unknown error: %d\n", status);
             break;
     }
 
     free(dokanOptions);
     free(dokanOperations);
+
+    DbgClose();
 
     return 0;
 

Index: fs.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/windows/client-service/Attic/fs.c,v
diff -p -u -r1.1.2.8 -r1.1.2.9
--- fs.c	16 Dec 2010 23:01:00 -0000	1.1.2.8
+++ fs.c	18 Dec 2010 19:31:51 -0000	1.1.2.9
@@ -133,9 +133,15 @@ int fs_resolve_path(const char *local_pa
     
     /* prepend mount directory to path */
     strcpy(full_path, mntent->mnt_dir);
+    printf("   full_path: %s\n", full_path);
+    /* append path */
     if (full_path[strlen(full_path)-1] != '/')
         strcat(full_path, "/");
-    strcat(full_path, trans_path);
+    if (trans_path[0] == '/')
+        strcat(full_path, trans_path+1);
+    else
+        strcat(full_path, trans_path);
+    strncpy(fs_path, full_path, fs_path_max);
 
     /* resolve the path against PVFS */
     ret = PVFS_util_resolve(full_path, &fs_id, fs_path, fs_path_max);
@@ -390,14 +396,14 @@ fs_mkdir_exit:
     return ret;
 }
 
-int fs_io(PVFS_io_type io_type,
+int fs_io(enum PVFS_io_type io_type,
           char *fs_path,
           void *buffer,
           size_t buffer_len,
           uint64_t offset,
-          size_t *op_len)
+          PVFS_size *op_len)
 {
-    PVFS_sys_mntent *mntent = fs_get_mntent(0);
+    struct PVFS_sys_mntent *mntent = fs_get_mntent(0);
     PVFS_sysresp_lookup resp_lookup;
     PVFS_object_ref object_ref;
     PVFS_Request file_req, mem_req;
@@ -440,19 +446,6 @@ fs_io_exit:
     return ret;
 }
 
-#define fs_read(fs_path, \
-                buffer, \
-                buffer_len, \
-                offset, \
-                read_len)  fs_io(PVFS_IO_READ, fs_path, buffer, buffer_len, offset, read_len)
-
-
-#define fs_write(fs_path, \
-                 buffer, \
-                 buffer_len, \
-                 offset, \
-                 write_len)  fs_io(PVFS_IO_WRITE, fs_path, buffer, buffer_len, offset, write_len)
-
 int fs_flush(char *fs_path)
 {
     struct PVFS_sys_mntent *mntent = fs_get_mntent(0);
@@ -476,27 +469,11 @@ fs_flush_exit:
     return ret;
 }
 
-int fs_find_first_file(char *fs_path,
-                       PVFS_ds_position *token,
-                       char *filename,
-                       size_t max_name_len)
-{
-    if (token == NULL)
-    {
-        return -PVFS_EINVAL;
-    }
-
-   *token = PVFS_READDIR_START;
-   return fs_find_next_file(fs_path, token, filename, max_name_len);
-}
-
 int fs_find_next_file(char *fs_path, 
                       PVFS_ds_position *token,
                       char *filename,
                       size_t max_name_len)
 {
-    int ret;
-
     struct PVFS_sys_mntent *mntent = fs_get_mntent(0);
     int ret;
     PVFS_sysresp_lookup resp_lookup;
@@ -534,6 +511,20 @@ int fs_find_next_file(char *fs_path, 
 fs_readdir_exit:
 
     return ret;
+}
+
+int fs_find_first_file(char *fs_path,
+                       PVFS_ds_position *token,
+                       char *filename,
+                       size_t max_name_len)
+{
+    if (token == NULL)
+    {
+        return -PVFS_EINVAL;
+    }
+
+   *token = PVFS_READDIR_START;
+   return fs_find_next_file(fs_path, token, filename, max_name_len);
 }
 
 int fs_finalize()

Index: fs.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/windows/client-service/Attic/fs.h,v
diff -p -u -r1.1.2.5 -r1.1.2.6
--- fs.h	16 Dec 2010 23:01:00 -0000	1.1.2.5
+++ fs.h	18 Dec 2010 19:31:51 -0000	1.1.2.6
@@ -34,17 +34,25 @@ int fs_setattr(char *fs_path,
 int fs_mkdir(char *fs_path,
              PVFS_handle *handle);
 
-int fs_read(char *fs_path, 
-            void *buffer,
-            size_t buffer_len,
-            PVFS_offset offset,
-            size_t *read_len);
+int fs_io(enum PVFS_io_type io_type,
+          char *fs_path,
+          void *buffer,
+          size_t buffer_len,
+          uint64_t offset,
+          PVFS_size *op_len);
 
-int fs_write(char *fs_path,
-             void *buffer,
-             size_t buffer_len,
-             PVFS_offset offset,
-             size_t *write_len);
+#define fs_read(fs_path, \
+                buffer, \
+                buffer_len, \
+                offset, \
+                read_len)  fs_io(PVFS_IO_READ, fs_path, buffer, buffer_len, offset, read_len)
+
+
+#define fs_write(fs_path, \
+                 buffer, \
+                 buffer_len, \
+                 offset, \
+                 write_len)  fs_io(PVFS_IO_WRITE, fs_path, buffer, buffer_len, offset, write_len)
 
 int fs_flush(char *fs_path);
 

Index: service-main.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/windows/client-service/Attic/service-main.c,v
diff -p -u -r1.1.2.3 -r1.1.2.4
--- service-main.c	6 Dec 2010 22:28:34 -0000	1.1.2.3
+++ service-main.c	18 Dec 2010 19:31:51 -0000	1.1.2.4
@@ -7,6 +7,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "fs.h"
+
 #define WIN32ServiceName           "orangefs-client"
 #define WIN32ServiceDisplayName    "OrangeFS Client"
 
@@ -17,8 +19,7 @@ SERVICE_STATUS service_status;
 int is_running = 0;
 
 /* externs */
-extern int fs_initialize();
-extern int fs_finalize();
+extern int __cdecl dokan_loop();
 
 void main_loop();
 
@@ -211,14 +212,15 @@ void WINAPI service_main(DWORD argc, cha
 
 void main_loop()
 {
+    int ret;
 
     /* init file systems */
-    fs_initialize();
+    ret = fs_initialize();
 
-    /* loop */
-    while (is_running)
+    /* run dokan operations */
+    if (ret == 0)
     {
-        Sleep(1000);
+        dokan_loop();
     }
 
     /* close file systems */



More information about the Pvfs2-cvs mailing list