drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
os0file.h File Reference
#include "univ.i"
#include <dirent.h>
#include <sys/stat.h>
#include <time.h>
Include dependency graph for os0file.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  os_file_stat_struct

Macros

#define os0file_h
#define OS_FILE_FROM_FD(fd)
#define OS_FILE_LOG_BLOCK_SIZE   srv_log_block_size

Typedefs

typedef struct fil_node_struct fil_node_t
typedef int os_file_t

Variables

ibool os_has_said_disk_full
ibool os_aio_print_debug
ulint os_file_n_pending_preads
ulint os_file_n_pending_pwrites
ulint os_n_pending_reads
ulint os_n_pending_writes
ulint os_innodb_umask
#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
#define OS_FILE_READ_ONLY   333
#define OS_FILE_READ_WRITE   444
#define OS_FILE_READ_ALLOW_DELETE   555 /* for ibbackup */
#define OS_FILE_AIO   61
#define OS_FILE_NORMAL   62
#define OS_DATA_FILE   100
#define OS_LOG_FILE   101
#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
#define OS_FILE_SHARING_VIOLATION   76
#define OS_FILE_ERROR_NOT_SPECIFIED   77
#define OS_FILE_INSUFFICIENT_RESOURCE   78
#define OS_FILE_AIO_INTERRUPTED   79
#define OS_FILE_OPERATION_ABORTED   80
#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
#define OS_AIO_NORMAL   21
#define OS_AIO_IBUF   22
#define OS_AIO_LOG   23
#define OS_AIO_SYNC   24
#define OS_AIO_SIMULATED_WAKE_LATER   512
#define OS_WIN31   1
#define OS_WIN95   2
#define OS_WINNT   3
#define OS_WIN2000   4
#define OS_WINXP   5
#define OS_WINVISTA   6
#define OS_WIN7   7
#define os_file_create(key, name, create, purpose, type, success)
#define os_file_create_simple(key, name, create, access, success)
#define os_file_create_simple_no_error_handling( key, name, create_mode, access, success)
#define os_file_close(file)
#define os_aio(type, mode, name, file, buf, offset, offset_high, n, message1, message2)
#define os_file_read(file, buf, offset, offset_high, n)
#define os_file_read_no_error_handling(file, buf, offset, offset_high, n)
#define os_file_write(name, file, buf, offset, offset_high, n)
#define os_file_flush(file)
#define os_file_rename(key, oldpath, newpath)
#define OS_FILE_MAX_PATH   4000
enum  os_file_type_enum { OS_FILE_TYPE_UNKNOWN = 0 , OS_FILE_TYPE_FILE , OS_FILE_TYPE_DIR , OS_FILE_TYPE_LINK }
typedef enum os_file_type_enum os_file_type_t
typedef struct os_file_stat_struct os_file_stat_t
typedef DIR * os_file_dir_t
ulint os_n_file_reads
ulint os_n_file_writes
ulint os_n_fsyncs
uint32_t srv_log_block_size
UNIV_INTERN void os_io_init_simple (void)
FILE * os_file_create_tmpfile (void)
UNIV_INTERN os_file_dir_t os_file_opendir (const char *dirname, ibool error_is_fatal)
UNIV_INTERN int os_file_closedir (os_file_dir_t dir)
UNIV_INTERN int os_file_readdir_next_file (const char *dirname, os_file_dir_t dir, os_file_stat_t *info)
UNIV_INTERN ibool os_file_create_directory (const char *pathname, ibool fail_if_exists)
UNIV_INTERN os_file_t os_file_create_simple_func (const char *name, ulint create_mode, ulint access_type, ibool *success)
UNIV_INTERN os_file_t os_file_create_simple_no_error_handling_func (const char *name, ulint create_mode, ulint access_type, ibool *success)
UNIV_INTERN void os_file_set_nocache (int fd, const char *file_name, const char *operation_name)
UNIV_INTERN os_file_t os_file_create_func (const char *name, ulint create_mode, ulint purpose, ulint type, ibool *success)
UNIV_INTERN ibool os_file_delete (const char *name)
UNIV_INTERN ibool os_file_delete_if_exists (const char *name)
UNIV_INTERN ibool os_file_rename_func (const char *oldpath, const char *newpath)
UNIV_INTERN ibool os_file_close_func (os_file_t file)
UNIV_INTERN ibool os_file_get_size (os_file_t file, ulint *size, ulint *size_high)
UNIV_INTERN ib_int64_t os_file_get_size_as_iblonglong (os_file_t file)
UNIV_INTERN ibool os_file_set_size (const char *name, os_file_t file, ulint size, ulint size_high)
UNIV_INTERN ibool os_file_set_eof (FILE *file)
UNIV_INTERN ibool os_file_flush_func (os_file_t file)
UNIV_INTERN ulint os_file_get_last_error (ibool report_all_errors)
UNIV_INTERN ibool os_file_read_func (os_file_t file, void *buf, ulint offset, ulint offset_high, ulint n)
UNIV_INTERN void os_file_read_string (FILE *file, char *str, ulint size)
UNIV_INTERN ibool os_file_read_no_error_handling_func (os_file_t file, void *buf, ulint offset, ulint offset_high, ulint n)
UNIV_INTERN ibool os_file_write_func (const char *name, os_file_t file, const void *buf, ulint offset, ulint offset_high, ulint n)
UNIV_INTERN ibool os_file_status (const char *path, ibool *exists, os_file_type_t *type)
UNIV_INTERN char * os_file_dirname (const char *path)
UNIV_INTERN ibool os_file_create_subdirs_if_needed (const char *path)
UNIV_INTERN ibool os_aio_init (ulint n_per_seg, ulint n_read_segs, ulint n_write_segs, ulint n_slots_sync)
UNIV_INTERN void os_aio_free (void)
UNIV_INTERN ibool os_aio_func (ulint type, ulint mode, const char *name, os_file_t file, void *buf, ulint offset, ulint offset_high, ulint n, fil_node_t *message1, void *message2)
UNIV_INTERN void os_aio_wake_all_threads_at_shutdown (void)
UNIV_INTERN void os_aio_wait_until_no_pending_writes (void)
UNIV_INTERN void os_aio_simulated_wake_handler_threads (void)
UNIV_INTERN void os_aio_simulated_put_read_threads_to_sleep (void)
UNIV_INTERN ibool os_aio_simulated_handle (ulint segment, fil_node_t **message1, void **message2, ulint *type)
UNIV_INTERN ibool os_aio_validate (void)
UNIV_INTERN void os_aio_print (FILE *file)
UNIV_INTERN void os_aio_refresh_stats (void)
UNIV_INTERN ibool os_file_get_status (const char *path, os_file_stat_t *stat_info)
UNIV_INTERN int innobase_mysql_tmpfile (void)

