Index: trunk/src/cutest_sh_tiger0.c
===================================================================
--- trunk/src/cutest_sh_tiger0.c	(revision 18)
+++ trunk/src/cutest_sh_tiger0.c	(revision 19)
@@ -233,4 +233,148 @@
   CuAssertTrue(tc, result == 0);
 
-
 }  
+
+/* test checksum of file upto some given length
+ */
+void Test_tiger_file_with_length(CuTest *tc) {
+
+  SL_TICKET     rval_open;
+  FILE * fp;
+  int result;
+  char * actual;
+  char * expected;
+
+  char * teststring = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996.\n";
+  int    testlen = strlen(teststring);
+
+  init();
+
+  fp = fopen("cutest_foo", "w");
+  CuAssertPtrNotNull(tc, fp);
+
+  result = fprintf(fp, "%s", teststring);
+  CuAssertTrue(tc, result >= 0);
+  result = fprintf(fp, "%s", teststring);
+  CuAssertTrue(tc, result >= 0);
+
+  result = fclose(fp);
+  CuAssertTrue(tc, result == 0);
+  
+  result = sh_tiger_hashtype("TIGER192");
+  CuAssertTrue(tc, result == 0);
+
+  /* same as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192) 
+   */
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, testlen, 0);
+  expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
+  CuAssertStrEquals(tc, expected, actual);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 2*testlen, 0);
+  expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
+  CuAssertStrEquals(tc, expected, actual);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 0, 0);
+  expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
+  CuAssertStrEquals(tc, expected, actual);
+
+  fp = fopen("cutest_foo", "a");
+  CuAssertPtrNotNull(tc, fp);
+  result = fprintf(fp, "%s", teststring);
+  CuAssertTrue(tc, result >= 0);
+  result = fclose(fp);
+  CuAssertTrue(tc, result == 0);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, testlen, 0);
+  expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
+  CuAssertStrEquals(tc, expected, actual);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 2*testlen, 0);
+  expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
+  CuAssertStrEquals(tc, expected, actual);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 3*testlen, 0);
+  expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F";
+  CuAssertStrEquals(tc, expected, actual);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 0, 0);
+  expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F";
+  CuAssertStrEquals(tc, expected, actual);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 5, 0);
+  expected = "9F00F599072300DD276ABB38C8EB6DEC37790C116F9D2BDF";
+  CuAssertStrEquals(tc, expected, actual);
+
+  /* same results as GNU md5sum */
+
+  result = sh_tiger_hashtype("MD5");
+  CuAssertTrue(tc, result == 0);
+
+  rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV);
+  CuAssertTrue(tc, rval_open >= 0);
+  tiger_fd  = rval_open;
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, testlen, 0);
+  expected = "11E7E7EA486136273606BEE57C71F34B0000000000000000";
+  CuAssertStrEquals(tc, expected, actual);
+
+  result = sl_rewind(rval_open);
+  CuAssertTrue(tc, rval_open >= 0);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 2*testlen, 0);
+  expected = "D49DAD474095D467E2E5EFCB2DC23A770000000000000000";
+  CuAssertStrEquals(tc, expected, actual);
+
+  result = sl_rewind(rval_open);
+  CuAssertTrue(tc, rval_open >= 0);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 3*testlen, 0);
+  expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000";
+  CuAssertStrEquals(tc, expected, actual);
+
+  result = sl_rewind(rval_open);
+  CuAssertTrue(tc, rval_open >= 0);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 0, 0);
+  expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000";
+  CuAssertStrEquals(tc, expected, actual);
+
+  /* same result as gpg --print-md SHA1 
+   */
+
+  result = sh_tiger_hashtype("SHA1");
+  CuAssertTrue(tc, result == 0);
+
+  result = sl_rewind(rval_open);
+  CuAssertTrue(tc, rval_open >= 0);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, testlen, 0);
+  expected = "F37DB4344CCD140EE315179E9A27512FB4704F0F00000000";
+  CuAssertStrEquals(tc, expected, actual);
+
+  result = sl_rewind(rval_open);
+  CuAssertTrue(tc, rval_open >= 0);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 2*testlen, 0);
+  expected = "D2AD5FC366452D81400BAC31F96269DEEF314BC200000000";
+  CuAssertStrEquals(tc, expected, actual);
+
+  result = sl_rewind(rval_open);
+  CuAssertTrue(tc, rval_open >= 0);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 3*testlen, 0);
+  expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000";
+  CuAssertStrEquals(tc, expected, actual);
+
+  result = sl_rewind(rval_open);
+  CuAssertTrue(tc, rval_open >= 0);
+
+  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 0, 0);
+  expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000";
+  CuAssertStrEquals(tc, expected, actual);
+
+  result = sl_close(rval_open);
+  CuAssertTrue(tc, result == 0);
+
+  result = remove("cutest_foo");
+  CuAssertTrue(tc, result == 0);
+}
Index: trunk/src/cutest_sh_tools.c
===================================================================
--- trunk/src/cutest_sh_tools.c	(revision 18)
+++ trunk/src/cutest_sh_tools.c	(revision 19)
@@ -4,4 +4,5 @@
 #include <string.h>
 #include "CuTest.h"
