MCPcopy Create free account
hub / github.com/MariaDB/server / check_temp_dir

Function check_temp_dir

sql/slave.cc:5006–5058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5004static int check_temp_dir_result= 0;
5005
5006static
5007int check_temp_dir(char* tmp_file)
5008{
5009 File fd;
5010 int result= 1; // Assume failure
5011 MY_DIR *dirp;
5012 char tmp_dir[FN_REFLEN];
5013 size_t tmp_dir_size;
5014 DBUG_ENTER("check_temp_dir");
5015
5016 /* This look is safe to use as this function is only called once */
5017 mysql_mutex_lock(&LOCK_start_thread);
5018 if (check_temp_dir_run)
5019 {
5020 if ((result= check_temp_dir_result))
5021 my_message(result, tmp_file, MYF(0));
5022 goto end;
5023 }
5024 check_temp_dir_run= 1;
5025
5026 /*
5027 Get the directory from the temporary file.
5028 */
5029 dirname_part(tmp_dir, tmp_file, &tmp_dir_size);
5030
5031 /*
5032 Check if the directory exists.
5033 */
5034 if (!(dirp=my_dir(tmp_dir,MYF(MY_WME))))
5035 goto end;
5036 my_dirend(dirp);
5037
5038 /*
5039 Check permissions to create a file. We use O_TRUNC to ensure that
5040 things works even if we happen to have and old file laying around.
5041 */
5042 if ((fd= mysql_file_create(key_file_misc,
5043 tmp_file, CREATE_MODE,
5044 O_WRONLY | O_BINARY | O_TRUNC | O_NOFOLLOW,
5045 MYF(MY_WME))) < 0)
5046 goto end;
5047
5048 result= 0; // Directory name ok
5049 /*
5050 Clean up.
5051 */
5052 mysql_file_close(fd, MYF(0));
5053 mysql_file_delete(key_file_misc, tmp_file, MYF(0));
5054
5055end:
5056 mysql_mutex_unlock(&LOCK_start_thread);
5057 DBUG_RETURN(result);
5058}
5059
5060
5061void

Callers 1

handle_slave_sqlFunction · 0.85

Calls 4

my_messageFunction · 0.85
dirname_partFunction · 0.85
my_dirFunction · 0.85
my_direndFunction · 0.85

Tested by

no test coverage detected