[GRASS-SVN] r46432 - grass/trunk/lib/segment
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat May 28 11:45:33 EDT 2011
Author: mmetz
Date: 2011-05-28 08:45:33 -0700 (Sat, 28 May 2011)
New Revision: 46432
Modified:
grass/trunk/lib/segment/format.c
Log:
segment lib: add LFS check
Modified: grass/trunk/lib/segment/format.c
===================================================================
--- grass/trunk/lib/segment/format.c 2011-05-28 15:36:51 UTC (rev 46431)
+++ grass/trunk/lib/segment/format.c 2011-05-28 15:45:33 UTC (rev 46432)
@@ -18,6 +18,7 @@
#include <unistd.h>
#include <limits.h>
#include <grass/gis.h>
+#include <grass/glocale.h>
#include <grass/segment.h>
@@ -119,6 +120,33 @@
return -3;
}
+ if (sizeof(off_t) == 4 && sizeof(double) >= 8) {
+ double d_size;
+ off_t o_size;
+
+ spr = ncols / scols;
+ if (ncols % scols)
+ spr++;
+
+ /* calculate total number of segments */
+ d_size = (double) spr * ((nrows + srows - 1) / srows);
+ /* multiply with segment size */
+ d_size *= srows * scols * len;
+
+ /* add header */
+ d_size += 5 * sizeof(int);
+
+ o_size = (off_t) d_size;
+
+ /* this test assumes that all off_t values can be exactly
+ * represented as double if sizeof(off_t) = 4 and sizeof(double) >= 8 */
+ if ((double) o_size != d_size) {
+ G_warning(_("Segment format: file size too large"));
+ G_warning(_("Please recompile with Large File Support (LFS)"));
+ return -1;
+ }
+ }
+
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