+#include "samhain.h"
 #include "sh_tools.h"
 
Index: trunk/src/make-tests.sh
===================================================================
--- trunk/src/make-tests.sh	(revision 18)
+++ trunk/src/make-tests.sh	(revision 19)
@@ -6,4 +6,9 @@
 # Author: Asim Jalis
 # Date: 01/08/2003
+
+# Modified to return non-zero if any test has failed
+# Rainer Wichmann, 29. Jan 2006
+# ...and to print to stderr if any test has failed
+# Rainer Wichmann, 31. Jan 2006
 
 if test $# -eq 0 ; then FILES=*.c ; else FILES=$* ; fi
@@ -26,5 +31,5 @@
 '
 
-void RunAllTests(void) 
+int RunAllTests(void) 
 {
     CuString *output = CuStringNew();
@@ -43,11 +48,16 @@
     CuSuiteSummary(suite, output);
     CuSuiteDetails(suite, output);
-    printf("%s\n", output->buffer);
+    if (suite->failCount > 0)
+      fprintf(stderr, "%s\n", output->buffer);
+    else
+      fprintf(stdout, "%s\n", output->buffer);
+    return suite->failCount;
 }
 
 int main(void)
 {
-    RunAllTests();
-    return 0;
+    int retval;
+    retval = RunAllTests();
+    return (retval == 0) ? 0 : 1;
 }
 '
Index: trunk/src/samhain.c
===================================================================
--- trunk/src/samhain.c	(revision 18)
+++ trunk/src/samhain.c	(revision 19)
@@ -1752,5 +1752,5 @@
 	    }
 	  
-	  if (sig_suspend_switch == 1)  /* SIGUSR2 */
+	  if (sig_suspend_switch > 0)  /* SIGUSR2 */
 	    {
 	      TPT((0, FIL__, __LINE__, _("msg=<Suspend switch.>\n")));
@@ -1762,5 +1762,5 @@
 		sh_global_suspend_flag = 1;
 	      }
-	      sig_suspend_switch = 0;
+	      --sig_suspend_switch;
 	      --sig_raised; --sig_urgent;
 	    }
Index: trunk/src/sh_err_log.c
===================================================================
--- trunk/src/sh_err_log.c	(revision 18)
+++ trunk/src/sh_err_log.c	(revision 19)
@@ -755,5 +755,5 @@
   if (skey->mlock_failed == SL_FALSE) 
     {
-      if ( (-1) == sh_unix_mlock( log_msg.msg, 
+      if ( (-1) == sh_unix_mlock( FIL__, __LINE__, log_msg.msg, 
 				  (size_t)(2*KEY_LEN + status + 32) ) ) 
 	{
Index: trunk/src/sh_files.c
===================================================================
--- trunk/src/sh_files.c	(revision 18)
+++ trunk/src/sh_files.c	(revision 19)
@@ -590,4 +590,10 @@
 	if (0 == strncmp(myword, _("HLN"), 3))
 	  sh_files_set_mask (mask, MODI_HLN, act);
+/* size may grow */
+	if (0 == strncmp(myword, _("GROW"), 3))
+	  sh_files_set_mask (mask, MODI_SGROW, act);
+/* use prelink */
+	if (0 == strncmp(myword, _("PRE"), 3))
+	  sh_files_set_mask (mask, MODI_PREL, act);
 	
       }
@@ -1010,5 +1016,6 @@
 	      ++dcount;
 	    }
-	  ptr->checked = S_TRUE;
+	  ptr->checked        = S_TRUE;
+	  ptr->childs_checked = S_TRUE;
 	}
 
@@ -1425,4 +1432,5 @@
 
   dirstack_t *    dst_ptr;
+  dirstack_t *    tmp_ptr;
 
   int             hardlink_num = 0;
@@ -1645,5 +1653,6 @@
 	file_class_next    = dst_ptr->class;
 	checked_flag       = dst_ptr->checked;
-	cchecked_flag      = dst_ptr->childs_checked;
+	/* not set, hence always FALSE                   */
+	/* cchecked_flag      = dst_ptr->childs_checked; */
       }
     
