Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!munnari.oz.au!csource!david From: david@csource.oz.au (david nugent) Newsgroups: comp.unix.i386 Subject: Re: SCO Unix 386 3.2.0 rename() fails on 14 char file names! Message-ID: <553@csource.oz.au> Date: 5 Jul 90 14:29:04 GMT References: <955@barsoom.nhh.no> Distribution: comp Organization: Unique Computing Pty Ltd, Melb, Aust. Lines: 43 In <955@barsoom.nhh.no> tih@barsoom.nhh.no (Tom Ivar Helbekkmo) writes: >Just discovered a bug in the rename() library function under SCO Unix >here... If either of the file names passed as parameters is 14 >characters in length, the call fails with ENAMETOOLONG. Seems there's >a fence-post error in there... :-) To work around it, use > unlink(target); > link(source, target); > unlink(source); >instead of > rename(source, target); >and you'll be OK. Albiet with _zero_ error checking. If the link() fails, you'll have nothing left. :-( It may also destroy errno if it fails; the call to unlink() might also fail, and you'll be left with no idea what when wrong. I use the following function under Unix's where there's no rename: int rename (source, target) char *source, *target; { int r; (void) unlink (target); if (r = link (source, target)) (void) unlink (source); return r; } david -- _______________________________________________________________________________ Unique Computing Pty Ltd Melbourne Australia - Communications Specialists david@csource.oz.au 3:632/348@fidonet 28:4100/1@signet