2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef __XFS_IRIX_H__
19 #define __XFS_IRIX_H__
31 #include <sys/param.h>
32 #include <sys/ioctl.h>
33 #include <sys/types.h>
34 #include <sys/statfs.h>
35 #include <sys/statvfs.h>
36 #include <sys/syssgi.h>
37 #include <sys/sysmacros.h>
38 #include <sys/fs/xfs_fsops.h>
39 #include <sys/fs/xfs_itable.h>
43 #define __s32 __int32_t
44 #define __s64 __int64_t
45 #define __u8 unsigned char
46 #define __u16 unsigned short
47 #define __u32 __uint32_t
48 #define __u64 __uint64_t
50 #define __int16_t short
51 #define __uint8_t unsigned char
52 #define __uint16_t unsigned short
53 #define loff_t off64_t
54 typedef off64_t xfs_off_t
;
55 typedef __int64_t xfs_ino_t
;
56 typedef __int32_t xfs_dev_t
;
57 typedef __int64_t xfs_daddr_t
;
58 typedef char* xfs_caddr_t
;
60 #define xfs_flock64 flock64
61 #define xfs_flock64_t struct flock64
63 typedef struct xfs_error_injection
{
66 } xfs_error_injection_t
;
68 /* --- xfs_fsop_*req - request data structures --- */
70 typedef struct xfs_fsop_bulkreq
{
77 typedef struct xfs_fsop_handlereq
{
78 __u32 fd
; /* fd for FD_TO_HANDLE */
79 void *path
; /* user pathname */
80 __u32 oflags
; /* open flags */
81 void *ihandle
; /* user supplied handle */
82 __u32 ihandlen
; /* user supplied length */
83 void *ohandle
; /* user buffer for handle */
84 __u32
*ohandlen
; /* user buffer length */
85 } xfs_fsop_handlereq_t
;
87 typedef struct xfs_fsop_setdm_handlereq
{
88 struct xfs_fsop_handlereq hreq
; /* handle information */
89 struct fsdmidata
*data
; /* DMAPI data */
90 } xfs_fsop_setdm_handlereq_t
;
92 typedef struct xfs_attrlist_cursor
{
94 } xfs_attrlist_cursor_t
;
96 typedef struct xfs_fsop_attrlist_handlereq
{
97 struct xfs_fsop_handlereq hreq
; /* handle interface structure */
98 struct xfs_attrlist_cursor pos
; /* opaque cookie, list offset */
99 __u32 flags
; /* which namespace to use */
100 __u32 buflen
; /* length of buffer supplied */
101 void *buffer
; /* returned names */
102 } xfs_fsop_attrlist_handlereq_t
;
104 typedef struct xfs_attr_multiop
{
111 } xfs_attr_multiop_t
;
113 typedef struct xfs_fsop_attrmulti_handlereq
{
114 struct xfs_fsop_handlereq hreq
; /* handle interface structure */
115 __u32 opcount
;/* count of following multiop */
116 struct xfs_attr_multiop
*ops
; /* attr_multi data */
117 } xfs_fsop_attrmulti_handlereq_t
;
120 #include <sys/endian.h>
121 #define __BYTE_ORDER BYTE_ORDER
122 #define __BIG_ENDIAN BIG_ENDIAN
123 #define __LITTLE_ENDIAN LITTLE_ENDIAN
124 #define __fswab16(x) (x)
125 #define __fswab32(x) (x)
126 #define __fswab64(x) (x)
128 /* Map some gcc macros for the MipsPRO compiler */
130 #define __sgi__ __sgi
131 #define __inline__ __inline
134 #define constpp char * const *
137 static __inline__
int xfsctl(const char *path
, int fd
, int cmd
, void *arg
)
139 if (cmd
>= 0 && cmd
< XFS_FSOPS_COUNT
) {
141 * We have a problem in that xfsctl takes 1 arg but
142 * some sgi xfs ops take an input arg and/or an output arg
143 * So have to special case the ops to decide if xfsctl arg
144 * is an input or an output argument.
146 if (cmd
== XFS_FS_GOINGDOWN
)
147 return syssgi(SGI_XFS_FSOPERATIONS
, fd
, cmd
, arg
, 0);
148 return syssgi(SGI_XFS_FSOPERATIONS
, fd
, cmd
, 0, arg
);
151 case SGI_FS_INUMBERS
:
152 case SGI_FS_BULKSTAT
:
153 return syssgi(cmd
, fd
,
154 ((xfs_fsop_bulkreq_t
*)arg
)->lastip
,
155 ((xfs_fsop_bulkreq_t
*)arg
)->icount
,
156 ((xfs_fsop_bulkreq_t
*)arg
)->ubuffer
,
157 ((xfs_fsop_bulkreq_t
*)arg
)->ocount
);
158 case SGI_FS_BULKSTAT_SINGLE
:
159 return syssgi(SGI_FS_BULKSTAT_SINGLE
, fd
,
160 ((xfs_fsop_bulkreq_t
*)arg
)->lastip
,
161 ((xfs_fsop_bulkreq_t
*)arg
)->ubuffer
);
162 case SGI_XFS_INJECT_ERROR
:
163 return syssgi(SGI_XFS_INJECT_ERROR
,
164 ((xfs_error_injection_t
*)arg
)->errtag
,
166 case SGI_XFS_CLEARALL_ERROR
:
167 return syssgi(SGI_XFS_CLEARALL_ERROR
, fd
);
168 case SGI_PATH_TO_HANDLE
:
169 case SGI_PATH_TO_FSHANDLE
:
171 ((xfs_fsop_handlereq_t
*)arg
)->path
,
172 ((xfs_fsop_handlereq_t
*)arg
)->ohandle
,
173 ((xfs_fsop_handlereq_t
*)arg
)->ohandlen
);
174 case SGI_FD_TO_HANDLE
:
176 ((xfs_fsop_handlereq_t
*)arg
)->fd
,
177 ((xfs_fsop_handlereq_t
*)arg
)->ohandle
,
178 ((xfs_fsop_handlereq_t
*)arg
)->ohandlen
);
179 case SGI_OPEN_BY_HANDLE
:
181 ((xfs_fsop_handlereq_t
*)arg
)->ihandle
,
182 ((xfs_fsop_handlereq_t
*)arg
)->ihandlen
,
183 ((xfs_fsop_handlereq_t
*)arg
)->oflags
);
184 case SGI_READLINK_BY_HANDLE
:
186 ((xfs_fsop_handlereq_t
*)arg
)->ihandle
,
187 ((xfs_fsop_handlereq_t
*)arg
)->ihandlen
,
188 ((xfs_fsop_handlereq_t
*)arg
)->ohandle
,
189 ((xfs_fsop_handlereq_t
*)arg
)->ohandlen
);
190 case SGI_ATTR_LIST_BY_HANDLE
:
192 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->hreq
.ihandle
,
193 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->hreq
.ihandlen
,
194 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->buffer
,
195 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->buflen
,
196 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->flags
,
197 &(((xfs_fsop_attrlist_handlereq_t
*)arg
)->pos
));
198 case SGI_ATTR_MULTI_BY_HANDLE
:
200 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->hreq
.ihandle
,
201 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->hreq
.ihandlen
,
202 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->ops
,
203 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->opcount
,
204 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->hreq
.oflags
);
205 case SGI_FSSETDM_BY_HANDLE
:
207 ((xfs_fsop_setdm_handlereq_t
*)arg
)->hreq
.ihandle
,
208 ((xfs_fsop_setdm_handlereq_t
*)arg
)->hreq
.ihandlen
,
209 ((xfs_fsop_setdm_handlereq_t
*)arg
)->data
);
211 return fcntl(fd
, cmd
, arg
);
214 static __inline__
int platform_test_xfs_fd(int fd
)
217 if (fstatvfs(fd
, &sbuf
) < 0)
219 return (strcmp(sbuf
.f_basetype
, "xfs") == 0);
222 static __inline__
int platform_test_xfs_path(const char *path
)
225 if (statvfs(path
, &sbuf
) < 0)
227 return (strcmp(sbuf
.f_basetype
, "xfs") == 0);
230 static __inline__
int platform_fstatfs(int fd
, struct statfs
*buf
)
232 return fstatfs(fd
, buf
, sizeof(struct statfs
), 0);
235 static __inline__
void platform_getoptreset(void)
240 static __inline__
char * strsep(char **s
, const char *ct
)
242 char *sbegin
= *s
, *end
;
246 end
= strpbrk(sbegin
, ct
);
253 #define HAVE_DIOATTR 1
254 #define HAVE_FSXATTR 1
255 #define HAVE_GETBMAP 1
256 #define HAVE_GETBMAPX 1
257 #define HAVE_FSDMIDATA 1
259 #define HAVE_IOCMACROS 1
260 #define HAVE_BBMACROS 1
262 #define __XFS_FS_H__ 1
264 #define XFS_IOC_DIOINFO F_DIOINFO
265 #define XFS_IOC_FSGETXATTR F_FSGETXATTR
266 #define XFS_IOC_FSSETXATTR F_FSSETXATTR
267 #define XFS_IOC_ALLOCSP64 F_ALLOCSP64
268 #define XFS_IOC_FREESP64 F_FREESP64
269 #define XFS_IOC_GETBMAP F_GETBMAP
270 #define XFS_IOC_FSSETDM F_FSSETDM
271 #define XFS_IOC_RESVSP F_RESVSP
272 #define XFS_IOC_RESVSP64 F_RESVSP64
273 #define XFS_IOC_UNRESVSP F_UNRESVSP
274 #define XFS_IOC_UNRESVSP64 F_UNRESVSP64
275 #define XFS_IOC_GETBMAPA F_GETBMAPA
276 #define XFS_IOC_FSGETXATTRA F_FSGETXATTRA
277 #define XFS_IOC_GETBMAPX F_GETBMAPX
279 #define XFS_IOC_FSGEOMETRY_V1 XFS_FS_GEOMETRY
280 #define XFS_IOC_FSBULKSTAT SGI_FS_BULKSTAT
281 #define XFS_IOC_FSBULKSTAT_SINGLE SGI_FS_BULKSTAT_SINGLE
282 #define XFS_IOC_FSINUMBERS SGI_FS_INUMBERS
283 #define XFS_IOC_PATH_TO_FSHANDLE SGI_PATH_TO_FSHANDLE
284 #define XFS_IOC_PATH_TO_HANDLE SGI_PATH_TO_HANDLE
285 #define XFS_IOC_FD_TO_HANDLE SGI_FD_TO_HANDLE
286 #define XFS_IOC_OPEN_BY_HANDLE SGI_OPEN_BY_HANDLE
287 #define XFS_IOC_READLINK_BY_HANDLE SGI_READLINK_BY_HANDLE
288 #define XFS_IOC_SWAPEXT /* TODO */
289 #define XFS_IOC_FSGROWFSDATA XFS_GROWFS_DATA
290 #define XFS_IOC_FSGROWFSLOG XFS_GROWFS_LOG
291 #define XFS_IOC_FSGROWFSRT XFS_GROWFS_RT
292 #define XFS_IOC_FSCOUNTS XFS_FS_COUNTS
293 #define XFS_IOC_SET_RESBLKS XFS_SET_RESBLKS
294 #define XFS_IOC_GET_RESBLKS XFS_GET_RESBLKS
295 #define XFS_IOC_ERROR_INJECTION SGI_XFS_INJECT_ERROR
296 #define XFS_IOC_ERROR_CLEARALL SGI_XFS_CLEARALL_ERROR
297 #define XFS_IOC_FREEZE XFS_FS_FREEZE
298 #define XFS_IOC_THAW XFS_FS_THAW
299 #define XFS_IOC_FSSETDM_BY_HANDLE SGI_FSSETDM_BY_HANDLE
300 #define XFS_IOC_ATTRLIST_BY_HANDLE SGI_ATTR_LIST_BY_HANDLE
301 #define XFS_IOC_ATTRMULTI_BY_HANDLE SGI_ATTR_MULTI_BY_HANDLE
302 #define XFS_IOC_FSGEOMETRY XFS_FS_GEOMETRY
303 #define XFS_IOC_GOINGDOWN XFS_FS_GOINGDOWN
305 #endif /* __XFS_IRIX_H__ */