@@ -1708,34 +1717,34 @@
 	    cchecked_flag = -1;
 	    
-	    dst_ptr     = (dirstack_t *) zAVLSearch(zdirListOne, tmpcat);
-
-	    if (dst_ptr) 
+	    tmp_ptr     = (dirstack_t *) zAVLSearch(zdirListOne, tmpcat);
+
+	    if (tmp_ptr) 
 	      {
 		TPT((0, FIL__, __LINE__, 
 		     _("msg=<%s -> recursion depth %d\n>"),
-		     dst_ptr->name, dst_ptr->rdepth));
-		rdepth_next   = dst_ptr->rdepth;
-		class_next    = dst_ptr->class;
+		     tmp_ptr->name, tmp_ptr->rdepth));
+		rdepth_next   = tmp_ptr->rdepth;
+		class_next    = tmp_ptr->class;
 		/* 28. Aug 2001 reversed
 		 */
-		cchecked_flag = dst_ptr->childs_checked;
-		checked_flag  = dst_ptr->checked;
+		cchecked_flag = tmp_ptr->childs_checked;
+		checked_flag  = tmp_ptr->checked;
 	      }
 	    
 	    if (checked_flag == -1)
 	      {
-		dst_ptr     = (dirstack_t *) zAVLSearch(zdirListTwo, tmpcat);
-
-		if (dst_ptr) 
+		tmp_ptr     = (dirstack_t *) zAVLSearch(zdirListTwo, tmpcat);
+
+		if (tmp_ptr) 
 		  {
 		    TPT((0, FIL__, __LINE__, 
 			 _("msg=<%s -> recursion depth %d\n>"),
-			 dst_ptr->name, dst_ptr->rdepth));
-		    rdepth_next   = dst_ptr->rdepth;
-		    class_next    = dst_ptr->class;
+			 tmp_ptr->name, tmp_ptr->rdepth));
+		    rdepth_next   = tmp_ptr->rdepth;
+		    class_next    = tmp_ptr->class;
 		    /* 28. Aug 2001 reversed
 		     */
-		    cchecked_flag = dst_ptr->childs_checked;
-		    checked_flag  = dst_ptr->checked;
+		    cchecked_flag = tmp_ptr->childs_checked;
+		    checked_flag  = tmp_ptr->checked;
 		  }
 	      }
@@ -1745,5 +1754,9 @@
 		sh_files_checkdir (class_next, rdepth_next, tmpcat, 
 				   dirlist->sh_d_name);
-		dst_ptr->childs_checked = S_TRUE;
+		tmp_ptr->childs_checked = S_TRUE;
+		/*
+		 * 04. Feb 2006 avoid double checking
+		 */
+		tmp_ptr->checked        = S_TRUE;
 	      }
 	    else if (checked_flag == -1)
@@ -1768,4 +1781,7 @@
     
     dirlist = dirlist->next;
+
+    if (dst_ptr)
+      dst_ptr->childs_checked = S_TRUE;
     
   } while (dirlist != NULL);
@@ -1820,5 +1836,5 @@
    */
   char            fullpath[PATH_MAX];
-  char            fileHash[KEY_LEN + 1];
+  char            fileHash[2*(KEY_LEN + 1)];
   int             status;
   file_type       theFile;
