]>
Commit | Line | Data |
---|---|---|
2d2a5db5 PS |
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_KFREEBSD_H__ | |
19 | #define __XFS_KFREEBSD_H__ | |
20 | ||
21 | #include <uuid/uuid.h> | |
22 | #include <sys/vfs.h> | |
23 | #include <sys/ioctl.h> | |
24 | #include <sys/sysmacros.h> | |
25 | #include <malloc.h> | |
26 | #include <getopt.h> | |
27 | #include <endian.h> | |
28 | #include <sys/stat.h> | |
29 | #include <sys/param.h> | |
30 | #include <sys/mount.h> | |
31 | #include <ctype.h> | |
32 | #include <libgen.h> | |
33 | #include <paths.h> | |
34 | #include <xfs/swab.h> | |
35 | ||
36 | #define constpp char * const * | |
37 | ||
38 | #define EFSCORRUPTED 990 /* Filesystem is corrupted */ | |
39 | ||
40 | typedef off_t xfs_off_t; | |
41 | typedef __uint64_t xfs_ino_t; | |
42 | typedef __uint32_t xfs_dev_t; | |
43 | typedef __int64_t xfs_daddr_t; | |
44 | typedef char* xfs_caddr_t; | |
45 | typedef off_t loff_t; | |
46 | ||
47 | #ifndef _UCHAR_T_DEFINED | |
48 | typedef unsigned char uchar_t; | |
49 | #define _UCHAR_T_DEFINED 1 | |
50 | #endif | |
51 | typedef enum { B_FALSE,B_TRUE } boolean_t; | |
52 | ||
53 | #define HAVE_FID 1 | |
54 | ||
55 | static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p) | |
56 | { | |
57 | return ioctl(fd, cmd, p); | |
58 | } | |
59 | ||
60 | static __inline__ int platform_test_xfs_fd(int fd) | |
61 | { | |
62 | struct statfs buf; | |
63 | if (fstatfs(fd, &buf) < 0) | |
64 | return 0; | |
65 | return strncmp(buf.f_fstypename, "xfs", 4) == 0; | |
66 | } | |
67 | ||
68 | static __inline__ int platform_test_xfs_path(const char *path) | |
69 | { | |
70 | struct statfs buf; | |
71 | if (statfs(path, &buf) < 0) | |
72 | return 0; | |
73 | return strncmp(buf.f_fstypename, "xfs", 4) == 0; | |
74 | } | |
75 | ||
76 | static __inline__ int platform_fstatfs(int fd, struct statfs *buf) | |
77 | { | |
78 | return fstatfs(fd, buf); | |
79 | } | |
80 | ||
81 | static __inline__ void platform_getoptreset(void) | |
82 | { | |
83 | extern int optind; | |
84 | optind = 0; | |
85 | } | |
86 | ||
87 | static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2) | |
88 | { | |
89 | return uuid_compare(*uu1, *uu2); | |
90 | } | |
91 | ||
92 | static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer) | |
93 | { | |
94 | uuid_unparse(*uu, buffer); | |
95 | } | |
96 | ||
97 | static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu) | |
98 | { | |
99 | return uuid_parse(buffer, *uu); | |
100 | } | |
101 | ||
102 | static __inline__ int platform_uuid_is_null(uuid_t *uu) | |
103 | { | |
104 | return uuid_is_null(*uu); | |
105 | } | |
106 | ||
107 | static __inline__ void platform_uuid_generate(uuid_t *uu) | |
108 | { | |
109 | uuid_generate(*uu); | |
110 | } | |
111 | ||
112 | static __inline__ void platform_uuid_clear(uuid_t *uu) | |
113 | { | |
114 | uuid_clear(*uu); | |
115 | } | |
116 | ||
117 | static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src) | |
118 | { | |
119 | uuid_copy(*dst, *src); | |
120 | } | |
121 | ||
122 | #endif /* __XFS_KFREEBSD_H__ */ |