[GRASS-SVN] r39790 - grass/branches/develbranch_6/lib/segment
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 23 05:21:50 EST 2009
Author: mmetz
Date: 2009-11-23 05:21:48 -0500 (Mon, 23 Nov 2009)
New Revision: 39790
Modified:
grass/branches/develbranch_6/lib/segment/Makefile
grass/branches/develbranch_6/lib/segment/format.c
Log:
use LFS if available (backported from trunk r39760, r39789)
Modified: grass/branches/develbranch_6/lib/segment/Makefile
===================================================================
--- grass/branches/develbranch_6/lib/segment/Makefile 2009-11-23 09:38:44 UTC (rev 39789)
+++ grass/branches/develbranch_6/lib/segment/Makefile 2009-11-23 10:21:48 UTC (rev 39790)
@@ -22,6 +22,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/branches/develbranch_6/lib/segment/format.c
===================================================================
--- grass/branches/develbranch_6/lib/segment/format.c 2009-11-23 09:38:44 UTC (rev 39789)
+++ grass/branches/develbranch_6/lib/segment/format.c 2009-11-23 10:21:48 UTC (rev 39790)
@@ -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;
+
+ 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