Commit c826ac9d authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: mysys_test_invalid_symlink

Remove maria_test_invalid_symlink() and myisam_test_invalid_symlink(),
introduce mysys_test_invalid_symlink(). Other engines might need it too
parent 24d8bc70
...@@ -548,6 +548,8 @@ extern ulong my_crc_dbug_check; ...@@ -548,6 +548,8 @@ extern ulong my_crc_dbug_check;
typedef int (*Process_option_func)(void *ctx, const char *group_name, typedef int (*Process_option_func)(void *ctx, const char *group_name,
const char *option); const char *option);
extern int (*mysys_test_invalid_symlink)(const char *filename);
#include <my_alloc.h> #include <my_alloc.h>
......
/* /*
Copyright (c) 2001, 2011, Oracle and/or its affiliates Copyright (c) 2001, 2011, Oracle and/or its affiliates
Copyright (c) 2010, 2017, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -23,6 +24,14 @@ ...@@ -23,6 +24,14 @@
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
static int always_valid(const char *filename __attribute__((unused)))
{
return 0;
}
int (*mysys_test_invalid_symlink)(const char *filename)= always_valid;
/* /*
Reads the content of a symbolic link Reads the content of a symbolic link
If the file is not a symbolic link, return the original file name in to. If the file is not a symbolic link, return the original file name in to.
......
...@@ -7267,7 +7267,7 @@ static int mysql_init_variables(void) ...@@ -7267,7 +7267,7 @@ static int mysql_init_variables(void)
mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0; mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
#if defined(HAVE_REALPATH) && !defined(HAVE_valgrind) && !defined(HAVE_BROKEN_REALPATH) #if defined(HAVE_REALPATH) && !defined(HAVE_valgrind) && !defined(HAVE_BROKEN_REALPATH)
/* We can only test for sub paths if my_symlink.c is using realpath */ /* We can only test for sub paths if my_symlink.c is using realpath */
myisam_test_invalid_symlink= test_if_data_home_dir; mysys_test_invalid_symlink= test_if_data_home_dir;
#endif #endif
opt_log= opt_slow_log= 0; opt_log= opt_slow_log= 0;
opt_bin_log= opt_bin_log_used= 0; opt_bin_log= opt_bin_log_used= 0;
......
...@@ -3572,10 +3572,6 @@ static int ha_maria_init(void *p) ...@@ -3572,10 +3572,6 @@ static int ha_maria_init(void *p)
maria_pagecache->extra_debug= 1; maria_pagecache->extra_debug= 1;
maria_assert_if_crashed_table= debug_assert_if_crashed_table; maria_assert_if_crashed_table= debug_assert_if_crashed_table;
#if defined(HAVE_REALPATH) && !defined(HAVE_valgrind) && !defined(HAVE_BROKEN_REALPATH)
/* We can only test for sub paths if my_symlink.c is using realpath */
maria_test_invalid_symlink= test_if_data_home_dir;
#endif
if (res) if (res)
maria_hton= 0; maria_hton= 0;
......
...@@ -288,7 +288,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -288,7 +288,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
MARIA_NAME_IEXT, MARIA_NAME_IEXT,
MY_UNPACK_FILENAME),MYF(0)); MY_UNPACK_FILENAME),MYF(0));
if (my_is_symlink(org_name) && if (my_is_symlink(org_name) &&
(realpath_err || (*maria_test_invalid_symlink)(name_buff))) (realpath_err || mysys_test_invalid_symlink(name_buff)))
{ {
my_errno= HA_WRONG_CREATE_OPTION; my_errno= HA_WRONG_CREATE_OPTION;
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -1880,7 +1880,7 @@ int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share, const char *org_name, ...@@ -1880,7 +1880,7 @@ int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share, const char *org_name,
if (my_is_symlink(real_data_name)) if (my_is_symlink(real_data_name))
{ {
if (my_realpath(real_data_name, real_data_name, MYF(0)) || if (my_realpath(real_data_name, real_data_name, MYF(0)) ||
(*maria_test_invalid_symlink)(real_data_name)) mysys_test_invalid_symlink(real_data_name))
{ {
my_errno= HA_WRONG_CREATE_OPTION; my_errno= HA_WRONG_CREATE_OPTION;
return 1; return 1;
......
...@@ -106,12 +106,6 @@ uint32 maria_readnext_vec[]= ...@@ -106,12 +106,6 @@ uint32 maria_readnext_vec[]=
SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_SMALLER SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_SMALLER
}; };
static int always_valid(const char *filename __attribute__((unused)))
{
return 0;
}
int (*maria_test_invalid_symlink)(const char *filename)= always_valid;
my_bool (*ma_killed)(MARIA_HA *)= ma_killed_standalone; my_bool (*ma_killed)(MARIA_HA *)= ma_killed_standalone;
#ifdef HAVE_PSI_INTERFACE #ifdef HAVE_PSI_INTERFACE
......
...@@ -30,7 +30,7 @@ int mi_delete_table(const char *name) ...@@ -30,7 +30,7 @@ int mi_delete_table(const char *name)
#endif #endif
fn_format(from,name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); fn_format(from,name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from)) if (my_is_symlink(from) && mysys_test_invalid_symlink(from))
{ {
/* /*
Symlink is pointing to file in data directory. Symlink is pointing to file in data directory.
...@@ -45,7 +45,7 @@ int mi_delete_table(const char *name) ...@@ -45,7 +45,7 @@ int mi_delete_table(const char *name)
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
} }
fn_format(from,name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); fn_format(from,name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from)) if (my_is_symlink(from) && mysys_test_invalid_symlink(from))
{ {
/* /*
Symlink is pointing to file in data directory. Symlink is pointing to file in data directory.
......
...@@ -93,7 +93,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -93,7 +93,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
realpath_err= my_realpath(name_buff, realpath_err= my_realpath(name_buff,
fn_format(org_name,name,"",MI_NAME_IEXT,4),MYF(0)); fn_format(org_name,name,"",MI_NAME_IEXT,4),MYF(0));
if (my_is_symlink(org_name) && if (my_is_symlink(org_name) &&
(realpath_err || (*myisam_test_invalid_symlink)(name_buff))) (realpath_err || mysys_test_invalid_symlink(name_buff)))
{ {
my_errno= HA_WRONG_CREATE_OPTION; my_errno= HA_WRONG_CREATE_OPTION;
DBUG_RETURN (NULL); DBUG_RETURN (NULL);
...@@ -1246,7 +1246,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, const char *org_name, ...@@ -1246,7 +1246,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, const char *org_name,
if (my_is_symlink(real_data_name)) if (my_is_symlink(real_data_name))
{ {
if (my_realpath(real_data_name, real_data_name, MYF(0)) || if (my_realpath(real_data_name, real_data_name, MYF(0)) ||
(*myisam_test_invalid_symlink)(real_data_name)) mysys_test_invalid_symlink(real_data_name))
{ {
my_errno= HA_WRONG_CREATE_OPTION; my_errno= HA_WRONG_CREATE_OPTION;
return 1; return 1;
......
...@@ -42,14 +42,6 @@ ulong myisam_data_pointer_size=4; ...@@ -42,14 +42,6 @@ ulong myisam_data_pointer_size=4;
ulonglong myisam_mmap_size= SIZE_T_MAX, myisam_mmap_used= 0; ulonglong myisam_mmap_size= SIZE_T_MAX, myisam_mmap_used= 0;
my_bool (*mi_killed)(MI_INFO *)= mi_killed_standalone; my_bool (*mi_killed)(MI_INFO *)= mi_killed_standalone;
static int always_valid(const char *filename __attribute__((unused)))
{
return 0;
}
int (*myisam_test_invalid_symlink)(const char *filename)= always_valid;
/* /*
read_vec[] is used for converting between P_READ_KEY.. and SEARCH_ read_vec[] is used for converting between P_READ_KEY.. and SEARCH_
Position is , == , >= , <= , > , < Position is , == , >= , <= , > , <
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment