smbclient, tar, and exclude

Glenn Burkhardt glenn at aoi.ultranet.com
Thu Jul 24 18:48:24 GMT 1997


As of release samba-1.9.16p11, the X option (exclude file) for tar
creates doesn't work recursively; if the exclude file is a directory,
files that are in the directory or subdirectories are not excluded from
the tar create.  

I would like the exclude feature to work recursively, and attached is a
patch to do it.  The exclude feature works the same way for both create
and extracts.


*** clitar.c	Thu Jul 24 14:05:49 1997
--- clitar.c.new	Thu Jul 24 13:58:29 1997
***************
*** 372,381 ****
  }
  
  /****************************************************************************
! Compare two strings in a slash insensitive way
  ***************************************************************************/
! int strslashcmp(char *s1,char *s2)
  {
    while(*s1 && *s2 &&
  	(*s1 == *s2
  	 || tolower(*s1) == tolower(*s2)
--- 372,386 ----
  }
  
  /****************************************************************************
! Compare two strings in a slash insensitive way, allowing s1 to match s2 
! if s1 is an "initial" string (up to directory marker).  Thus, if s2 is 
! a file in any subdirectory of s1, declare a match.
  ***************************************************************************/
! static
! int strslashcmp(char *s1, char *s2)
  {
+   char *s1_0=s1;
+ 
    while(*s1 && *s2 &&
  	(*s1 == *s2
  	 || tolower(*s1) == tolower(*s2)
***************
*** 384,389 ****
--- 389,405 ----
  	  s1++; s2++;
    }
  
+   /* if s1 has a trailing slash, it compared equal, so s1 is an "initial" 
+      string of s2.
+    */
+   if (!*s1 && s1 != s1_0 && (*(s1-1) == '/' || *(s1-1) == '\\')) return 0;
+ 
+   /* ignore trailing slash on s1 */
+   if (!*s2 && (*s1 == '/' || *s1 == '\\') && !*(s1+1)) return 0;
+ 
+   /* check for s1 is an "initial" string of s2 */
+   if (*s2 == '/' || *s2 == '\\') return 0;
+ 
    return *s1-*s2;
  }
  
***************
*** 1127,1137 ****
  
      strcpy(exclaim, cur_dir);
      *(exclaim+strlen(exclaim)-1)='\0';
- 
-     if (clipfind(cliplist, clipn, exclaim)) {
-       DEBUG(3,("Skipping directory %s\n", exclaim));
-       return;
-     }
  
      strcat(exclaim, "\\");
      strcat(exclaim, finfo->name);
--- 1143,1148 ----
*** proto.h	Thu Jul 24 14:32:28 1997
--- proto.h.new	Thu Jul 24 10:56:09 1997
***************
*** 50,56 ****
  
  /*The following definitions come from  clitar.c  */
  
- int strslashcmp(char *s1,char *s2);
  int padit(char *buf, int bufsize, int padsize);
  void cmd_block(void);
  void cmd_tarmode(void);
--- 50,55 ----


More information about the samba mailing list