Return to BSD News archive
Path: sserve!manuel!munnari.oz.au!uunet!auspex-gw!guy From: guy@Auspex.COM (Guy Harris) Newsgroups: comp.unix.bsd Subject: Re: Cpio and symbolic links (was Re: stock 0.1 swap not enough.) Keywords: cpio, bug, symbolic link Message-ID: <14081@auspex-gw.auspex.com> Date: 16 Aug 92 10:14:32 GMT References: <1992Aug9.175542.16722@mks.com> <Bszz1K.28B@twwells.com> <1992Aug15.143740.27391@vuse.vanderbilt.edu> Sender: news@auspex-gw.auspex.com Organization: Auspex Systems, Santa Clara Lines: 51 Nntp-Posting-Host: auspex.auspex.com >Even the SunOS version which was made aware of symlinks by a well-known wizard I've not tried rewriting UNIX from scratch, so I wouldn't go that far. :-) >has problems with symlinks in the presence of some combination of switches (in >my case "-pdl"). The "net-2" version has the symlink changes I made at Sun in it, which means it has the same bug. Here's the fix: *** cpio.c.dist Sun Aug 16 02:59:08 1992 --- cpio.c Sun Aug 16 02:59:16 1992 *************** *** 488,494 **** i++; strcpy(fullp, &(Hdr.h_name[i])); ! if( PassLink && !A_directory && Dev == Statb.st_dev ) { if(link(Hdr.h_name, Fullname) < 0) { switch(errno) { case ENOENT: --- 488,495 ---- i++; strcpy(fullp, &(Hdr.h_name[i])); ! if( PassLink && !A_directory && !A_symlink ! && Dev == Statb.st_dev ) { if(link(Hdr.h_name, Fullname) < 0) { switch(errno) { case ENOENT: which tells it not to make hard links to symlinks (in SunOS 4.x, at least, that results in hard links being made to the target of the symlink, even if it's a directory, if you have permission to do so; in SVR4, it results in a hard link being made to the symlink itself, so that people can still use the crufty old "link()"/"unlink()" hack to rename files, even if the file is a symlink). I think I see a place where the "net-2" version can screw up when writing symlinks out; normally, I'd put a patch out for that, but since I saw it when comparing the SunOS code I'd fixed here to the "net-2" code with the same fix applied, I'll not do so, for reasons that should be obvious to people reading other threads in this group. (1/2 :-)) I *will* say, however, that you should check to make sure that all the code that writes out stuff does the same sort of thing for symlinks that it does for other file types; if you do so, you may find the problem.... Then again, there may be a GNU "cpio", which may well be missing that bug and other bugs.