* bug#5496: xdev rename-file of symlinks-to-directories broken
@ 2010-01-30 2:15 David De La Harpe Golden
2010-01-31 4:50 ` Chong Yidong
0 siblings, 1 reply; 2+ messages in thread
From: David De La Harpe Golden @ 2010-01-30 2:15 UTC (permalink / raw)
To: 5496
[-- Attachment #1: Type: text/plain, Size: 850 bytes --]
So, file-directory-p returns non-nil for symlinks to directories, so
delete-directory now (i.e. following #5436/#3353) gets incorrectly
called in rename-file if you try to rename a symlink-to-a-directory to a
location on another device. The copy-directory bit is already guarded
appropriately, but not the delete-directory bit.
delete-directory at least then fails rather than following the symlink
and then recursively deleting. However, the result a user would no doubt
expect is for just the symlink to be renamed.
e.g. /tmp and /home different filesystems
mkdir /home/david/foo
cd /tmp
mkdir bar
ln -s bar baz
; in emacs
(rename-file "/tmp/baz" "/home/david/foo")
result:
baz symlink to a "bar" in /home/david/foo
- consistent with shell mv behaviour.
Unfortunately, /tmp/baz won't be removed properly without attached tiny
patch.
[-- Attachment #2: symlink_dir_rename_r1.diff --]
[-- Type: text/x-patch, Size: 779 bytes --]
=== modified file 'src/fileio.c'
--- src/fileio.c 2010-01-28 17:47:05 +0000
+++ src/fileio.c 2010-01-30 01:50:33 +0000
@@ -2295,17 +2295,21 @@
/* We have already prompted if it was an integer, so don't
have copy-file prompt again. */
Fcopy_file (file, newname,
NILP (ok_if_already_exists) ? Qnil : Qt,
Qt, Qt);
count = SPECPDL_INDEX ();
specbind (Qdelete_by_moving_to_trash, Qnil);
- if (!NILP (Ffile_directory_p (file)))
+ if (
+#ifdef S_IFLNK
+ (NILP (symlink_target)) &&
+#endif
+ (!NILP (Ffile_directory_p (file))))
call2 (Qdelete_directory, file, Qt);
else
Fdelete_file (file);
unbind_to (count, Qnil);
}
else
report_file_error ("Renaming", list2 (file, newname));
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#5496: xdev rename-file of symlinks-to-directories broken
2010-01-30 2:15 bug#5496: xdev rename-file of symlinks-to-directories broken David De La Harpe Golden
@ 2010-01-31 4:50 ` Chong Yidong
0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2010-01-31 4:50 UTC (permalink / raw)
To: David De La Harpe Golden; +Cc: 5496
> mkdir /home/david/foo
> cd /tmp
> mkdir bar
> ln -s bar baz
>
> ; in emacs
> (rename-file "/tmp/baz" "/home/david/foo")
>
> result:
> baz symlink to a "bar" in /home/david/foo
> - consistent with shell mv behaviour.
> Unfortunately, /tmp/baz won't be removed properly without attached tiny
> patch.
Patch looks reasonable. Checked in, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-01-31 4:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-30 2:15 bug#5496: xdev rename-file of symlinks-to-directories broken David De La Harpe Golden
2010-01-31 4:50 ` Chong Yidong
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).