home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / bsd / 4222 < prev    next >
Encoding:
Internet Message Format  |  1992-08-15  |  2.4 KB

  1. Path: sparky!uunet!auspex-gw!guy
  2. From: guy@Auspex.COM (Guy Harris)
  3. Newsgroups: comp.unix.bsd
  4. Subject: Re: Cpio and symbolic links (was Re: stock 0.1 swap not enough.)
  5. Keywords: cpio, bug, symbolic link
  6. Message-ID: <14081@auspex-gw.auspex.com>
  7. Date: 16 Aug 92 10:14:32 GMT
  8. References: <1992Aug9.175542.16722@mks.com> <Bszz1K.28B@twwells.com> <1992Aug15.143740.27391@vuse.vanderbilt.edu>
  9. Sender: news@auspex-gw.auspex.com
  10. Organization: Auspex Systems, Santa Clara
  11. Lines: 51
  12. Nntp-Posting-Host: auspex.auspex.com
  13.  
  14. >Even the SunOS version which was made aware of symlinks by a well-known wizard
  15.  
  16. I've not tried rewriting UNIX from scratch, so I wouldn't go that far.
  17. :-)
  18.  
  19. >has problems with symlinks in the presence of some combination of switches (in
  20. >my case "-pdl").
  21.  
  22. The "net-2" version has the symlink changes I made at Sun in it, which
  23. means it has the same bug.  Here's the fix:
  24.  
  25. *** cpio.c.dist    Sun Aug 16 02:59:08 1992
  26. --- cpio.c    Sun Aug 16 02:59:16 1992
  27. ***************
  28. *** 488,494 ****
  29.                   i++;
  30.               strcpy(fullp, &(Hdr.h_name[i]));
  31.   
  32. !             if( PassLink  &&  !A_directory  &&  Dev == Statb.st_dev ) {
  33.                   if(link(Hdr.h_name, Fullname) < 0) {
  34.                       switch(errno) {
  35.                           case ENOENT:
  36. --- 488,495 ----
  37.                   i++;
  38.               strcpy(fullp, &(Hdr.h_name[i]));
  39.   
  40. !             if( PassLink  &&  !A_directory  &&  !A_symlink
  41. !                 && Dev == Statb.st_dev ) {
  42.                   if(link(Hdr.h_name, Fullname) < 0) {
  43.                       switch(errno) {
  44.                           case ENOENT:
  45.  
  46. which tells it not to make hard links to symlinks (in SunOS 4.x, at
  47. least, that results in hard links being made to the target of the
  48. symlink, even if it's a directory, if you have permission to do so; in
  49. SVR4, it results in a hard link being made to the symlink itself, so
  50. that people can still use the crufty old "link()"/"unlink()" hack to
  51. rename files, even if the file is a symlink).
  52.  
  53. I think I see a place where the "net-2" version can screw up when
  54. writing symlinks out; normally, I'd put a patch out for that, but since
  55. I saw it when comparing the SunOS code I'd fixed here to the "net-2"
  56. code with the same fix applied, I'll not do so, for reasons that should
  57. be obvious to people reading other threads in this group. (1/2 :-))
  58.  
  59. I *will* say, however, that you should check to make sure that all the
  60. code that writes out stuff does the same sort of thing for symlinks that
  61. it does for other file types; if you do so, you may find the problem....
  62.  
  63. Then again, there may be a GNU "cpio", which may well be missing that
  64. bug and other bugs.
  65.