#include "mysys_priv.h"#include "mysys_err.h"#include <my_dir.h>#include <errno.h>Include dependency graph for my_open.c:

Go to the source code of this file.
Functions | |
| File | my_open (const char *FileName, int Flags, myf MyFlags) |
| int | my_close (File fd, myf MyFlags) |
| File | my_register_filename (File fd, const char *FileName, enum file_type type_of_file, uint error_message_number, myf MyFlags) |
Definition at line 90 of file my_open.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, EE_BADCLOSE, err, errno, ME_BELL, ME_WAITTANG, mutex, my_errno, my_error(), MY_FAE, my_file_info, my_file_limit, my_file_opened, my_filename(), my_free, MY_WME, MYF, name, pthread_mutex_destroy, pthread_mutex_lock, pthread_mutex_unlock, st_my_file_info::type, and UNOPEN.
Referenced by cache_remove_open_tmp(), MYSQL_LOG::close(), MYSQL_BIN_LOG::close(), ha_tina::close(), close_cached_file(), com_edit(), compress(), ha_tina::create(), create_check_file(), create_defaults_file(), create_file(), create_frm(), create_instance_in_file(), create_pid_file(), default_local_infile_end(), destroy(), dump_local_log_entries(), dump_remote_log_entries(), dyn_string_cmp(), examine_log(), flush_error_log(), ha_archive::free_share(), free_share(), ft_init_stopwords(), get_options(), init_ddl_log(), load_db_opt(), main(), mapped_files::mapped_files(), mi_close(), mi_log(), mi_panic(), mi_sort_index(), my_append(), my_copy(), my_create_with_symlink(), my_read_charset_file(), my_register_filename(), myisamchk(), myrg_create(), myrg_open(), mysql_create_frm(), mysql_frm_type(), mysql_load(), MYSQL_LOG::open(), MYSQL_BIN_LOG::open(), open_binlog(), MYSQL_BIN_LOG::open_index_file(), open_table_def(), Load_log_processor::process(), Load_log_processor::process_first_event(), read_texts(), readfrm(), release_ddl_log(), ha_tina::repair(), ha_tina::rnd_end(), run_scheduler(), run_task(), sql_create_definition_file(), sql_parse_prepare(), str_to_file(), test_if_case_insensitive(), update_frm_version(), Item_load_file::val_str(), wait_pidfile(), write_db_opt(), writefrm(), and mapped_files::~mapped_files().
00091 { 00092 int err; 00093 DBUG_ENTER("my_close"); 00094 DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags)); 00095 00096 pthread_mutex_lock(&THR_LOCK_open); 00097 do 00098 { 00099 err= close(fd); 00100 } while (err == -1 && errno == EINTR); 00101 00102 if (err) 00103 { 00104 DBUG_PRINT("error",("Got error %d on close",err)); 00105 my_errno=errno; 00106 if (MyFlags & (MY_FAE | MY_WME)) 00107 my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG),my_filename(fd),errno); 00108 } 00109 if ((uint) fd < my_file_limit && my_file_info[fd].type != UNOPEN) 00110 { 00111 my_free(my_file_info[fd].name, MYF(0)); 00112 #if defined(THREAD) && !defined(HAVE_PREAD) 00113 pthread_mutex_destroy(&my_file_info[fd].mutex); 00114 #endif 00115 my_file_info[fd].type = UNOPEN; 00116 } 00117 my_file_opened--; 00118 pthread_mutex_unlock(&THR_LOCK_open); 00119 DBUG_RETURN(err); 00120 } /* my_close */
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 38 of file my_open.c.
References check_if_legal_filename(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, EE_FILENOTFOUND, errno, FILE_BY_OPEN, my_register_filename(), MY_S_IREAD, MY_S_IWRITE, my_umask, O_BINARY, O_SHARE, and SH_DENYNO.
Referenced by az_open(), com_edit(), create_check_file(), create_defaults_file(), create_instance_in_file(), default_local_infile_init(), dump_local_log_entries(), dyn_string_cmp(), examine_log(), flush_error_log(), ft_init_stopwords(), get_options(), ha_archive::get_share(), get_share(), ha_tina::init_tina_writer(), load_db_opt(), main(), mapped_files::mapped_files(), mi_open(), mi_open_datafile(), mi_open_keyfile(), mi_panic(), my_append(), my_copy(), my_read_charset_file(), myrg_open(), mysql_frm_type(), mysql_load(), MYSQL_LOG::open(), ha_tina::open(), open_binlog(), MYSQL_BIN_LOG::open_index_file(), open_table_def(), Load_log_processor::process(), read_ddl_log_header(), read_texts(), readfrm(), ha_tina::repair(), ha_tina::rnd_end(), run_scheduler(), run_task(), sql_parse_prepare(), str_to_file(), update_frm_version(), Item_load_file::val_str(), wait_pidfile(), and Show_instance_log::write_data().
00042 { 00043 File fd; 00044 DBUG_ENTER("my_open"); 00045 DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d", 00046 FileName, Flags, MyFlags)); 00047 #if defined(__WIN__) 00048 /* 00049 Check that we don't try to open or create a file name that may 00050 cause problems for us in the future (like PRN) 00051 */ 00052 if (check_if_legal_filename(FileName)) 00053 { 00054 errno= EACCES; 00055 DBUG_RETURN(my_register_filename(-1, FileName, FILE_BY_OPEN, 00056 EE_FILENOTFOUND, MyFlags)); 00057 } 00058 #ifndef __WIN__ 00059 if (Flags & O_SHARE) 00060 fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO, 00061 MY_S_IREAD | MY_S_IWRITE); 00062 else 00063 fd = open((my_string) FileName, Flags | O_BINARY, 00064 MY_S_IREAD | MY_S_IWRITE); 00065 #else 00066 fd= my_sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO, 00067 MY_S_IREAD | MY_S_IWRITE); 00068 #endif 00069 00070 #elif !defined(NO_OPEN_3) 00071 fd = open(FileName, Flags, my_umask); /* Normal unix */ 00072 #else 00073 fd = open((my_string) FileName, Flags); 00074 #endif 00075 DBUG_RETURN(my_register_filename(fd, FileName, FILE_BY_OPEN, 00076 EE_FILENOTFOUND, MyFlags)); 00077 } /* my_open */
Here is the call graph for this function:

Here is the caller graph for this function:

| File my_register_filename | ( | File | fd, | |
| const char * | FileName, | |||
| enum file_type | type_of_file, | |||
| uint | error_message_number, | |||
| myf | MyFlags | |||
| ) |
Definition at line 133 of file my_open.c.
References DBUG_PRINT, EE_OUT_OF_FILERESOURCES, errno, ME_BELL, ME_WAITTANG, mutex, my_close(), my_errno, my_error(), MY_FAE, MY_FFNF, my_file_info, my_file_limit, my_file_opened, MY_MUTEX_INIT_FAST, my_strdup(), MY_WME, MYF, name, pthread_mutex_init, pthread_mutex_lock, pthread_mutex_unlock, thread_safe_increment, and st_my_file_info::type.
Referenced by create_temp_file(), my_create(), my_dup(), and my_open().
00135 { 00136 if ((int) fd >= 0) 00137 { 00138 if ((uint) fd >= my_file_limit) 00139 { 00140 #if defined(THREAD) && !defined(HAVE_PREAD) 00141 (void) my_close(fd,MyFlags); 00142 my_errno=EMFILE; 00143 if (MyFlags & (MY_FFNF | MY_FAE | MY_WME)) 00144 my_error(EE_OUT_OF_FILERESOURCES, MYF(ME_BELL+ME_WAITTANG), 00145 FileName, my_errno); 00146 return(-1); 00147 #endif 00148 thread_safe_increment(my_file_opened,&THR_LOCK_open); 00149 return(fd); /* safeguard */ 00150 } 00151 pthread_mutex_lock(&THR_LOCK_open); 00152 if ((my_file_info[fd].name = (char*) my_strdup(FileName,MyFlags))) 00153 { 00154 my_file_opened++; 00155 my_file_info[fd].type = type_of_file; 00156 #if defined(THREAD) && !defined(HAVE_PREAD) 00157 pthread_mutex_init(&my_file_info[fd].mutex,MY_MUTEX_INIT_FAST); 00158 #endif 00159 pthread_mutex_unlock(&THR_LOCK_open); 00160 DBUG_PRINT("exit",("fd: %d",fd)); 00161 return(fd); 00162 } 00163 pthread_mutex_unlock(&THR_LOCK_open); 00164 (void) my_close(fd, MyFlags); 00165 my_errno=ENOMEM; 00166 } 00167 else 00168 my_errno=errno; 00169 DBUG_PRINT("error",("Got error %d on open",my_errno)); 00170 if (MyFlags & (MY_FFNF | MY_FAE | MY_WME)) 00171 my_error(error_message_number, MYF(ME_BELL+ME_WAITTANG), 00172 FileName, my_errno); 00173 return(fd); 00174 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7