Detailed Description

The interface to the operating system file io

Created 10/21/1995 Heikki Tuuri

Definition in file os0file.h.

Macro Definition Documentation

◆ os0file_h

#define os0file_h

Definition at line 37 of file os0file.h.

◆ os_aio

#define os_aio ( type,
mode,
name,
file,
buf,
offset,
offset_high,
n,
message1,
message2 )
Value:
os_aio_func(type, mode, name, file, buf, offset, offset_high, n,\
message1, message2)
UNIV_INTERN ibool os_aio_func(ulint type, ulint mode, const char *name, os_file_t file, void *buf, ulint offset, ulint offset_high, ulint n, fil_node_t *message1, void *message2)
Definition os0file.cc:4005

Definition at line 322 of file os0file.h.

◆ OS_AIO_IBUF

#define OS_AIO_IBUF   22

Asynchronous i/o for ibuf pages or ibuf bitmap pages

Definition at line 154 of file os0file.h.

◆ OS_AIO_LOG

#define OS_AIO_LOG   23

Asynchronous i/o for the log

Definition at line 156 of file os0file.h.

◆ OS_AIO_N_PENDING_IOS_PER_THREAD

#define OS_AIO_N_PENDING_IOS_PER_THREAD   32

Win NT does not allow more than 64

Definition at line 148 of file os0file.h.

◆ OS_AIO_NORMAL

#define OS_AIO_NORMAL   21

Modes for aio operations Normal asynchronous i/o not for ibuf pages or ibuf bitmap pages

Definition at line 152 of file os0file.h.

◆ OS_AIO_SIMULATED_WAKE_LATER

#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

Definition at line 167 of file os0file.h.

◆ OS_AIO_SYNC

#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.

Definition at line 157 of file os0file.h.

◆ OS_DATA_FILE

#define OS_DATA_FILE   100

Types for file create

Definition at line 124 of file os0file.h.

◆ OS_FILE_AIO

#define OS_FILE_AIO   61

Definition at line 119 of file os0file.h.

◆ OS_FILE_AIO_INTERRUPTED

#define OS_FILE_AIO_INTERRUPTED   79

Definition at line 137 of file os0file.h.

◆ OS_FILE_AIO_RESOURCES_RESERVED

#define OS_FILE_AIO_RESOURCES_RESERVED
Value:
75 /* wait for OS aio resources
to become available again */

Definition at line 133 of file os0file.h.

◆ OS_FILE_ALREADY_EXISTS

#define OS_FILE_ALREADY_EXISTS   73

Definition at line 131 of file os0file.h.

◆ os_file_close

#define os_file_close ( file)
Value:
UNIV_INTERN ibool os_file_close_func(os_file_t file)
Definition os0file.cc:1807

Definition at line 320 of file os0file.h.

◆ OS_FILE_CREATE

#define OS_FILE_CREATE   52

Definition at line 108 of file os0file.h.

◆ os_file_create

#define os_file_create ( key,
name,
create,
purpose,
type,
success )
Value:
os_file_create_func(name, create, purpose, type, success)
UNIV_INTERN os_file_t os_file_create_func(const char *name, ulint create_mode, ulint purpose, ulint type, ibool *success)
Definition os0file.cc:1378

Definition at line 309 of file os0file.h.

◆ OS_FILE_CREATE_PATH

#define OS_FILE_CREATE_PATH   55

Definition at line 111 of file os0file.h.

◆ os_file_create_simple

#define os_file_create_simple ( key,
name,
create,
access,
success )
Value:
os_file_create_simple_func(name, create_mode, access, success)
UNIV_INTERN os_file_t os_file_create_simple_func(const char *name, ulint create_mode, ulint access_type, ibool *success)
Definition os0file.cc:1074

Definition at line 312 of file os0file.h.

◆ os_file_create_simple_no_error_handling

#define os_file_create_simple_no_error_handling ( key,
name,
create_mode,
access,
success )
Value:
name, create_mode, access, success)
UNIV_INTERN os_file_t os_file_create_simple_no_error_handling_func(const char *name, ulint create_mode, ulint access_type, ibool *success)
Definition os0file.cc:1217

