The world's most popular open source database
#include <sys/stat.h>Include dependency graph for my_dir.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Classes | |
| struct | fileinfo |
| struct | st_my_dir |
Defines | |
| #define | MY_S_IFMT S_IFMT |
| #define | MY_S_IFDIR S_IFDIR |
| #define | MY_S_IFCHR S_IFCHR |
| #define | MY_S_IFBLK S_IFBLK |
| #define | MY_S_IFREG S_IFREG |
| #define | MY_S_IFIFO S_IFIFO |
| #define | MY_S_ISUID S_ISUID |
| #define | MY_S_ISGID S_ISGID |
| #define | MY_S_ISVTX S_ISVTX |
| #define | MY_S_IREAD S_IREAD |
| #define | MY_S_IWRITE S_IWRITE |
| #define | MY_S_IEXEC S_IEXEC |
| #define | MY_S_ISDIR(m) (((m) & MY_S_IFMT) == MY_S_IFDIR) |
| #define | MY_S_ISCHR(m) (((m) & MY_S_IFMT) == MY_S_IFCHR) |
| #define | MY_S_ISBLK(m) (((m) & MY_S_IFMT) == MY_S_IFBLK) |
| #define | MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG) |
| #define | MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO) |
| #define | MY_DONT_SORT 512 |
| #define | MY_WANT_STAT 1024 |
| #define | MY_STAT struct stat |
Typedefs | |
| typedef fileinfo | FILEINFO |
| typedef st_my_dir | MY_DIR |
Functions | |
| MY_DIR * | my_dir (const char *path, myf MyFlags) |
| void | my_dirend (MY_DIR *buffer) |
| MY_STAT * | my_stat (const char *path, MY_STAT *stat_area, myf my_flags) |
| int | my_fstat (int filenr, MY_STAT *stat_area, myf MyFlags) |
| #define MY_DONT_SORT 512 |
Definition at line 49 of file my_dir.h.
Referenced by find_uniq_filename(), my_dir(), mysql_rename_db(), mysql_rm_db(), mysql_rm_known_files(), and mysql_rm_tmp_tables().
| #define MY_S_IREAD S_IREAD |
| #define MY_S_ISDIR | ( | m | ) | (((m) & MY_S_IFMT) == MY_S_IFDIR) |
| #define MY_S_ISREG | ( | m | ) | (((m) & MY_S_IFMT) == MY_S_IFREG) |
Definition at line 46 of file my_dir.h.
Referenced by get_options(), sys_check_log_path(), and Show_instance_log_files::write_data().
| #define MY_S_IWRITE S_IWRITE |
Definition at line 40 of file my_dir.h.
Referenced by my_create(), my_open(), and sys_check_log_path().
| #define MY_STAT struct stat |
Definition at line 73 of file my_dir.h.
Referenced by com_edit(), create_sys_files(), dyn_string_cmp(), File_class::exists(), get_options(), get_share(), ha_archive::info(), main(), mi_status(), modify_defaults_file(), my_copy(), my_dir(), my_read_charset_file(), my_rename(), mysql_create_db(), mysql_load(), prepare_for_repair(), readfrm(), search_default_file_with_ext(), sql_parse_prepare(), sys_check_log_path(), test_file_exists_res(), test_if_case_insensitive(), Item_load_file::val_str(), and Show_instance_log::write_data().
| #define MY_WANT_STAT 1024 |
Definition at line 98 of file my_lib.c.
References ALIGN_SIZE, alloc_root(), buffer, st_dynamic_array::buffer, bzero, comp_names(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_my_dir::dir_entry, directory_file_name(), dirent, EE_DIR, st_dynamic_array::elements, ENTRIES_INCREMENT, ENTRIES_START_SIZE, errno, error, FN_REFLEN, init_alloc_root(), ME_BELL, ME_WAITTANG, my_dirend(), MY_DONT_SORT, my_errno, my_error(), MY_FAE, my_free, my_init_dynamic_array, my_malloc(), MY_S_IREAD, MY_STAT, my_stat(), MY_WANT_STAT, MY_WME, MYF, fileinfo::mystat, fileinfo::name, NAMES_START_SIZE, NULL, st_my_dir::number_off_files, pthread_mutex_lock, pthread_mutex_unlock, push_dynamic, qsort(), qsort_cmp, READDIR, strdup_root(), strend(), strmov(), and VOID.
Referenced by find_files(), find_uniq_filename(), main(), mysql_rename_db(), mysql_rm_db(), mysql_rm_known_files(), mysql_rm_tmp_tables(), and search_default_file_with_ext().
00099 { 00100 char *buffer; 00101 MY_DIR *result= 0; 00102 FILEINFO finfo; 00103 DYNAMIC_ARRAY *dir_entries_storage; 00104 MEM_ROOT *names_storage; 00105 DIR *dirp; 00106 struct dirent *dp; 00107 char tmp_path[FN_REFLEN+1],*tmp_file; 00108 #ifdef THREAD 00109 char dirent_tmp[sizeof(struct dirent)+_POSIX_PATH_MAX+1]; 00110 #endif 00111 DBUG_ENTER("my_dir"); 00112 DBUG_PRINT("my",("path: '%s' MyFlags: %d",path,MyFlags)); 00113 00114 #if defined(THREAD) && !defined(HAVE_READDIR_R) 00115 pthread_mutex_lock(&THR_LOCK_open); 00116 #endif 00117 00118 dirp = opendir(directory_file_name(tmp_path,(my_string) path)); 00119 #if defined(__amiga__) 00120 if ((dirp->dd_fd) < 0) /* Directory doesn't exists */ 00121 goto error; 00122 #endif 00123 if (dirp == NULL || 00124 ! (buffer= my_malloc(ALIGN_SIZE(sizeof(MY_DIR)) + 00125 ALIGN_SIZE(sizeof(DYNAMIC_ARRAY)) + 00126 sizeof(MEM_ROOT), MyFlags))) 00127 goto error; 00128 00129 dir_entries_storage= (DYNAMIC_ARRAY*)(buffer + ALIGN_SIZE(sizeof(MY_DIR))); 00130 names_storage= (MEM_ROOT*)(buffer + ALIGN_SIZE(sizeof(MY_DIR)) + 00131 ALIGN_SIZE(sizeof(DYNAMIC_ARRAY))); 00132 00133 if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO), 00134 ENTRIES_START_SIZE, ENTRIES_INCREMENT)) 00135 { 00136 my_free((gptr) buffer,MYF(0)); 00137 goto error; 00138 } 00139 init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE); 00140 00141 /* MY_DIR structure is allocated and completly initialized at this point */ 00142 result= (MY_DIR*)buffer; 00143 00144 tmp_file=strend(tmp_path); 00145 00146 #ifdef THREAD 00147 dp= (struct dirent*) dirent_tmp; 00148 #else 00149 dp=0; 00150 #endif 00151 00152 while (!(READDIR(dirp,(struct dirent*) dirent_tmp,dp))) 00153 { 00154 if (!(finfo.name= strdup_root(names_storage, dp->d_name))) 00155 goto error; 00156 00157 if (MyFlags & MY_WANT_STAT) 00158 { 00159 if (!(finfo.mystat= (MY_STAT*)alloc_root(names_storage, 00160 sizeof(MY_STAT)))) 00161 goto error; 00162 00163 bzero(finfo.mystat, sizeof(MY_STAT)); 00164 VOID(strmov(tmp_file,dp->d_name)); 00165 VOID(my_stat(tmp_path, finfo.mystat, MyFlags)); 00166 if (!(finfo.mystat->st_mode & MY_S_IREAD)) 00167 continue; 00168 } 00169 else 00170 finfo.mystat= NULL; 00171 00172 if (push_dynamic(dir_entries_storage, (gptr)&finfo)) 00173 goto error; 00174 } 00175 00176 (void) closedir(dirp); 00177 #if defined(THREAD) && !defined(HAVE_READDIR_R) 00178 pthread_mutex_unlock(&THR_LOCK_open); 00179 #endif 00180 result->dir_entry= (FILEINFO *)dir_entries_storage->buffer; 00181 result->number_off_files= dir_entries_storage->elements; 00182 00183 if (!(MyFlags & MY_DONT_SORT)) 00184 qsort((void *) result->dir_entry, result->number_off_files, 00185 sizeof(FILEINFO), (qsort_cmp) comp_names); 00186 DBUG_RETURN(result); 00187 00188 error: 00189 #if defined(THREAD) && !defined(HAVE_READDIR_R) 00190 pthread_mutex_unlock(&THR_LOCK_open); 00191 #endif 00192 my_errno=errno; 00193 if (dirp) 00194 (void) closedir(dirp); 00195 my_dirend(result); 00196 if (MyFlags & (MY_FAE | MY_WME)) 00197 my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,my_errno); 00198 DBUG_RETURN((MY_DIR *) NULL); 00199 } /* my_dir */
Here is the call graph for this function:

Here is the caller graph for this function:

| void my_dirend | ( | MY_DIR * | buffer | ) |
Definition at line 73 of file my_lib.c.
References ALIGN_SIZE, buffer, DBUG_ENTER, DBUG_VOID_RETURN, delete_dynamic(), free_root(), my_free, and MYF.
Referenced by find_files(), find_uniq_filename(), my_dir(), mysql_rename_db(), mysql_rm_arc_files(), mysql_rm_known_files(), and search_default_file_with_ext().
00074 { 00075 DBUG_ENTER("my_dirend"); 00076 if (buffer) 00077 { 00078 delete_dynamic((DYNAMIC_ARRAY*)((char*)buffer + 00079 ALIGN_SIZE(sizeof(MY_DIR)))); 00080 free_root((MEM_ROOT*)((char*)buffer + ALIGN_SIZE(sizeof(MY_DIR)) + 00081 ALIGN_SIZE(sizeof(DYNAMIC_ARRAY))), MYF(0)); 00082 my_free((gptr) buffer,MYF(0)); 00083 } 00084 DBUG_VOID_RETURN; 00085 } /* my_dirend */
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_fstat | ( | int | filenr, | |
| MY_STAT * | stat_area, | |||
| myf | MyFlags | |||
| ) |
Referenced by mi_status(), modify_defaults_file(), readfrm(), and Show_instance_log::write_data().
Here is the caller graph for this function:

| MY_STAT* my_stat | ( | const char * | path, | |
| MY_STAT * | stat_area, | |||
| myf | my_flags | |||
| ) |
Definition at line 527 of file my_lib.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, EE_STAT, errno, error, ME_BELL, ME_WAITTANG, my_errno, my_error(), MY_FAE, my_free, my_malloc(), MY_WME, MYF, and NULL.
Referenced by com_edit(), create_sys_files(), dyn_string_cmp(), File_class::exists(), find_files(), get_options(), get_share(), ha_archive::info(), main(), my_copy(), my_dir(), my_read_charset_file(), my_rename(), mysql_create_db(), mysql_load(), prepare_for_repair(), search_default_file_with_ext(), sql_parse_prepare(), sys_check_log_path(), test_file_exists_res(), test_if_case_insensitive(), and Item_load_file::val_str().
00528 { 00529 int m_used; 00530 DBUG_ENTER("my_stat"); 00531 DBUG_PRINT("my", ("path: '%s', stat_area: 0x%lx, MyFlags: %d", path, 00532 (byte *) stat_area, my_flags)); 00533 00534 if ((m_used= (stat_area == NULL))) 00535 if (!(stat_area = (MY_STAT *) my_malloc(sizeof(MY_STAT), my_flags))) 00536 goto error; 00537 if (! stat((my_string) path, (struct stat *) stat_area) ) 00538 DBUG_RETURN(stat_area); 00539 00540 DBUG_PRINT("error",("Got errno: %d from stat", errno)); 00541 my_errno= errno; 00542 if (m_used) /* Free if new area */ 00543 my_free((gptr) stat_area,MYF(0)); 00544 00545 error: 00546 if (my_flags & (MY_FAE+MY_WME)) 00547 { 00548 my_error(EE_STAT, MYF(ME_BELL+ME_WAITTANG),path,my_errno); 00549 DBUG_RETURN((MY_STAT *) NULL); 00550 } 00551 DBUG_RETURN((MY_STAT *) NULL); 00552 } /* my_stat */
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7

