| 1 | /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
| 2 | // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: |
| 3 | #ident "$Id$" |
| 4 | /*====== |
| 5 | This file is part of PerconaFT. |
| 6 | |
| 7 | |
| 8 | Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. |
| 9 | |
| 10 | PerconaFT is free software: you can redistribute it and/or modify |
| 11 | it under the terms of the GNU General Public License, version 2, |
| 12 | as published by the Free Software Foundation. |
| 13 | |
| 14 | PerconaFT is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
| 21 | |
| 22 | ---------------------------------------- |
| 23 | |
| 24 | PerconaFT is free software: you can redistribute it and/or modify |
| 25 | it under the terms of the GNU Affero General Public License, version 3, |
| 26 | as published by the Free Software Foundation. |
| 27 | |
| 28 | PerconaFT is distributed in the hope that it will be useful, |
| 29 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 30 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 31 | GNU Affero General Public License for more details. |
| 32 | |
| 33 | You should have received a copy of the GNU Affero General Public License |
| 34 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
| 35 | ======= */ |
| 36 | |
| 37 | #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." |
| 38 | |
| 39 | #pragma once |
| 40 | |
| 41 | #include <dirent.h> |
| 42 | #include <sys/time.h> |
| 43 | |
| 44 | #include "toku_stdint.h" |
| 45 | #include "toku_os_types.h" |
| 46 | |
| 47 | // Returns: the current process id |
| 48 | int toku_os_getpid(void) __attribute__((__visibility__("default" ))); |
| 49 | |
| 50 | // Returns: the current thread id |
| 51 | int toku_os_gettid(void) __attribute__((__visibility__("default" ))); |
| 52 | |
| 53 | // Returns: the number of processors in the system |
| 54 | int toku_os_get_number_processors(void); |
| 55 | |
| 56 | // Returns: the number of active processors in the system |
| 57 | int toku_os_get_number_active_processors(void); |
| 58 | |
| 59 | // Returns: the system page size (in bytes) |
| 60 | int toku_os_get_pagesize(void); |
| 61 | |
| 62 | // Returns: the size of physical memory (in bytes) |
| 63 | uint64_t toku_os_get_phys_memory_size(void) __attribute__((__visibility__("default" ))); |
| 64 | |
| 65 | // Returns the processor frequency in Hz |
| 66 | // Returns 0 if success |
| 67 | int toku_os_get_processor_frequency(uint64_t *hz); |
| 68 | |
| 69 | // Returns: 0 on success |
| 70 | // sets fsize to the number of bytes in a file |
| 71 | int toku_os_get_file_size(int fildes, int64_t *fsize) __attribute__((__visibility__("default" ))); |
| 72 | |
| 73 | // Returns: 0 on success |
| 74 | // Initializes id as a unique fileid for fildes on success. |
| 75 | int toku_os_get_unique_file_id(int fildes, struct fileid *id); |
| 76 | |
| 77 | //Locks a file (should not be open to begin with). |
| 78 | //Returns: file descriptor (or -1 on error) |
| 79 | int toku_os_lock_file(const char *name); |
| 80 | |
| 81 | //Unlocks and closes a file locked by toku_os_lock_on_file |
| 82 | int toku_os_unlock_file(int fildes); |
| 83 | |
| 84 | int toku_os_mkdir(const char *pathname, mode_t mode) __attribute__((__visibility__("default" ))); |
| 85 | |
| 86 | // Get the current process user and kernel use times |
| 87 | int toku_os_get_process_times(struct timeval *usertime, struct timeval *kerneltime); |
| 88 | |
| 89 | // Get the maximum size of the process data size (in bytes) |
| 90 | // Success: returns 0 and sets *maxdata to the data size |
| 91 | // Fail: returns an error number |
| 92 | int toku_os_get_max_process_data_size(uint64_t *maxdata) __attribute__((__visibility__("default" ))); |
| 93 | |
| 94 | int toku_os_initialize_settings(int verbosity) __attribute__((__visibility__("default" ))); |
| 95 | |
| 96 | bool toku_os_is_absolute_name(const char* path) __attribute__((__visibility__("default" ))); |
| 97 | |
| 98 | // Return true if huge pages are enabled. See portability/huge_page_detection.cc for methodology. |
| 99 | bool toku_os_huge_pages_enabled(void) __attribute__((__visibility__("default" ))); |
| 100 | |
| 101 | // Set whether or not writes assert when ENOSPC is returned or they wait for space |
| 102 | void toku_set_assert_on_write_enospc(int do_assert) __attribute__((__visibility__("default" ))); |
| 103 | |
| 104 | // Get file system write information |
| 105 | // *enospc_last_time is the last time ENOSPC was returned by write or pwrite |
| 106 | // *enospc_current is the number of threads waiting on space |
| 107 | // *enospc_total is the number of times ENOSPC was returned by write or pwrite |
| 108 | void toku_fs_get_write_info(time_t *enospc_last_time, uint64_t *enospc_current, uint64_t *enospc_total); |
| 109 | |
| 110 | void toku_fsync_dirfd_without_accounting(DIR *dirp); |
| 111 | |
| 112 | int toku_fsync_dir_by_name_without_accounting(const char *dir_name); |
| 113 | |
| 114 | // Get the file system free and total space for the file system that contains a path name |
| 115 | // *avail_size is set to the bytes of free space in the file system available for non-root |
| 116 | // *free_size is set to the bytes of free space in the file system |
| 117 | // *total_size is set to the total bytes in the file system |
| 118 | // Return 0 on success, otherwise an error number |
| 119 | int toku_get_filesystem_sizes(const char *path, |
| 120 | uint64_t *avail_size, |
| 121 | uint64_t *free_size, |
| 122 | uint64_t *total_size); |
| 123 | |
| 124 | // Portable linux 'dup2' |
| 125 | int toku_dup2(int fd, int fd2) __attribute__((__visibility__("default" ))); |
| 126 | |