SCO Unix 386 3.2.0 rename() fails on 14 char file names!
david nugent
david at csource.oz.au
Fri Jul 6 00:29:04 AEST 1990
In <955 at barsoom.nhh.no> tih at 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 at csource.oz.au 3:632/348 at fidonet 28:4100/1 at signet
More information about the Comp.unix.i386
mailing list