]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/linux.h
Merge branch 'repair-speedup-20091112'
[thirdparty/xfsprogs-dev.git] / include / linux.h
1 /*
2 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public License
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write the Free Software Foundation,
15 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 #ifndef __XFS_LINUX_H__
18 #define __XFS_LINUX_H__
19
20 #include <uuid/uuid.h>
21 #include <sys/vfs.h>
22 #include <sys/ioctl.h>
23 #include <sys/param.h>
24 #include <sys/sysmacros.h>
25 #include <malloc.h>
26 #include <getopt.h>
27 #include <endian.h>
28
29 static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p)
30 {
31 return ioctl(fd, cmd, p);
32 }
33
34 static __inline__ int platform_test_xfs_fd(int fd)
35 {
36 struct statfs buf;
37 if (fstatfs(fd, &buf) < 0)
38 return 0;
39 return (buf.f_type == 0x58465342); /* XFSB */
40 }
41
42 static __inline__ int platform_test_xfs_path(const char *path)
43 {
44 struct statfs buf;
45 if (statfs(path, &buf) < 0)
46 return 0;
47 return (buf.f_type == 0x58465342); /* XFSB */
48 }
49
50 static __inline__ int platform_fstatfs(int fd, struct statfs *buf)
51 {
52 return fstatfs(fd, buf);
53 }
54
55 static __inline__ void platform_getoptreset(void)
56 {
57 extern int optind;
58 optind = 0;
59 }
60
61 static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
62 {
63 return uuid_compare(*uu1, *uu2);
64 }
65
66 static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer)
67 {
68 uuid_unparse(*uu, buffer);
69 }
70
71 static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu)
72 {
73 return uuid_parse(buffer, *uu);
74 }
75
76 static __inline__ int platform_uuid_is_null(uuid_t *uu)
77 {
78 return uuid_is_null(*uu);
79 }
80
81 static __inline__ void platform_uuid_generate(uuid_t *uu)
82 {
83 uuid_generate(*uu);
84 }
85
86 static __inline__ void platform_uuid_clear(uuid_t *uu)
87 {
88 uuid_clear(*uu);
89 }
90
91 static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)
92 {
93 uuid_copy(*dst, *src);
94 }
95
96 #ifndef BLKDISCARD
97 #define BLKDISCARD _IO(0x12,119)
98 #endif
99
100 static __inline__ int
101 platform_discard_blocks(int fd, uint64_t start, uint64_t len)
102 {
103 __uint64_t range[2] = { start, len };
104
105 if (ioctl(fd, BLKDISCARD, &range) < 0)
106 return errno;
107 return 0;
108 }
109
110 #if (__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ <= 1))
111 # define constpp const char * const *
112 #else
113 # define constpp char * const *
114 #endif
115
116 #define ENOATTR ENODATA /* Attribute not found */
117 #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
118
119 typedef loff_t xfs_off_t;
120 typedef __uint64_t xfs_ino_t;
121 typedef __uint32_t xfs_dev_t;
122 typedef __int64_t xfs_daddr_t;
123 typedef char* xfs_caddr_t;
124
125 #ifndef _UCHAR_T_DEFINED
126 typedef unsigned char uchar_t;
127 #define _UCHAR_T_DEFINED 1
128 #endif
129
130 #ifndef _BOOLEAN_T_DEFINED
131 typedef enum {B_FALSE, B_TRUE} boolean_t;
132 #define _BOOLEAN_T_DEFINED 1
133 #endif
134
135 #endif /* __XFS_LINUX_H__ */