summaryrefslogtreecommitdiff
path: root/storage/innobase/os
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-05-18 12:13:18 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-05-18 12:13:18 +0300
commit08b6fd93957280c1b3e12c30ead1b6b90a7dff26 (patch)
treeafe34161fbf79bac0d860b87ba7d541a2ee66386 /storage/innobase/os
parent4240704abc2d51a2e46fb85049b601fce5d5b24c (diff)
downloadmariadb-git-08b6fd93957280c1b3e12c30ead1b6b90a7dff26.tar.gz
MDEV-25710: Dead code os_file_opendir() in the server
The functions fil_file_readdir_next_file(), os_file_opendir(), os_file_closedir() became dead code in the server in MariaDB 10.4.0 with commit 09af00cbde1d62dfda574dee10e5c0fd240c3f7f (the removal of the crash recovery logic for the TRUNCATE TABLE implementation that was replaced in MDEV-13564). os_file_opendir(), os_file_closedir(): Define as macros.
Diffstat (limited to 'storage/innobase/os')
-rw-r--r--storage/innobase/os/os0file.cc275
1 files changed, 0 insertions, 275 deletions
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index 62908d37337..17e043caf39 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -2680,133 +2680,6 @@ os_file_create_directory(
return(true);
}
-/**
-The os_file_opendir() function opens a directory stream corresponding to the
-directory named by the dirname argument. The directory stream is positioned
-at the first entry. In both Unix and Windows we automatically skip the '.'
-and '..' items at the start of the directory listing.
-@param[in] dirname directory name; it must not contain a trailing
- '\' or '/'
-@param[in] is_fatal true if we should treat an error as a fatal
- error; if we try to open symlinks then we do
- not wish a fatal error if it happens not to be
- a directory
-@return directory stream, NULL if error */
-os_file_dir_t
-os_file_opendir(
- const char* dirname,
- bool error_is_fatal)
-{
- os_file_dir_t dir;
- dir = opendir(dirname);
-
- if (dir == NULL && error_is_fatal) {
- os_file_handle_error(dirname, "opendir");
- }
-
- return(dir);
-}
-
-/** Closes a directory stream.
-@param[in] dir directory stream
-@return 0 if success, -1 if failure */
-int
-os_file_closedir(
- os_file_dir_t dir)
-{
- int ret = closedir(dir);
-
- if (ret != 0) {
- os_file_handle_error_no_exit(NULL, "closedir", false);
- }
-
- return(ret);
-}
-
-/** This function returns information of the next file in the directory. We jump
-over the '.' and '..' entries in the directory.
-@param[in] dirname directory name or path
-@param[in] dir directory stream
-@param[out] info buffer where the info is returned
-@return 0 if ok, -1 if error, 1 if at the end of the directory */
-int
-os_file_readdir_next_file(
- const char* dirname,
- os_file_dir_t dir,
- os_file_stat_t* info)
-{
- struct dirent* ent;
- char* full_path;
- int ret;
- struct stat statinfo;
-
-next_file:
-
- ent = readdir(dir);
-
- if (ent == NULL) {
-
- return(1);
- }
-
- ut_a(strlen(ent->d_name) < OS_FILE_MAX_PATH);
-
- if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) {
-
- goto next_file;
- }
-
- strcpy(info->name, ent->d_name);
-
- full_path = static_cast<char*>(
- ut_malloc_nokey(strlen(dirname) + strlen(ent->d_name) + 10));
-
- sprintf(full_path, "%s/%s", dirname, ent->d_name);
-
- ret = stat(full_path, &statinfo);
-
- if (ret) {
-
- if (errno == ENOENT) {
- /* readdir() returned a file that does not exist,
- it must have been deleted in the meantime. Do what
- would have happened if the file was deleted before
- readdir() - ignore and go to the next entry.
- If this is the last entry then info->name will still
- contain the name of the deleted file when this
- function returns, but this is not an issue since the
- caller shouldn't be looking at info when end of
- directory is returned. */
-
- ut_free(full_path);
-
- goto next_file;
- }
-
- os_file_handle_error_no_exit(full_path, "stat", false);
-
- ut_free(full_path);
-
- return(-1);
- }
-
- info->size = statinfo.st_size;
-
- if (S_ISDIR(statinfo.st_mode)) {
- info->type = OS_FILE_TYPE_DIR;
- } else if (S_ISLNK(statinfo.st_mode)) {
- info->type = OS_FILE_TYPE_LINK;
- } else if (S_ISREG(statinfo.st_mode)) {
- info->type = OS_FILE_TYPE_FILE;
- } else {
- info->type = OS_FILE_TYPE_UNKNOWN;
- }
-
- ut_free(full_path);
-
- return(0);
-}
-
/** NOTE! Use the corresponding macro os_file_create(), not directly
this function!
Opens an existing file or creates a new.
@@ -3820,154 +3693,6 @@ os_file_create_directory(
return(true);
}
-/** The os_file_opendir() function opens a directory stream corresponding to the
-directory named by the dirname argument. The directory stream is positioned
-at the first entry. In both Unix and Windows we automatically skip the '.'
-and '..' items at the start of the directory listing.
-@param[in] dirname directory name; it must not contain a trailing
- '\' or '/'
-@param[in] is_fatal true if we should treat an error as a fatal
- error; if we try to open symlinks then we do
- not wish a fatal error if it happens not to
- be a directory
-@return directory stream, NULL if error */
-os_file_dir_t
-os_file_opendir(
- const char* dirname,
- bool error_is_fatal)
-{
- os_file_dir_t dir;
- LPWIN32_FIND_DATA lpFindFileData;
- char path[OS_FILE_MAX_PATH + 3];
-
- ut_a(strlen(dirname) < OS_FILE_MAX_PATH);
-
- strcpy(path, dirname);
- strcpy(path + strlen(path), "\\*");
-
- /* Note that in Windows opening the 'directory stream' also retrieves
- the first entry in the directory. Since it is '.', that is no problem,
- as we will skip over the '.' and '..' entries anyway. */
-
- lpFindFileData = static_cast<LPWIN32_FIND_DATA>(
- ut_malloc_nokey(sizeof(WIN32_FIND_DATA)));
-
- dir = FindFirstFile((LPCTSTR) path, lpFindFileData);
-
- ut_free(lpFindFileData);
-
- if (dir == INVALID_HANDLE_VALUE) {
-
- if (error_is_fatal) {
- os_file_handle_error(dirname, "opendir");
- }
-
- return(NULL);
- }
-
- return(dir);
-}
-
-/** Closes a directory stream.
-@param[in] dir directory stream
-@return 0 if success, -1 if failure */
-int
-os_file_closedir(
- os_file_dir_t dir)
-{
- BOOL ret;
-
- ret = FindClose(dir);
-
- if (!ret) {
- os_file_handle_error_no_exit(NULL, "closedir", false);
-
- return(-1);
- }
-
- return(0);
-}
-
-/** This function returns information of the next file in the directory. We
-jump over the '.' and '..' entries in the directory.
-@param[in] dirname directory name or path
-@param[in] dir directory stream
-@param[out] info buffer where the info is returned
-@return 0 if ok, -1 if error, 1 if at the end of the directory */
-int
-os_file_readdir_next_file(
- const char* dirname,
- os_file_dir_t dir,
- os_file_stat_t* info)
-{
- BOOL ret;
- int status;
- WIN32_FIND_DATA find_data;
-
-next_file:
-
- ret = FindNextFile(dir, &find_data);
-
- if (ret > 0) {
-
- const char* name;
-
- name = static_cast<const char*>(find_data.cFileName);
-
- ut_a(strlen(name) < OS_FILE_MAX_PATH);
-
- if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
-
- goto next_file;
- }
-
- strcpy(info->name, name);
-
- info->size = find_data.nFileSizeHigh;
- info->size <<= 32;
- info->size |= find_data.nFileSizeLow;
-
- if (find_data.dwFileAttributes
- & FILE_ATTRIBUTE_REPARSE_POINT) {
-
- /* TODO: test Windows symlinks */
- /* TODO: MySQL has apparently its own symlink
- implementation in Windows, dbname.sym can
- redirect a database directory:
- REFMAN "windows-symbolic-links.html" */
-
- info->type = OS_FILE_TYPE_LINK;
-
- } else if (find_data.dwFileAttributes
- & FILE_ATTRIBUTE_DIRECTORY) {
-
- info->type = OS_FILE_TYPE_DIR;
-
- } else {
-
- /* It is probably safest to assume that all other
- file types are normal. Better to check them rather
- than blindly skip them. */
-
- info->type = OS_FILE_TYPE_FILE;
- }
-
- status = 0;
-
- } else if (GetLastError() == ERROR_NO_MORE_FILES) {
-
- status = 1;
-
- } else {
-
- os_file_handle_error_no_exit(NULL, "readdir_next_file", false);
-
- status = -1;
- }
-
- return(status);
-}
-
/** Check that IO of specific size is possible for the file
opened with FILE_FLAG_NO_BUFFERING.