`warp=' term in configuration file

Anders Christensen anders@pvv.unit.no
Tue, 22 Aug 1995 23:29:47 +0200


Version 1.73; patch 001: Addition of `warp=' term to linktree

This patch allows the linktree to be spread on several partitions, and
it allows sub-hierarchies of the linktree to be included into the linktree 
by a symbolic link from the linktree. 

This patch was implemented specifically for Statoil, where this
functionality was required, and it has been running there for several
months. However, this patch was extracted a larger diff, and it has
not yet been taken back and tested.

The patch consists of the following changes:

  1) A new term is added for the `linktree' statement in the
     configuration file. This term is `warp=dirs', which declares that
     the named directories can be `warped'. 

     `Warping' means that if a linktree is defined with `warp=foobar',
     and /store/foobar is a symbolic link to a directory, then all
     scanning of the linktree will include the hierarchy pointed to by
     /store/foobar. Normally, Store would only notice that
     /store/foobar was pointing out of the store, and delete it; and
     under no circumstances would Store normally search the hiererachy
     pointed to by /store/foobar for links or files.

     This might be the result of amd-mounting sub-trees of the
     linktree; i.e. that /store/foobar is a pointer to
     /a/blah/blah/foobar.

  2) Previously, running `find' in the linktree in lib/findccl.pl, was
     done using `-inum $inum -prune' if the linktree (/store) and a
     server (/store/store) both resided on the same partition. Else,
     it was done using `-xdev'. 

     With this patch, neither of these two terms will occur in the
     find-process, provided that the linktree top and the server are
     not on the same device (physically), and that server is not
     located (logically) below the linktree (e.g. /store/store is
     logically below /store).

  3) With this patch, separate find-processes are run for the top of
     the linktree and all the warped directories of that linktree. 

  4) A new global variable, %'wrpdir, is introduced. It contains a
     per-linktree, space-separated list of all warped directories for
     that linktree. 

An example of the usage of the new term is:

   linktree foo dir=/store [...] warp=gnu,lib/tex [...]

which allows /store/gnu and /store/lib/tex to be located on another
partition than /store, e.g. if they are automounted using `amd'. 

diff -ur ver-1.73/cclient.pl current/cclient.pl
--- ver-1.73/cclient.pl	Sat Jul  8 19:17:20 1995
+++ current/cclient.pl	Tue Aug 22 18:14:30 1995
@@ -88,6 +88,10 @@
 
     @startdirs=&getstartdirs($topdir) ;
     &'output('Trace', "Startdirs @startdirs\n"); #'
