]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/darwin.h
Fix compilation for non-Linux builds (thanks to FreeBSD folks).
[thirdparty/xfsprogs-dev.git] / include / darwin.h
1 /*
2 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
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.
8 *
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.
13 *
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
17 */
18 #ifndef __XFS_DARWIN_H__
19 #define __XFS_DARWIN_H__
20
21 #include <uuid/uuid.h>
22 #include <libgen.h>
23 #include <sys/vm.h>
24 #include <sys/stat.h>
25 #include <sys/ioctl.h>
26 #include <sys/mount.h>
27
28 #include <sys/syscall.h>
29 # ifndef SYS_fsctl
30 # define SYS_fsctl 242
31 # endif
32 static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p)
33 {
34 return syscall(SYS_fsctl, path, cmd, p, 0);
35 }
36
37 static __inline__ int platform_test_xfs_fd(int fd)
38 {
39 struct statfs buf;
40 if (fstatfs(fd, &buf) < 0)
41 return 0;
42 return (strcmp(buf.f_fstypename, "xfs") == 0);
43 }
44
45 static __inline__ int platform_test_xfs_path(const char *path)
46 {
47 struct statfs buf;
48 if (statfs(path, &buf) < 0)
49 return 0;
50 return (strcmp(buf.f_fstypename, "xfs") == 0);
51 }
52
53 static __inline__ int platform_fstatfs(int fd, struct statfs *buf)
54 {
55 return fstatfs(fd, buf);
56 }
57
58 static __inline__ void platform_getoptreset(void)
59 {
60 extern int optreset;
61 optreset = 0;
62 }
63
64 #define __int8_t int8_t
65 #define __int16_t int16_t
66 #define __int32_t int32_t
67 #define __int32_t int32_t
68 #define __int64_t int64_t
69 #define __uint8_t u_int8_t
70 #define __uint16_t u_int16_t
71 #define __uint32_t u_int32_t
72 #define __uint64_t u_int64_t
73 #define loff_t off_t
74 #define off64_t off_t
75
76 typedef off_t xfs_off_t;
77 typedef u_int64_t xfs_ino_t;
78 typedef u_int32_t xfs_dev_t;
79 typedef int64_t xfs_daddr_t;
80 typedef char* xfs_caddr_t;
81
82 typedef unsigned char uchar_t;
83 #define stat64 stat
84 #define fstat64 fstat
85 #define lseek64 lseek
86 #define pread64 pread
87 #define pwrite64 pwrite
88 #define ftruncate64 ftruncate
89 #define fdatasync fsync
90 #define memalign(a,sz) valloc(sz)
91
92 #include <machine/endian.h>
93 #define __BYTE_ORDER BYTE_ORDER
94 #define __BIG_ENDIAN BIG_ENDIAN
95 #define __LITTLE_ENDIAN LITTLE_ENDIAN
96 #include <xfs/swab.h>
97
98 #define O_LARGEFILE 0
99 #ifndef O_DIRECT
100 #define O_DIRECT 0
101 #endif
102 #ifndef O_SYNC
103 #define O_SYNC 0
104 #endif
105
106 #define B_FALSE 0
107 #define B_TRUE 1
108
109 #define ENOATTR 989 /* Attribute not found */
110 #define EFSCORRUPTED 990 /* Filesystem is corrupted */
111 #define constpp char * const *
112
113 #define HAVE_FID 1
114
115 #endif /* __XFS_DARWIN_H__ */