| Summary: | Bug in mv(1) | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Samuel Tardieu <sam> | ||||
| Component: | bin | Assignee: | Pawel Jakub Dawidek <pjd> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | 4.9-STABLE | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
|
Description
Samuel Tardieu
2004-03-18 19:00:28 UTC
Responsible Changed From-To: freebsd-bugs->pjd I'll take this one. State Changed From-To: open->closed Fix commited to HEAD, will be MFCed after 3 days. I haven't used this patch, because it was incorrect in few places. Anyway, thank you for your report! On Thu, Mar 18, 2004 at 07:53:55PM +0100, Samuel Tardieu wrote: +> >Description: +> In some cases, mv is unable to move files. Four conditions must +> be met to have it fail as far as I can see: +> 1) The source must be a symlink +> 2) The target must be a symlink +> 3) The target must point onto a mounting point +> 4) The source and target must not be on the same filesystem +> +> In this case, mv will issue an inappropriate "cannot rename a +> mounting point" error. Thanks. I commited a fix to -CURRENT, but haven't used your patch. The problems with your patch are: 1. You should give "PATH_MAX - 1" to readlink() as it doesn't append NUL character. 2. When symlink() succeed and unlink() failed you aren't removing created symlink. 3. When target already exists, you don't remove it first, but you should. 4. You're not bothering about setting correct permissions and owner, etc. My patch is much simpler, it just use fastcopy() function when rename(2) fails with EXDEV and 'from' is a symblic link. http://www.freebsd.org/cgi/cvsweb.cgi/src/bin/mv/mv.c.diff?r1=1.41&r2=1.42 -- Pawel Jakub Dawidek http://www.FreeBSD.org pjd@FreeBSD.org http://garage.freebsd.pl FreeBSD committer Am I Evil? Yes, I Am! On 21/03, Pawel Jakub Dawidek wrote: | My patch is much simpler, it just use fastcopy() function when rename(2) | fails with EXDEV and 'from' is a symblic link. Yup, much simpler. I didn't realize that fastcopy() was able to copy symbolic links contents, I thought it could only copy file contents. Sam |