~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_symlink.c

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
#include "mysys_priv.h"
17
17
#include "mysys_err.h"
18
 
#include <mystrings/m_string.h>
 
18
#include <m_string.h>
19
19
#include <errno.h>
20
20
#ifdef HAVE_REALPATH
21
21
#include <sys/param.h>
35
35
int my_readlink(char *to, const char *filename, myf MyFlags)
36
36
{
37
37
#ifndef HAVE_READLINK
38
 
  strcpy(to,filename);
 
38
  strmov(to,filename);
39
39
  return 1;
40
40
#else
41
41
  int result=0;
42
42
  int length;
 
43
  DBUG_ENTER("my_readlink");
43
44
 
44
45
  if ((length=readlink(filename, to, FN_REFLEN-1)) < 0)
45
46
  {
47
48
    if ((my_errno=errno) == EINVAL)
48
49
    {
49
50
      result= 1;
50
 
      strcpy(to,filename);
 
51
      strmov(to,filename);
51
52
    }
52
53
    else
53
54
    {
58
59
  }
59
60
  else
60
61
    to[length]=0;
61
 
  return(result);
 
62
  DBUG_PRINT("exit" ,("result: %d", result));
 
63
  DBUG_RETURN(result);
62
64
#endif /* HAVE_READLINK */
63
65
}
64
66
 
71
73
  return 0;
72
74
#else
73
75
  int result;
 
76
  DBUG_ENTER("my_symlink");
 
77
  DBUG_PRINT("enter",("content: %s  linkname: %s", content, linkname));
74
78
 
75
79
  result= 0;
76
80
  if (symlink(content, linkname))
82
86
  }
83
87
  else if ((MyFlags & MY_SYNC_DIR) && my_sync_dir_by_file(linkname, MyFlags))
84
88
    result= -1;
85
 
  return(result);
 
89
  DBUG_RETURN(result);
86
90
#endif /* HAVE_READLINK */
87
91
}
88
92
 
104
108
#define BUFF_LEN FN_LEN
105
109
#endif
106
110
 
107
 
int my_realpath(char *to, const char *filename, myf MyFlags)
 
111
int my_realpath(char *to, const char *filename,
 
112
                myf MyFlags __attribute__((unused)))
108
113
{
109
 
#if defined(HAVE_REALPATH) &&  !defined(HAVE_BROKEN_REALPATH)
 
114
#if defined(HAVE_REALPATH) && !defined(HAVE_purify) && !defined(HAVE_BROKEN_REALPATH)
110
115
  int result=0;
111
116
  char buff[BUFF_LEN];
112
117
  struct stat stat_buff;
 
118
  DBUG_ENTER("my_realpath");
113
119
 
114
120
  if (!(MyFlags & MY_RESOLVE_LINK) ||
115
121
      (!lstat(filename,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
116
122
  {
117
123
    char *ptr;
 
124
    DBUG_PRINT("info",("executing realpath"));
118
125
    if ((ptr=realpath(filename,buff)))
119
126
    {
120
 
      strncpy(to,ptr,FN_REFLEN-1);
 
127
      strmake(to,ptr,FN_REFLEN-1);
121
128
    }
122
129
    else
123
130
    {
126
133
        original name but will at least be able to resolve paths that starts
127
134
        with '.'.
128
135
      */
 
136
      DBUG_PRINT("error",("realpath failed with errno: %d", errno));
129
137
      my_errno=errno;
130
138
      if (MyFlags & MY_WME)
131
139
        my_error(EE_REALPATH, MYF(0), filename, my_errno);
132
 
      my_load_path(to, filename, NULL);
 
140
      my_load_path(to, filename, NullS);
133
141
      result= -1;
134
142
    }
135
143
  }
136
 
  return(result);
 
144
  DBUG_RETURN(result);
137
145
#else
138
 
  my_load_path(to, filename, NULL);
 
146
  my_load_path(to, filename, NullS);
139
147
  return 0;
140
148
#endif
141
149
}