Index: trunk/src/sh_forward.c
===================================================================
--- trunk/src/sh_forward.c	(revision 18)
+++ trunk/src/sh_forward.c	(revision 19)
@@ -4995,5 +4995,5 @@
 	  }
 	
-	if (sig_suspend_switch == 1)  /* SIGUSR2 */
+	if (sig_suspend_switch > 0)  /* SIGUSR2 */
 	  {
 	    TPT((0, FIL__, __LINE__, _("msg=<Suspend switch.>\n")));
@@ -5005,5 +5005,5 @@
 	      sh_global_suspend_flag = 1;
 	    }
-	    sig_suspend_switch = 0;
+	    --sig_suspend_switch;
 	    --sig_raised; --sig_urgent;
 	  }
@@ -5171,4 +5171,16 @@
       tcurrent = (unsigned long) time (NULL);
 
+      /* check for time limit exceeded
+       */
+      if ((tcurrent - tchkold) > (unsigned int) 3 )
+	{
+	  tchkold = tcurrent;
+	  client_time_check(/* all_clients */);
+	}
+      
+      /* seed / re-seed the PRNG if required
+       */
+      (void) taus_seed();
+
       /* select() timeout handling.
        */
@@ -5246,18 +5258,5 @@
 	    }
 	}
-
-      /* check for time limit exceeded
-       */
-      if ((tcurrent - tchkold) > (unsigned int) 3 )
-	{
-	  tchkold = tcurrent;
-	  client_time_check(/* all_clients */);
-	}
-      tcurrent = tcurrent;
-      
-      /* seed / re-seed the PRNG if required
-       */
-      (void) taus_seed();
-      
+      /* continue */
     }
   /* notreached */
Index: trunk/src/sh_hash.c
===================================================================
--- trunk/src/sh_hash.c	(revision 18)
+++ trunk/src/sh_hash.c	(revision 19)
@@ -2485,10 +2485,28 @@
 
   if ( (fileHash != NULL) && (p->theFile.checksum != NULL)   && 
-       (strncmp (fileHash, p->theFile.checksum, 50) != 0) && 
+       (strncmp (fileHash, p->theFile.checksum, KEY_LEN) != 0) && 
        (theFile->check_mask & MODI_CHK) != 0)
     {
-      modi_mask |= MODI_CHK;
-      change_code[0] = 'C';
-      TPT ((0, FIL__, __LINE__, _("mod=<checksum>")));
+      if ((theFile->check_mask & MODI_SGROW) == 0)
+	{
+	  modi_mask |= MODI_CHK;
+	  change_code[0] = 'C';
+	  TPT ((0, FIL__, __LINE__, _("mod=<checksum>")));
+	}
+      else
+	{
+	  if (0 != strncmp (&fileHash[KEY_LEN + 1], 
+			    p->theFile.checksum, KEY_LEN))
+	    {
+	      modi_mask |= MODI_CHK;
+	      change_code[0] = 'C';
+	      TPT ((0, FIL__, __LINE__, _("mod=<checksum>")));
+	    }
+	  else
+	    {
+	      p->theFile.size  = theFile->size;
+	      sl_strlcpy(p->theFile.checksum, fileHash, KEY_LEN+1);
+	    }
+	}
     } 
 
@@ -2621,16 +2639,11 @@
        (theFile->check_mask & MODI_SIZ) != 0)
     {
-      if (class == SH_LEVEL_LOGGROW && theFile->size < (off_t) p->theFile.size)
+      if ((theFile->check_mask & MODI_SGROW) == 0 || 
+	  theFile->size < (off_t) p->theFile.size)
 	{
 	  modi_mask |= MODI_SIZ;
 	  change_code[9] = 'S';
 	  TPT ((0, FIL__, __LINE__, _("mod=<size>")));
-	} 
-      else if (class != SH_LEVEL_LOGGROW)
-	{ 
-	  modi_mask |= MODI_SIZ;
-	  change_code[9] = 'S';
-	  TPT ((0, FIL__, __LINE__, _("mod=<size>")));
-	} 
+	}
     }
   change_code[10] = '\0';
