home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / gnu / utils / bug / 2017 < prev    next >
Encoding:
Text File  |  1992-11-08  |  5.2 KB  |  250 lines

  1. Newsgroups: gnu.utils.bug
  2. Path: sparky!uunet!think.com!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ced.berkeley.edu!jeg
  3. From: jeg@ced.berkeley.edu (James Ganong)
  4. Subject: more on tar-1.11.1 incremental dumps
  5. Message-ID: <9211090201.AA16987@ced.berkeley.edu>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Mon, 9 Nov 1992 02:01:08 GMT
  10. Approved: bug-gnu-utils@prep.ai.mit.edu
  11. Lines: 237
  12.  
  13. i sent in a patch for tar-1.11.1/gnu.c which i have repeated below.
  14.  
  15. one of the effects of the bug was to backup more directories
  16. than strictly necessary, which was a good thing because it
  17. mooted another bug that cause some dirs that should be backed up to get 
  18. skipped.
  19.  
  20. so if you use my first fix you probably want to use something
  21. like the second fix i am sending you in this note also.
  22.  
  23. here is my first patch:
  24.  
  25. ------- gnu.c -------
  26. 162,172c162,170
  27. <         strp=buf;
  28. <         dev=atol(strp);
  29. <         while(isdigit(*strp))
  30. <             strp++;
  31. <         ino=atol(strp);
  32. <         while(isspace(*strp))
  33. <             strp++;
  34. <         while(isdigit(*strp))
  35. <             strp++;
  36. <         strp++;
  37. <         add_dir(un_quote_string(strp),dev,ino,(char *)0);
  38. ---
  39. >         {
  40. >             unsigned long t,u;
  41. >             char scratch[1000];
  42. >             sscanf(buf, "%lu %lu %s", &t, &u, scratch);
  43. >             dev=t;
  44. >             ino=u;
  45. >         add_dir(un_quote_string(scratch),dev,ino,(char *)0);
  46. >         }
  47.  
  48. with just this patch in place the following test
  49. winds up with the file d/e/hi not being restored.
  50.  
  51. # set up the test data
  52.  
  53. rm -r d
  54. mkdir d
  55. mkdir d/d
  56. mkdir d/e
  57. echo hi > d/d/hi
  58.  
  59. # do a level 0 backup
  60.  
  61. rm date0
  62. tar -cvf tar0 -g date0 d
  63.  
  64. sleep 2
  65. mv d/d/hi d/e
  66.  
  67. # do a level 1 backup
  68. cp date0 date1
  69. tar -cvf tar1 -g date1 d
  70.  
  71. # now simulate loosing it all
  72. rm -r d
  73.  
  74. # do the restore
  75.  
  76. tar -xvf tar0 -G
  77.  
  78. tar -xvf tar1 -G
  79.  
  80.  
  81.  
  82. #end of test case
  83.  
  84. after this test case is run d/e/hi does not exist
  85. and wish i did.
  86.  
  87. i think the problem is that tar is not backup up the contents
  88. of the dir d/e when it is doing the level 1 backup:
  89. tar -cvf tar1 -g date1 d
  90. + tar -cvf tar1 -g date1 d
  91. d/
  92. d/d/
  93. d/e/
  94.  
  95.  
  96. tar-1.11.1 DOES backup the contents
  97. of the dir d/e, but i think for the wrong reasons, because
  98. it backs up the contents of ALL the directories.
  99.  
  100. tar -cvf tar1 -g date1 d
  101. tar: directory d/d has been renamed.
  102. tar: directory d/e has been renamed.
  103. d/
  104. d/d/
  105. d/e/
  106. d/e/hi
  107.  
  108. you can see the problem with the following test case with tar-1.11.1
  109.  
  110. # set up the test data
  111.  
  112. rm -r d
  113. mkdir d
  114. mkdir d/d
  115. mkdir d/e
  116. mkdir d/f
  117. echo hi > d/d/hi
  118. echo goodbye > d/f/bye
  119.  
  120. # do a level 0 backup
  121.  
  122. rm date0
  123. tar -cvf tar0 -g date0 d
  124.  
  125. sleep 2
  126. mv d/d/hi d/e
  127.  
  128. # do a level 1 backup
  129. cp date0 date1
  130. tar -cvf tar1 -g date1 d
  131.  
  132. # now simulate loosing it all
  133. rm -r d
  134.  
  135. # do the restore
  136.  
  137. tar -xvf tar0 -G
  138.  
  139. tar -xvf tar1 -G
  140.  
  141.  
  142.  
  143.  
  144. # end of test case
  145.  
  146. the problem is that dir d/f gets backed up in the level 1 backup even though
  147. nothing about it has changed:
  148.  
  149. tar -cvf tar1 -g date1 d
  150. tar: directory d/d has been renamed.
  151. tar: directory d/e has been renamed.
  152. tar: directory d/f has been renamed.
  153. d/
  154. d/d/
  155. d/e/
  156. d/f/
  157. d/e/hi
  158. d/f/bye
  159.  
  160. i noticed that when tar is deciding to incrementally dump a dir (or not
  161. it only looks at the inode number and device, not at the date.
  162. here is my patch to address this.  (along with my first patch,
  163. apply it to tar-1.11.1/gnu.c)  note that i don't really know what
  164. is going on here, so please look at it carefully before using it.
  165.  
  166.  
  167. *** gnu.c.orig    Sun Nov  8 17:53:14 1992
  168. --- gnu.c    Sun Nov  8 17:53:27 1992
  169. ***************
  170. *** 159,176 ****
  171.           strp= &buf[strlen(buf)];
  172.           if(strp[-1]=='\n')
  173.               strp[-1]='\0';
  174. !         strp=buf;
  175. !         dev=atol(strp);
  176. !         while(isdigit(*strp))
  177. !             strp++;
  178. !         ino=atol(strp);
  179. !         while(isspace(*strp))
  180. !             strp++;
  181. !         while(isdigit(*strp))
  182. !             strp++;
  183. !         strp++;
  184. !         add_dir(un_quote_string(strp),dev,ino,(char *)0);
  185. !     }
  186.       fclose(fp);
  187.   }
  188.   
  189. --- 159,174 ----
  190.           strp= &buf[strlen(buf)];
  191.           if(strp[-1]=='\n')
  192.               strp[-1]='\0';
  193. !         {
  194. !           unsigned long t,u;
  195. !           char scratch[1000];
  196. !        
  197. !           sscanf(buf, "%lu %lu %s", &t, &u, scratch);
  198. !           dev=t;
  199. !           ino=u;
  200. !           add_dir(un_quote_string(scratch),dev,ino,(char *)0);
  201. !         }
  202. !           }
  203.       fclose(fp);
  204.   }
  205.   
  206. ***************
  207. *** 377,391 ****
  208.                       if(   dp->dev!=hs.st_dev
  209.                           || dp->ino!=hs.st_ino) {
  210.                              if(f_verbose)
  211. !                             msg("directory %s has been renamed.",namebuf);
  212.                           dp->allnew=1;
  213.                           dp->dev=hs.st_dev;
  214.                           dp->ino=hs.st_ino;
  215.                       }
  216.                       dp->dir_text="";
  217.                   } else {
  218.                       if(f_verbose)
  219. !                         msg("Directory %s is new",namebuf);
  220.                       add_dir(namebuf,hs.st_dev,hs.st_ino,"");
  221.                       dp=get_dir(namebuf);
  222.                       dp->allnew=1;
  223. --- 375,398 ----
  224.                       if(   dp->dev!=hs.st_dev
  225.                           || dp->ino!=hs.st_ino) {
  226.                              if(f_verbose)
  227. !                           msg("%s is a new dir reusing an old dir name.",namebuf);
  228.                           dp->allnew=1;
  229.                           dp->dev=hs.st_dev;
  230.                           dp->ino=hs.st_ino;
  231. +                           } else if (f_new_files &&
  232. +                              new_time>hs.st_mtime &&
  233. +                              new_time>hs.st_mtime &&
  234. +                              (f_new_files>1 || new_time>hs.st_ctime)) {
  235. +                         if (f_verbose) {
  236. +                           msg("dir %s has been changed since previous .",namebuf);
  237. +                         }
  238. +                         dp->allnew=1;
  239.                       }
  240.                       dp->dir_text="";
  241.                   } else {
  242.                       if(f_verbose)
  243. !                       msg("%s is a new dir name",namebuf);
  244.                       add_dir(namebuf,hs.st_dev,hs.st_ino,"");
  245.                       dp=get_dir(namebuf);
  246.                       dp->allnew=1;
  247.  
  248.