Index: trunk/include/sh_dbIO.h
===================================================================
--- trunk/include/sh_dbIO.h	(revision 542)
+++ trunk/include/sh_dbIO.h	(revision 543)
@@ -59,3 +59,11 @@
 int sh_dbIO_list_filter (const char * c);
 
+/* alternative rootfs */
+
+int sh_dbIO_init_rootfs (const char * rootfs);
+size_t sh_dbIO_get_rootfs_len();
+char * sh_dbIO_rootfs_prepend(char * path);
+char * sh_dbIO_rootfs_strip(char * path);
+char * sh_dbIO_rootfs_strip_link(char * path);
+
 #endif
Index: trunk/src/sh_dbIO.c
===================================================================
--- trunk/src/sh_dbIO.c	(revision 542)
+++ trunk/src/sh_dbIO.c	(revision 543)
@@ -385,4 +385,79 @@
       path[len-2] = '\0';
   }
+  return path;
+}
+
+/******************************************************************
+ *
+ * Use different init rootfs (patch by Kemal H.)
+ *
+ ******************************************************************/
+
+static char * sh_dbIO_rootfs = NULL;
+static size_t sh_dbIO_rootfs_len = 0;
+
+int sh_dbIO_init_rootfs (const char * rootfs)
+{
+  if (NULL == sh_dbIO_rootfs)
+    {
+      sh_dbIO_rootfs     = sh_util_strdup (rootfs);
+      sh_dbIO_rootfs_len = sl_strlen(sh_dbIO_rootfs);
+      return 0;
+    }
+  return -1;
+}
+
+size_t sh_dbIO_get_rootfs_len()
+{
+  return sh_dbIO_rootfs_len;
+}
+
+/* Prepend rootfs when reading from config file ('path' must be allocated with sufficient space).
+ */
+char * sh_dbIO_rootfs_prepend(char * path)
+{
+  if (0 == sh_dbIO_rootfs_len)
+    return path;
+  
+  memmove (path + sh_dbIO_rootfs_len, path, sl_strlen(path) + 1);
+  memcpy  (path, sh_dbIO_rootfs, sh_dbIO_rootfs_len);
+
+  return path;
+}
+
+
+/* Strip rootfs when writing to database file.
+ */
+char * sh_dbIO_rootfs_strip(char * path)
+{
+  if (sh_dbIO_rootfs_len == 0)
+    {
+      return path;
+    }
+  else
+    {
+      size_t len = sl_strlen(path);
+
+      memmove (path, path + sh_dbIO_rootfs_len, len + 1 - sh_dbIO_rootfs_len);
+      if(path[0] != '/')
+	{
+	  path[0]='/';
+	  path[1]='\0';
+	}
+    }
+
+  return path;
+}
+
+char * sh_dbIO_rootfs_strip_link(char * path)
+{
+  if (sh_dbIO_rootfs_len == 0)
+    return path;
+  if (strstr(path, sh_dbIO_rootfs) == path)
+    {
+      size_t len = sl_strlen(path);
+
+      memmove (path, path + sh_dbIO_rootfs_len, len + 1 - sh_dbIO_rootfs_len);
+    }
   return path;
 }
Index: trunk/src/sh_files.c
===================================================================
--- trunk/src/sh_files.c	(revision 542)
+++ trunk/src/sh_files.c	(revision 543)
@@ -215,10 +215,16 @@
 {
   char  * p;
-
+  
   if (!str_s || *str_s == '\0')
     return NULL;
 
   *len = sl_strlen(str_s);
-
+  if (sh.flag.checkSum == SH_CHECK_INIT)
+    {
+      size_t addspace = sh_dbIO_get_rootfs_len();
+      if (addspace != 0 && S_TRUE == sl_ok_adds (*len, addspace))
+	*len += addspace;
+    }
+  
   if ( (str_s[0] == '"'  && str_s[*len-1] == '"' ) ||
        (str_s[0] == '\'' && str_s[*len-1] == '\'') )
@@ -1421,4 +1427,7 @@
     SL_RETURN((-1), _("sh_files_pushfile"));
 
+  if (sh.flag.checkSum == SH_CHECK_INIT)
+    p = sh_dbIO_rootfs_prepend(p);
+      
   if (len >= PATH_MAX) 
     {
@@ -1855,4 +1864,7 @@
     }
 
+  if (sh.flag.checkSum == SH_CHECK_INIT)
+    tail = sh_dbIO_rootfs_prepend(tail);
+
   len = sl_strlen(tail);
 
@@ -2763,4 +2775,8 @@
 	MODI_SET(theFile->check_flags, MODI_NOCHECK);
       sh_tiger_get_mask_hashtype(&(theFile->check_flags));
+
+      sh_dbIO_rootfs_strip(theFile->fullpath);
+      if (theFile->link_path)
+	sh_dbIO_rootfs_strip_link(theFile->link_path);
       sh_dbIO_data_write (theFile, fileHash);
     }
Index: trunk/src/sh_getopt.c
===================================================================
--- trunk/src/sh_getopt.c	(revision 542)
+++ trunk/src/sh_getopt.c	(revision 543)
@@ -291,4 +291,9 @@
     HAS_ARG_YES, 
     sh_dbCreate},
+  { N_("init-rootfs"),  
+    '-', 
+    N_("Build database based on another rootfs"),  
+    HAS_ARG_YES, 
+    sh_dbIO_init_rootfs},
   { N_("wait-on-check"),  
     'w', 
Index: trunk/src/sh_suidchk.c
===================================================================
--- trunk/src/sh_suidchk.c	(revision 542)
+++ trunk/src/sh_suidchk.c	(revision 543)
@@ -1303,4 +1303,5 @@
 		    /* Running init. Report on files detected.
 		     */
+		    sh_dbIO_rootfs_strip(theFile->fullpath);
 		    sh_dbIO_data_write (theFile, fileHash); /* no call to sh_error_handle */
 		    SH_MUTEX_LOCK(mutex_thread_nolog);
