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>
43 #define __int16_t short
44 #define __uint8_t unsigned char
45 #define __uint16_t unsigned short
47 typedef unsigned char __u8
;
48 typedef signed char __s8
;
49 typedef unsigned short __u16
;
50 typedef signed short __s16
;
51 typedef unsigned int __u32
;
52 typedef signed int __s32
;
53 typedef unsigned long long int __u64
;
54 typedef signed long long int __s64
;
56 typedef off_t xfs_off_t
;
57 typedef __int64_t xfs_ino_t
;
58 typedef __int32_t xfs_dev_t
;
59 typedef __int64_t xfs_daddr_t
;
60 typedef __u32 xfs_nlink_t
;
62 #define xfs_flock64 flock64
63 #define xfs_flock64_t struct flock64
65 #define EFSBADCRC 991 /* Bad CRC detected */
67 typedef struct xfs_error_injection
{
70 } xfs_error_injection_t
;
72 /* --- xfs_fsop_*req - request data structures --- */
74 typedef struct xfs_fsop_bulkreq
{
81 typedef struct xfs_fsop_handlereq
{
82 __u32 fd
; /* fd for FD_TO_HANDLE */
83 void *path
; /* user pathname */
84 __u32 oflags
; /* open flags */
85 void *ihandle
; /* user supplied handle */
86 __u32 ihandlen
; /* user supplied length */
87 void *ohandle
; /* user buffer for handle */
88 __u32
*ohandlen
; /* user buffer length */
89 } xfs_fsop_handlereq_t
;
91 typedef struct xfs_fsop_setdm_handlereq
{
92 struct xfs_fsop_handlereq hreq
; /* handle information */
93 struct fsdmidata
*data
; /* DMAPI data */
94 } xfs_fsop_setdm_handlereq_t
;
96 typedef struct xfs_attrlist_cursor
{
98 } xfs_attrlist_cursor_t
;
100 typedef struct xfs_fsop_attrlist_handlereq
{
101 struct xfs_fsop_handlereq hreq
; /* handle interface structure */
102 struct xfs_attrlist_cursor pos
; /* opaque cookie, list offset */
103 __u32 flags
; /* which namespace to use */
104 __u32 buflen
; /* length of buffer supplied */
105 void *buffer
; /* returned names */
106 } xfs_fsop_attrlist_handlereq_t
;
108 typedef struct xfs_fsop_getparents_handlereq
{
109 struct xfs_fsop_handlereq hreq
; /* handle interface structure */
110 struct xfs_attrlist_cursor pos
; /* opaque cookie, list offset */
111 __u32 buflen
; /* length of buffer supplied */
112 void *buffer
; /* returned data */
113 __u32
*ocount
; /* return number of links */
114 __u32
*omore
; /* return whether more to come */
115 } xfs_fsop_getparents_handlereq_t
;
117 typedef struct xfs_attr_multiop
{
124 } xfs_attr_multiop_t
;
126 typedef struct xfs_fsop_attrmulti_handlereq
{
127 struct xfs_fsop_handlereq hreq
; /* handle interface structure */
128 __u32 opcount
;/* count of following multiop */
129 struct xfs_attr_multiop
*ops
; /* attr_multi data */
130 } xfs_fsop_attrmulti_handlereq_t
;
132 /* start doing packed stuctures here */
133 #define HAVE_FORMAT32 1
135 typedef struct xfs_inode_log_format_32
{
136 __u16 ilf_type
; /* inode log item type */
137 __u16 ilf_size
; /* size of this item */
138 __u32 ilf_fields
; /* flags for fields logged */
139 __u16 ilf_asize
; /* size of attr d/ext/root */
140 __u16 ilf_dsize
; /* size of data/ext/root */
141 __u64 ilf_ino
; /* inode number */
143 __u32 ilfu_rdev
; /* rdev value for dev inode*/
144 uuid_t ilfu_uuid
; /* mount point value */
146 __s64 ilf_blkno
; /* blkno of inode buffer */
147 __s32 ilf_len
; /* len of inode buffer */
148 __s32 ilf_boffset
; /* off of inode in buffer */
149 } xfs_inode_log_format_32_t
;
151 typedef struct xfs_extent_32
{
156 typedef struct xfs_efi_log_format_32
{
157 __u16 efi_type
; /* efi log item type */
158 __u16 efi_size
; /* size of this item */
159 __u32 efi_nextents
; /* # extents to free */
160 __u64 efi_id
; /* efi identifier */
161 xfs_extent_32_t efi_extents
[1]; /* array of extents to free */
162 } xfs_efi_log_format_32_t
;
164 typedef struct xfs_efd_log_format_32
{
165 __u16 efd_type
; /* efd log item type */
166 __u16 efd_size
; /* size of this item */
167 __u32 efd_nextents
; /* # of extents freed */
168 __u64 efd_efi_id
; /* id of corresponding efi */
169 xfs_extent_32_t efd_extents
[1]; /* array of extents freed */
170 } xfs_efd_log_format_32_t
;
173 /* end of packed stuctures */
175 #include <sys/endian.h>
176 #define __BYTE_ORDER BYTE_ORDER
177 #define __BIG_ENDIAN BIG_ENDIAN
178 #define __LITTLE_ENDIAN LITTLE_ENDIAN
180 /* Map some gcc macros for the MipsPRO compiler */
182 #define __builtin_constant_p(x) (0)
183 #define __FUNCTION__ "XFS"
184 #define __sgi__ __sgi
185 #define __inline__ __inline
186 #define inline __inline
190 static __inline__
int xfsctl(const char *path
, int fd
, int cmd
, void *arg
)
192 if (cmd
>= 0 && cmd
< XFS_FSOPS_COUNT
) {
194 * We have a problem in that xfsctl takes 1 arg but
195 * some sgi xfs ops take an input arg and/or an output arg
196 * So have to special case the ops to decide if xfsctl arg
197 * is an input or an output argument.
199 if (cmd
== XFS_FS_GOINGDOWN
)
200 return syssgi(SGI_XFS_FSOPERATIONS
, fd
, cmd
, arg
, 0);
201 return syssgi(SGI_XFS_FSOPERATIONS
, fd
, cmd
, 0, arg
);
204 case SGI_FS_INUMBERS
:
205 case SGI_FS_BULKSTAT
:
206 return syssgi(cmd
, fd
,
207 ((xfs_fsop_bulkreq_t
*)arg
)->lastip
,
208 ((xfs_fsop_bulkreq_t
*)arg
)->icount
,
209 ((xfs_fsop_bulkreq_t
*)arg
)->ubuffer
,
210 ((xfs_fsop_bulkreq_t
*)arg
)->ocount
);
211 case SGI_FS_BULKSTAT_SINGLE
:
212 return syssgi(SGI_FS_BULKSTAT_SINGLE
, fd
,
213 ((xfs_fsop_bulkreq_t
*)arg
)->lastip
,
214 ((xfs_fsop_bulkreq_t
*)arg
)->ubuffer
);
215 case SGI_XFS_INJECT_ERROR
:
216 return syssgi(SGI_XFS_INJECT_ERROR
,
217 ((xfs_error_injection_t
*)arg
)->errtag
,
219 case SGI_XFS_CLEARALL_ERROR
:
220 return syssgi(SGI_XFS_CLEARALL_ERROR
, fd
);
221 case SGI_PATH_TO_HANDLE
:
222 case SGI_PATH_TO_FSHANDLE
:
224 ((xfs_fsop_handlereq_t
*)arg
)->path
,
225 ((xfs_fsop_handlereq_t
*)arg
)->ohandle
,
226 ((xfs_fsop_handlereq_t
*)arg
)->ohandlen
);
227 case SGI_FD_TO_HANDLE
:
229 ((xfs_fsop_handlereq_t
*)arg
)->fd
,
230 ((xfs_fsop_handlereq_t
*)arg
)->ohandle
,
231 ((xfs_fsop_handlereq_t
*)arg
)->ohandlen
);
232 case SGI_OPEN_BY_HANDLE
:
234 ((xfs_fsop_handlereq_t
*)arg
)->ihandle
,
235 ((xfs_fsop_handlereq_t
*)arg
)->ihandlen
,
236 ((xfs_fsop_handlereq_t
*)arg
)->oflags
);
237 case SGI_READLINK_BY_HANDLE
:
239 ((xfs_fsop_handlereq_t
*)arg
)->ihandle
,
240 ((xfs_fsop_handlereq_t
*)arg
)->ihandlen
,
241 ((xfs_fsop_handlereq_t
*)arg
)->ohandle
,
242 ((xfs_fsop_handlereq_t
*)arg
)->ohandlen
);
243 case SGI_ATTR_LIST_BY_HANDLE
:
245 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->hreq
.ihandle
,
246 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->hreq
.ihandlen
,
247 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->buffer
,
248 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->buflen
,
249 ((xfs_fsop_attrlist_handlereq_t
*)arg
)->flags
,
250 &(((xfs_fsop_attrlist_handlereq_t
*)arg
)->pos
));
251 case SGI_XFS_GETPARENTS
:
252 case SGI_XFS_GETPARENTPATHS
:
254 ((xfs_fsop_getparents_handlereq_t
*)arg
)->hreq
.ihandle
,
255 ((xfs_fsop_getparents_handlereq_t
*)arg
)->hreq
.ihandlen
,
256 ((xfs_fsop_getparents_handlereq_t
*)arg
)->buffer
,
257 ((xfs_fsop_getparents_handlereq_t
*)arg
)->buflen
,
258 &(((xfs_fsop_getparents_handlereq_t
*)arg
)->pos
),
259 ((xfs_fsop_getparents_handlereq_t
*)arg
)->ocount
,
260 ((xfs_fsop_getparents_handlereq_t
*)arg
)->omore
);
261 case SGI_ATTR_MULTI_BY_HANDLE
:
263 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->hreq
.ihandle
,
264 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->hreq
.ihandlen
,
265 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->ops
,
266 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->opcount
,
267 ((xfs_fsop_attrmulti_handlereq_t
*)arg
)->hreq
.oflags
);
268 case SGI_FSSETDM_BY_HANDLE
:
270 ((xfs_fsop_setdm_handlereq_t
*)arg
)->hreq
.ihandle
,
271 ((xfs_fsop_setdm_handlereq_t
*)arg
)->hreq
.ihandlen
,
272 ((xfs_fsop_setdm_handlereq_t
*)arg
)->data
);
274 return fcntl(fd
, cmd
, arg
);
277 static __inline__
int platform_test_xfs_fd(int fd
)
280 if (fstatvfs(fd
, &sbuf
) < 0)
282 return strncmp(sbuf
.f_basetype
, "xfs", 4) == 0;
285 static __inline__
int platform_test_xfs_path(const char *path
)
288 if (statvfs(path
, &sbuf
) < 0)
290 return strncmp(sbuf
.f_basetype
, "xfs", 4) == 0;
293 static __inline__
int platform_fstatfs(int fd
, struct statfs
*buf
)
295 return fstatfs(fd
, buf
, sizeof(struct statfs
), 0);
298 static __inline__
void platform_getoptreset(void)
303 static __inline__
int platform_uuid_compare(uuid_t
*uu1
, uuid_t
*uu2
)
306 return uuid_compare(uu1
, uu2
, &status
);
309 static __inline__
void platform_uuid_unparse(uuid_t
*uu
, char *buffer
)
313 uuid_to_string(uu
, &s
, &status
);
314 if (status
== uuid_s_ok
)
316 else buffer
[0] = '\0';
320 static __inline__
int platform_uuid_parse(char *buffer
, uuid_t
*uu
)
323 uuid_from_string(buffer
, uu
, &status
);
324 return (status
== uuid_s_ok
);
327 static __inline__
int platform_uuid_is_null(uuid_t
*uu
)
330 return uuid_is_nil(uu
, &status
);
333 static __inline__
void platform_uuid_generate(uuid_t
*uu
)
336 uuid_create(uu
, &status
);
339 static __inline__
void platform_uuid_clear(uuid_t
*uu
)
342 uuid_create_nil(uu
, &status
);
345 static __inline__
void platform_uuid_copy(uuid_t
*dst
, uuid_t
*src
)
347 memcpy(dst
, src
, sizeof(uuid_t
));
350 static __inline__
int
351 platform_discard_blocks(int fd
, uint64_t start
, uint64_t len
)
356 static __inline__
char * strsep(char **s
, const char *ct
)
358 char *sbegin
= *s
, *end
;
362 end
= strpbrk(sbegin
, ct
);
369 #define HAVE_DIOATTR 1
370 #define HAVE_FSXATTR 1
371 #define HAVE_GETBMAP 1
372 #define HAVE_GETBMAPX 1
373 #define HAVE_FSDMIDATA 1
375 #define HAVE_IOCMACROS 1
376 #define HAVE_BBMACROS 1
378 #define __XFS_FS_H__ 1
380 #define XFS_IOC_DIOINFO F_DIOINFO
381 #define XFS_IOC_ALLOCSP64 F_ALLOCSP64
382 #define XFS_IOC_FREESP64 F_FREESP64
383 #define XFS_IOC_GETBMAP F_GETBMAP
384 #define XFS_IOC_FSSETDM F_FSSETDM
385 #define XFS_IOC_RESVSP F_RESVSP
386 #define XFS_IOC_RESVSP64 F_RESVSP64
387 #define XFS_IOC_UNRESVSP F_UNRESVSP
388 #define XFS_IOC_UNRESVSP64 F_UNRESVSP64
389 #define XFS_IOC_GETBMAPA F_GETBMAPA
390 #define XFS_IOC_FSGETXATTRA F_FSGETXATTRA
391 #define XFS_IOC_GETBMAPX F_GETBMAPX
393 #define XFS_IOC_FSGEOMETRY_V1 XFS_FS_GEOMETRY
394 #define XFS_IOC_FSBULKSTAT SGI_FS_BULKSTAT
395 #define XFS_IOC_FSBULKSTAT_SINGLE SGI_FS_BULKSTAT_SINGLE
396 #define XFS_IOC_FSINUMBERS SGI_FS_INUMBERS
397 #define XFS_IOC_PATH_TO_FSHANDLE SGI_PATH_TO_FSHANDLE
398 #define XFS_IOC_PATH_TO_HANDLE SGI_PATH_TO_HANDLE
399 #define XFS_IOC_FD_TO_HANDLE SGI_FD_TO_HANDLE
400 #define XFS_IOC_OPEN_BY_HANDLE SGI_OPEN_BY_HANDLE
401 #define XFS_IOC_READLINK_BY_HANDLE SGI_READLINK_BY_HANDLE
402 #define XFS_IOC_SWAPEXT /* TODO */
403 #define XFS_IOC_FSGROWFSDATA XFS_GROWFS_DATA
404 #define XFS_IOC_FSGROWFSLOG XFS_GROWFS_LOG
405 #define XFS_IOC_FSGROWFSRT XFS_GROWFS_RT
406 #define XFS_IOC_FSCOUNTS XFS_FS_COUNTS
407 #define XFS_IOC_SET_RESBLKS XFS_SET_RESBLKS
408 #define XFS_IOC_GET_RESBLKS XFS_GET_RESBLKS
409 #define XFS_IOC_ERROR_INJECTION SGI_XFS_INJECT_ERROR
410 #define XFS_IOC_ERROR_CLEARALL SGI_XFS_CLEARALL_ERROR
411 #define XFS_IOC_FREEZE XFS_FS_FREEZE
412 #define XFS_IOC_THAW XFS_FS_THAW
413 #define XFS_IOC_FSSETDM_BY_HANDLE SGI_FSSETDM_BY_HANDLE
414 #define XFS_IOC_ATTRLIST_BY_HANDLE SGI_ATTR_LIST_BY_HANDLE
415 #define XFS_IOC_ATTRMULTI_BY_HANDLE SGI_ATTR_MULTI_BY_HANDLE
416 #define XFS_IOC_FSGEOMETRY XFS_FS_GEOMETRY
417 #define XFS_IOC_GOINGDOWN XFS_FS_GOINGDOWN
418 #define XFS_IOC_GETPARENTS SGI_XFS_GETPARENTS
419 #define XFS_IOC_GETPARENTPATHS SGI_XFS_GETPARENTPATHS
421 #define _AIOCB64_T_DEFINED 1
423 /* check whether we have to define FS_IOC_FS[GS]ETXATTR ourselves */
426 __u32 fsx_xflags
; /* xflags field value (get/set) */
427 __u32 fsx_extsize
; /* extsize field value (get/set)*/
428 __u32 fsx_nextents
; /* nextents field value (get) */
429 __u32 fsx_projid
; /* project identifier (get/set) */
430 __u32 fsx_cowextsize
; /* cow extsize field value (get/set) */
431 unsigned char fsx_pad
[8];
435 * Flags for the fsx_xflags field
437 #define FS_XFLAG_REALTIME 0x00000001 /* data in realtime volume */
438 #define FS_XFLAG_PREALLOC 0x00000002 /* preallocated file extents */
439 #define FS_XFLAG_IMMUTABLE 0x00000008 /* file cannot be modified */
440 #define FS_XFLAG_APPEND 0x00000010 /* all writes append */
441 #define FS_XFLAG_SYNC 0x00000020 /* all writes synchronous */
442 #define FS_XFLAG_NOATIME 0x00000040 /* do not update access time */
443 #define FS_XFLAG_NODUMP 0x00000080 /* do not include in backups */
444 #define FS_XFLAG_RTINHERIT 0x00000100 /* create with rt bit set */
445 #define FS_XFLAG_PROJINHERIT 0x00000200 /* create with parents projid */
446 #define FS_XFLAG_NOSYMLINKS 0x00000400 /* disallow symlink creation */
447 #define FS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */
448 #define FS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
449 #define FS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
450 #define FS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
451 #define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */
452 #define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
454 #define FS_IOC_FSGETXATTR F_FSGETXATTR
455 #define FS_IOC_FSSETXATTR F_FSSETXATTR
459 #ifndef FS_XFLAG_COWEXTSIZE
460 #define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */
464 * Abstraction of mountpoints.
466 struct mntent_cursor
{
470 static inline int platform_mntent_open(struct mntent_cursor
* cursor
, char *mtab
)
472 cursor
->mtabp
= setmntent(mtab
, "r");
473 if (!cursor
->mtabp
) {
474 fprintf(stderr
, "Error: cannot read %s\n", mtab
);
480 static inline struct mntent
* platform_mntent_next(struct mntent_cursor
* cursor
)
482 return getmntent(cursor
->mtabp
);
485 static inline void platform_mntent_close(struct mntent_cursor
* cursor
)
487 endmntent(cursor
->mtabp
);
491 #endif /* __XFS_IRIX_H__ */