Definition at line 315 of file os0file.h.

◆ OS_FILE_DISK_FULL

#define OS_FILE_DISK_FULL   72

Definition at line 130 of file os0file.h.

◆ OS_FILE_ERROR_NOT_SPECIFIED

#define OS_FILE_ERROR_NOT_SPECIFIED   77

Definition at line 135 of file os0file.h.

◆ os_file_flush

#define os_file_flush ( file)
Value:
UNIV_INTERN ibool os_file_flush_func(os_file_t file)
Definition os0file.cc:2109

Definition at line 337 of file os0file.h.

◆ OS_FILE_FROM_FD

#define OS_FILE_FROM_FD ( fd)
Value:
fd

Convert a C file descriptor to a native file handle

Parameters
fdfile descriptor
Returns
native file handle

Definition at line 91 of file os0file.h.

◆ OS_FILE_INSUFFICIENT_RESOURCE

#define OS_FILE_INSUFFICIENT_RESOURCE   78

Definition at line 136 of file os0file.h.

◆ OS_FILE_LOG

#define OS_FILE_LOG   256 /* This can be ORed to type */

Definition at line 145 of file os0file.h.

◆ OS_FILE_LOG_BLOCK_SIZE

#define OS_FILE_LOG_BLOCK_SIZE   srv_log_block_size

The next value should be smaller or equal to the smallest sector size used on any disk. A log block is required to be a portion of disk which is written so that if the start and the end of a block get written to disk, then the whole 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 the log.

Definition at line 104 of file os0file.h.

◆ OS_FILE_MAX_PATH

#define OS_FILE_MAX_PATH   4000

Definition at line 358 of file os0file.h.

◆ OS_FILE_NORMAL

#define OS_FILE_NORMAL   62

Definition at line 120 of file os0file.h.

◆ OS_FILE_NOT_FOUND

#define OS_FILE_NOT_FOUND   71

Error codes from os_file_get_last_error

Definition at line 129 of file os0file.h.

◆ OS_FILE_OPEN

#define OS_FILE_OPEN   51

Options for file_create

Definition at line 107 of file os0file.h.

◆ OS_FILE_OPEN_RAW

#define OS_FILE_OPEN_RAW   54

Definition at line 110 of file os0file.h.

◆ OS_FILE_OPEN_RETRY

#define OS_FILE_OPEN_RETRY
Value:
56 /* for os_file_create() on
the first ibdata file */

Definition at line 112 of file os0file.h.

◆ OS_FILE_OPERATION_ABORTED

#define OS_FILE_OPERATION_ABORTED   80

Definition at line 138 of file os0file.h.

◆ OS_FILE_OVERWRITE

#define OS_FILE_OVERWRITE   53

Definition at line 109 of file os0file.h.

◆ OS_FILE_PATH_ERROR

#define OS_FILE_PATH_ERROR   74

Definition at line 132 of file os0file.h.

◆ OS_FILE_READ

#define OS_FILE_READ   10

Types for aio operations

Definition at line 142 of file os0file.h.

◆ os_file_read

#define os_file_read ( file,
buf,
offset,
offset_high,
n )
Value:
os_file_read_func(file, buf, offset, offset_high, n)
UNIV_INTERN ibool os_file_read_func(os_file_t file, void *buf, ulint offset, ulint offset_high, ulint n)
Definition os0file.cc:2426

Definition at line 327 of file os0file.h.

◆ OS_FILE_READ_ALLOW_DELETE

#define OS_FILE_READ_ALLOW_DELETE   555 /* for ibbackup */

Definition at line 116 of file os0file.h.

◆ os_file_read_no_error_handling

#define os_file_read_no_error_handling ( file,
buf,
offset,
offset_high,
n )
Value:
os_file_read_no_error_handling_func(file, buf, offset, offset_high, n)
UNIV_INTERN ibool os_file_read_no_error_handling_func(os_file_t file, void *buf, ulint offset, ulint offset_high, ulint n)
Definition os0file.cc:2555

Definition at line 330 of file os0file.h.

◆ OS_FILE_READ_ONLY

#define OS_FILE_READ_ONLY   333

Definition at line 114 of file os0file.h.

◆ OS_FILE_READ_WRITE

#define OS_FILE_READ_WRITE   444

Definition at line 115 of file os0file.h.

◆ os_file_rename

#define os_file_rename ( key,
oldpath,
newpath )
Value:
os_file_rename_func(oldpath, newpath)
UNIV_INTERN ibool os_file_rename_func(const char *oldpath, const char *newpath)
Definition os0file.cc:1767

Definition at line 339 of file os0file.h.

◆ OS_FILE_SHARING_VIOLATION

#define OS_FILE_SHARING_VIOLATION   76

Definition at line 134 of file os0file.h.

◆ OS_FILE_WRITE

#define OS_FILE_WRITE   11

Definition at line 143 of file os0file.h.

◆ os_file_write

#define os_file_write ( name,
file,
buf,
offset,
offset_high,
n )
Value:
os_file_write_func(name, file, buf, offset, offset_high, n)
UNIV_INTERN ibool os_file_write_func(const char *name, os_file_t file, const void *buf, ulint offset, ulint offset_high, ulint n)
Definition os0file.cc:2687

