Skip to content

Commit

Permalink
cleanup: mysys_test_invalid_symlink
Browse files Browse the repository at this point in the history
Remove maria_test_invalid_symlink() and myisam_test_invalid_symlink(),
introduce mysys_test_invalid_symlink(). Other engines might need it too
  • Loading branch information
vuvova committed Feb 27, 2017
1 parent 24d8bc7 commit c826ac9
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 25 deletions.
2 changes: 2 additions & 0 deletions include/my_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ extern ulong my_crc_dbug_check;
typedef int (*Process_option_func)(void *ctx, const char *group_name,
const char *option);

extern int (*mysys_test_invalid_symlink)(const char *filename);

#include <my_alloc.h>


Expand Down
9 changes: 9 additions & 0 deletions mysys/my_symlink.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
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
it under the terms of the GNU General Public License as published by
Expand All @@ -23,6 +24,14 @@
#include <sys/stat.h>
#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
If the file is not a symbolic link, return the original file name in to.
Expand Down
2 changes: 1 addition & 1 deletion sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7267,7 +7267,7 @@ static int mysql_init_variables(void)
mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
#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 */
myisam_test_invalid_symlink= test_if_data_home_dir;
mysys_test_invalid_symlink= test_if_data_home_dir;
#endif
opt_log= opt_slow_log= 0;
opt_bin_log= opt_bin_log_used= 0;
Expand Down
4 changes: 0 additions & 4 deletions storage/maria/ha_maria.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3572,10 +3572,6 @@ static int ha_maria_init(void *p)
maria_pagecache->extra_debug= 1;
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)
maria_hton= 0;

Expand Down
4 changes: 2 additions & 2 deletions storage/maria/ma_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
MARIA_NAME_IEXT,
MY_UNPACK_FILENAME),MYF(0));
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;
DBUG_RETURN(0);
Expand Down Expand Up @@ -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_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;
return 1;
Expand Down
6 changes: 0 additions & 6 deletions storage/maria/ma_static.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ uint32 maria_readnext_vec[]=
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;

#ifdef HAVE_PSI_INTERFACE
Expand Down
4 changes: 2 additions & 2 deletions storage/myisam/mi_delete_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int mi_delete_table(const char *name)
#endif

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.
Expand All @@ -45,7 +45,7 @@ int mi_delete_table(const char *name)
DBUG_RETURN(my_errno);
}
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.
Expand Down
4 changes: 2 additions & 2 deletions storage/myisam/mi_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
realpath_err= my_realpath(name_buff,
fn_format(org_name,name,"",MI_NAME_IEXT,4),MYF(0));
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;
DBUG_RETURN (NULL);
Expand Down Expand Up @@ -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_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;
return 1;
Expand Down
8 changes: 0 additions & 8 deletions storage/myisam/mi_static.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ ulong myisam_data_pointer_size=4;
ulonglong myisam_mmap_size= SIZE_T_MAX, myisam_mmap_used= 0;
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_
Position is , == , >= , <= , > , <
Expand Down

0 comments on commit c826ac9

Please sign in to comment.