The following should summarize what I encountered.  I'll download the
4.0w version and give it a try.

phil@procyon:/home/phil 2704> mv --version
mv (GNU fileutils) 4.0
phil@procyon:/home/phil 2705> rm -fr testdir1 testdir2
phil@procyon:/home/phil 2706> mkdir testdir1 testdir2
phil@procyon:/home/phil 2707> touch testdir1/file1
phil@procyon:/home/phil 2708> ln testdir1/file1 testdir1/file2
phil@procyon:/home/phil 2709> mv testdir1/file1 testdir1/file2 testdir2
mv: testdir2/file2: No such file or directory
phil@procyon:/home/phil 2710> ls -il testdir*/file*
1310995 -rw-------   2 phil     phil            0 Jul 23 12:13 testdir1/file2
1310995 -rw-------   2 phil     phil            0 Jul 23 12:13 testdir2/file1
phil@procyon:/home/phil 2711>

The platform is Intel x86, Slackware 7.0, Linux 2.2.16, libc 2.1.2.


> Thanks for the reports and patch.
> I don't see what version of mv you're using, but suspect it's
> no newer than the one from fileutils-4.0.
> 
> That bug is fixed in the latest test release.
> (and in every test release since 4.0)
> 
>   ftp://alpha.gnu.org/gnu/fetish/fileutils-4.0w.tar.gz
> 
> [btw, you shouldn't use strdup there -- it'd introduce a leak]
> 
> "Daniel R. Grayson" <[EMAIL PROTECTED]> writes:
> | It turns out to be a memory allocation bug.  Sometimes "mv" has to copy the
> | files, instead of moving them, for example, when moving from one filesystem
> | to another.  So keeps track of the inode numbers of the files it's already
> | moved, so in case it is about to move another link to a file it's already
> | moved, it can simply make a new link on the new file system.  Unfortunately,
> | when it saves the destination name of that earlier file, it forgets to create
> | a new copy of the string, so the memory for that string gets freed, the next
> | string gets the same memory, and over-writes it.
> |
> | Here is a fix.
> |
> | rhenium# diff -u fileutils-4.0/src/cp-hash.c-orig fileutils-4.0/src/cp-hash.c
> | --- fileutils-4.0/src/cp-hash.c-orig        Tue Jul 18 19:40:37 2000
> | +++ fileutils-4.0/src/cp-hash.c     Tue Jul 18 19:40:42 2000
> | @@ -156,7 +156,7 @@
> |    ep = *hp = &ht->entry_tab[ht->first_free_entry++];
> |    ep->ino = ino;
> |    ep->dev = dev;
> | -  ep->node = (char *) node;
> | +  ep->node = (char *) strdup(node);
> |    ep->coll_link = ep2;             /* ep2 is NULL if not collision.  */
> |
> |    return NULL;
> [...]
> 


-- 
| Phil Howard - KA9WGN | My current websites: linuxhomepage.com, ham.org
| phil  (at)  ipal.net +----------------------------------------------------
| Dallas - Texas - USA | [EMAIL PROTECTED]

Reply via email to