📄 os0file.h
字号:
/******************************************************The interface to the operating system file io(c) 1995 Innobase OyCreated 10/21/1995 Heikki Tuuri*******************************************************/#ifndef os0file_h#define os0file_h#include "univ.i"#ifndef __WIN__#include <dirent.h>#include <sys/stat.h>#include <time.h>#endiftypedef struct fil_node_struct fil_node_t;#ifdef UNIV_DO_FLUSHextern ibool os_do_not_call_flush_at_each_write;#endif /* UNIV_DO_FLUSH */extern ibool os_has_said_disk_full;extern ibool os_aio_print_debug;extern ulint os_file_n_pending_preads;extern ulint os_file_n_pending_pwrites;extern ulint os_n_pending_reads;extern ulint os_n_pending_writes;#ifdef __WIN__/* We define always WIN_ASYNC_IO, and check at run-time whether the OS actually supports it: Win 95 does not, NT does. */#define WIN_ASYNC_IO#define UNIV_NON_BUFFERED_IO#endif#ifdef __WIN__#define os_file_t HANDLE#elsetypedef int os_file_t;#endifextern ulint os_innodb_umask;/* If this flag is TRUE, then we will use the native aio of theOS (provided we compiled Innobase with it in), otherwise we willuse simulated aio we build below with threads */extern ibool os_aio_use_native_aio;#define OS_FILE_SECTOR_SIZE 512/* The next value should be smaller or equal to the smallest sector size usedon any disk. A log block is required to be a portion of disk which is writtenso that if the start and the end of a block get written to disk, then thewhole block gets written. This should be true even in most cases of a crash:if this fails for a log block, then it is equivalent to a media failure in thelog. */#define OS_FILE_LOG_BLOCK_SIZE 512/* Options for file_create */#define OS_FILE_OPEN 51#define OS_FILE_CREATE 52#define OS_FILE_OVERWRITE 53#define OS_FILE_OPEN_RAW 54#define OS_FILE_CREATE_PATH 55#define OS_FILE_OPEN_RETRY 56 /* for os_file_create() on the first ibdata file */#define OS_FILE_READ_ONLY 333#define OS_FILE_READ_WRITE 444#define OS_FILE_READ_ALLOW_DELETE 555 /* for ibbackup *//* Options for file_create */#define OS_FILE_AIO 61#define OS_FILE_NORMAL 62/* Types for file create */#define OS_DATA_FILE 100#define OS_LOG_FILE 101/* Error codes from os_file_get_last_error */#define OS_FILE_NOT_FOUND 71#define OS_FILE_DISK_FULL 72#define OS_FILE_ALREADY_EXISTS 73#define OS_FILE_PATH_ERROR 74#define OS_FILE_AIO_RESOURCES_RESERVED 75 /* wait for OS aio resources to become available again */#define OS_FILE_ERROR_NOT_SPECIFIED 76/* Types for aio operations */#define OS_FILE_READ 10#define OS_FILE_WRITE 11#define OS_FILE_LOG 256 /* This can be ORed to type */#define OS_AIO_N_PENDING_IOS_PER_THREAD 32 /* Win NT does not allow more than 64 *//* Modes for aio operations */#define OS_AIO_NORMAL 21 /* Normal asynchronous i/o not for ibuf pages or ibuf bitmap pages */#define OS_AIO_IBUF 22 /* Asynchronous i/o for ibuf pages or ibuf bitmap pages */#define OS_AIO_LOG 23 /* Asynchronous i/o for the log */#define OS_AIO_SYNC 24 /* Asynchronous i/o where the calling thread will itself wait for the i/o to complete, doing also the job of the i/o-handler thread; can be used for any pages, ibuf or non-ibuf. This is used to save CPU time, as we can do with fewer thread switches. Plain synchronous i/o is not as good, because it must serialize the file seek and read or write, causing a bottleneck for parallelism. */#define OS_AIO_SIMULATED_WAKE_LATER 512 /* This can be ORed to mode in the call of os_aio(...), if the caller wants to post several i/o requests in a batch, and only after that wake the i/o-handler thread; this has effect only in simulated aio */ #define OS_WIN31 1#define OS_WIN95 2 #define OS_WINNT 3#define OS_WIN2000 4extern ulint os_n_file_reads;extern ulint os_n_file_writes;extern ulint os_n_fsyncs;/* File types for directory entry data type */enum os_file_type_enum{ OS_FILE_TYPE_UNKNOWN = 0, OS_FILE_TYPE_FILE, /* regular file */ OS_FILE_TYPE_DIR, /* directory */ OS_FILE_TYPE_LINK /* symbolic link */};typedef enum os_file_type_enum os_file_type_t;/* Maximum path string length in bytes when referring to tables with in the'./databasename/tablename.ibd' path format; we can allocate at least 2 buffersof this size from the thread stack; that is why this should not be made muchbigger than 4000 bytes */#define OS_FILE_MAX_PATH 4000/* Struct used in fetching information of a file in a directory */struct os_file_stat_struct{ char name[OS_FILE_MAX_PATH]; /* path to a file */ os_file_type_t type; /* file type */ ib_longlong size; /* file size */ time_t ctime; /* creation time */ time_t mtime; /* modification time */ time_t atime; /* access time */};typedef struct os_file_stat_struct os_file_stat_t;#ifdef __WIN__typedef HANDLE os_file_dir_t; /* directory stream */#elsetypedef DIR* os_file_dir_t; /* directory stream */#endif/***************************************************************************Gets the operating system version. Currently works only on Windows. */ulintos_get_os_version(void);/*===================*/ /* out: OS_WIN95, OS_WIN31, OS_WINNT, or OS_WIN2000 *//********************************************************************Creates the seek mutexes used in positioned reads and writes. */voidos_io_init_simple(void);/*===================*//***************************************************************************Creates a temporary file. */FILE*os_file_create_tmpfile(void);/*========================*/ /* out: temporary file handle, or NULL on error *//***************************************************************************The os_file_opendir() function opens a directory stream corresponding to thedirectory named by the dirname argument. The directory stream is positionedat the first entry. In both Unix and Windows we automatically skip the '.'and '..' items at the start of the directory listing. */os_file_dir_tos_file_opendir(/*============*/ /* out: directory stream, NULL if error */ const char* dirname, /* in: directory name; it must not contain a trailing '\' or '/' */ ibool error_is_fatal);/* in: 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 *//***************************************************************************Closes a directory stream. */intos_file_closedir(/*=============*/ /* out: 0 if success, -1 if failure */ os_file_dir_t dir); /* in: directory stream *//***************************************************************************This function returns information of the next file in the directory. We jumpover the '.' and '..' entries in the directory. */intos_file_readdir_next_file(/*======================*/ /* out: 0 if ok, -1 if error, 1 if at the end of the directory */ const char* dirname,/* in: directory name or path */ os_file_dir_t dir, /* in: directory stream */ os_file_stat_t* info); /* in/out: buffer where the info is returned *//*********************************************************************This function attempts to create a directory named pathname. The new directorygets default permissions. On Unix, the permissions are (0770 & ~umask). If thedirectory exists already, nothing is done and the call succeeds, unless thefail_if_exists arguments is true. */iboolos_file_create_directory(/*=====================*/ /* out: TRUE if call succeeds, FALSE on error */ const char* pathname, /* in: directory name as null-terminated string */ ibool fail_if_exists);/* in: if TRUE, pre-existing directory is treated as an error. *//********************************************************************A simple function to open or create a file. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -