Back to index

cell-binutils  2.17cvs20070401
fileio.h
Go to the documentation of this file.
00001 /* Hosted File I/O interface definitions, for GDB, the GNU Debugger.
00002 
00003    Copyright 2003, 2007 Free Software Foundation, Inc.
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public License as
00007    published by the Free Software Foundation; either version 2 of the
00008    License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful, but
00011    WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00018    02111-1307, USA.  */
00019 
00020 #ifndef GDB_FILEIO_H_
00021 #define GDB_FILEIO_H_
00022 
00023 /* The following flags are defined to be independent of the host
00024    as well as the target side implementation of these constants.
00025    All constants are defined with a leading FILEIO_ in the name
00026    to allow the usage of these constants together with the
00027    corresponding implementation dependent constants in one module. */
00028 
00029 /* open(2) flags */
00030 #define FILEIO_O_RDONLY           0x0
00031 #define FILEIO_O_WRONLY           0x1
00032 #define FILEIO_O_RDWR             0x2
00033 #define FILEIO_O_APPEND           0x8
00034 #define FILEIO_O_CREAT          0x200
00035 #define FILEIO_O_TRUNC          0x400
00036 #define FILEIO_O_EXCL           0x800
00037 #define FILEIO_O_SUPPORTED  (FILEIO_O_RDONLY | FILEIO_O_WRONLY| \
00038                              FILEIO_O_RDWR   | FILEIO_O_APPEND| \
00039                              FILEIO_O_CREAT  | FILEIO_O_TRUNC| \
00040                              FILEIO_O_EXCL)
00041 
00042 /* mode_t bits */
00043 #define FILEIO_S_IFREG        0100000
00044 #define FILEIO_S_IFDIR         040000
00045 #define FILEIO_S_IFCHR         020000
00046 #define FILEIO_S_IRUSR           0400
00047 #define FILEIO_S_IWUSR           0200
00048 #define FILEIO_S_IXUSR           0100
00049 #define FILEIO_S_IRWXU           0700
00050 #define FILEIO_S_IRGRP            040
00051 #define FILEIO_S_IWGRP            020
00052 #define FILEIO_S_IXGRP            010
00053 #define FILEIO_S_IRWXG            070
00054 #define FILEIO_S_IROTH             04
00055 #define FILEIO_S_IWOTH             02
00056 #define FILEIO_S_IXOTH             01
00057 #define FILEIO_S_IRWXO             07
00058 #define FILEIO_S_SUPPORTED         (FILEIO_S_IFREG|FILEIO_S_IFDIR|  \
00059                                 FILEIO_S_IRWXU|FILEIO_S_IRWXG|  \
00060                                     FILEIO_S_IRWXO)
00061 
00062 /* lseek(2) flags */
00063 #define FILEIO_SEEK_SET             0
00064 #define FILEIO_SEEK_CUR             1
00065 #define FILEIO_SEEK_END             2
00066 
00067 /* errno values */
00068 #define FILEIO_EPERM                1
00069 #define FILEIO_ENOENT               2
00070 #define FILEIO_EINTR                4
00071 #define FILEIO_EIO                  5
00072 #define FILEIO_EBADF                9
00073 #define FILEIO_EACCES              13
00074 #define FILEIO_EFAULT              14
00075 #define FILEIO_EBUSY               16
00076 #define FILEIO_EEXIST              17
00077 #define FILEIO_ENODEV              19
00078 #define FILEIO_ENOTDIR             20
00079 #define FILEIO_EISDIR              21
00080 #define FILEIO_EINVAL              22
00081 #define FILEIO_ENFILE              23
00082 #define FILEIO_EMFILE              24
00083 #define FILEIO_EFBIG               27
00084 #define FILEIO_ENOSPC              28
00085 #define FILEIO_ESPIPE              29
00086 #define FILEIO_EROFS               30
00087 #define FILEIO_ENOSYS                 88
00088 #define FILEIO_ENAMETOOLONG        91
00089 #define FILEIO_EUNKNOWN          9999
00090 
00091 /* limits */
00092 #define FILEIO_INT_MIN    -2147483648L
00093 #define FILEIO_INT_MAX     2147483647L
00094 #define FILEIO_UINT_MAX    4294967295UL
00095 #define FILEIO_LONG_MIN   -9223372036854775808LL
00096 #define FILEIO_LONG_MAX    9223372036854775807LL
00097 #define FILEIO_ULONG_MAX   18446744073709551615ULL
00098 
00099 /* Integral types as used in protocol. */
00100 #if 0
00101 typedef __int32_t fio_int_t;
00102 typedef __uint32_t fio_uint_t, fio_mode_t, fio_time_t;
00103 typedef __int64_t fio_long_t;
00104 typedef __uint64_t fio_ulong_t;
00105 #endif
00106 
00107 #define FIO_INT_LEN   4
00108 #define FIO_UINT_LEN  4
00109 #define FIO_MODE_LEN  4
00110 #define FIO_TIME_LEN  4
00111 #define FIO_LONG_LEN  8
00112 #define FIO_ULONG_LEN 8
00113 
00114 typedef char fio_int_t[FIO_INT_LEN];   
00115 typedef char fio_uint_t[FIO_UINT_LEN];
00116 typedef char fio_mode_t[FIO_MODE_LEN];
00117 typedef char fio_time_t[FIO_TIME_LEN];
00118 typedef char fio_long_t[FIO_LONG_LEN];
00119 typedef char fio_ulong_t[FIO_ULONG_LEN];
00120 
00121 /* Struct stat as used in protocol.  For complete independence
00122    of host/target systems, it's defined as an array with offsets
00123    to the members. */
00124 
00125 struct fio_stat {
00126   fio_uint_t  fst_dev;
00127   fio_uint_t  fst_ino;
00128   fio_mode_t  fst_mode;
00129   fio_uint_t  fst_nlink;
00130   fio_uint_t  fst_uid;
00131   fio_uint_t  fst_gid;
00132   fio_uint_t  fst_rdev;
00133   fio_ulong_t fst_size;
00134   fio_ulong_t fst_blksize;
00135   fio_ulong_t fst_blocks;
00136   fio_time_t  fst_atime;
00137   fio_time_t  fst_mtime;
00138   fio_time_t  fst_ctime;
00139 };
00140 
00141 struct fio_timeval {
00142   fio_time_t  ftv_sec;
00143   fio_long_t  ftv_usec;
00144 };
00145 
00146 #endif /* GDB_FILEIO_H_ */