175fd0b74Schristos /* Hosted File I/O interface definitions, for GDB, the GNU Debugger. 275fd0b74Schristos 3*e992f068Schristos Copyright (C) 2003-2022 Free Software Foundation, Inc. 475fd0b74Schristos 575fd0b74Schristos This program is free software; you can redistribute it and/or modify 675fd0b74Schristos it under the terms of the GNU General Public License as published by 775fd0b74Schristos the Free Software Foundation; either version 3 of the License, or 875fd0b74Schristos (at your option) any later version. 975fd0b74Schristos 1075fd0b74Schristos This program is distributed in the hope that it will be useful, 1175fd0b74Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 1275fd0b74Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1375fd0b74Schristos GNU General Public License for more details. 1475fd0b74Schristos 1575fd0b74Schristos You should have received a copy of the GNU General Public License 1675fd0b74Schristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 1775fd0b74Schristos 1875fd0b74Schristos #ifndef GDB_FILEIO_H_ 1975fd0b74Schristos #define GDB_FILEIO_H_ 2075fd0b74Schristos 2175fd0b74Schristos /* The following flags are defined to be independent of the host 2275fd0b74Schristos as well as the target side implementation of these constants. 2375fd0b74Schristos All constants are defined with a leading FILEIO_ in the name 2475fd0b74Schristos to allow the usage of these constants together with the 2575fd0b74Schristos corresponding implementation dependent constants in one module. */ 2675fd0b74Schristos 2775fd0b74Schristos /* open(2) flags */ 2875fd0b74Schristos #define FILEIO_O_RDONLY 0x0 2975fd0b74Schristos #define FILEIO_O_WRONLY 0x1 3075fd0b74Schristos #define FILEIO_O_RDWR 0x2 3175fd0b74Schristos #define FILEIO_O_APPEND 0x8 3275fd0b74Schristos #define FILEIO_O_CREAT 0x200 3375fd0b74Schristos #define FILEIO_O_TRUNC 0x400 3475fd0b74Schristos #define FILEIO_O_EXCL 0x800 3575fd0b74Schristos #define FILEIO_O_SUPPORTED (FILEIO_O_RDONLY | FILEIO_O_WRONLY| \ 3675fd0b74Schristos FILEIO_O_RDWR | FILEIO_O_APPEND| \ 3775fd0b74Schristos FILEIO_O_CREAT | FILEIO_O_TRUNC| \ 3875fd0b74Schristos FILEIO_O_EXCL) 3975fd0b74Schristos 4075fd0b74Schristos /* mode_t bits */ 4175fd0b74Schristos #define FILEIO_S_IFREG 0100000 4275fd0b74Schristos #define FILEIO_S_IFDIR 040000 4375fd0b74Schristos #define FILEIO_S_IFCHR 020000 4475fd0b74Schristos #define FILEIO_S_IRUSR 0400 4575fd0b74Schristos #define FILEIO_S_IWUSR 0200 4675fd0b74Schristos #define FILEIO_S_IXUSR 0100 4775fd0b74Schristos #define FILEIO_S_IRWXU 0700 4875fd0b74Schristos #define FILEIO_S_IRGRP 040 4975fd0b74Schristos #define FILEIO_S_IWGRP 020 5075fd0b74Schristos #define FILEIO_S_IXGRP 010 5175fd0b74Schristos #define FILEIO_S_IRWXG 070 5275fd0b74Schristos #define FILEIO_S_IROTH 04 5375fd0b74Schristos #define FILEIO_S_IWOTH 02 5475fd0b74Schristos #define FILEIO_S_IXOTH 01 5575fd0b74Schristos #define FILEIO_S_IRWXO 07 5675fd0b74Schristos #define FILEIO_S_SUPPORTED (FILEIO_S_IFREG|FILEIO_S_IFDIR| \ 5775fd0b74Schristos FILEIO_S_IRWXU|FILEIO_S_IRWXG| \ 5875fd0b74Schristos FILEIO_S_IRWXO) 5975fd0b74Schristos 6075fd0b74Schristos /* lseek(2) flags */ 6175fd0b74Schristos #define FILEIO_SEEK_SET 0 6275fd0b74Schristos #define FILEIO_SEEK_CUR 1 6375fd0b74Schristos #define FILEIO_SEEK_END 2 6475fd0b74Schristos 6575fd0b74Schristos /* errno values */ 6675fd0b74Schristos #define FILEIO_EPERM 1 6775fd0b74Schristos #define FILEIO_ENOENT 2 6875fd0b74Schristos #define FILEIO_EINTR 4 6975fd0b74Schristos #define FILEIO_EIO 5 7075fd0b74Schristos #define FILEIO_EBADF 9 7175fd0b74Schristos #define FILEIO_EACCES 13 7275fd0b74Schristos #define FILEIO_EFAULT 14 7375fd0b74Schristos #define FILEIO_EBUSY 16 7475fd0b74Schristos #define FILEIO_EEXIST 17 7575fd0b74Schristos #define FILEIO_ENODEV 19 7675fd0b74Schristos #define FILEIO_ENOTDIR 20 7775fd0b74Schristos #define FILEIO_EISDIR 21 7875fd0b74Schristos #define FILEIO_EINVAL 22 7975fd0b74Schristos #define FILEIO_ENFILE 23 8075fd0b74Schristos #define FILEIO_EMFILE 24 8175fd0b74Schristos #define FILEIO_EFBIG 27 8275fd0b74Schristos #define FILEIO_ENOSPC 28 8375fd0b74Schristos #define FILEIO_ESPIPE 29 8475fd0b74Schristos #define FILEIO_EROFS 30 8575fd0b74Schristos #define FILEIO_ENOSYS 88 8675fd0b74Schristos #define FILEIO_ENAMETOOLONG 91 8775fd0b74Schristos #define FILEIO_EUNKNOWN 9999 8875fd0b74Schristos 8975fd0b74Schristos /* limits */ 9075fd0b74Schristos #define FILEIO_INT_MIN -2147483648L 9175fd0b74Schristos #define FILEIO_INT_MAX 2147483647L 9275fd0b74Schristos #define FILEIO_UINT_MAX 4294967295UL 9375fd0b74Schristos #define FILEIO_LONG_MIN -9223372036854775808LL 9475fd0b74Schristos #define FILEIO_LONG_MAX 9223372036854775807LL 9575fd0b74Schristos #define FILEIO_ULONG_MAX 18446744073709551615ULL 9675fd0b74Schristos 9775fd0b74Schristos /* Integral types as used in protocol. */ 9875fd0b74Schristos #if 0 9975fd0b74Schristos typedef __int32_t fio_int_t; 10075fd0b74Schristos typedef __uint32_t fio_uint_t, fio_mode_t, fio_time_t; 10175fd0b74Schristos typedef __int64_t fio_long_t; 10275fd0b74Schristos typedef __uint64_t fio_ulong_t; 10375fd0b74Schristos #endif 10475fd0b74Schristos 10575fd0b74Schristos #define FIO_INT_LEN 4 10675fd0b74Schristos #define FIO_UINT_LEN 4 10775fd0b74Schristos #define FIO_MODE_LEN 4 10875fd0b74Schristos #define FIO_TIME_LEN 4 10975fd0b74Schristos #define FIO_LONG_LEN 8 11075fd0b74Schristos #define FIO_ULONG_LEN 8 11175fd0b74Schristos 11275fd0b74Schristos typedef char fio_int_t[FIO_INT_LEN]; 11375fd0b74Schristos typedef char fio_uint_t[FIO_UINT_LEN]; 11475fd0b74Schristos typedef char fio_mode_t[FIO_MODE_LEN]; 11575fd0b74Schristos typedef char fio_time_t[FIO_TIME_LEN]; 11675fd0b74Schristos typedef char fio_long_t[FIO_LONG_LEN]; 11775fd0b74Schristos typedef char fio_ulong_t[FIO_ULONG_LEN]; 11875fd0b74Schristos 11975fd0b74Schristos /* Struct stat as used in protocol. For complete independence 12075fd0b74Schristos of host/target systems, it's defined as an array with offsets 12175fd0b74Schristos to the members. */ 12275fd0b74Schristos 12375fd0b74Schristos struct fio_stat { 12475fd0b74Schristos fio_uint_t fst_dev; 12575fd0b74Schristos fio_uint_t fst_ino; 12675fd0b74Schristos fio_mode_t fst_mode; 12775fd0b74Schristos fio_uint_t fst_nlink; 12875fd0b74Schristos fio_uint_t fst_uid; 12975fd0b74Schristos fio_uint_t fst_gid; 13075fd0b74Schristos fio_uint_t fst_rdev; 13175fd0b74Schristos fio_ulong_t fst_size; 13275fd0b74Schristos fio_ulong_t fst_blksize; 13375fd0b74Schristos fio_ulong_t fst_blocks; 13475fd0b74Schristos fio_time_t fst_atime; 13575fd0b74Schristos fio_time_t fst_mtime; 13675fd0b74Schristos fio_time_t fst_ctime; 13775fd0b74Schristos }; 13875fd0b74Schristos 13975fd0b74Schristos struct fio_timeval { 14075fd0b74Schristos fio_time_t ftv_sec; 14175fd0b74Schristos fio_long_t ftv_usec; 14275fd0b74Schristos }; 14375fd0b74Schristos 14475fd0b74Schristos #endif /* GDB_FILEIO_H_ */ 145