]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/irix.h
Get xfstests building on irix using root/toolroot.
[thirdparty/xfsprogs-dev.git] / include / irix.h
1 /*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 *
32 */
33 #ifndef __XFS_IRIX_H__
34 #define __XFS_IRIX_H__
35
36 #include <stdlib.h>
37 #include <unistd.h>
38 #include <libgen.h>
39 #include <values.h>
40 #include <strings.h>
41 #include <inttypes.h>
42 #include <limits.h>
43 #include <fcntl.h>
44 #include <sys/stat.h>
45 #include <sys/uuid.h>
46 #include <sys/param.h>
47 #include <sys/ioctl.h>
48 #include <sys/types.h>
49 #include <sys/statfs.h>
50 #include <sys/statvfs.h>
51 #include <sys/syssgi.h>
52 #include <sys/sysmacros.h>
53 #include <sys/fs/xfs_fsops.h>
54 #include <sys/fs/xfs_itable.h>
55
56 #define __s8 char
57 #define __s16 short
58 #define __s32 __int32_t
59 #define __s64 __int64_t
60 #define __u8 unsigned char
61 #define __u16 unsigned short
62 #define __u32 __int32_t
63 #define __u64 __int64_t
64 #define __int8_t char
65 #define __int16_t short
66 #define __uint8_t unsigned char
67 #define __uint16_t unsigned short
68 #define loff_t off64_t
69 typedef off64_t xfs_off_t;
70 typedef __int64_t xfs_ino_t;
71 typedef __int32_t xfs_dev_t;
72 typedef __int64_t xfs_daddr_t;
73 typedef char* xfs_caddr_t;
74
75 #define xfs_flock64 flock64
76 #define xfs_flock64_t struct flock64
77
78 typedef struct xfs_error_injection {
79 __int32_t fd;
80 __int32_t errtag;
81 } xfs_error_injection_t;
82
83
84 typedef struct xfs_fsop_bulkreq {
85 ino64_t *lastip;
86 __int32_t icount;
87 xfs_bstat_t *ubuffer;
88 __int32_t *ocount;
89 } xfs_fsop_bulkreq_t;
90
91 #include <sys/endian.h>
92 #define __BYTE_ORDER BYTE_ORDER
93 #define __BIG_ENDIAN BIG_ENDIAN
94 #define __LITTLE_ENDIAN LITTLE_ENDIAN
95 #define __fswab16(x) (x)
96 #define __fswab32(x) (x)
97 #define __fswab64(x) (x)
98
99 /* Map some gcc macros for the MipsPRO compiler */
100 #ifndef __GNUC__
101 #define __sgi__ __sgi
102 #define __inline__ __inline
103 #endif
104
105 #define constpp char * const *
106
107 static __inline__ int xfsctl(const char *path, int fd, int cmd, void *arg)
108 {
109 if (cmd >= 0 && cmd < XFS_FSOPS_COUNT) {
110 /*
111 * We have a problem in that xfsctl takes 1 arg but
112 * some sgi xfs ops take an input arg and/or an output arg
113 * So have to special case the ops to decide if xfsctl arg
114 * is an input or an output argument.
115 */
116 if (cmd == XFS_FS_GOINGDOWN)
117 return syssgi(SGI_XFS_FSOPERATIONS, fd, cmd, arg, 0);
118 return syssgi(SGI_XFS_FSOPERATIONS, fd, cmd, 0, arg);
119 }
120 switch (cmd) {
121 case SGI_FS_BULKSTAT:
122 return syssgi(SGI_FS_BULKSTAT, fd,
123 ((xfs_fsop_bulkreq_t*)arg)->lastip,
124 ((xfs_fsop_bulkreq_t*)arg)->icount,
125 ((xfs_fsop_bulkreq_t*)arg)->ubuffer,
126 ((xfs_fsop_bulkreq_t*)arg)->ocount);
127 case SGI_FS_BULKSTAT_SINGLE:
128 return syssgi(SGI_FS_BULKSTAT_SINGLE, fd,
129 ((xfs_fsop_bulkreq_t*)arg)->lastip,
130 ((xfs_fsop_bulkreq_t*)arg)->ubuffer);
131 case SGI_XFS_INJECT_ERROR:
132 return syssgi(SGI_XFS_INJECT_ERROR,
133 ((xfs_error_injection_t*)arg)->errtag,
134 fd);
135 case SGI_XFS_CLEARALL_ERROR:
136 return syssgi(SGI_XFS_CLEARALL_ERROR, fd);
137 }
138 return fcntl(fd, cmd, arg);
139 }
140
141 static __inline__ int platform_test_xfs_fd(int fd)
142 {
143 struct statvfs sbuf;
144 if (fstatvfs(fd, &sbuf) < 0)
145 return 0;
146 return (strcmp(sbuf.f_basetype, "xfs") == 0);
147 }
148
149 static __inline__ int platform_test_xfs_path(const char *path)
150 {
151 struct statvfs sbuf;
152 if (statvfs(path, &sbuf) < 0)
153 return 0;
154 return (strcmp(sbuf.f_basetype, "xfs") == 0);
155 }
156
157 static __inline__ int platform_fstatfs(int fd, struct statfs *buf)
158 {
159 return fstatfs(fd, buf, sizeof(struct statfs), 0);
160 }
161
162 static __inline__ void platform_getoptreset(void)
163 {
164 getoptreset();
165 }
166
167 static __inline__ char * strsep(char **s, const char *ct)
168 {
169 char *sbegin = *s, *end;
170
171 if (!sbegin)
172 return NULL;
173 end = strpbrk(sbegin, ct);
174 if (end)
175 *end++ = '\0';
176 *s = end;
177 return sbegin;
178 }
179
180 #define HAVE_DIOATTR 1
181 #define HAVE_FSXATTR 1
182 #define HAVE_GETBMAP 1
183 #define HAVE_GETBMAPX 1
184 #define HAVE_FSDMIDATA 1
185 #define HAVE_FID 1
186 #define HAVE_IOCMACROS 1
187 #define HAVE_BBMACROS 1
188
189 #define __XFS_FS_H__ 1
190
191 #define XFS_IOC_DIOINFO F_DIOINFO
192 #define XFS_IOC_FSGETXATTR F_FSGETXATTR
193 #define XFS_IOC_FSSETXATTR F_FSSETXATTR
194 #define XFS_IOC_ALLOCSP64 F_ALLOCSP64
195 #define XFS_IOC_FREESP64 F_FREESP64
196 #define XFS_IOC_GETBMAP F_GETBMAP
197 #define XFS_IOC_FSSETDM F_FSSETDM
198 #define XFS_IOC_RESVSP F_RESVSP
199 #define XFS_IOC_RESVSP64 F_RESVSP64
200 #define XFS_IOC_UNRESVSP F_UNRESVSP
201 #define XFS_IOC_UNRESVSP64 F_UNRESVSP64
202 #define XFS_IOC_GETBMAPA F_GETBMAPA
203 #define XFS_IOC_FSGETXATTRA F_FSGETXATTRA
204 #define XFS_IOC_GETBMAPX F_GETBMAPX
205
206 #define XFS_IOC_FSGEOMETRY_V1 XFS_FS_GEOMETRY
207 #define XFS_IOC_FSBULKSTAT SGI_FS_BULKSTAT
208 #define XFS_IOC_FSBULKSTAT_SINGLE SGI_FS_BULKSTAT_SINGLE
209 #define XFS_IOC_FSINUMBERS /* TODO */
210 #define XFS_IOC_PATH_TO_FSHANDLE /* TODO */
211 #define XFS_IOC_PATH_TO_HANDLE /* TODO */
212 #define XFS_IOC_FD_TO_HANDLE /* TODO */
213 #define XFS_IOC_OPEN_BY_HANDLE /* TODO */
214 #define XFS_IOC_READLINK_BY_HANDLE /* TODO */
215 #define XFS_IOC_SWAPEXT /* TODO */
216 #define XFS_IOC_FSGROWFSDATA XFS_GROWFS_DATA
217 #define XFS_IOC_FSGROWFSLOG XFS_GROWFS_LOG
218 #define XFS_IOC_FSGROWFSRT XFS_GROWFS_RT
219 #define XFS_IOC_FSCOUNTS XFS_FS_COUNTS
220 #define XFS_IOC_SET_RESBLKS XFS_SET_RESBLKS
221 #define XFS_IOC_GET_RESBLKS XFS_GET_RESBLKS
222 #define XFS_IOC_ERROR_INJECTION SGI_XFS_INJECT_ERROR
223 #define XFS_IOC_ERROR_CLEARALL SGI_XFS_CLEARALL_ERROR
224 #define XFS_IOC_FREEZE XFS_FS_FREEZE
225 #define XFS_IOC_THAW XFS_FS_THAW
226 #define XFS_IOC_FSSETDM_BY_HANDLE /* TODO */
227 #define XFS_IOC_ATTRLIST_BY_HANDLE /* TODO */
228 #define XFS_IOC_ATTRMULTI_BY_HANDLE /* TODO */
229 #define XFS_IOC_FSGEOMETRY XFS_FS_GEOMETRY
230 #define XFS_IOC_GOINGDOWN XFS_FS_GOINGDOWN
231
232 #endif /* __XFS_IRIX_H__ */