+    if ($'wrpdir{$linktree}) {
+	@startdirs = &uniq(@startdirs, split(',',$'wrpdir{$linktree})) ; 
+    }  
+    grep( s|^|$'topdir{$linktree}/|, @startdirs ) ; 
    
 # There are two find operations. These two should be subsumed into
 # on (internal) find operation.
diff -ur ver-1.73/lib/client.pl current/lib/client.pl
--- ver-1.73/lib/client.pl	Sat Jul  8 19:41:25 1995
+++ current/lib/client.pl	Tue Aug 22 17:55:50 1995
@@ -200,7 +200,7 @@
    for $dir ( sort keys %dirs ) {
        next if $dir eq '';
        if ( lstat("$topdir/$dir") ) {
-	   unless ( -d _ ) {
+	   unless ( -d _ || ( grep(/^$dir$/,split(',',$'wrpdir{$linktree})))) {
 	       &'output('Warning',"$topdir/$dir was not a directory in linktree $linktree (but is now)\n",
 			'','',$app,$ver);
 	       unlink("$topdir/$dir");
diff -ur ver-1.73/lib/conffile.pl current/lib/conffile.pl
--- ver-1.73/lib/conffile.pl	Sat Jul  8 20:13:37 1995
+++ current/lib/conffile.pl	Tue Aug 22 17:55:57 1995
@@ -94,6 +94,7 @@
    undef %'hostnm ;             # Linktree host.
    undef %'topdir ;             # Physical Directory (e.g. /store, /usr/store).
    undef %'archit ;             # The linktree architecture.
+   undef %'wrpdir ;             # warpable directories (AChr '95)
    undef %'domnit ;             # The linktree domain.
    undef %'relpit ;             # The linktree level.
    undef %'archdomspecit ;     # 'Generic' specification of architecture and
@@ -240,6 +241,11 @@
             $'archit{$linktree}=$1,next if ( m/^arch=(.*)/ ) ;
             $'domnit{$linktree}=$1,next if ( m/^domain=(.*)/ ) ;
             $'relpit{$linktree}=$1,next if ( m/^level=(.*)/ ) ;
+#
+# The following two lines added by Anders Christensen 6 jan, 95; 
+# implements linktree warping and coexistence
+            $'wrpdir{$linktree}=$1,next if ( m/^warp=(.*)/ ) ;
+
             # This is like the parsing above:
             if ( m/^unwantedfile=(.*)/ ) {
                 $uwfile = $1 ;
diff -ur ver-1.73/lib/ficcl.pl current/lib/ficcl.pl
--- ver-1.73/lib/ficcl.pl	Sat Jul  8 20:15:11 1995
+++ current/lib/ficcl.pl	Tue Aug 22 17:56:06 1995
@@ -26,11 +26,11 @@
 	}
     }
     &'output('Trace', "findccl: \$regexp is '$regexp'\n"); 
-    $tdev = (stat($top))[0];
     chop($cwd = `pwd`);
-    foreach $topdir (@startdirs) {
+    foreach $topdir (grep(s|$|/.|,@startdirs)) {
 	(($topdev,$topino,$topmode) = lstat($topdir))
 	  || (warn("Can't lstat $topdir: $!\n"), next);
+ 	$tdev = $topdev ;
 	if (-d _) {
 	    if (chdir($topdir)) {
 		$topdir =~ s,/$,, ;
diff -ur ver-1.73/postinst.pl current/postinst.pl
--- ver-1.73/postinst.pl	Sat Jul  8 18:59:38 1995
+++ current/postinst.pl	Tue Aug 22 18:46:16 1995
@@ -164,25 +164,26 @@
 $inum = (stat("$stop"))[1];
 $idev = (stat("$stop"))[0];
 
-$ldev = (stat("$prf/."))[0];
+@allfiles = () ;
+foreach $subtree ( $prf, grep($_="$prf/$_",split(',',$'wrpdir{$lkt})) )
+{
+  next if (-l $subtree && ! -d "$subtree/.") ;
+  $ldev = (stat("$subtree/."))[0];
+  &'output('Trace', "Running find under $subtree (" . 
+	(($ldev==$idev)?"except inum $inum":"-xdev") . ")\n");
 
-if ( $ldev == $idev ) {
-  &'output('Trace', "Running find under $prf exceptinum $inum\n");
-
-  open (FOO, "find $prf/. -inum $inum -prune -o -type f -print|") ;
-  @allfiles = <FOO> ;
-  close (FOO);
-  chop (@allfiles );
-} else {
-  &'output('Trace', "Running find -xdev under $prf\n");
-
-  open (FOO, "find $prf/. -xdev -type f -print|") ;
-  @allfiles = <FOO> ;
+  if ($ldev==$idev) {
+     $term = "-inum $inum -prune -o" ;
+  } elsif (substr($stop,0,length($subtree)) eq $subtree) {
+     $term = "-xdev" ;
+  } else {
+     $term = "" ;
+  }
+  open (FOO, "find $subtree/. $term -type f -print|") ;
+  chop (@tmp = <FOO>) ;
+  push( @allfiles, @tmp ) ;
   close (FOO);
-  chop ( @allfiles );
 }
-
-#print "Found @allfiles\n" ;
 
 sub readnotlinks {
     local ( %notlinksregexps );