Definition at line 334 of file os0file.h.

◆ OS_LOG_FILE

#define OS_LOG_FILE   101

Definition at line 125 of file os0file.h.

◆ OS_WIN2000

#define OS_WIN2000   4

Microsoft Windows 2000

Definition at line 178 of file os0file.h.

◆ OS_WIN31

#define OS_WIN31   1

Microsoft Windows 3.x

Definition at line 175 of file os0file.h.

◆ OS_WIN7

#define OS_WIN7   7

Microsoft Windows 7 or Windows Server 2008 R2

Definition at line 183 of file os0file.h.

◆ OS_WIN95

#define OS_WIN95   2

Microsoft Windows 95

Definition at line 176 of file os0file.h.

◆ OS_WINNT

#define OS_WINNT   3

Microsoft Windows NT 3.x

Definition at line 177 of file os0file.h.

◆ OS_WINVISTA

#define OS_WINVISTA   6

Microsoft Windows Vista or Windows Server 2008

Definition at line 181 of file os0file.h.

◆ OS_WINXP

#define OS_WINXP   5

Microsoft Windows XP or Windows Server 2003

Definition at line 179 of file os0file.h.

Typedef Documentation

◆ fil_node_t

typedef struct fil_node_struct fil_node_t

File node of a tablespace or the log data space

Definition at line 48 of file os0file.h.

◆ os_file_dir_t

typedef DIR* os_file_dir_t

directory stream

Definition at line 374 of file os0file.h.

◆ os_file_stat_t

typedef struct os_file_stat_struct os_file_stat_t

Definition at line 369 of file os0file.h.

◆ os_file_t

typedef int os_file_t

File handle

Definition at line 87 of file os0file.h.

◆ os_file_type_t

typedef enum os_file_type_enum os_file_type_t

Definition at line 352 of file os0file.h.

Enumeration Type Documentation

◆ os_file_type_enum

enum os_file_type_enum

Definition at line 346 of file os0file.h.

Function Documentation

◆ innobase_mysql_tmpfile()

UNIV_INTERN int innobase_mysql_tmpfile ( void )

Creates a temporary file that will be deleted on close. This function is defined in ha_innodb.cc.

Returns
temporary file descriptor, or < 0 on error

Creates a temporary file.

Returns
temporary file descriptor, or < 0 on error

Definition at line 1477 of file ha_innodb.cc.

◆ os_aio_free()

UNIV_INTERN void os_aio_free ( void )

Definition at line 3475 of file os0file.cc.

◆ os_aio_func()

UNIV_INTERN ibool os_aio_func ( ulint type,
ulint mode,
const char * name,
os_file_t file,
void * buf,
ulint offset,
ulint offset_high,
ulint n,
fil_node_t * message1,
void * message2 )

NOTE! Use the corresponding macro os_aio(), not directly this function! Requests an asynchronous i/o operation.

Returns
TRUE if request was queued successfully, FALSE if fail in: message for the aio handler (can be used to identify a completed aio operation); ignored if mode is OS_AIO_SYNC

NOTE! Use the corresponding macro os_aio(), not directly this function! Requests an asynchronous i/o operation.

Returns
TRUE if request was queued successfully, FALSE if fail
Parameters
typein: OS_FILE_READ or OS_FILE_WRITE
modein: OS_AIO_NORMAL, ..., possibly ORed to OS_AIO_SIMULATED_WAKE_LATER: the last flag advises this function not to wake i/o-handler threads, but the caller will do the waking explicitly later, in this way the caller can post several requests in a batch; NOTE that the batch must not be so big that it exhausts the slots in aio arrays! NOTE that a simulated batch may introduce hidden chances of deadlocks, because i/os are not actually handled until all have been posted: use with great caution!
namein: name of the file or path as a null-terminated string
filein: handle to a file
bufin: buffer where to read or from which to write
offsetin: least significant 32 bits of file offset where to read or write
offset_highin: most significant 32 bits of offset
nin: number of bytes to read or write
message1in: message for the aio handler (can be used to identify a completed aio operation); ignored if mode is OS_AIO_SYNC
message2in: message for the aio handler (can be used to identify a completed aio operation); ignored if mode is OS_AIO_SYNC

Definition at line 4005 of file os0file.cc.

◆ os_aio_init()

UNIV_INTERN ibool os_aio_init ( ulint n_per_seg,
ulint n_read_segs,
ulint n_write_segs,
ulint n_slots_sync )

Definition at line 3387 of file os0file.cc.

◆ os_aio_print()

UNIV_INTERN void os_aio_print ( FILE * file)

Prints info of the aio arrays. in: file where to print

Prints info of the aio arrays.

Parameters
filein: file where to print

Definition at line 5056 of file os0file.cc.

◆ os_aio_refresh_stats()

UNIV_INTERN void os_aio_refresh_stats ( void )

Refreshes the statistics used to print per-second averages.

Definition at line 5202 of file os0file.cc.

◆ os_aio_simulated_handle()

UNIV_INTERN ibool os_aio_simulated_handle ( ulint global_segment,
fil_node_t ** message1,
void ** message2,
ulint * type )

Does simulated aio. This function should be called by an i/o-handler thread.

Returns
TRUE if the aio operation succeeded out: OS_FILE_WRITE or ..._READ

Does simulated aio. This function should be called by an i/o-handler thread.

