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
;
120 /* start doing packed stuctures here */
121 #define HAVE_FORMAT32 1
123 typedef struct xfs_inode_log_format_32
{
124 __u16 ilf_type
; /* inode log item type */
125 __u16 ilf_size
; /* size of this item */
126 __u32 ilf_fields
; /* flags for fields logged */
127 __u16 ilf_asize
; /* size of attr d/ext/root */
128 __u16 ilf_dsize
; /* size of data/ext/root */
129 __u64 ilf_ino
; /* inode number */
131 __u32 ilfu_rdev
; /* rdev value for dev inode*/
132 uuid_t ilfu_uuid
; /* mount point value */
134 __s64 ilf_blkno
; /* blkno of inode buffer */
135 __s32 ilf_len
; /* len of inode buffer */
136 __s32 ilf_boffset
; /* off of inode in buffer */
137 } xfs_inode_log_format_32_t
;
139 typedef struct xfs_extent_32
{
144 typedef struct xfs_efi_log_format_32
{
145 __u16 efi_type
; /* efi log item type */
146 __u16 efi_size
; /* size of this item */
147 __u32 efi_nextents
; /* # extents to free */
148 __u64 efi_id
; /* efi identifier */
149 xfs_extent_32_t efi_extents
[1]; /* array of extents to free */
150 } xfs_efi_log_format_32_t
;
152 typedef struct xfs_efd_log_format_32
{
153 __u16 efd_type
; /* efd log item type */
154 __u16 efd_size
; /* size of this item */
155 __u32 efd_nextents
; /* # of extents freed */
156 __u64 efd_efi_id
; /* id of corresponding efi */
157 xfs_extent_32_t efd_extents
[1]; /* array of extents freed */
158 } xfs_efd_log_format_32_t
;
161 /* end of packed stuctures */
163 #include <sys/endian.h>
164 #define __BYTE_ORDER BYTE_ORDER
165 #define __BIG_ENDIAN BIG_ENDIAN
166 #define __LITTLE_ENDIAN LITTLE_ENDIAN
168 /* Map some gcc macros for the MipsPRO compiler */
170 #define __builtin_constant_p(x) (0)
171 #define __FUNCTION__ "XFS"
172 #define __sgi__ __sgi
173 #define __inline__ __inline
174 #define inline __inline
177 #define constpp char * const *
180 static __inline__
int xfsctl(const char *path
, int fd
, int cmd
, void *arg
)
182 if (cmd
>= 0 && cmd
< XFS_FSOPS_COUNT
) {
184 * We have a problem in that xfsctl takes 1 arg but
185 * some sgi xfs ops take an input arg and/or an output arg
186 * So have to special case the ops to decide if xfsctl arg
187 * is an input or an output argument.
189 if (cmd
== XFS_FS_GOINGDOWN
)
190 return syssgi(SGI_XFS_FSOPERATIONS
, fd
, cmd
, arg
, 0);
191 return syssgi(SGI_XFS_FSOPERATIONS
, fd
, cmd
, 0, arg
);
194 case SGI_FS_INUMBERS
:
195 case SGI_FS_BULKSTAT
:
196 return syssgi(cmd
, fd
,
197 ((xfs_fsop_bulkreq_t
*)arg
)->lastip
,
198 ((xfs_fsop_bulkreq_t
*)arg
)->icount
,
199 ((xfs_fsop_bulkreq_t
*)arg
)->ubuffer
,
200 ((xfs_fsop_bulkreq_t
*)arg
)->ocount
);
201 case SGI_FS_BULKSTAT_SINGLE
:
202 return syssgi(SGI_FS_BULKSTAT_SINGLE
, fd
,
203 ((xfs_fsop_bulkreq_t
*)arg
)->lastip
,
204 ((xfs_fsop_bulkreq_t
*)arg
)->ubuffer
);
205 case SGI_XFS_INJECT_ERROR
:
206 return syssgi(SGI_XFS_INJECT_ERROR
,
207 ((xfs_error_injection_t
*)arg
)->errtag
,
209 case SGI_XFS_CLEARALL_ERROR
:
210 return syssgi(SGI_XFS_CLEARALL_ERROR
, fd
);
211 case SGI_PATH_TO_HANDLE
:
212 case SGI_PATH_TO_FSHANDLE
:
214 ((xfs_fsop_handlereq_t
*)arg
)->path
,
215 ((xfs_fsop_handlereq_t
*)arg
)->ohandle
,
216 ((xfs_fsop_handlereq_t
*)arg
)->ohandlen
);
217 case SGI_FD_TO_HANDLE
:
219 ((xfs_fsop_handlereq_t
*)arg
)->fd
,
220 ((xfs_fsop_handlereq_t
*)arg
)->ohandle
,
221 ((xfs_fsop_handlereq_t
*)arg
)->ohandlen
);
222 case SGI_OPEN_BY_HANDLE
:
224 ((xfs_fsop_handlereq_t
*)arg
)->ihandle
,
225 ((xfs_fsop_handlereq_t
*)arg
)->ihandlen
,
226 ((xfs_fsop_handlereq_t
*)arg
)->oflags
);
227 case SGI_READLINK_BY_HANDLE
:
229 ((xfs_fsop_handlereq_t
*)arg
)->ihandle
,
230 ((xfs_fsop_handlereq_t
*)arg
)->ihandlen
,
231 ((xfs_fsop_handlereq_t
*)arg
)->ohandle
,
232 ((xfs_fsop_handlereq_t
*)arg
)->ohandlen
);
233 case SGI_ATTR_LIST_BY_HANDLE
:
235 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->hreq
.ihandle
,
236 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->hreq
.ihandlen
,
237 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->buffer
,
238 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->buflen
,
239 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->flags
,
240 &(((xfs_fsop_attrlist_handlereq_t
*)arg
)->pos
));
241 case SGI_XFS_GETPARENTS
:
242 case SGI_XFS_GETPARENTPATHS
:
244 ((xfs_fsop_getparents_handlereq_t
*)arg
)->hreq
.ihandle
,
245 ((xfs_fsop_getparents_handlereq_t
*)arg
)->hreq
.ihandlen
,
246 ((xfs_fsop_getparents_handlereq_t
*)arg
)->buffer
,
247 ((xfs_fsop_getparents_handlereq_t
*)arg
)->buflen
,
248 &(((xfs_fsop_getparents_handlereq_t
*)arg
)->pos
),
249 ((xfs_fsop_getparents_handlereq_t
*)arg
)->ocount
,
250 ((xfs_fsop_getparents_handlereq_t
*)arg
)->omore
);
251 case SGI_ATTR_MULTI_BY_HANDLE
:
253 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->hreq
.ihandle
,
254 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->hreq
.ihandlen
,
255 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->ops
,
256 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->opcount
,
257 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->hreq
.oflags
);
258 case SGI_FSSETDM_BY_HANDLE
:
260 ((xfs_fsop_setdm_handlereq_t
*)arg
)->hreq
.ihandle
,
261 ((xfs_fsop_setdm_handlereq_t
*)arg
)->hreq
.ihandlen
,
262 ((xfs_fsop_setdm_handlereq_t
*)arg
)->data
);
264 return fcntl(fd
, cmd
, arg
);
267 static __inline__
int platform_test_xfs_fd(int fd
)
270 if (fstatvfs(fd
, &sbuf
) < 0)
272 return strncmp(sbuf
.f_basetype
, "xfs", 4) == 0;
275 static __inline__
int platform_test_xfs_path(const char *path
)
278 if (statvfs(path
, &sbuf
) < 0)
280 return strncmp(sbuf
.f_basetype
, "xfs", 4) == 0;
283 static __inline__
int platform_fstatfs(int fd
, struct statfs
*buf
)
285 return fstatfs(fd
, buf
, sizeof(struct statfs
), 0);
288 static __inline__
void platform_getoptreset(void)
293 static __inline__
int platform_uuid_compare(uuid_t
*uu1
, uuid_t
*uu2
)
296 return uuid_compare(uu1
, uu2
, &status
);
299 static __inline__
void platform_uuid_unparse(uuid_t
*uu
, char *buffer
)
303 uuid_to_string(uu
, &s
, &status
);
304 if (status
== uuid_s_ok
)
306 else buffer
[0] = '\0';
310 static __inline__
int platform_uuid_parse(char *buffer
, uuid_t
*uu
)
313 uuid_from_string(buffer
, uu
, &status
);
314 return (status
== uuid_s_ok
);
317 static __inline__
int platform_uuid_is_null(uuid_t
*uu
)
320 return uuid_is_nil(uu
, &status
);
323 static __inline__
void platform_uuid_generate(uuid_t
*uu
)
326 uuid_create(uu
, &status
);
329 static __inline__
void platform_uuid_clear(uuid_t
*uu
)
332 uuid_create_nil(uu
, &status
);
335 static __inline__
void platform_uuid_copy(uuid_t
*dst
, uuid_t
*src
)
337 memcpy(dst
, src
, sizeof(uuid_t
));
340 static __inline__
char * strsep(char **s
, const char *ct
)
342 char *sbegin
= *s
, *end
;
346 end
= strpbrk(sbegin
, ct
);
353 #define HAVE_DIOATTR 1
354 #define HAVE_FSXATTR 1
355 #define HAVE_GETBMAP 1
356 #define HAVE_GETBMAPX 1
357 #define HAVE_FSDMIDATA 1
359 #define HAVE_IOCMACROS 1
360 #define HAVE_BBMACROS 1
362 #define __XFS_FS_H__ 1
364 #define XFS_IOC_DIOINFO F_DIOINFO
365 #define XFS_IOC_FSGETXATTR F_FSGETXATTR
366 #define XFS_IOC_FSSETXATTR F_FSSETXATTR
367 #define XFS_IOC_ALLOCSP64 F_ALLOCSP64
368 #define XFS_IOC_FREESP64 F_FREESP64
369 #define XFS_IOC_GETBMAP F_GETBMAP
370 #define XFS_IOC_FSSETDM F_FSSETDM
371 #define XFS_IOC_RESVSP F_RESVSP
372 #define XFS_IOC_RESVSP64 F_RESVSP64
373 #define XFS_IOC_UNRESVSP F_UNRESVSP
374 #define XFS_IOC_UNRESVSP64 F_UNRESVSP64
375 #define XFS_IOC_GETBMAPA F_GETBMAPA
376 #define XFS_IOC_FSGETXATTRA F_FSGETXATTRA
377 #define XFS_IOC_GETBMAPX F_GETBMAPX
379 #define XFS_IOC_FSGEOMETRY_V1 XFS_FS_GEOMETRY
380 #define XFS_IOC_FSBULKSTAT SGI_FS_BULKSTAT
381 #define XFS_IOC_FSBULKSTAT_SINGLE SGI_FS_BULKSTAT_SINGLE
382 #define XFS_IOC_FSINUMBERS SGI_FS_INUMBERS
383 #define XFS_IOC_PATH_TO_FSHANDLE SGI_PATH_TO_FSHANDLE
384 #define XFS_IOC_PATH_TO_HANDLE SGI_PATH_TO_HANDLE
385 #define XFS_IOC_FD_TO_HANDLE SGI_FD_TO_HANDLE
386 #define XFS_IOC_OPEN_BY_HANDLE SGI_OPEN_BY_HANDLE
387 #define XFS_IOC_READLINK_BY_HANDLE SGI_READLINK_BY_HANDLE
388 #define XFS_IOC_SWAPEXT /* TODO */
389 #define XFS_IOC_FSGROWFSDATA XFS_GROWFS_DATA
390 #define XFS_IOC_FSGROWFSLOG XFS_GROWFS_LOG
391 #define XFS_IOC_FSGROWFSRT XFS_GROWFS_RT
392 #define XFS_IOC_FSCOUNTS XFS_FS_COUNTS
393 #define XFS_IOC_SET_RESBLKS XFS_SET_RESBLKS
394 #define XFS_IOC_GET_RESBLKS XFS_GET_RESBLKS
395 #define XFS_IOC_ERROR_INJECTION SGI_XFS_INJECT_ERROR
396 #define XFS_IOC_ERROR_CLEARALL SGI_XFS_CLEARALL_ERROR
397 #define XFS_IOC_FREEZE XFS_FS_FREEZE
398 #define XFS_IOC_THAW XFS_FS_THAW
399 #define XFS_IOC_FSSETDM_BY_HANDLE SGI_FSSETDM_BY_HANDLE
400 #define XFS_IOC_ATTRLIST_BY_HANDLE SGI_ATTR_LIST_BY_HANDLE
401 #define XFS_IOC_ATTRMULTI_BY_HANDLE SGI_ATTR_MULTI_BY_HANDLE
402 #define XFS_IOC_FSGEOMETRY XFS_FS_GEOMETRY
403 #define XFS_IOC_GOINGDOWN XFS_FS_GOINGDOWN
404 #define XFS_IOC_GETPARENTS SGI_XFS_GETPARENTS
405 #define XFS_IOC_GETPARENTPATHS SGI_XFS_GETPARENTPATHS
407 #define _AIOCB64_T_DEFINED 1
409 #define XFS_XFLAG_NODEFRAG 0x00002000
411 #endif /* __XFS_IRIX_H__ */