summaryrefslogtreecommitdiff
path: root/mysys/my_symlink2.c
diff options
context:
space:
mode:
authorunknown <svoj@june.mysql.com>2007-11-12 15:16:00 +0400
committerunknown <svoj@june.mysql.com>2007-11-12 15:16:00 +0400
commitc63fd4dd32154044c0fcca00d3ea0d5ddb614fee (patch)
treed6db35fefc5e9feede999e66574f618f6b6ce3df /mysys/my_symlink2.c
parent85425773e8fc6d71625c7476349839b0d372fb5f (diff)
parent88701b45a935016c31af3bd6817dd4ee4c7ccd37 (diff)
downloadmariadb-git-c63fd4dd32154044c0fcca00d3ea0d5ddb614fee.tar.gz
Merge mysql.com:/home/svoj/devel/mysql/BUG32111/mysql-4.1-engines
into mysql.com:/home/svoj/devel/mysql/BUG32111/mysql-5.0-engines mysql-test/r/symlink.result: Auto merged mysql-test/t/symlink.test: Auto merged mysys/my_symlink2.c: Auto merged
Diffstat (limited to 'mysys/my_symlink2.c')
-rw-r--r--mysys/my_symlink2.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/mysys/my_symlink2.c b/mysys/my_symlink2.c
index e2493874097..ee0a45cf93b 100644
--- a/mysys/my_symlink2.c
+++ b/mysys/my_symlink2.c
@@ -126,6 +126,7 @@ int my_rename_with_symlink(const char *from, const char *to, myf MyFlags)
int was_symlink= (!my_disable_symlinks &&
!my_readlink(link_name, from, MYF(0)));
int result=0;
+ int name_is_different;
DBUG_ENTER("my_rename_with_symlink");
if (!was_symlink)
@@ -134,6 +135,14 @@ int my_rename_with_symlink(const char *from, const char *to, myf MyFlags)
/* Change filename that symlink pointed to */
strmov(tmp_name, to);
fn_same(tmp_name,link_name,1); /* Copy dir */
+ name_is_different= strcmp(link_name, tmp_name);
+ if (name_is_different && !access(tmp_name, F_OK))
+ {
+ my_errno= EEXIST;
+ if (MyFlags & MY_WME)
+ my_error(EE_CANTCREATEFILE, MYF(0), tmp_name, EEXIST);
+ DBUG_RETURN(1);
+ }
/* Create new symlink */
if (my_symlink(tmp_name, to, MyFlags))
@@ -145,7 +154,7 @@ int my_rename_with_symlink(const char *from, const char *to, myf MyFlags)
the same basename and different directories.
*/
- if (strcmp(link_name, tmp_name) && my_rename(link_name, tmp_name, MyFlags))
+ if (name_is_different && my_rename(link_name, tmp_name, MyFlags))
{
int save_errno=my_errno;
my_delete(to, MyFlags); /* Remove created symlink */