Quellcode durchsuchen

enable LFS

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@39760 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz vor 15 Jahren
Ursprung
Commit
8cdc939244
2 geänderte Dateien mit 19 neuen und 0 gelöschten Zeilen
  1. 5 0
      lib/segment/Makefile
  2. 14 0
      lib/segment/format.c

+ 5 - 0
lib/segment/Makefile

@@ -6,6 +6,11 @@ LIB = SEGMENT
 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:

+ 14 - 0
lib/segment/format.c

@@ -17,6 +17,7 @@
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
+#include <limits.h>
 #include <grass/segment.h>
 
 
@@ -118,6 +119,19 @@ static int _segment_format(int fd,
 	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;