]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/platform_defs.h.in
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
34 #ifndef __XFS_PLATFORM_DEFS_H__
35 #define __XFS_PLATFORM_DEFS_H__
46 #include <sys/types.h>
47 #include <uuid/uuid.h>
50 #if defined(__linux__)
53 #include <sys/ioctl.h>
54 #include <sys/param.h>
55 #include <linux/types.h>
61 static __inline__
int xfsctl(const char *path
, int fd
, int cmd
, void *p
)
63 return ioctl(fd
, cmd
, p
);
66 static __inline__
int platform_test_xfs_fd(int fd
)
69 if (fstatfs(fd
, &buf
) < 0)
71 return (buf
.f_type
== 0x58465342); /* XFSB */
74 static __inline__
int platform_fstatfs(int fd
, struct statfs
*buf
)
76 return fstatfs(fd
, buf
);
80 # if defined (__powerpc__)
81 # define O_DIRECT 0400000
82 # elif defined (__sparc__)
83 # define O_DIRECT 0x100000
87 #if (__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ <= 1))
88 # define constpp const char * const *
90 # define constpp char * const *
93 #define ENOATTR ENODATA /* Attribute not found */
94 #define EFSCORRUPTED 990 /* Filesystem is corrupted */
96 typedef loff_t xfs_off_t
;
97 typedef __uint64_t xfs_ino_t
;
98 typedef __uint32_t xfs_dev_t
;
99 typedef __int64_t xfs_daddr_t
;
100 typedef char* xfs_caddr_t
;
102 #ifndef _UCHAR_T_DEFINED
103 typedef unsigned char uchar_t
;
104 #define _UCHAR_T_DEFINED 1
106 typedef enum { B_FALSE
,B_TRUE
} boolean_t
;
109 #elif defined(__FreeBSD__)
111 #include <sys/stat.h>
113 #include <machine/endian.h>
114 #include <sys/param.h>
118 /* FreeBSD file API is 64-bit aware */
119 #define fstat64 fstat
120 #define ftruncate64 ftruncate
121 #define lseek64 lseek
123 #define pwrite64 pwrite
124 #define pread64 pread
125 #define memalign(a,size) valloc(size)
127 typedef u_int8_t __u8
;
129 typedef u_int16_t __u16
;
130 typedef int16_t __s16
;
131 typedef u_int32_t __u32
;
132 typedef int32_t __s32
;
133 typedef u_int64_t __u64
;
134 typedef int64_t __s64
;
136 #define constpp char * const *
138 #define EFSCORRUPTED 990 /* Filesystem is corrupted */
140 typedef off_t xfs_off_t
;
141 typedef __uint64_t xfs_ino_t
;
142 typedef __uint32_t xfs_dev_t
;
143 typedef __int64_t xfs_daddr_t
;
144 typedef char* xfs_caddr_t
;
146 #ifndef _UCHAR_T_DEFINED
147 typedef unsigned char uchar_t
;
148 #define _UCHAR_T_DEFINED 1
150 typedef enum { B_FALSE
,B_TRUE
} boolean_t
;
153 #define HAVE_SWABMACROS 1
154 #define INT_SWAP16(type,var) ((typeof(type))(__bswap16((__u16)(var))))
155 #define INT_SWAP32(type,var) ((typeof(type))(__bswap32((__u32)(var))))
156 #define INT_SWAP64(type,var) ((typeof(type))(__bswap64((__u64)(var))))
159 #elif defined(__APPLE__) /* Darwin */
163 #include <sys/stat.h>
164 #include <sys/ioctl.h>
165 #include <sys/mount.h>
167 #include <sys/syscall.h>
169 # define SYS_fsctl 242
171 static __inline__
int xfsctl(const char *path
, int fd
, int cmd
, void *p
)
173 return syscall(SYS_fsctl
, path
, cmd
, p
, 0);
176 static __inline__
int platform_test_xfs_fd(int fd
)
179 if (fstatfs(fd
, &buf
) < 0)
181 return (strcmp(buf
.f_fstypename
, "xfs") == 0);
184 static __inline__
int platform_fstatfs(int fd
, struct statfs
*buf
)
186 return fstatfs(fd
, buf
);
189 #define __int8_t int8_t
190 #define __int16_t int16_t
191 #define __int32_t int32_t
192 #define __int32_t int32_t
193 #define __int64_t int64_t
194 #define __uint8_t u_int8_t
195 #define __uint16_t u_int16_t
196 #define __uint32_t u_int32_t
197 #define __uint64_t u_int64_t
199 #define __s16 int16_t
200 #define __s32 int32_t
201 #define __s64 int64_t
202 #define __u8 u_int8_t
203 #define __u16 u_int16_t
204 #define __u32 u_int32_t
205 #define __u64 u_int64_t
207 #define off64_t off_t
209 typedef off_t xfs_off_t
;
210 typedef u_int64_t xfs_ino_t
;
211 typedef u_int32_t xfs_dev_t
;
212 typedef int64_t xfs_daddr_t
;
213 typedef char* xfs_caddr_t
;
215 typedef unsigned char uchar_t
;
217 #define fstat64 fstat
218 #define lseek64 lseek
219 #define pread64 pread
220 #define pwrite64 pwrite
221 #define ftruncate64 ftruncate
222 #define fdatasync fsync
223 #define memalign(a,sz) malloc(sz)
225 #include <machine/endian.h>
226 #define __BYTE_ORDER BYTE_ORDER
227 #define __BIG_ENDIAN BIG_ENDIAN
228 #define __LITTLE_ENDIAN LITTLE_ENDIAN
231 #define O_LARGEFILE 0
242 #define ENOATTR 989 /* Attribute not found */
243 #define EFSCORRUPTED 990 /* Filesystem is corrupted */
244 #define constpp char * const *
249 #elif defined(__sgi__) /* SGI IRIX */
254 #include <inttypes.h>
255 #include <sys/stat.h>
256 #include <sys/param.h>
257 #include <sys/ioctl.h>
258 #include <sys/types.h>
259 #include <sys/statfs.h>
260 #include <sys/statvfs.h>
261 #include <sys/sysmacros.h>
265 #define __s32 __int32_t
266 #define __s64 __int64_t
267 #define __u8 unsigned char
268 #define __u16 unsigned short
269 #define __u32 __int32_t
270 #define __u64 __int64_t
271 #define __int8_t char
272 #define __int16_t short
273 #define __uint8_t unsigned char
274 #define __uint16_t unsigned short
275 #define loff_t off64_t
276 typedef off64_t xfs_off_t
;
277 typedef __int64_t xfs_ino_t
;
278 typedef __int32_t xfs_dev_t
;
279 typedef __int64_t xfs_daddr_t
;
280 typedef char* xfs_caddr_t
;
282 #include <sys/endian.h>
283 #define __BYTE_ORDER BYTE_ORDER
284 #define __BIG_ENDIAN BIG_ENDIAN
285 #define __LITTLE_ENDIAN LITTLE_ENDIAN
288 #define INT_MAX INT32_MAX
289 #define UINT_MAX UINT32_MAX
290 #define PATH_MAX MAXPATHLEN
291 #define constpp char * const *
292 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
294 static __inline__
int xfsctl(const char *path
, int fd
, int cmd
, void *p
)
296 fprintf(stderr
, "%s: line %d syssgi/fcntl mapping not implemented\n",
302 static __inline__
int platform_test_xfs_fd(int fd
)
305 if (fstatvfs(fd
, &sbuf
) < 0)
307 return (strcmp(sbuf
.f_basetype
, "xfs") == 0);
310 static __inline__
int platform_fstatfs(int fd
, struct statfs
*buf
)
312 return fstatfs(fd
, buf
, sizeof(struct statfs
), 0);
315 static __inline__
char * strsep(char **s
, const char *ct
)
317 char *sbegin
= *s
, *end
;
321 end
= strpbrk(sbegin
, ct
);
328 #define HAVE_DIOATTR 1
329 #define HAVE_FSXATTR 1
330 #define HAVE_GETBMAP 1
331 #define HAVE_GETBMAPX 1
332 #define HAVE_FSDMIDATA 1
334 #define HAVE_BBMACROS 1
338 # error unknown platform... have fun porting!
342 /* long and pointer must be either 32 bit or 64 bit */
343 #undef HAVE_32BIT_LONG
344 #undef HAVE_64BIT_LONG
345 #undef HAVE_32BIT_PTR
346 #undef HAVE_64BIT_PTR
348 #if defined(HAVE_32BIT_LONG)
349 # define BITS_PER_LONG 32
350 #elif defined(HAVE_64BIT_LONG)
351 # define BITS_PER_LONG 64
353 # error Unknown long size
356 /* Check if __psint_t is set to something meaningful */
357 #undef HAVE___PSINT_T
358 #ifndef HAVE___PSINT_T
359 # ifdef HAVE_32BIT_PTR
360 typedef int __psint_t
;
361 # elif defined HAVE_64BIT_PTR
362 # ifdef HAVE_64BIT_LONG
363 typedef long __psint_t
;
365 /* This is a very strange architecture, which has 64 bit pointers but */
366 /* not 64 bit longs. So, just punt here and assume long long is OK. */
367 typedef long long __psint_t
;
370 # error Unknown pointer size
374 /* Check if __psunsigned_t is set to something meaningful */
375 #undef HAVE___PSUNSIGNED_T
376 #ifndef HAVE___PSUNSIGNED_T
377 # ifdef HAVE_32BIT_PTR
378 typedef unsigned int __psunsigned_t
;
379 # elif defined HAVE_64BIT_PTR
380 # ifdef HAVE_64BIT_LONG
381 typedef long __psunsigned_t
;
383 /* This is a very strange architecture, which has 64 bit pointers but */
384 /* not 64 bit longs. So, just punt here and assume long long is OK. */
385 typedef unsigned long long __psunsigned_t
;
388 # error Unknown pointer size
392 /* Define if you want gettext (I18N) support */
393 #undef ENABLE_GETTEXT
394 #ifdef ENABLE_GETTEXT
395 # include <libintl.h>
396 # define _(x) gettext(x)
399 # define textdomain(d) do { } while (0)
400 # define bindtextdomain(d,dir) do { } while (0)
405 # define ASSERT assert
407 # define ASSERT(EX) ((void) 0)
410 #define IRIX_DEV_BITSMAJOR 14
411 #define IRIX_DEV_BITSMINOR 18
412 #define IRIX_DEV_MAXMAJ 0x1ff
413 #define IRIX_DEV_MAXMIN 0x3ffff
414 #define IRIX_DEV_MAJOR(dev) ((int)(((unsigned)(dev) >> IRIX_DEV_BITSMINOR) \
416 #define IRIX_DEV_MINOR(dev) ((int)((dev) & IRIX_DEV_MAXMIN))
417 #define IRIX_MKDEV(major,minor) ((dev_t)(((major) << IRIX_DEV_BITSMINOR) \
418 | (minor&IRIX_DEV_MAXMIN)))
419 #define IRIX_DEV_TO_KDEVT(dev) makedev(IRIX_DEV_MAJOR(dev),IRIX_DEV_MINOR(dev))
421 #endif /* __XFS_PLATFORM_DEFS_H__ */