Index: trunk/src/sh_suidchk.c
===================================================================
--- trunk/src/sh_suidchk.c	(revision 18)
+++ trunk/src/sh_suidchk.c	(revision 19)
@@ -417,5 +417,5 @@
 
   file_type       theFile;
-  char            fileHash[KEY_LEN + 1];
+  char            fileHash[2*(KEY_LEN + 1)];
 
   SL_ENTER(_("sh_suidchk_check_internal"));
Index: trunk/src/sh_tiger0.c
===================================================================
--- trunk/src/sh_tiger0.c	(revision 18)
+++ trunk/src/sh_tiger0.c	(revision 19)
@@ -104,9 +104,9 @@
 static
 word64 * sh_tiger_hash_val (char * filename, TigerType what, 
-			    unsigned long Length, int timeout)
+			    UINT64 Length, int timeout)
 #else
 static
 sh_word32 * sh_tiger_hash_val (char * filename, TigerType what, 
-			       unsigned long Length, int timeout)
+			       UINT64 Length, int timeout)
 #endif
 {
@@ -117,5 +117,6 @@
   char    * tmp;
   sh_byte * bptr;
-  sh_byte bbuf[64];
+  sh_byte   bbuf[64];
+  UINT64    bcount = 0;
 
   static int lockflag = SL_FALSE;
@@ -178,15 +179,17 @@
       
 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
-    if (lockflag == SL_FALSE && skey->mlock_failed == SL_FALSE) 
+    if ((lockflag == SL_FALSE) && (skey->mlock_failed == SL_FALSE)) 
       {
-        if ( (-1) == sh_unix_mlock((char *)buffer,(PRIV_MAX)*sizeof(sh_byte))) 
+	lockflag = SL_TRUE;
+        if ( (-1) == sh_unix_mlock(FIL__, __LINE__, 
+				   (char *)buffer, 
+				   (PRIV_MAX)*sizeof(sh_byte))) 
           skey->mlock_failed = SL_TRUE;
-	lockflag = SL_TRUE;
       }
 #else
     if (lockflag == SL_FALSE && skey->mlock_failed == SL_FALSE)
       {
+	lockflag = SL_TRUE;
 	skey->mlock_failed = SL_TRUE;
-	lockflag = SL_TRUE;
       }
 #endif
@@ -229,4 +232,12 @@
 
 	    SL_RETURN( NULL, _("sh_tiger_hash_val"));
+	  }
+
+	if (Length > 0)
+	  {
+	    bcount += count;
+	    if (bcount > Length) 
+	      count = count - (bcount - Length);
+	    count = (count < 0) ? 0 : count;
 	  }
 
@@ -382,5 +393,5 @@
   if (what == TIGER_DATA && filename != NULL) 
     {
-      tiger(TIGER_CAST filename,  (sh_word32) Length, res); 
+      tiger(TIGER_CAST filename, (sh_word32) Length, res); 
       SL_RETURN(res, _("sh_tiger_hash_val"));
     }
@@ -692,5 +703,6 @@
    resulting message digest number will be written into the 16 bytes
    beginning at RESBLOCK.  */
-static int md5_stream(char * filename, void *resblock, int timeout)
+static int md5_stream(char * filename, void *resblock, 
+		      UINT64 Length, int timeout)
 {
   /* Important: BLOCKSIZE must be a multiple of 64.  */
@@ -702,4 +714,5 @@
   char * tmp;
   uid_t   euid;
+  UINT64  bcount = 0;
 
   unsigned long pages_read;
@@ -762,4 +775,12 @@
 	}
 
+      if (Length > 0)
+	{
+	  bcount += n;
+	  if (bcount > Length) 
+	    n = n - (bcount - Length);
+	  n = (n < 0) ? 0 : n;
+	}
+
       sum += n;
     }
@@ -807,7 +828,7 @@
 static
 char * sh_tiger_md5_hash  (char * filename, TigerType what, 
-			   unsigned long Length, int timeout)
-{
-  int cnt = (int) Length;
+			   UINT64 Length, int timeout)
+{
+  int cnt;
   static char out[KEY_LEN+1];
   unsigned char md5buffer[16];
@@ -822,5 +843,5 @@
     }
 
-  (void) md5_stream (filename, md5buffer, timeout);
+  (void) md5_stream (filename, md5buffer, Length, timeout);
 
   /*@-bufferoverflowhigh -usedef@*/
