summaryrefslogtreecommitdiff
path: root/mysys/my_symlink2.c
diff options
context:
space:
mode:
authorunknown <svoj@june.mysql.com>2007-11-12 15:26:37 +0400
committerunknown <svoj@june.mysql.com>2007-11-12 15:26:37 +0400
commite1d98e8d51b3cd95d9ce4ac4afe56cd74ad4830b (patch)
tree416675f554f9510d74bab6b059d70c318873771d /mysys/my_symlink2.c
parent076f2f732df6670a3ee7b8e290b2b66a04a77fe6 (diff)
parentc63fd4dd32154044c0fcca00d3ea0d5ddb614fee (diff)
downloadmariadb-git-e1d98e8d51b3cd95d9ce4ac4afe56cd74ad4830b.tar.gz
Merge mysql.com:/home/svoj/devel/mysql/BUG32111/mysql-5.0-engines
into mysql.com:/home/svoj/devel/mysql/BUG32111/mysql-5.1-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 2a46fb3abea..7c3ddbb911c 100644
--- a/mysys/my_symlink2.c
+++ b/mysys/my_symlink2.c
@@ -130,6 +130,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)
@@ -138,6 +139,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))
@@ -149,7 +158,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 */