15796c8dcSSimon Schubert /* Hosted File I/O interface definitions, for GDB, the GNU Debugger. 25796c8dcSSimon Schubert 3*ef5ccd6cSJohn Marino Copyright 2003-2013 Free Software Foundation, Inc. 45796c8dcSSimon Schubert 55796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 65796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 75796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 85796c8dcSSimon Schubert (at your option) any later version. 95796c8dcSSimon Schubert 105796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 115796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 125796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 135796c8dcSSimon Schubert GNU General Public License for more details. 145796c8dcSSimon Schubert 155796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 165796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 175796c8dcSSimon Schubert 185796c8dcSSimon Schubert #ifndef GDB_FILEIO_H_ 195796c8dcSSimon Schubert #define GDB_FILEIO_H_ 205796c8dcSSimon Schubert 215796c8dcSSimon Schubert /* The following flags are defined to be independent of the host 225796c8dcSSimon Schubert as well as the target side implementation of these constants. 235796c8dcSSimon Schubert All constants are defined with a leading FILEIO_ in the name 245796c8dcSSimon Schubert to allow the usage of these constants together with the 255796c8dcSSimon Schubert corresponding implementation dependent constants in one module. */ 265796c8dcSSimon Schubert 275796c8dcSSimon Schubert /* open(2) flags */ 285796c8dcSSimon Schubert #define FILEIO_O_RDONLY 0x0 295796c8dcSSimon Schubert #define FILEIO_O_WRONLY 0x1 305796c8dcSSimon Schubert #define FILEIO_O_RDWR 0x2 315796c8dcSSimon Schubert #define FILEIO_O_APPEND 0x8 325796c8dcSSimon Schubert #define FILEIO_O_CREAT 0x200 335796c8dcSSimon Schubert #define FILEIO_O_TRUNC 0x400 345796c8dcSSimon Schubert #define FILEIO_O_EXCL 0x800 355796c8dcSSimon Schubert #define FILEIO_O_SUPPORTED (FILEIO_O_RDONLY | FILEIO_O_WRONLY| \ 365796c8dcSSimon Schubert FILEIO_O_RDWR | FILEIO_O_APPEND| \ 375796c8dcSSimon Schubert FILEIO_O_CREAT | FILEIO_O_TRUNC| \ 385796c8dcSSimon Schubert FILEIO_O_EXCL) 395796c8dcSSimon Schubert 405796c8dcSSimon Schubert /* mode_t bits */ 415796c8dcSSimon Schubert #define FILEIO_S_IFREG 0100000 425796c8dcSSimon Schubert #define FILEIO_S_IFDIR 040000 435796c8dcSSimon Schubert #define FILEIO_S_IFCHR 020000 445796c8dcSSimon Schubert #define FILEIO_S_IRUSR 0400 455796c8dcSSimon Schubert #define FILEIO_S_IWUSR 0200 465796c8dcSSimon Schubert #define FILEIO_S_IXUSR 0100 475796c8dcSSimon Schubert #define FILEIO_S_IRWXU 0700 485796c8dcSSimon Schubert #define FILEIO_S_IRGRP 040 495796c8dcSSimon Schubert #define FILEIO_S_IWGRP 020 505796c8dcSSimon Schubert #define FILEIO_S_IXGRP 010 515796c8dcSSimon Schubert #define FILEIO_S_IRWXG 070 525796c8dcSSimon Schubert #define FILEIO_S_IROTH 04 535796c8dcSSimon Schubert #define FILEIO_S_IWOTH 02 545796c8dcSSimon Schubert #define FILEIO_S_IXOTH 01 555796c8dcSSimon Schubert #define FILEIO_S_IRWXO 07 565796c8dcSSimon Schubert #define FILEIO_S_SUPPORTED (FILEIO_S_IFREG|FILEIO_S_IFDIR| \ 575796c8dcSSimon Schubert FILEIO_S_IRWXU|FILEIO_S_IRWXG| \ 585796c8dcSSimon Schubert FILEIO_S_IRWXO) 595796c8dcSSimon Schubert 605796c8dcSSimon Schubert /* lseek(2) flags */ 615796c8dcSSimon Schubert #define FILEIO_SEEK_SET 0 625796c8dcSSimon Schubert #define FILEIO_SEEK_CUR 1 635796c8dcSSimon Schubert #define FILEIO_SEEK_END 2 645796c8dcSSimon Schubert 655796c8dcSSimon Schubert /* errno values */ 665796c8dcSSimon Schubert #define FILEIO_EPERM 1 675796c8dcSSimon Schubert #define FILEIO_ENOENT 2 685796c8dcSSimon Schubert #define FILEIO_EINTR 4 695796c8dcSSimon Schubert #define FILEIO_EIO 5 705796c8dcSSimon Schubert #define FILEIO_EBADF 9 715796c8dcSSimon Schubert #define FILEIO_EACCES 13 725796c8dcSSimon Schubert #define FILEIO_EFAULT 14 735796c8dcSSimon Schubert #define FILEIO_EBUSY 16 745796c8dcSSimon Schubert #define FILEIO_EEXIST 17 755796c8dcSSimon Schubert #define FILEIO_ENODEV 19 765796c8dcSSimon Schubert #define FILEIO_ENOTDIR 20 775796c8dcSSimon Schubert #define FILEIO_EISDIR 21 785796c8dcSSimon Schubert #define FILEIO_EINVAL 22 795796c8dcSSimon Schubert #define FILEIO_ENFILE 23 805796c8dcSSimon Schubert #define FILEIO_EMFILE 24 815796c8dcSSimon Schubert #define FILEIO_EFBIG 27 825796c8dcSSimon Schubert #define FILEIO_ENOSPC 28 835796c8dcSSimon Schubert #define FILEIO_ESPIPE 29 845796c8dcSSimon Schubert #define FILEIO_EROFS 30 855796c8dcSSimon Schubert #define FILEIO_ENOSYS 88 865796c8dcSSimon Schubert #define FILEIO_ENAMETOOLONG 91 875796c8dcSSimon Schubert #define FILEIO_EUNKNOWN 9999 885796c8dcSSimon Schubert 895796c8dcSSimon Schubert /* limits */ 905796c8dcSSimon Schubert #define FILEIO_INT_MIN -2147483648L 915796c8dcSSimon Schubert #define FILEIO_INT_MAX 2147483647L 925796c8dcSSimon Schubert #define FILEIO_UINT_MAX 4294967295UL 935796c8dcSSimon Schubert #define FILEIO_LONG_MIN -9223372036854775808LL 945796c8dcSSimon Schubert #define FILEIO_LONG_MAX 9223372036854775807LL 955796c8dcSSimon Schubert #define FILEIO_ULONG_MAX 18446744073709551615ULL 965796c8dcSSimon Schubert 975796c8dcSSimon Schubert /* Integral types as used in protocol. */ 985796c8dcSSimon Schubert #if 0 995796c8dcSSimon Schubert typedef __int32_t fio_int_t; 1005796c8dcSSimon Schubert typedef __uint32_t fio_uint_t, fio_mode_t, fio_time_t; 1015796c8dcSSimon Schubert typedef __int64_t fio_long_t; 1025796c8dcSSimon Schubert typedef __uint64_t fio_ulong_t; 1035796c8dcSSimon Schubert #endif 1045796c8dcSSimon Schubert 1055796c8dcSSimon Schubert #define FIO_INT_LEN 4 1065796c8dcSSimon Schubert #define FIO_UINT_LEN 4 1075796c8dcSSimon Schubert #define FIO_MODE_LEN 4 1085796c8dcSSimon Schubert #define FIO_TIME_LEN 4 1095796c8dcSSimon Schubert #define FIO_LONG_LEN 8 1105796c8dcSSimon Schubert #define FIO_ULONG_LEN 8 1115796c8dcSSimon Schubert 1125796c8dcSSimon Schubert typedef char fio_int_t[FIO_INT_LEN]; 1135796c8dcSSimon Schubert typedef char fio_uint_t[FIO_UINT_LEN]; 1145796c8dcSSimon Schubert typedef char fio_mode_t[FIO_MODE_LEN]; 1155796c8dcSSimon Schubert typedef char fio_time_t[FIO_TIME_LEN]; 1165796c8dcSSimon Schubert typedef char fio_long_t[FIO_LONG_LEN]; 1175796c8dcSSimon Schubert typedef char fio_ulong_t[FIO_ULONG_LEN]; 1185796c8dcSSimon Schubert 1195796c8dcSSimon Schubert /* Struct stat as used in protocol. For complete independence 1205796c8dcSSimon Schubert of host/target systems, it's defined as an array with offsets 1215796c8dcSSimon Schubert to the members. */ 1225796c8dcSSimon Schubert 1235796c8dcSSimon Schubert struct fio_stat { 1245796c8dcSSimon Schubert fio_uint_t fst_dev; 1255796c8dcSSimon Schubert fio_uint_t fst_ino; 1265796c8dcSSimon Schubert fio_mode_t fst_mode; 1275796c8dcSSimon Schubert fio_uint_t fst_nlink; 1285796c8dcSSimon Schubert fio_uint_t fst_uid; 1295796c8dcSSimon Schubert fio_uint_t fst_gid; 1305796c8dcSSimon Schubert fio_uint_t fst_rdev; 1315796c8dcSSimon Schubert fio_ulong_t fst_size; 1325796c8dcSSimon Schubert fio_ulong_t fst_blksize; 1335796c8dcSSimon Schubert fio_ulong_t fst_blocks; 1345796c8dcSSimon Schubert fio_time_t fst_atime; 1355796c8dcSSimon Schubert fio_time_t fst_mtime; 1365796c8dcSSimon Schubert fio_time_t fst_ctime; 1375796c8dcSSimon Schubert }; 1385796c8dcSSimon Schubert 1395796c8dcSSimon Schubert struct fio_timeval { 1405796c8dcSSimon Schubert fio_time_t ftv_sec; 1415796c8dcSSimon Schubert fio_long_t ftv_usec; 1425796c8dcSSimon Schubert }; 1435796c8dcSSimon Schubert 1445796c8dcSSimon Schubert #endif /* GDB_FILEIO_H_ */ 145