@@ -1202,5 +1223,6 @@
    resulting message digest number will be written into the 16 bytes
    beginning at RESBLOCK.  */
-static int sha1_stream(char * filename, void *resblock, int timeout)
+static int sha1_stream(char * filename, void *resblock, 
+		       UINT64 Length, int timeout)
 {
   /* Important: BLOCKSIZE must be a multiple of 64.  */
@@ -1212,4 +1234,5 @@
   char * tmp;
   uid_t  euid;
+  UINT64 bcount = 0;
 
   unsigned long pages_read;
@@ -1275,4 +1298,12 @@
 	}
 
+      if (Length > 0)
+	{
+	  bcount += n;
+	  if (bcount > Length) 
+	    n = n - (bcount - Length);
+	  n = (n < 0) ? 0 : n;
+	}
+
       sum += n;
     }
@@ -1322,5 +1353,5 @@
 
 static char * sh_tiger_sha1_hash  (char * filename, TigerType what, 
-				   unsigned long Length, int timeout)
+				   UINT64 Length, int timeout)
 {
   int cnt = (int) Length;  /* fix compiler warning */
@@ -1337,5 +1368,5 @@
     }
 
-  (void) sha1_stream (filename, sha1buffer, timeout);
+  (void) sha1_stream (filename, sha1buffer, Length, timeout);
 
   /*@-bufferoverflowhigh -usedef@*/
@@ -1388,8 +1419,8 @@
 
 static char * sh_tiger_hash_internal (char * filename, TigerType what, 
-				      unsigned long Length, int timeout);
+				      UINT64 Length, int timeout);
 
 char * sh_tiger_hash (char * filename, TigerType what, 
-		      unsigned long Length)
+		      UINT64 Length)
 {
   return sh_tiger_hash_internal (filename, what, Length, 0);
@@ -1397,5 +1428,5 @@
 
 char * sh_tiger_generic_hash (char * filename, TigerType what, 
-			      unsigned long Length, int timeout)
+			      UINT64 Length, int timeout)
 {
 #ifdef USE_SHA1
@@ -1414,5 +1445,5 @@
   
 static char * sh_tiger_hash_internal (char * filename, TigerType what, 
-				      unsigned long Length, int timeout)
+				      UINT64 Length, int timeout)
 {
 #if defined(TIGER_64_BIT)
@@ -1423,5 +1454,5 @@
   static char out[KEY_LEN+1];
 
-  SL_ENTER( _("sh_tiger_hash"));
+  SL_ENTER( _("sh_tiger_hash_internal"));
 
   res = sh_tiger_hash_val (filename, what, Length, timeout);
@@ -1451,14 +1482,14 @@
       /*@+bufferoverflowhigh@*/
       out[KEY_LEN] = '\0';
-      SL_RETURN( out, _("sh_tiger_hash"));
+      SL_RETURN( out, _("sh_tiger_hash_internal"));
 
     }
 
    SL_RETURN( _("000000000000000000000000000000000000000000000000"), 
-	      _("sh_tiger_hash"));
+	      _("sh_tiger_hash_internal"));
 }
 
 char * sh_tiger_hash_gpg (char * filename, TigerType what, 
-			  unsigned long Length)
+			  UINT64 Length)
 {
   size_t  len;
@@ -1530,5 +1561,5 @@
 UINT32 * sh_tiger_hash_uint32 (char * filename, 
 			       TigerType what, 
-			       unsigned long Length)
+			       UINT64 Length)
 {
 #if defined(TIGER_64_BIT)
Index: trunk/src/sh_unix.c
===================================================================
--- trunk/src/sh_unix.c	(revision 18)
+++ trunk/src/sh_unix.c	(revision 19)
@@ -573,5 +573,5 @@
   if (mysignal == SIGUSR2)
     {
-      sig_suspend_switch    = 1;
+      ++sig_suspend_switch;
       ++sig_urgent;
     }
@@ -1582,5 +1582,6 @@
   if (skey->mlock_failed == SL_FALSE)
     {
-      if ( (-1) == sh_unix_mlock( (char *) skey, sizeof (sh_key_t)) ) 
+      if ( (-1) == sh_unix_mlock( FIL__, __LINE__, 
+				  (char *) skey, sizeof (sh_key_t)) ) 
 	{
 	  skey->mlock_failed = SL_TRUE;
@@ -2754,4 +2755,35 @@
 #include "sh_ignore.h"
 
+int sh_unix_checksum_size (char * filename, struct stat * fbuf, 
+			   char * fileHash, int alert_timeout)
+{
+  file_type tmpFile;
+  int status;
+
+  SL_ENTER(_("sh_unix_checksum_size"));
+
+  /* lookup file in database */
+  status = sh_hash_get_it (filename, &tmpFile);
+  if (status != 0) {
+    goto out;
+  }
+
+  /* if last < current get checksum */
+  if (tmpFile.size < fbuf->st_size)
+    {
+      strcpy(fileHash,                         /* known to fit */
+	     sh_tiger_generic_hash (filename, TIGER_FD, tmpFile.size, 
+				    alert_timeout));
+
+      /* return */
+      SL_RETURN( 0, _("sh_unix_checksum_size"));
+    }
+
+ out:
+  strcpy(fileHash,                              /* known to fit */
+	 _("000000000000000000000000000000000000000000000000"));
+  SL_RETURN( -1, _("sh_unix_checksum_size"));
+}
+
 int sh_unix_getinfo (int level, char * filename, file_type * theFile, 
 		     char * fileHash, int policy)
@@ -2891,5 +2923,5 @@
 		     _("000000000000000000000000000000000000000000000000"));
 	    }
-	  else if (policy == SH_LEVEL_PRELINK && 
+	  else if ((theFile->check_mask & MODI_PREL) != 0 && 
 		   S_TRUE == sh_prelink_iself(rval_open, fbuf.st_size, 
 					      alert_timeout))
@@ -2906,4 +2938,12 @@
 		     sh_tiger_generic_hash (theFile->fullpath, TIGER_FD, 0, 
 					    alert_timeout));
+	      if ((theFile->check_mask & MODI_SGROW) != 0)
+		{
+		  sl_rewind(rval_open);
+		  tiger_fd = rval_open;
+		  sh_unix_checksum_size (theFile->fullpath, &fbuf, 
+					 &fileHash[KEY_LEN + 1], 
+					 alert_timeout);
+		}
 	    }
 	}
