]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/gnukfreebsd.h
xfs: fix off-by-one error in xfs_rtalloc_query_range
[thirdparty/xfsprogs-dev.git] / include / gnukfreebsd.h
CommitLineData
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>
7141fc5b 34#include <mntent.h>
2d2a5db5 35
2d2a5db5 36#define EFSCORRUPTED 990 /* Filesystem is corrupted */
99c1ec96 37#define EFSBADCRC 991 /* Bad CRC detected */
2d2a5db5 38
24842c5c
CH
39typedef unsigned char __u8;
40typedef signed char __s8;
41typedef unsigned short __u16;
42typedef signed short __s16;
43typedef unsigned int __u32;
44typedef signed int __s32;
45typedef unsigned long long int __u64;
46typedef signed long long int __s64;
47
d8079fe0 48typedef off_t xfs_off_t;
14f8b681
DW
49typedef uint64_t xfs_ino_t;
50typedef uint32_t xfs_dev_t;
51typedef int64_t xfs_daddr_t;
d8079fe0
DW
52typedef __u32 xfs_nlink_t;
53
2d2a5db5
PS
54#define HAVE_FID 1
55
56static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p)
57{
58 return ioctl(fd, cmd, p);
59}
60
61static __inline__ int platform_test_xfs_fd(int fd)
62{
63 struct statfs buf;
64 if (fstatfs(fd, &buf) < 0)
65 return 0;
66 return strncmp(buf.f_fstypename, "xfs", 4) == 0;
67}
68
69static __inline__ int platform_test_xfs_path(const char *path)
70{
71 struct statfs buf;
72 if (statfs(path, &buf) < 0)
73 return 0;
74 return strncmp(buf.f_fstypename, "xfs", 4) == 0;
75}
76
77static __inline__ int platform_fstatfs(int fd, struct statfs *buf)
78{
79 return fstatfs(fd, buf);
80}
81
82static __inline__ void platform_getoptreset(void)
83{
84 extern int optind;
85 optind = 0;
86}
87
88static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
89{
90 return uuid_compare(*uu1, *uu2);
91}
92
93static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer)
94{
95 uuid_unparse(*uu, buffer);
96}
97
98static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu)
99{
100 return uuid_parse(buffer, *uu);
101}
102
103static __inline__ int platform_uuid_is_null(uuid_t *uu)
104{
105 return uuid_is_null(*uu);
106}
107
108static __inline__ void platform_uuid_generate(uuid_t *uu)
109{
110 uuid_generate(*uu);
111}
112
113static __inline__ void platform_uuid_clear(uuid_t *uu)
114{
115 uuid_clear(*uu);
116}
117
118static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)
119{
120 uuid_copy(*dst, *src);
121}
122
38393d27
CH
123static __inline__ int
124platform_discard_blocks(int fd, uint64_t start, uint64_t len)
125{
126 return 0;
127}
128
7141fc5b
JT
129/**
130 * Abstraction of mountpoints.
131 */
132struct mntent_cursor {
133 FILE *mtabp;
134};
135
136static inline int platform_mntent_open(struct mntent_cursor * cursor, char *mtab)
137{
138 cursor->mtabp = setmntent(mtab, "r");
139 if (!cursor->mtabp) {
140 fprintf(stderr, "Error: cannot read %s\n", mtab);
141 return 1;
142 }
143 return 0;
144}
145
146static inline struct mntent * platform_mntent_next(struct mntent_cursor * cursor)
147{
148 return getmntent(cursor->mtabp);
149}
150
151static inline void platform_mntent_close(struct mntent_cursor * cursor)
152{
153 endmntent(cursor->mtabp);
154}
155
2d2a5db5 156#endif /* __XFS_KFREEBSD_H__ */