apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r592970 - in /apr/apr/trunk: file_io/win32/filestat.c file_io/win32/open.c include/arch/win32/apr_arch_misc.h test/testlfs.c
Date Thu, 08 Nov 2007 00:23:39 GMT
Author: wrowe
Date: Wed Nov  7 16:23:38 2007
New Revision: 592970

URL: http://svn.apache.org/viewvc?rev=592970&view=rev
Log:
Learn the appropriate csize Allocation magic applicable
to Windows 2000 (when sparse was introduced) and later.

This reverts a bogus test case.

Modified:
    apr/apr/trunk/file_io/win32/filestat.c
    apr/apr/trunk/file_io/win32/open.c
    apr/apr/trunk/include/arch/win32/apr_arch_misc.h
    apr/apr/trunk/test/testlfs.c

Modified: apr/apr/trunk/file_io/win32/filestat.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/filestat.c?rev=592970&r1=592969&r2=592970&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/filestat.c (original)
+++ apr/apr/trunk/file_io/win32/filestat.c Wed Nov  7 16:23:38 2007
@@ -304,7 +304,14 @@
              *   http://go.microsoft.com/fwlink/?linkid=84083
              * you probably understand why APR chooses not to implement.
              */
-            ;
+            IOSB sb;
+            FSI fi;
+            if ((ZwQueryInformationFile((HANDLE)ufile, &sb, 
+                                       &fi, sizeof(fi), 5) == 0) 
+                    && (sb.Status == 0)) {
+                finfo->csize = fi.AllocationSize;
+                finfo->valid |= APR_FINFO_CSIZE;
+            }
         }
         else {
             SetLastError(NO_ERROR);

Modified: apr/apr/trunk/file_io/win32/open.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/open.c?rev=592970&r1=592969&r2=592970&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/open.c (original)
+++ apr/apr/trunk/file_io/win32/open.c Wed Nov  7 16:23:38 2007
@@ -221,6 +221,9 @@
 #endif
 }
 
+#if APR_HAS_UNICODE_FS
+    IF_WIN_OS_IS_UNICODE
+    {
 static apr_status_t make_sparse_file(apr_file_t *file)
 {
     BY_HANDLE_FILE_INFORMATION info;
@@ -270,6 +273,7 @@
     }
     return rv;
 }
+#endif
 
 apr_status_t file_cleanup(void *thefile)
 {
@@ -421,8 +425,8 @@
     ELSE_WIN_OS_IS_ANSI {
         handle = CreateFileA(fname, oflags, sharemode,
                              NULL, createflags, attributes, 0);
-        /* These features are not supported on this platform. */
-        flag &= ~(APR_SENDFILE_ENABLED | APR_FOPEN_SPARSE);
+        /* This feature is not supported on this platform. */
+        flag &= ~APR_SENDFILE_ENABLED
     }
 #endif
     if (handle == INVALID_HANDLE_VALUE) {
@@ -458,14 +462,20 @@
         }
     }
 
-    if ((*new)->flags & APR_FOPEN_SPARSE) {
-        if ((rv = make_sparse_file(*new)) != APR_SUCCESS)
-            /* The great mystery; do we close the file and return an error?
-             * Do we add a new APR_INCOMPLETE style error saying opened, but
-             * NOTSPARSE?  For now let's simply mark the file as not-sparse.
-             */
-            (*new)->flags &= ~APR_FOPEN_SPARSE;
+#if APR_HAS_UNICODE_FS
+    if ((apr_os_level >= APR_WIN_2000) && ((*new)->flags & APR_FOPEN_SPARSE))
{
+            if ((rv = make_sparse_file(*new)) != APR_SUCCESS)
+                /* The great mystery; do we close the file and return an error?
+                 * Do we add a new APR_INCOMPLETE style error saying opened, but
+                 * NOTSPARSE?  For now let's simply mark the file as not-sparse.
+                 */
+                (*new)->flags &= ~APR_FOPEN_SPARSE;
+        }
     }
+    else
+#endif
+        /* This feature is not supported on this platform. */
+        (*new)->flags &= ~APR_FOPEN_SPARSE;
 
     /* Create a pollset with room for one descriptor. */
     /* ### check return codes */

Modified: apr/apr/trunk/include/arch/win32/apr_arch_misc.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/arch/win32/apr_arch_misc.h?rev=592970&r1=592969&r2=592970&view=diff
==============================================================================
--- apr/apr/trunk/include/arch/win32/apr_arch_misc.h (original)
+++ apr/apr/trunk/include/arch/win32/apr_arch_misc.h Wed Nov  7 16:23:38 2007
@@ -375,6 +375,31 @@
     (hObject, info, pOI, LenOI, pSizeOI));
 #define QueryObject apr_winapi_NtQueryObject
 
+typedef struct IOSB {
+    union {
+    UINT Status;
+    PVOID reserved;
+    };
+    ULONG_PTR Information; /* Varies by op, consumed buffer size for FSI below */
+} IOSB, *PIOSB;
+
+typedef struct FSI {
+    LONGLONG AllocationSize;
+    LONGLONG EndOfFile;
+    ULONG    NumberOfLinks;
+    BOOL     DeletePending;
+    BOOL     Directory;
+} FSI, *PFSI;
+
+APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, LONG, WINAPI, ZwQueryInformationFile, 0, (
+    HANDLE hObject,    /* Obvious */
+    PVOID  pIOSB,      /* Point to the IOSB buffer for detailed return results */
+    PVOID  pFI,        /* The buffer, using FIB above */
+    ULONG  LenFI,      /* Use sizeof(FI) */
+    ULONG  info),      /* Use 5 for FSI documented above*/
+    (hObject, pIOSB, pFI, LenFI, info));
+#define ZwQueryInformationFile apr_winapi_ZwQueryInformationFile
+
 #endif /* !defined(_WIN32_WCE) */
 
 #endif  /* ! MISC_H */

Modified: apr/apr/trunk/test/testlfs.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testlfs.c?rev=592970&r1=592969&r2=592970&view=diff
==============================================================================
--- apr/apr/trunk/test/testlfs.c (original)
+++ apr/apr/trunk/test/testlfs.c Wed Nov  7 16:23:38 2007
@@ -66,13 +66,12 @@
 
     if (rv == APR_SUCCESS) {
         rv = apr_file_info_get(&testsize, APR_FINFO_CSIZE, f);
-        if (rv == APR_INCOMPLETE)
-            rv = apr_stat(&testsize, TESTFN, APR_FINFO_CSIZE, p);
     }
 
     /* give up if we can't determine the allocation size of the file,
      * or if it's not an obviously small allocation but the allocation
-     * unit doesn't appear insanely large
+     * unit doesn't appear insanely large - on most platforms, it's just
+     * zero physical bytes at this point.
      */
     if (rv != APR_SUCCESS || (testsize.csize > oneMB
                               && testsize.csize < oneMB * 2)) {



Mime
View raw message