Returns
TRUE if the aio operation succeeded
Parameters
global_segmentin: the number of the segment in the aio arrays to wait for; segment 0 is the ibuf i/o thread, segment 1 the log i/o thread, then follow the non-ibuf read threads, and as the last are the non-ibuf write threads
message1out: the messages passed with the aio request; note that also in the case where the aio operation failed, these output parameters are valid and can be used to restart the operation, for example
typeout: OS_FILE_WRITE or ..._READ

Definition at line 4641 of file os0file.cc.

◆ os_aio_simulated_put_read_threads_to_sleep()

UNIV_INTERN void os_aio_simulated_put_read_threads_to_sleep ( void )

This function can be called if one wants to post a batch of reads and prefers an i/o-handler thread to handle them all at once later. You must call os_aio_simulated_wake_handler_threads later to ensure the threads are not left sleeping!

Definition at line 3920 of file os0file.cc.

◆ os_aio_simulated_wake_handler_threads()

UNIV_INTERN void os_aio_simulated_wake_handler_threads ( void )

Wakes up simulated aio i/o-handler threads if they have something to do.

Definition at line 3895 of file os0file.cc.

◆ os_aio_validate()

UNIV_INTERN ibool os_aio_validate ( void )

Validates the consistency of the aio system.

Returns
TRUE if ok

Validates the consistency the aio system.

Returns
TRUE if ok

Definition at line 5006 of file os0file.cc.

◆ os_aio_wait_until_no_pending_writes()

UNIV_INTERN void os_aio_wait_until_no_pending_writes ( void )

Waits until there are no pending writes in os_aio_write_array. There can be other, synchronous, pending writes.

Definition at line 3562 of file os0file.cc.

◆ os_aio_wake_all_threads_at_shutdown()

UNIV_INTERN void os_aio_wake_all_threads_at_shutdown ( void )

Wakes up all async i/o threads so that they know to exit themselves in shutdown.

Definition at line 3524 of file os0file.cc.

◆ os_file_close_func()

UNIV_INTERN ibool os_file_close_func ( os_file_t file)

NOTE! Use the corresponding macro os_file_close(), not directly this function! Closes a file handle. In case of error, error number can be retrieved with os_file_get_last_error.

Returns
TRUE if success in, own: handle to a file

NOTE! Use the corresponding macro os_file_close(), not directly this function! Closes a file handle. In case of error, error number can be retrieved with os_file_get_last_error.

Returns
TRUE if success
Parameters
filein, own: handle to a file

Definition at line 1807 of file os0file.cc.

◆ os_file_closedir()

UNIV_INTERN int os_file_closedir ( os_file_dir_t dir)

Closes a directory stream.

Returns
0 if success, -1 if failure in: directory stream

Closes a directory stream.

Returns
0 if success, -1 if failure
Parameters
dirin: directory stream

Definition at line 817 of file os0file.cc.

◆ os_file_create_directory()

UNIV_INTERN ibool os_file_create_directory ( const char * pathname,
ibool fail_if_exists )

This function attempts to create a directory named pathname. The new directory gets default permissions. On Unix, the permissions are (0770 & ~umask). If the directory exists already, nothing is done and the call succeeds, unless the fail_if_exists arguments is true.

Returns
TRUE if call succeeds, FALSE on error in: if TRUE, pre-existing directory is treated as an error.

This function attempts to create a directory named pathname. The new directory gets default permissions. On Unix the permissions are (0770 & ~umask). If the directory exists already, nothing is done and the call succeeds, unless the fail_if_exists arguments is true.

Returns
TRUE if call succeeds, FALSE on error
Parameters
pathnamein: directory name as null-terminated string
fail_if_existsin: if TRUE, pre-existing directory is treated as an error.

Definition at line 1029 of file os0file.cc.

◆ os_file_create_func()

UNIV_INTERN os_file_t os_file_create_func ( const char * name,
ulint create_mode,
ulint purpose,
ulint type,
ibool * success )

NOTE! Use the corresponding macro os_file_create(), not directly this function! Opens an existing file or creates a new.

Returns
own: handle to the file, not defined if error, error number can be retrieved with os_file_get_last_error out: TRUE if succeed, FALSE if error

NOTE! Use the corresponding macro os_file_create(), not directly this function! Opens an existing file or creates a new.

Returns
own: handle to the file, not defined if error, error number can be retrieved with os_file_get_last_error
Parameters
namein: name of the file or path as a null-terminated string
create_modein: OS_FILE_OPEN if an existing file is opened (if does not exist, error), or OS_FILE_CREATE if a new file is created (if exists, error), OS_FILE_OVERWRITE if a new file is created or an old overwritten; OS_FILE_OPEN_RAW, if a raw device or disk partition should be opened
purposein: OS_FILE_AIO, if asynchronous, non-buffered i/o is desired, OS_FILE_NORMAL, if any normal file; NOTE that it also depends on type, os_aio_.. and srv_.. variables whether we really use async i/o or unbuffered i/o: look in the function source code for the exact rules
typein: OS_DATA_FILE or OS_LOG_FILE
successout: TRUE if succeed, FALSE if error

Definition at line 1378 of file os0file.cc.

◆ os_file_create_simple_func()

UNIV_INTERN os_file_t os_file_create_simple_func ( const char * name,
ulint create_mode,
ulint access_type,
ibool * success )

NOTE! Use the corresponding macro os_file_create_simple(), not directly this function! A simple function to open or create a file.

