]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/darwin.h
Fix an endianness issue in the FreeBSD headers, remove a no-longer-needed HAVE macro...
[thirdparty/xfsprogs-dev.git] / include / darwin.h
1 /*
2 * Copyright (c) 2004-2006 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 <machine/endian.h>
29 #define __BYTE_ORDER BYTE_ORDER
30 #define __BIG_ENDIAN BIG_ENDIAN
31 #define __LITTLE_ENDIAN LITTLE_ENDIAN
32 #include <xfs/swab.h>
33
34 #include <sys/syscall.h>
35 # ifndef SYS_fsctl
36 # define SYS_fsctl 242
37 # endif
38 static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p)
39 {
40 return syscall(SYS_fsctl, path, cmd, p, 0);
41 }
42
43 static __inline__ int platform_test_xfs_fd(int fd)
44 {
45 struct statfs buf;
46 if (fstatfs(fd, &buf) < 0)
47 return 0;
48 return strncmp(buf.f_fstypename, "xfs", 4) == 0;
49 }
50
51 static __inline__ int platform_test_xfs_path(const char *path)
52 {
53 struct statfs buf;
54 if (statfs(path, &buf) < 0)
55 return 0;
56 return strncmp(buf.f_fstypename, "xfs", 4) == 0;
57 }
58
59 static __inline__ int platform_fstatfs(int fd, struct statfs *buf)
60 {
61 return fstatfs(fd, buf);
62 }
63
64 static __inline__ void platform_getoptreset(void)
65 {
66 extern int optreset;
67 optreset = 0;
68 }
69
70 static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
71 {
72 return uuid_compare(uu1, uu2, NULL);
73 }
74
75 static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer)
76 {
77 uint32_t status;
78 char *s;
79 uuid_to_string(uu, &s, &status);
80 if (status == uuid_s_ok)
81 strcpy(buffer, s);
82 else buffer[0] = '\0';
83 free(s);
84 }
85
86 static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu)
87 {
88 uint32_t status;
89 uuid_from_string(buffer, uu, &status);
90 return (status == uuid_s_ok);
91 }
92
93 static __inline__ int platform_uuid_is_null(uuid_t *uu)
94 {
95 return uuid_is_nil(uu, NULL);
96 }
97
98 static __inline__ void platform_uuid_generate(uuid_t *uu)
99 {
100 uuid_create(uu, NULL);
101 }
102
103 static __inline__ void platform_uuid_clear(uuid_t *uu)
104 {
105 uuid_create_nil(uu, NULL);
106 }
107
108 static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)
109 {
110 memcpy(dst, src, sizeof(uuid_t));
111 }
112
113 #define __int8_t int8_t
114 #define __int16_t int16_t
115 #define __int32_t int32_t
116 #define __int32_t int32_t
117 #define __int64_t int64_t
118 #define __uint8_t u_int8_t
119 #define __uint16_t u_int16_t
120 #define __uint32_t u_int32_t
121 #define __uint64_t u_int64_t
122 #define loff_t off_t
123 #define off64_t off_t
124
125 typedef off_t xfs_off_t;
126 typedef u_int64_t xfs_ino_t;
127 typedef u_int32_t xfs_dev_t;
128 typedef int64_t xfs_daddr_t;
129 typedef char* xfs_caddr_t;
130
131 typedef unsigned char uchar_t;
132 #define stat64 stat
133 #define fstat64 fstat
134 #define lseek64 lseek
135 #define pread64 pread
136 #define pwrite64 pwrite
137 #define ftruncate64 ftruncate
138 #define fdatasync fsync
139 #define memalign(a,sz) valloc(sz)
140
141 #define O_LARGEFILE 0
142 #ifndef O_DIRECT
143 #define O_DIRECT 0
144 #endif
145 #ifndef O_SYNC
146 #define O_SYNC 0
147 #endif
148
149 #define B_FALSE 0
150 #define B_TRUE 1
151
152 #define ENOATTR 989 /* Attribute not found */
153 #define EFSCORRUPTED 990 /* Filesystem is corrupted */
154 #define constpp char * const *
155
156 #define HAVE_FID 1
157
158 #endif /* __XFS_DARWIN_H__ */