summaryrefslogtreecommitdiff
path: root/mysys/my_symlink.c
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-06-01 03:53:14 +0300
committerunknown <monty@hundin.mysql.fi>2001-06-01 03:53:14 +0300
commitb4773dc2fb1ff3bbc88c44cdce5ffdcdf893433d (patch)
tree18a56f1559667b7d6f2f77918362b9fca42865a5 /mysys/my_symlink.c
parent8c8244918fc37bb25656a5f8b451a362e4b16577 (diff)
downloadmariadb-git-b4773dc2fb1ff3bbc88c44cdce5ffdcdf893433d.tar.gz
Added symlink support to mysys library.
Docs/manual.texi: Link info change include/my_sys.h: Added functions for symlink support libmysql/Makefile.shared: Added mf_symlink.c to library. mysys/Makefile.am: Added functions for symlink support mysys/mf_same.c: cleanup mysys/my_symlink.c: Added functions for symlink support
Diffstat (limited to 'mysys/my_symlink.c')
-rw-r--r--mysys/my_symlink.c47
1 files changed, 7 insertions, 40 deletions
diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c
index e195adcd4c5..65d165fc026 100644
--- a/mysys/my_symlink.c
+++ b/mysys/my_symlink.c
@@ -18,6 +18,7 @@
#include "mysys_priv.h"
#include "mysys_err.h"
#include <m_string.h>
+#include <errno.h>
#ifdef HAVE_REALPATH
#include <sys/param.h>
#include <sys/stat.h>
@@ -26,13 +27,16 @@
/*
Reads the content of a symbolic link
If the file is not a symbolic link, return the original file name in to.
+ Returns: 0 if table was a symlink,
+ 1 if table was a normal file
+ -1 on error.
*/
int my_readlink(char *to, const char *filename, myf MyFlags)
{
#ifndef HAVE_READLINK
strmov(to,filename);
- return 0;
+ return 1;
#else
int result=0;
int length;
@@ -43,6 +47,7 @@ int my_readlink(char *to, const char *filename, myf MyFlags)
/* Don't give an error if this wasn't a symlink */
if ((my_errno=errno) == EINVAL)
{
+ result= 1;
strmov(to,filename);
}
else
@@ -81,44 +86,6 @@ int my_symlink(const char *content, const char *linkname, myf MyFlags)
#endif /* HAVE_READLINK */
}
-
-/*
- Create a file and a symbolic link that points to this file
- If linkname is a null pointer or equal to filename, we don't
- create a link.
- */
-
-
-File my_create_with_symlink(const char *linkname, const char *filename,
- int createflags, int access_flags, myf MyFlags)
-{
- File file;
- int tmp_errno;
- DBUG_ENTER("my_create_with_symlink");
- if ((file=my_create(filename, createflags, access_flags, MyFlags)) >= 0)
- {
- /* Test if we should create a link */
- if (linkname && strcmp(linkname,filename))
- {
- /* Delete old link/file */
- if (MyFlags & MY_DELETE_OLD)
- my_delete(linkname, MYF(0));
- /* Create link */
- if (my_symlink(filename, linkname, MyFlags))
- {
- /* Fail, remove everything we have done */
- tmp_errno=my_errno;
- my_close(file,MYF(0));
- my_delete(filename, MYF(0));
- file= -1;
- my_errno=tmp_errno;
- }
- }
- }
- DBUG_RETURN(file);
-}
-
-
/*
Resolve all symbolic links in path
'to' may be equal to 'filename'
@@ -162,7 +129,7 @@ int my_realpath(char *to, const char *filename, myf MyFlags)
result= -1;
}
}
- return result;
+ DBUG_RETURN(result);
#else
if (to != filename)
strmov(to,filename);