Returns
own: handle to the file, not defined if error, error number can be retrieved with os_file_get_last_error out: TRUE if succeed, FALSE if error

NOTE! Use the corresponding macro os_file_create_simple(), not directly this function! A simple function to open or create a file.

Returns
own: handle to the file, not defined if error, error number can be retrieved with os_file_get_last_error
Parameters
namein: name of the file or path as a null-terminated string
create_modein: OS_FILE_OPEN if an existing file is opened (if does not exist, error), or OS_FILE_CREATE if a new file is created (if exists, error), or OS_FILE_CREATE_PATH if new file (if exists, error) and subdirectories along its path are created (if needed)
access_typein: OS_FILE_READ_ONLY or OS_FILE_READ_WRITE
successout: TRUE if succeed, FALSE if error

Definition at line 1074 of file os0file.cc.

◆ os_file_create_simple_no_error_handling_func()

UNIV_INTERN os_file_t os_file_create_simple_no_error_handling_func ( const char * name,
ulint create_mode,
ulint access_type,
ibool * success )

NOTE! Use the corresponding macro os_file_create_simple_no_error_handling(), not directly this function! A simple function to open or create a file.

Returns
own: handle to the file, not defined if error, error number can be retrieved with os_file_get_last_error out: TRUE if succeed, FALSE if error

NOTE! Use the corresponding macro os_file_create_simple_no_error_handling(), not directly this function! A simple function to open or create a file.

Returns
own: handle to the file, not defined if error, error number can be retrieved with os_file_get_last_error
Parameters
namein: name of the file or path as a null-terminated string
create_modein: OS_FILE_OPEN if an existing file is opened (if does not exist, error), or OS_FILE_CREATE if a new file is created (if exists, error)
access_typein: OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or OS_FILE_READ_ALLOW_DELETE; the last option is used by a backup program reading the file
successout: TRUE if succeed, FALSE if error

Definition at line 1217 of file os0file.cc.

◆ os_file_create_subdirs_if_needed()

UNIV_INTERN ibool os_file_create_subdirs_if_needed ( const char * path)

Creates all missing subdirectories along the given path.

Returns
TRUE if call succeeded FALSE otherwise in: path name

Creates all missing subdirectories along the given path.

Returns
TRUE if call succeeded FALSE otherwise
Parameters
pathin: path name

Definition at line 3102 of file os0file.cc.

◆ os_file_create_tmpfile()

FILE * os_file_create_tmpfile ( void )

Creates a temporary file. This function is like tmpfile(3), but the temporary file is created in the MySQL temporary directory.

Returns
temporary file handle, or NULL on error

Definition at line 729 of file os0file.cc.

◆ os_file_delete()

UNIV_INTERN ibool os_file_delete ( const char * name)

Deletes a file. The file has to be closed before calling this.

Returns
TRUE if success in: file path as a null-terminated string

Deletes a file. The file has to be closed before calling this.

Returns
TRUE if success
Parameters
namein: file path as a null-terminated string

Definition at line 1702 of file os0file.cc.

◆ os_file_delete_if_exists()

UNIV_INTERN ibool os_file_delete_if_exists ( const char * name)

Deletes a file if it exists. The file has to be closed before calling this.

Returns
TRUE if success in: file path as a null-terminated string

Deletes a file if it exists. The file has to be closed before calling this.

Returns
TRUE if success
Parameters
namein: file path as a null-terminated string

Definition at line 1640 of file os0file.cc.

◆ os_file_dirname()

UNIV_INTERN char * os_file_dirname ( const char * path)

The function os_file_dirname returns a directory component of a null-terminated pathname string. In the usual case, dirname returns the string up to, but not including, the final '/', and basename is the component following the final '/'. Trailing '/' charac� ters are not counted as part of the pathname.

If path does not contain a slash, dirname returns the string ".".

Concatenating the string returned by dirname, a "/", and the basename yields a complete pathname.

The return value is a copy of the directory component of the pathname. The copy is allocated from heap. It is the caller responsibility to free it after it is no longer needed.

The following list of examples (taken from SUSv2) shows the strings returned by dirname and basename for different paths:

   path       dirname      basename
   "/usr/lib"     "/usr"       "lib"
   "/usr/"        "/"      "usr"
   "usr"        "."      "usr"
   "/"        "/"      "/"
   "."        "."      "."
   ".."       "."      ".."
Returns
own: directory component of the pathname in: pathname

The function os_file_dirname returns a directory component of a null-terminated pathname string. In the usual case, dirname returns the string up to, but not including, the final '/', and basename is the component following the final '/'. Trailing '/' charac� ters are not counted as part of the pathname.

If path does not contain a slash, dirname returns the string ".".

Concatenating the string returned by dirname, a "/", and the basename yields a complete pathname.

The return value is a copy of the directory component of the pathname. The copy is allocated from heap. It is the caller responsibility to free it after it is no longer needed.

The following list of examples (taken from SUSv2) shows the strings returned by dirname and basename for different paths:

   path       dirname      basename
   "/usr/lib"     "/usr"       "lib"
   "/usr/"        "/"      "usr"
   "usr"        "."      "usr"
   "/"        "/"      "/"
   "."        "."      "."
   ".."       "."      ".."
Returns
own: directory component of the pathname
Parameters
pathin: pathname

Definition at line 3072 of file os0file.cc.

◆ os_file_flush_func()

UNIV_INTERN ibool os_file_flush_func ( os_file_t file)

