2 * Copyright (c) 2000-2006 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>
42 #define __int16_t short
43 #define __uint8_t unsigned char
44 #define __uint16_t unsigned short
45 #define loff_t off64_t
46 typedef off64_t xfs_off_t
;
47 typedef __int64_t xfs_ino_t
;
48 typedef __int32_t xfs_dev_t
;
49 typedef __int64_t xfs_daddr_t
;
50 typedef char* xfs_caddr_t
;
52 #define xfs_flock64 flock64
53 #define xfs_flock64_t struct flock64
55 typedef struct xfs_error_injection
{
58 } xfs_error_injection_t
;
60 /* --- xfs_fsop_*req - request data structures --- */
62 typedef struct xfs_fsop_bulkreq
{
69 typedef struct xfs_fsop_handlereq
{
70 __u32 fd
; /* fd for FD_TO_HANDLE */
71 void *path
; /* user pathname */
72 __u32 oflags
; /* open flags */
73 void *ihandle
; /* user supplied handle */
74 __u32 ihandlen
; /* user supplied length */
75 void *ohandle
; /* user buffer for handle */
76 __u32
*ohandlen
; /* user buffer length */
77 } xfs_fsop_handlereq_t
;
79 typedef struct xfs_fsop_setdm_handlereq
{
80 struct xfs_fsop_handlereq hreq
; /* handle information */
81 struct fsdmidata
*data
; /* DMAPI data */
82 } xfs_fsop_setdm_handlereq_t
;
84 typedef struct xfs_attrlist_cursor
{
86 } xfs_attrlist_cursor_t
;
88 typedef struct xfs_fsop_attrlist_handlereq
{
89 struct xfs_fsop_handlereq hreq
; /* handle interface structure */
90 struct xfs_attrlist_cursor pos
; /* opaque cookie, list offset */
91 __u32 flags
; /* which namespace to use */
92 __u32 buflen
; /* length of buffer supplied */
93 void *buffer
; /* returned names */
94 } xfs_fsop_attrlist_handlereq_t
;
96 typedef struct xfs_fsop_getparents_handlereq
{
97 struct xfs_fsop_handlereq hreq
; /* handle interface structure */
98 struct xfs_attrlist_cursor pos
; /* opaque cookie, list offset */
99 __u32 buflen
; /* length of buffer supplied */
100 void *buffer
; /* returned data */
101 __u32
*ocount
; /* return number of links */
102 __u32
*omore
; /* return whether more to come */
103 } xfs_fsop_getparents_handlereq_t
;
105 typedef struct xfs_attr_multiop
{
112 } xfs_attr_multiop_t
;
114 typedef struct xfs_fsop_attrmulti_handlereq
{
115 struct xfs_fsop_handlereq hreq
; /* handle interface structure */
116 __u32 opcount
;/* count of following multiop */
117 struct xfs_attr_multiop
*ops
; /* attr_multi data */
118 } xfs_fsop_attrmulti_handlereq_t
;
121 #include <sys/endian.h>
122 #define __BYTE_ORDER BYTE_ORDER
123 #define __BIG_ENDIAN BIG_ENDIAN
124 #define __LITTLE_ENDIAN LITTLE_ENDIAN
125 #define __swab16(x) (x)
126 #define __swab32(x) (x)
127 #define __swab64(x) (x)
129 /* Map some gcc macros for the MipsPRO compiler */
131 #define INT_SWAP16(type,var) (var)
132 #define INT_SWAP32(type,var) (var)
133 #define INT_SWAP64(type,var) (var)
134 #define HAVE_SWABMACROS 1 /* no typeof available */
135 #define __builtin_constant_p(x) (0)
136 #define __FUNCTION__ "XFS"
137 #define __sgi__ __sgi
138 #define __inline__ __inline
139 #define inline __inline
142 #define constpp char * const *
145 static __inline__
int xfsctl(const char *path
, int fd
, int cmd
, void *arg
)
147 if (cmd
>= 0 && cmd
< XFS_FSOPS_COUNT
) {
149 * We have a problem in that xfsctl takes 1 arg but
150 * some sgi xfs ops take an input arg and/or an output arg
151 * So have to special case the ops to decide if xfsctl arg
152 * is an input or an output argument.
154 if (cmd
== XFS_FS_GOINGDOWN
)
155 return syssgi(SGI_XFS_FSOPERATIONS
, fd
, cmd
, arg
, 0);
156 return syssgi(SGI_XFS_FSOPERATIONS
, fd
, cmd
, 0, arg
);
159 case SGI_FS_INUMBERS
:
160 case SGI_FS_BULKSTAT
:
161 return syssgi(cmd
, fd
,
162 ((xfs_fsop_bulkreq_t
*)arg
)->lastip
,
163 ((xfs_fsop_bulkreq_t
*)arg
)->icount
,
164 ((xfs_fsop_bulkreq_t
*)arg
)->ubuffer
,
165 ((xfs_fsop_bulkreq_t
*)arg
)->ocount
);
166 case SGI_FS_BULKSTAT_SINGLE
:
167 return syssgi(SGI_FS_BULKSTAT_SINGLE
, fd
,
168 ((xfs_fsop_bulkreq_t
*)arg
)->lastip
,
169 ((xfs_fsop_bulkreq_t
*)arg
)->ubuffer
);
170 case SGI_XFS_INJECT_ERROR
:
171 return syssgi(SGI_XFS_INJECT_ERROR
,
172 ((xfs_error_injection_t
*)arg
)->errtag
,
174 case SGI_XFS_CLEARALL_ERROR
:
175 return syssgi(SGI_XFS_CLEARALL_ERROR
, fd
);
176 case SGI_PATH_TO_HANDLE
:
177 case SGI_PATH_TO_FSHANDLE
:
179 ((xfs_fsop_handlereq_t
*)arg
)->path
,
180 ((xfs_fsop_handlereq_t
*)arg
)->ohandle
,
181 ((xfs_fsop_handlereq_t
*)arg
)->ohandlen
);
182 case SGI_FD_TO_HANDLE
:
184 ((xfs_fsop_handlereq_t
*)arg
)->fd
,
185 ((xfs_fsop_handlereq_t
*)arg
)->ohandle
,
186 ((xfs_fsop_handlereq_t
*)arg
)->ohandlen
);
187 case SGI_OPEN_BY_HANDLE
:
189 ((xfs_fsop_handlereq_t
*)arg
)->ihandle
,
190 ((xfs_fsop_handlereq_t
*)arg
)->ihandlen
,
191 ((xfs_fsop_handlereq_t
*)arg
)->oflags
);
192 case SGI_READLINK_BY_HANDLE
:
194 ((xfs_fsop_handlereq_t
*)arg
)->ihandle
,
195 ((xfs_fsop_handlereq_t
*)arg
)->ihandlen
,
196 ((xfs_fsop_handlereq_t
*)arg
)->ohandle
,
197 ((xfs_fsop_handlereq_t
*)arg
)->ohandlen
);
198 case SGI_ATTR_LIST_BY_HANDLE
:
200 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->hreq
.ihandle
,
201 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->hreq
.ihandlen
,
202 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->buffer
,
203 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->buflen
,
204 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->flags
,
205 &(((xfs_fsop_attrlist_handlereq_t
*)arg
)->pos
));
206 case SGI_XFS_GETPARENTS
:
207 case SGI_XFS_GETPARENTPATHS
:
209 ((xfs_fsop_getparents_handlereq_t
*)arg
)->hreq
.ihandle
,
210 ((xfs_fsop_getparents_handlereq_t
*)arg
)->hreq
.ihandlen
,
211 ((xfs_fsop_getparents_handlereq_t
*)arg
)->buffer
,
212 ((xfs_fsop_getparents_handlereq_t
*)arg
)->buflen
,
213 &(((xfs_fsop_getparents_handlereq_t
*)arg
)->pos
),
214 ((xfs_fsop_getparents_handlereq_t
*)arg
)->ocount
,
215 ((xfs_fsop_getparents_handlereq_t
*)arg
)->omore
);
216 case SGI_ATTR_MULTI_BY_HANDLE
:
218 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->hreq
.ihandle
,
219 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->hreq
.ihandlen
,
220 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->ops
,
221 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->opcount
,
222 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->hreq
.oflags
);
223 case SGI_FSSETDM_BY_HANDLE
:
225 ((xfs_fsop_setdm_handlereq_t
*)arg
)->hreq
.ihandle
,
226 ((xfs_fsop_setdm_handlereq_t
*)arg
)->hreq
.ihandlen
,
227 ((xfs_fsop_setdm_handlereq_t
*)arg
)->data
);
229 return fcntl(fd
, cmd
, arg
);
232 static __inline__
int platform_test_xfs_fd(int fd
)
235 if (fstatvfs(fd
, &sbuf
) < 0)
237 return strncmp(sbuf
.f_basetype
, "xfs", 4) == 0;
240 static __inline__
int platform_test_xfs_path(const char *path
)
243 if (statvfs(path
, &sbuf
) < 0)
245 return strncmp(sbuf
.f_basetype
, "xfs", 4) == 0;
248 static __inline__
int platform_fstatfs(int fd
, struct statfs
*buf
)
250 return fstatfs(fd
, buf
, sizeof(struct statfs
), 0);
253 static __inline__
void platform_getoptreset(void)
258 static __inline__
int platform_uuid_compare(uuid_t
*uu1
, uuid_t
*uu2
)
261 return uuid_compare(uu1
, uu2
, &status
);
264 static __inline__
void platform_uuid_unparse(uuid_t
*uu
, char *buffer
)
268 uuid_to_string(uu
, &s
, &status
);
269 if (status
== uuid_s_ok
)
271 else buffer
[0] = '\0';
275 static __inline__
int platform_uuid_parse(char *buffer
, uuid_t
*uu
)
278 uuid_from_string(buffer
, uu
, &status
);
279 return (status
== uuid_s_ok
);
282 static __inline__
int platform_uuid_is_null(uuid_t
*uu
)
285 return uuid_is_nil(uu
, &status
);
288 static __inline__
void platform_uuid_generate(uuid_t
*uu
)
291 uuid_create(uu
, &status
);
294 static __inline__
void platform_uuid_clear(uuid_t
*uu
)
297 uuid_create_nil(uu
, &status
);
300 static __inline__
void platform_uuid_copy(uuid_t
*dst
, uuid_t
*src
)
302 memcpy(dst
, src
, sizeof(uuid_t
));
305 static __inline__
char * strsep(char **s
, const char *ct
)
307 char *sbegin
= *s
, *end
;
311 end
= strpbrk(sbegin
, ct
);
318 #define HAVE_DIOATTR 1
319 #define HAVE_FSXATTR 1
320 #define HAVE_GETBMAP 1
321 #define HAVE_GETBMAPX 1
322 #define HAVE_FSDMIDATA 1
324 #define HAVE_IOCMACROS 1
325 #define HAVE_BBMACROS 1
327 #define __XFS_FS_H__ 1
329 #define XFS_IOC_DIOINFO F_DIOINFO
330 #define XFS_IOC_FSGETXATTR F_FSGETXATTR
331 #define XFS_IOC_FSSETXATTR F_FSSETXATTR
332 #define XFS_IOC_ALLOCSP64 F_ALLOCSP64
333 #define XFS_IOC_FREESP64 F_FREESP64
334 #define XFS_IOC_GETBMAP F_GETBMAP
335 #define XFS_IOC_FSSETDM F_FSSETDM
336 #define XFS_IOC_RESVSP F_RESVSP
337 #define XFS_IOC_RESVSP64 F_RESVSP64
338 #define XFS_IOC_UNRESVSP F_UNRESVSP
339 #define XFS_IOC_UNRESVSP64 F_UNRESVSP64
340 #define XFS_IOC_GETBMAPA F_GETBMAPA
341 #define XFS_IOC_FSGETXATTRA F_FSGETXATTRA
342 #define XFS_IOC_GETBMAPX F_GETBMAPX
344 #define XFS_IOC_FSGEOMETRY_V1 XFS_FS_GEOMETRY
345 #define XFS_IOC_FSBULKSTAT SGI_FS_BULKSTAT
346 #define XFS_IOC_FSBULKSTAT_SINGLE SGI_FS_BULKSTAT_SINGLE
347 #define XFS_IOC_FSINUMBERS SGI_FS_INUMBERS
348 #define XFS_IOC_PATH_TO_FSHANDLE SGI_PATH_TO_FSHANDLE
349 #define XFS_IOC_PATH_TO_HANDLE SGI_PATH_TO_HANDLE
350 #define XFS_IOC_FD_TO_HANDLE SGI_FD_TO_HANDLE
351 #define XFS_IOC_OPEN_BY_HANDLE SGI_OPEN_BY_HANDLE
352 #define XFS_IOC_READLINK_BY_HANDLE SGI_READLINK_BY_HANDLE
353 #define XFS_IOC_SWAPEXT /* TODO */
354 #define XFS_IOC_FSGROWFSDATA XFS_GROWFS_DATA
355 #define XFS_IOC_FSGROWFSLOG XFS_GROWFS_LOG
356 #define XFS_IOC_FSGROWFSRT XFS_GROWFS_RT
357 #define XFS_IOC_FSCOUNTS XFS_FS_COUNTS
358 #define XFS_IOC_SET_RESBLKS XFS_SET_RESBLKS
359 #define XFS_IOC_GET_RESBLKS XFS_GET_RESBLKS
360 #define XFS_IOC_ERROR_INJECTION SGI_XFS_INJECT_ERROR
361 #define XFS_IOC_ERROR_CLEARALL SGI_XFS_CLEARALL_ERROR
362 #define XFS_IOC_FREEZE XFS_FS_FREEZE
363 #define XFS_IOC_THAW XFS_FS_THAW
364 #define XFS_IOC_FSSETDM_BY_HANDLE SGI_FSSETDM_BY_HANDLE
365 #define XFS_IOC_ATTRLIST_BY_HANDLE SGI_ATTR_LIST_BY_HANDLE
366 #define XFS_IOC_ATTRMULTI_BY_HANDLE SGI_ATTR_MULTI_BY_HANDLE
367 #define XFS_IOC_FSGEOMETRY XFS_FS_GEOMETRY
368 #define XFS_IOC_GOINGDOWN XFS_FS_GOINGDOWN
369 #define XFS_IOC_GETPARENTS SGI_XFS_GETPARENTS
370 #define XFS_IOC_GETPARENTPATHS SGI_XFS_GETPARENTPATHS
372 #endif /* __XFS_IRIX_H__ */