# HG changeset patch # User Richard M. Stallman # Date 1119562166 0 # Node ID c3da886cec72ba44d68ab2b23140be1fea595873 # Parent 47f9bb41d14408535d85962816170c89752fe26c (Frename_file): Preserve owner and group, if possible. diff -r 47f9bb41d144 -r c3da886cec72 src/fileio.c --- a/src/fileio.c Thu Jun 23 21:28:07 2005 +0000 +++ b/src/fileio.c Thu Jun 23 21:29:26 2005 +0000 @@ -2775,6 +2775,7 @@ { if (errno == EXDEV) { + struct stat data; #ifdef S_IFLNK symlink_target = Ffile_symlink_p (file); if (! NILP (symlink_target)) @@ -2787,6 +2788,11 @@ so don't have copy-file prompt again. */ NILP (ok_if_already_exists) ? Qnil : Qt, Qt, Qnil); + + /* Preserve owner and group, if possible (if we are root). */ + if (stat (SDATA (encoded_file), &data) >= 0) + chown (SDATA (encoded_file), data.st_uid, data.st_gid); + Fdelete_file (file); } else