NOTE! Use the corresponding macro os_file_flush(), not directly this function! Flushes the write buffers of a given file to the disk.

Returns
TRUE if success in, own: handle to a file

NOTE! Use the corresponding macro os_file_flush(), not directly this function! Flushes the write buffers of a given file to the disk.

Returns
TRUE if success
Parameters
filein, own: handle to a file

Definition at line 2109 of file os0file.cc.

◆ os_file_get_last_error()

UNIV_INTERN ulint os_file_get_last_error ( ibool report_all_errors)

Retrieves the last error number if an error occurs in a file io function. The number should be retrieved before any other OS calls (because they may overwrite the error number). If the number is not known to this program, the OS error number + 100 is returned.

Returns
error number, or OS error number + 100 in: TRUE if we want an error message printed of all errors

Retrieves the last error number if an error occurs in a file io function. The number should be retrieved before any other OS calls (because they may overwrite the error number). If the number is not known to this program, the OS error number + 100 is returned.

Returns
error number, or OS error number + 100
Parameters
report_all_errorsin: TRUE if we want an error message printed of all errors

Definition at line 385 of file os0file.cc.

◆ os_file_get_size()

UNIV_INTERN ibool os_file_get_size ( os_file_t file,
ulint * size,
ulint * size_high )

Gets a file size.

Returns
TRUE if success out: most significant 32 bits of size

Gets a file size.

Returns
TRUE if success
Parameters
filein: handle to a file
sizeout: least significant 32 bits of file size
size_highout: most significant 32 bits of size

Definition at line 1882 of file os0file.cc.

◆ os_file_get_size_as_iblonglong()

UNIV_INTERN ib_int64_t os_file_get_size_as_iblonglong ( os_file_t file)

Gets file size as a 64-bit integer ib_int64_t.

Returns
size in bytes, -1 if error in: handle to a file

Gets file size as a 64-bit integer ib_int64_t.

Returns
size in bytes, -1 if error
Parameters
filein: handle to a file

Definition at line 1930 of file os0file.cc.

◆ os_file_get_status()

UNIV_INTERN ibool os_file_get_status ( const char * path,
os_file_stat_t * stat_info )

This function returns information about the specified file

Returns
TRUE if stat information found information of a file in a directory

This function returns information about the specified file

Returns
TRUE if stat information found
Parameters
pathin: pathname of the file
stat_infoinformation of a file in a directory

Definition at line 2962 of file os0file.cc.

◆ os_file_opendir()

UNIV_INTERN os_file_dir_t os_file_opendir ( const char * dirname,
ibool error_is_fatal )

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.

Returns
directory stream, NULL if error 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

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.

Returns
directory stream, NULL if error
Parameters
dirnamein: directory name; it must not contain a trailing '\' or '/'
error_is_fatalin: 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

Definition at line 761 of file os0file.cc.

◆ os_file_read_func()

UNIV_INTERN ibool os_file_read_func ( os_file_t file,
void * buf,
ulint offset,
ulint offset_high,
ulint n )

NOTE! Use the corresponding macro os_file_read(), not directly this function! Requests a synchronous read operation.

Returns
TRUE if request was successful, FALSE if fail in: number of bytes to read

NOTE! Use the corresponding macro os_file_read(), not directly this function! Requests a synchronous positioned read operation.

Returns
TRUE if request was successful, FALSE if fail
Parameters
filein: handle to a file
bufin: buffer where to read
offsetin: least significant 32 bits of file offset where to read
offset_highin: most significant 32 bits of offset
nin: number of bytes to read

Definition at line 2426 of file os0file.cc.

◆ os_file_read_no_error_handling_func()

UNIV_INTERN ibool os_file_read_no_error_handling_func ( os_file_t file,
void * buf,
ulint offset,
ulint offset_high,
ulint n )

NOTE! Use the corresponding macro os_file_read_no_error_handling(), not directly this function! Requests a synchronous positioned read operation. This function does not do any error handling. In case of error it returns FALSE.

Returns
TRUE if request was successful, FALSE if fail in: number of bytes to read

NOTE! Use the corresponding macro os_file_read_no_error_handling(), not directly this function! Requests a synchronous positioned read operation. This function does not do any error handling. In case of error it returns FALSE.

Returns
TRUE if request was successful, FALSE if fail
Parameters
filein: handle to a file
bufin: buffer where to read
offsetin: least significant 32 bits of file offset where to read
offset_highin: most significant 32 bits of offset
nin: number of bytes to read

Definition at line 2555 of file os0file.cc.

◆ os_file_read_string()

UNIV_INTERN void os_file_read_string ( FILE * file,
char * str,
ulint size )

Rewind file to its start, read at most size - 1 bytes from it to str, and NUL-terminate str. All errors are silently ignored. This function is mostly meant to be used with temporary files. in: size of buffer

Rewind file to its start, read at most size - 1 bytes from it to str, and NUL-terminate str. All errors are silently ignored. This function is mostly meant to be used with temporary files.

Parameters
filein: file to read from
strin: buffer where to read
sizein: size of buffer

Definition at line 2663 of file os0file.cc.

◆ os_file_readdir_next_file()

UNIV_INTERN int os_file_readdir_next_file ( const char * dirname,
os_file_dir_t dir,
os_file_stat_t * info )

This function returns information of the next file in the directory. We jump over the '.' and '..' entries in the directory.