@@ -2939,4 +2979,12 @@
 						alert_timeout),
 			 KEY_LEN + 1);
+	      if ((theFile->check_mask & MODI_SGROW) != 0) 
+		{
+		  sl_rewind(rval_open);
+		  tiger_fd = rval_open;
+		  sh_unix_checksum_size (theFile->fullpath, &fbuf, 
+					 &fileHash[KEY_LEN + 1], 
+					 alert_timeout);
+		}
 	    }
 	}
@@ -3648,4 +3696,6 @@
   unsigned long  page_start;
   int            page_refcount;
+  char           file[64];
+  int            line;
   struct sh_page_lt * next;
 } sh_page_l;
@@ -3691,5 +3741,5 @@
 
 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
-int sh_unix_mlock (void * in_addr, size_t len)
+int sh_unix_mlock (char * file, int line, void * in_addr, size_t len)
 {
   int         num_pages;
@@ -3755,4 +3805,6 @@
       page_list->page_start = addr;
       page_list->page_refcount = 1;
+      sl_strlcpy(page_list->file, file, 64);
+      page_list->line = line;
       status = mlock( (void *) addr, pagesize);
       if (status != 0)
@@ -3929,8 +3981,14 @@
   while (page_list != NULL)
     {
+#ifdef WITH_TPT
+      sl_snprintf(str, 128, _("file: %s line: %d page: %d"), 
+		  page_list->file, page_list->line, i+1);
+      sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, i, MSG_E_SUBGEN,
+		  str, _("sh_unix_count_mlock"));
+#endif
       page_list = page_list->next;
       ++i;
     }
-  sprintf(str, _("%d pages locked"), i);               /* known to fit  */
+  sl_snprintf(str, 128, _("%d pages locked"), i);
   sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, i, MSG_E_SUBGEN,
 		  str, _("sh_unix_count_mlock"));
