1 /* Hosted File I/O interface definitions, for GDB, the GNU Debugger. 2 3 Copyright (C) 2003-2014 Free Software Foundation, Inc. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 18 #ifndef GDB_FILEIO_H_ 19 #define GDB_FILEIO_H_ 20 21 /* The following flags are defined to be independent of the host 22 as well as the target side implementation of these constants. 23 All constants are defined with a leading FILEIO_ in the name 24 to allow the usage of these constants together with the 25 corresponding implementation dependent constants in one module. */ 26 27 /* open(2) flags */ 28 #define FILEIO_O_RDONLY 0x0 29 #define FILEIO_O_WRONLY 0x1 30 #define FILEIO_O_RDWR 0x2 31 #define FILEIO_O_APPEND 0x8 32 #define FILEIO_O_CREAT 0x200 33 #define FILEIO_O_TRUNC 0x400 34 #define FILEIO_O_EXCL 0x800 35 #define FILEIO_O_SUPPORTED (FILEIO_O_RDONLY | FILEIO_O_WRONLY| \ 36 FILEIO_O_RDWR | FILEIO_O_APPEND| \ 37 FILEIO_O_CREAT | FILEIO_O_TRUNC| \ 38 FILEIO_O_EXCL) 39 40 /* mode_t bits */ 41 #define FILEIO_S_IFREG 0100000 42 #define FILEIO_S_IFDIR 040000 43 #define FILEIO_S_IFCHR 020000 44 #define FILEIO_S_IRUSR 0400 45 #define FILEIO_S_IWUSR 0200 46 #define FILEIO_S_IXUSR 0100 47 #define FILEIO_S_IRWXU 0700 48 #define FILEIO_S_IRGRP 040 49 #define FILEIO_S_IWGRP 020 50 #define FILEIO_S_IXGRP 010 51 #define FILEIO_S_IRWXG 070 52 #define FILEIO_S_IROTH 04 53 #define FILEIO_S_IWOTH 02 54 #define FILEIO_S_IXOTH 01 55 #define FILEIO_S_IRWXO 07 56 #define FILEIO_S_SUPPORTED (FILEIO_S_IFREG|FILEIO_S_IFDIR| \ 57 FILEIO_S_IRWXU|FILEIO_S_IRWXG| \ 58 FILEIO_S_IRWXO) 59 60 /* lseek(2) flags */ 61 #define FILEIO_SEEK_SET 0 62 #define FILEIO_SEEK_CUR 1 63 #define FILEIO_SEEK_END 2 64 65 /* errno values */ 66 #define FILEIO_EPERM 1 67 #define FILEIO_ENOENT 2 68 #define FILEIO_EINTR 4 69 #define FILEIO_EIO 5 70 #define FILEIO_EBADF 9 71 #define FILEIO_EACCES 13 72 #define FILEIO_EFAULT 14 73 #define FILEIO_EBUSY 16 74 #define FILEIO_EEXIST 17 75 #define FILEIO_ENODEV 19 76 #define FILEIO_ENOTDIR 20 77 #define FILEIO_EISDIR 21 78 #define FILEIO_EINVAL 22 79 #define FILEIO_ENFILE 23 80 #define FILEIO_EMFILE 24 81 #define FILEIO_EFBIG 27 82 #define FILEIO_ENOSPC 28 83 #define FILEIO_ESPIPE 29 84 #define FILEIO_EROFS 30 85 #define FILEIO_ENOSYS 88 86 #define FILEIO_ENAMETOOLONG 91 87 #define FILEIO_EUNKNOWN 9999 88 89 /* limits */ 90 #define FILEIO_INT_MIN -2147483648L 91 #define FILEIO_INT_MAX 2147483647L 92 #define FILEIO_UINT_MAX 4294967295UL 93 #define FILEIO_LONG_MIN -9223372036854775808LL 94 #define FILEIO_LONG_MAX 9223372036854775807LL 95 #define FILEIO_ULONG_MAX 18446744073709551615ULL 96 97 /* Integral types as used in protocol. */ 98 #if 0 99 typedef __int32_t fio_int_t; 100 typedef __uint32_t fio_uint_t, fio_mode_t, fio_time_t; 101 typedef __int64_t fio_long_t; 102 typedef __uint64_t fio_ulong_t; 103 #endif 104 105 #define FIO_INT_LEN 4 106 #define FIO_UINT_LEN 4 107 #define FIO_MODE_LEN 4 108 #define FIO_TIME_LEN 4 109 #define FIO_LONG_LEN 8 110 #define FIO_ULONG_LEN 8 111 112 typedef char fio_int_t[FIO_INT_LEN]; 113 typedef char fio_uint_t[FIO_UINT_LEN]; 114 typedef char fio_mode_t[FIO_MODE_LEN]; 115 typedef char fio_time_t[FIO_TIME_LEN]; 116 typedef char fio_long_t[FIO_LONG_LEN]; 117 typedef char fio_ulong_t[FIO_ULONG_LEN]; 118 119 /* Struct stat as used in protocol. For complete independence 120 of host/target systems, it's defined as an array with offsets 121 to the members. */ 122 123 struct fio_stat { 124 fio_uint_t fst_dev; 125 fio_uint_t fst_ino; 126 fio_mode_t fst_mode; 127 fio_uint_t fst_nlink; 128 fio_uint_t fst_uid; 129 fio_uint_t fst_gid; 130 fio_uint_t fst_rdev; 131 fio_ulong_t fst_size; 132 fio_ulong_t fst_blksize; 133 fio_ulong_t fst_blocks; 134 fio_time_t fst_atime; 135 fio_time_t fst_mtime; 136 fio_time_t fst_ctime; 137 }; 138 139 struct fio_timeval { 140 fio_time_t ftv_sec; 141 fio_long_t ftv_usec; 142 }; 143 144 #endif /* GDB_FILEIO_H_ */ 145