Returns
0 if ok, -1 if error, 1 if at the end of the directory in/out: buffer where the info is returned

This function returns information of the next file in the directory. We jump over the '.' and '..' entries in the directory.

Returns
0 if ok, -1 if error, 1 if at the end of the directory
Parameters
dirnamein: directory name or path
dirin: directory stream
infoin/out: buffer where the info is returned

Definition at line 852 of file os0file.cc.

◆ os_file_rename_func()

UNIV_INTERN ibool os_file_rename_func ( const char * oldpath,
const char * newpath )

NOTE! Use the corresponding macro os_file_rename(), not directly this function! Renames a file (can also move it to another directory). It is safest that the file is closed before calling this function.

Returns
TRUE if success in: new file path

NOTE! Use the corresponding macro os_file_rename(), not directly this function! Renames a file (can also move it to another directory). It is safest that the file is closed before calling this function.

Returns
TRUE if success
Parameters
oldpathin: old file path as a null-terminated string
newpathin: new file path

Definition at line 1767 of file os0file.cc.

◆ os_file_set_eof()

UNIV_INTERN ibool os_file_set_eof ( FILE * file)

Truncates a file at its current position.

Returns
TRUE if success in: file to be truncated

Truncates a file at its current position.

Returns
TRUE if success
Parameters
filein: file to be truncated

Definition at line 2042 of file os0file.cc.

◆ os_file_set_nocache()

UNIV_INTERN void os_file_set_nocache ( int fd,
const char * file_name,
const char * operation_name )

Tries to disable OS caching on an opened file descriptor. in: "open" or "create"; used in the diagnostic message

Tries to disable OS caching on an opened file descriptor.

Parameters
fdin: file descriptor to alter
file_namein: used in the diagnostic message
operation_namein: "open" or "create"; used in the diagnostic message

Definition at line 1327 of file os0file.cc.

◆ os_file_set_size()

UNIV_INTERN ibool os_file_set_size ( const char * name,
os_file_t file,
ulint size,
ulint size_high )

Write the specified number of zeros to a newly created file.

Returns
TRUE if success in: most significant 32 bits of size

Write the specified number of zeros to a newly created file.

Returns
TRUE if success
Parameters
namein: name of the file or path as a null-terminated string
filein: handle to a file
sizein: least significant 32 bits of file size
size_highin: most significant 32 bits of size

Definition at line 1953 of file os0file.cc.

◆ os_file_status()

UNIV_INTERN ibool os_file_status ( const char * path,
ibool * exists,
os_file_type_t * type )

Check the existence and type of the given file.

Returns
TRUE if call succeeded out: type of the file (if it exists)

Check the existence and type of the given file.

Returns
TRUE if call succeeded
Parameters
pathin: pathname of the file
existsout: TRUE if file exists
typeout: type of the file (if it exists)

Definition at line 2890 of file os0file.cc.

◆ os_file_write_func()

UNIV_INTERN ibool os_file_write_func ( const char * name,
os_file_t file,
const void * buf,
ulint offset,
ulint offset_high,
ulint n )

NOTE! Use the corresponding macro os_file_write(), not directly this function! Requests a synchronous write operation.

Returns
TRUE if request was successful, FALSE if fail in: number of bytes to write

NOTE! Use the corresponding macro os_file_write(), not directly this function! Requests a synchronous write operation.

Returns
TRUE if request was successful, FALSE if fail
Parameters
namein: name of the file or path as a null-terminated string
filein: handle to a file
bufin: buffer from which to write
offsetin: least significant 32 bits of file offset where to write
offset_highin: most significant 32 bits of offset
nin: number of bytes to write

Definition at line 2687 of file os0file.cc.

◆ os_io_init_simple()

UNIV_INTERN void os_io_init_simple ( void )

Creates the seek mutexes used in positioned reads and writes.

Definition at line 711 of file os0file.cc.

Variable Documentation

◆ os_aio_print_debug

ibool os_aio_print_debug
extern

Flag: enable debug printout for asynchronous i/o

Definition at line 149 of file os0file.cc.

◆ os_file_n_pending_preads

ulint os_file_n_pending_preads
extern

Number of pending os_file_pread() operations

Definition at line 299 of file os0file.cc.

◆ os_file_n_pending_pwrites

ulint os_file_n_pending_pwrites
extern

Number of pending os_file_pwrite() operations

Definition at line 301 of file os0file.cc.

◆ os_has_said_disk_full

ibool os_has_said_disk_full
extern

Definition at line 292 of file os0file.cc.

◆ os_innodb_umask

ulint os_innodb_umask
extern

Umask for creating files

Definition at line 70 of file os0file.cc.

◆ os_n_file_reads

ulint os_n_file_reads
extern

Definition at line 283 of file os0file.cc.

◆ os_n_file_writes

ulint os_n_file_writes
extern

Definition at line 285 of file os0file.cc.

◆ os_n_fsyncs

ulint os_n_fsyncs
extern

Definition at line 286 of file os0file.cc.

◆ os_n_pending_reads

ulint os_n_pending_reads
extern

Number of pending read operations

Definition at line 305 of file os0file.cc.

◆ os_n_pending_writes

ulint os_n_pending_writes
extern

Number of pending write operations

Definition at line 303 of file os0file.cc.

◆ srv_log_block_size

uint32_t srv_log_block_size
extern

Definition at line 275 of file srv0srv.cc.