]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/freebsd.h
2 * Copyright (c) 2004-2005 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 <machine/endian.h>
32 /* FreeBSD file API is 64-bit aware */
34 #define ftruncate64 ftruncate
37 #define pwrite64 pwrite
39 #define fdatasync fsync
40 #define memalign(a,size) valloc(size)
42 typedef u_int8_t __u8
;
44 typedef u_int16_t __u16
;
45 typedef int16_t __s16
;
46 typedef u_int32_t __u32
;
47 typedef int32_t __s32
;
48 typedef u_int64_t __u64
;
49 typedef int64_t __s64
;
51 #define constpp char * const *
53 #define EFSCORRUPTED 990 /* Filesystem is corrupted */
55 typedef off_t xfs_off_t
;
56 typedef off_t off64_t
;
57 typedef __uint64_t xfs_ino_t
;
58 typedef __uint32_t xfs_dev_t
;
59 typedef __int64_t xfs_daddr_t
;
60 typedef char* xfs_caddr_t
;
63 #ifndef _UCHAR_T_DEFINED
64 typedef unsigned char uchar_t
;
65 #define _UCHAR_T_DEFINED 1
67 typedef enum { B_FALSE
,B_TRUE
} boolean_t
;
72 #define HAVE_SWABMACROS 1
73 #define INT_SWAP16(type,var) ((typeof(type))(__bswap16((__u16)(var))))
74 #define INT_SWAP32(type,var) ((typeof(type))(__bswap32((__u32)(var))))
75 #define INT_SWAP64(type,var) ((typeof(type))(__bswap64((__u64)(var))))
77 static __inline__
int xfsctl(const char *path
, int fd
, int cmd
, void *p
)
79 return ioctl(fd
, cmd
, p
);
82 static __inline__
int platform_test_xfs_fd(int fd
)
85 if (fstatfs(fd
, &buf
) < 0)
87 return strcpy(buf
.f_fstypename
, "xfs") == 0;
90 static __inline__
int platform_test_xfs_path(const char *path
)
93 if (statfs(path
, &buf
) < 0)
95 return strcpy(buf
.f_fstypename
, "xfs") == 0;
98 static __inline__
int platform_fstatfs(int fd
, struct statfs
*buf
)
100 return fstatfs(fd
, buf
);
103 static __inline__
void platform_getoptreset(void)
110 * Implement Linux libuuid functions in terms of DEC DCE's uuid
111 * functions from FreeBSD libc.
114 static __inline__
int gnu_uuid_compare(uuid_t a
, uuid_t b
)
116 return uuid_compare(&a
, &b
, NULL
);
118 #define uuid_compare gnu_uuid_compare
120 static __inline__
int uuid_is_null(uuid_t uid
)
122 return uuid_is_nil(&uid
, NULL
);
125 static __inline__
void uuid_unparse(uuid_t uid
, char *buf
)
129 uuid_to_string(&uid
, &str
, &status
);
130 if (status
== uuid_s_ok
)
136 static __inline__
int gnu_uuid_parse(const char *buf
, uuid_t
*uid
)
139 uuid_from_string(buf
, uid
, &status
);
140 return (status
== uuid_s_ok
);
142 #define uuid_parse(s,u) gnu_uuid_parse((s), &(u))
144 #define uuid_generate(uid) uuid_create(&(uid), NULL)
145 #define uuid_clear(uid) uuid_create_nil(&(uid), NULL)
146 #define uuid_copy(dst, src) memcpy(&(dst), &(src), sizeof(uuid_t))
148 #endif /* __XFS_FREEBSD_H__ */