]>
Commit | Line | Data |
---|---|---|
c0211f67 | 1 | /* |
f302e9e4 | 2 | * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved. |
c0211f67 | 3 | * |
f302e9e4 NS |
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. | |
c0211f67 | 7 | * |
f302e9e4 NS |
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. | |
c0211f67 | 12 | * |
f302e9e4 NS |
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 | |
c0211f67 NS |
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> | |
25d246df | 24 | #include <sys/sysmacros.h> |
66210ef2 | 25 | #include <sys/stat.h> |
5d1b7f0f | 26 | #include <inttypes.h> |
c0211f67 NS |
27 | #include <malloc.h> |
28 | #include <getopt.h> | |
29 | #include <endian.h> | |
a2ceac1f | 30 | #include <stdbool.h> |
c0211f67 NS |
31 | |
32 | static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p) | |
33 | { | |
34 | return ioctl(fd, cmd, p); | |
35 | } | |
36 | ||
37 | static __inline__ int platform_test_xfs_fd(int fd) | |
38 | { | |
39 | struct statfs buf; | |
40 | if (fstatfs(fd, &buf) < 0) | |
41 | return 0; | |
42 | return (buf.f_type == 0x58465342); /* XFSB */ | |
43 | } | |
44 | ||
45 | static __inline__ int platform_test_xfs_path(const char *path) | |
46 | { | |
47 | struct statfs buf; | |
48 | if (statfs(path, &buf) < 0) | |
49 | return 0; | |
50 | return (buf.f_type == 0x58465342); /* XFSB */ | |
51 | } | |
52 | ||
53 | static __inline__ int platform_fstatfs(int fd, struct statfs *buf) | |
54 | { | |
55 | return fstatfs(fd, buf); | |
56 | } | |
57 | ||
58 | static __inline__ void platform_getoptreset(void) | |
59 | { | |
60 | extern int optind; | |
61 | optind = 0; | |
62 | } | |
63 | ||
1552a820 NS |
64 | static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2) |
65 | { | |
66 | return uuid_compare(*uu1, *uu2); | |
67 | } | |
68 | ||
4d32d744 | 69 | static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer) |
1552a820 | 70 | { |
4d32d744 NS |
71 | uuid_unparse(*uu, buffer); |
72 | } | |
73 | ||
74 | static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu) | |
75 | { | |
76 | return uuid_parse(buffer, *uu); | |
1552a820 NS |
77 | } |
78 | ||
79 | static __inline__ int platform_uuid_is_null(uuid_t *uu) | |
80 | { | |
81 | return uuid_is_null(*uu); | |
82 | } | |
c0211f67 | 83 | |
4d32d744 NS |
84 | static __inline__ void platform_uuid_generate(uuid_t *uu) |
85 | { | |
86 | uuid_generate(*uu); | |
87 | } | |
88 | ||
89 | static __inline__ void platform_uuid_clear(uuid_t *uu) | |
90 | { | |
91 | uuid_clear(*uu); | |
92 | } | |
93 | ||
94 | static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src) | |
95 | { | |
96 | uuid_copy(*dst, *src); | |
97 | } | |
98 | ||
ad136b33 CH |
99 | #ifndef BLKDISCARD |
100 | #define BLKDISCARD _IO(0x12,119) | |
101 | #endif | |
102 | ||
103 | static __inline__ int | |
f96aff0c | 104 | platform_discard_blocks(int fd, uint64_t start, uint64_t len) |
ad136b33 | 105 | { |
f96aff0c | 106 | __uint64_t range[2] = { start, len }; |
ad136b33 CH |
107 | |
108 | if (ioctl(fd, BLKDISCARD, &range) < 0) | |
109 | return errno; | |
110 | return 0; | |
111 | } | |
112 | ||
c0211f67 NS |
113 | #if (__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ <= 1)) |
114 | # define constpp const char * const * | |
115 | #else | |
116 | # define constpp char * const * | |
117 | #endif | |
118 | ||
119 | #define ENOATTR ENODATA /* Attribute not found */ | |
1552a820 | 120 | #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ |
c0211f67 NS |
121 | |
122 | typedef loff_t xfs_off_t; | |
123 | typedef __uint64_t xfs_ino_t; | |
124 | typedef __uint32_t xfs_dev_t; | |
125 | typedef __int64_t xfs_daddr_t; | |
126 | typedef char* xfs_caddr_t; | |
127 | ||
128 | #ifndef _UCHAR_T_DEFINED | |
129 | typedef unsigned char uchar_t; | |
130 | #define _UCHAR_T_DEFINED 1 | |
131 | #endif | |
132 | ||
133 | #ifndef _BOOLEAN_T_DEFINED | |
134 | typedef enum {B_FALSE, B_TRUE} boolean_t; | |
135 | #define _BOOLEAN_T_DEFINED 1 | |
136 | #endif | |
137 | ||
cb5b3ef4 | 138 | #endif /* __XFS_LINUX_H__ */ |