fileio.h 4.7 KB

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