On Mon, Jul 14, 2008 at 01:54:30PM +0200, Mike Hommey wrote:
> On Mon, Jul 14, 2008 at 01:40:32PM +0200, Mike Hommey wrote:
> > On Mon, Jul 14, 2008 at 01:31:39PM +0200, Mike Hommey wrote:
> > > On Mon, Jul 14, 2008 at 01:23:00PM +0200, Sven Joachim wrote:
> > > > forwarded 489733 https://bugzilla.mozilla.org/show_bug.cgi?id=278738
> > > > thanks
> > > > 
> > > > On 2008-07-14 13:18 +0200, Mike Hommey wrote:
> > > > 
> > > > > On Mon, Jul 14, 2008 at 12:28:51PM +0200, Sven Joachim wrote:
> > > > >> But it will not trigger the bug.  Instead I have found a way to
> > > > >> reproduce it:
> > > > >> 
> > > > >> --8<---------------cut here---------------start------------->8---
> > > > >> # create scratch directory
> > > > >> mkdir /tmp/scratch
> > > > >> cd /tmp/scratch
> > > > >> # create a bunch of files for the listing
> > > > >> touch $(seq 500)
> > > > >> # create a big file
> > > > >> dd if=/dev/zero of=sparse-file bs=1 count=0 seek=2G
> > > > >> --8<---------------cut here---------------end--------------->8---
> > > > >> 
> > > > >> => The listing of /tmp/scratch in the browsers is truncated.
> > > > >> 
> > > > >> This will very likely not be reproducible under amd64, so you should 
> > > > >> get
> > > > >> yourself an i386 chroot for it.  In the original directory I have a 
> > > > >> 4G
> > > > >> DVD image which triggered the problem.
> > > > >
> > > > > It doesn't display anything here, though I didn't do the touch $(seq
> > > > > 500)...
> > > > 
> > > > Probably it doesn't display anything _because_ you didn't run the touch
> > > > command.  Meanwhile I found an upstream bug at
> > > > https://bugzilla.mozilla.org/show_bug.cgi?id=278738 that states
> > > > compiling with -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 might work.
> > > 
> > > I doubt that, because of some bad casting.
> > > 
> > > Can you try the attached patch?
> > 
> > Hum, this one should be better.
> 
> And this one even better. It builds, at least.

No it doesn't. This one, does.

Mike
diff --git a/build/autoconf/config.guess b/build/autoconf/config.guess
index a20b311..13940a3 100755
--- a/build/autoconf/config.guess
+++ b/build/autoconf/config.guess
@@ -1,4 +1,5 @@
 #! /bin/sh
+exec "/usr/share/misc/config.guess" "$@"
 # Attempt to guess a canonical system name.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
diff --git a/build/autoconf/config.sub b/build/autoconf/config.sub
index 2d91b11..0049ffd 100755
--- a/build/autoconf/config.sub
+++ b/build/autoconf/config.sub
@@ -1,4 +1,5 @@
 #! /bin/sh
+exec "/usr/share/misc/config.sub" "$@"
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp
index 99f52a6..8ab912f 100644
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -280,12 +280,21 @@ nsLocalFile::nsLocalFileConstructor(nsISupports *outer,
 
 nsresult 
 nsLocalFile::FillStatCache() {
+#ifdef HAVE_STAT64
+    if (stat64(mPath.get(), &mCachedStat) == -1) {
+        // try lstat it may be a symlink
+        if (lstat64(mPath.get(), &mCachedStat) == -1) {
+            return NSRESULT_FOR_ERRNO();
+        }
+    }
+#else
     if (stat(mPath.get(), &mCachedStat) == -1) {
         // try lstat it may be a symlink
         if (lstat(mPath.get(), &mCachedStat) == -1) {
             return NSRESULT_FOR_ERRNO();
         }
     }
+#endif
     mHaveCachedStat = PR_TRUE;
     return NS_OK;
 }
@@ -1109,9 +1118,12 @@ nsLocalFile::GetFileSize(PRInt64 *aFileSize)
     }
 #endif
 
-    /* XXX autoconf for and use stat64 if available */
     if (!S_ISDIR(mCachedStat.st_mode)) {
+#ifdef HAVE_STAT64
+        *aFileSize = mCachedStat.st_size;
+#else
         LL_UI2L(*aFileSize, (PRUint32)mCachedStat.st_size);
+#endif
     }
     return NS_OK;
 }
@@ -1136,11 +1148,17 @@ nsLocalFile::GetFileSizeOfLink(PRInt64 *aFileSize)
     CHECK_mPath();
     NS_ENSURE_ARG(aFileSize);
 
+#ifdef HAVE_LSTAT64
+    struct stat64 sbuf;
+    if (lstat64(mPath.get(), &sbuf) == -1)
+        return NSRESULT_FOR_ERRNO();
+    *aFileSize = sbuf.st_size;
+#else
     struct stat sbuf;
     if (lstat(mPath.get(), &sbuf) == -1)
         return NSRESULT_FOR_ERRNO();
-    /* XXX autoconf for and use lstat64 if available */
     LL_UI2L(*aFileSize, (PRUint32)sbuf.st_size);
+#endif
     return NS_OK;
 }
 
diff --git a/xpcom/io/nsLocalFileUnix.h b/xpcom/io/nsLocalFileUnix.h
index 9203b33..c51f2d9 100644
--- a/xpcom/io/nsLocalFileUnix.h
+++ b/xpcom/io/nsLocalFileUnix.h
@@ -113,7 +113,11 @@ private:
     ~nsLocalFile() {}
 
 protected:
+#ifdef HAVE_STAT64
+    struct stat64 mCachedStat;
+#else
     struct stat  mCachedStat;
+#endif
     nsCString    mPath;
     PRPackedBool mHaveCachedStat;
 

Reply via email to