]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/freebsd.h
2 * Copyright (c) 2004-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_FREEBSD_H__
19 #define __XFS_FREEBSD_H__
22 #include <sys/param.h>
23 #include <sys/ioccom.h>
24 #include <sys/mount.h>
30 #include <sys/endian.h>
31 #define __BYTE_ORDER BYTE_ORDER
32 #define __BIG_ENDIAN BIG_ENDIAN
33 #define __LITTLE_ENDIAN LITTLE_ENDIAN
35 /* FreeBSD file API is 64-bit aware */
37 #define ftruncate64 ftruncate
40 #define pwrite64 pwrite
42 #define fdatasync fsync
43 #define memalign(a,sz) valloc(sz)
45 #define constpp char * const *
47 #define EFSCORRUPTED 990 /* Filesystem is corrupted */
49 typedef off_t xfs_off_t
;
50 typedef off_t off64_t
;
51 typedef __uint64_t xfs_ino_t
;
52 typedef __uint32_t xfs_dev_t
;
53 typedef __int64_t xfs_daddr_t
;
54 typedef char* xfs_caddr_t
;
57 #ifndef _UCHAR_T_DEFINED
58 typedef unsigned char uchar_t
;
59 #define _UCHAR_T_DEFINED 1
61 typedef enum { B_FALSE
,B_TRUE
} boolean_t
;
67 static __inline__
int xfsctl(const char *path
, int fd
, int cmd
, void *p
)
69 return ioctl(fd
, cmd
, p
);
72 static __inline__
int platform_test_xfs_fd(int fd
)
75 if (fstatfs(fd
, &buf
) < 0)
77 return strncmp(buf
.f_fstypename
, "xfs", 4) == 0;
80 static __inline__
int platform_test_xfs_path(const char *path
)
83 if (statfs(path
, &buf
) < 0)
85 return strncmp(buf
.f_fstypename
, "xfs", 4) == 0;
88 static __inline__
int platform_fstatfs(int fd
, struct statfs
*buf
)
90 return fstatfs(fd
, buf
);
93 static __inline__
void platform_getoptreset(void)
99 static __inline__
int platform_uuid_compare(uuid_t
*uu1
, uuid_t
*uu2
)
101 return uuid_compare(uu1
, uu2
, NULL
);
104 static __inline__
void platform_uuid_unparse(uuid_t
*uu
, char *buffer
)
108 uuid_to_string(uu
, &s
, &status
);
109 if (status
== uuid_s_ok
)
111 else buffer
[0] = '\0';
115 static __inline__
int platform_uuid_parse(char *buffer
, uuid_t
*uu
)
118 uuid_from_string(buffer
, uu
, &status
);
119 return (status
== uuid_s_ok
);
122 static __inline__
int platform_uuid_is_null(uuid_t
*uu
)
124 return uuid_is_nil(uu
, NULL
);
127 static __inline__
void platform_uuid_generate(uuid_t
*uu
)
129 uuid_create(uu
, NULL
);
132 static __inline__
void platform_uuid_clear(uuid_t
*uu
)
134 uuid_create_nil(uu
, NULL
);
137 static __inline__
void platform_uuid_copy(uuid_t
*dst
, uuid_t
*src
)
139 memcpy(dst
, src
, sizeof(uuid_t
));
142 #endif /* __XFS_FREEBSD_H__ */