diff options
Diffstat (limited to 'innobase/os/os0file.c')
-rw-r--r-- | innobase/os/os0file.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 5c140e4b798..8b9a0582781 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -711,13 +711,41 @@ http://www.mysql.com/doc/en/Windows_symbolic_links.html */ char* full_path; int ret; struct stat statinfo; +#ifdef HAVE_READDIR_R + char dirent_buf[sizeof(struct dirent) + _POSIX_PATH_MAX + + 100]; + /* In /mysys/my_lib.c, _POSIX_PATH_MAX + 1 is used as + the max file name len; but in most standards, the + length is NAME_MAX; we add 100 to be even safer */ +#endif + next_file: - ent = readdir(dir); + +#ifdef HAVE_READDIR_R + ret = readdir_r(dir, (struct dirent*)dirent_buf, &ent); + + if (ret != 0) { + fprintf(stderr, +"InnoDB: cannot read directory %s, error %lu\n", dirname, (ulong)ret); + + return(-1); + } if (ent == NULL) { + /* End of directory */ + return(1); } + ut_a(strlen(ent->d_name) < _POSIX_PATH_MAX + 100 - 1); +#else + ent = readdir(dir); + + if (ent == NULL) { + + return(1); + } +#endif ut_a(strlen(ent->d_name) < OS_FILE_MAX_PATH); if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) { |