[GRASS-SVN] r39760 - grass/trunk/lib/segment

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 19 04:09:48 EST 2009


Author: mmetz
Date: 2009-11-19 04:09:45 -0500 (Thu, 19 Nov 2009)
New Revision: 39760

Modified:
   grass/trunk/lib/segment/Makefile
   grass/trunk/lib/segment/format.c
Log:
enable LFS

Modified: grass/trunk/lib/segment/Makefile
===================================================================
--- grass/trunk/lib/segment/Makefile	2009-11-19 08:56:03 UTC (rev 39759)
+++ grass/trunk/lib/segment/Makefile	2009-11-19 09:09:45 UTC (rev 39760)
@@ -6,6 +6,11 @@
 include $(MODULE_TOPDIR)/include/Make/Lib.make
 include $(MODULE_TOPDIR)/include/Make/Doxygen.make
 
+#compile if LFS Large File Support present:
+ifneq ($(USE_LARGEFILES),)
+	EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
 default: lib
 
 #doxygen:

Modified: grass/trunk/lib/segment/format.c
===================================================================
--- grass/trunk/lib/segment/format.c	2009-11-19 08:56:03 UTC (rev 39759)
+++ grass/trunk/lib/segment/format.c	2009-11-19 09:09:45 UTC (rev 39760)
@@ -17,6 +17,7 @@
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
+#include <limits.h>
 #include <grass/segment.h>
 
 
@@ -118,6 +119,19 @@
 	return -3;
     }
 
+    /* no LFS, file size within 2GB limit ? */
+    if (sizeof(off_t) == 4) {
+	double file_size;
+
+	file_size = (double) nrows * ncols * len > INT_MAX;
+
+	if (file_size > INT_MAX) {
+	    G_warning("segment file size would be %.2fGB, but file size limit is 2GB", file_size / (1 << 30));
+	    G_warning("please recompile with LFS");
+	    G_fatal_error("can not create temporary segment file");
+	}
+    }
+
     if (lseek(fd, 0L, SEEK_SET) == (off_t) - 1) {
 	G_warning("Segment_format: %s", strerror(errno));
 	return -1;



More information about the grass-commit mailing list