]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/freebsd.h
2 * Copyright (c) 2004-2006 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>
31 #include <sys/endian.h>
32 #define __BYTE_ORDER BYTE_ORDER
33 #define __BIG_ENDIAN BIG_ENDIAN
34 #define __LITTLE_ENDIAN LITTLE_ENDIAN
36 /* FreeBSD file API is 64-bit aware */
37 #define fdatasync fsync
38 #define memalign(a,sz) valloc(sz)
40 #define EFSCORRUPTED 990 /* Filesystem is corrupted */
41 #define EFSBADCRC 991 /* Bad CRC detected */
43 typedef unsigned char __u8
;
44 typedef signed char __s8
;
45 typedef unsigned short __u16
;
46 typedef signed short __s16
;
47 typedef unsigned int __u32
;
48 typedef signed int __s32
;
49 typedef unsigned long long int __u64
;
50 typedef signed long long int __s64
;
52 typedef off_t xfs_off_t
;
53 typedef __uint64_t xfs_ino_t
;
54 typedef __uint32_t xfs_dev_t
;
55 typedef __int64_t xfs_daddr_t
;
56 typedef __u32 xfs_nlink_t
;
62 static __inline__
int xfsctl(const char *path
, int fd
, int cmd
, void *p
)
64 return ioctl(fd
, cmd
, p
);
67 static __inline__
int platform_test_xfs_fd(int fd
)
70 if (fstatfs(fd
, &buf
) < 0)
72 return strncmp(buf
.f_fstypename
, "xfs", 4) == 0;
75 static __inline__
int platform_test_xfs_path(const char *path
)
78 if (statfs(path
, &buf
) < 0)
80 return strncmp(buf
.f_fstypename
, "xfs", 4) == 0;
83 static __inline__
int platform_fstatfs(int fd
, struct statfs
*buf
)
85 return fstatfs(fd
, buf
);
88 static __inline__
void platform_getoptreset(void)
94 static __inline__
int platform_uuid_compare(uuid_t
*uu1
, uuid_t
*uu2
)
96 return uuid_compare(uu1
, uu2
, NULL
);
99 static __inline__
void platform_uuid_unparse(uuid_t
*uu
, char *buffer
)
103 uuid_to_string(uu
, &s
, &status
);
104 if (status
== uuid_s_ok
)
106 else buffer
[0] = '\0';
110 static __inline__
int platform_uuid_parse(char *buffer
, uuid_t
*uu
)
113 uuid_from_string(buffer
, uu
, &status
);
114 return (status
== uuid_s_ok
);
117 static __inline__
int platform_uuid_is_null(uuid_t
*uu
)
119 return uuid_is_nil(uu
, NULL
);
122 static __inline__
void platform_uuid_generate(uuid_t
*uu
)
124 uuid_create(uu
, NULL
);
127 static __inline__
void platform_uuid_clear(uuid_t
*uu
)
129 uuid_create_nil(uu
, NULL
);
132 static __inline__
void platform_uuid_copy(uuid_t
*dst
, uuid_t
*src
)
134 memcpy(dst
, src
, sizeof(uuid_t
));
137 static __inline__
int
138 platform_discard_blocks(int fd
, uint64_t start
, uint64_t len
)
144 * Abstraction of mountpoints.
146 struct mntent_cursor
{
150 static inline int platform_mntent_open(struct mntent_cursor
* cursor
, char *mtab
)
152 cursor
->mtabp
= setmntent(mtab
, "r");
153 if (!cursor
->mtabp
) {
154 fprintf(stderr
, "Error: cannot read %s\n", mtab
);
160 static inline struct mntent
* platform_mntent_next(struct mntent_cursor
* cursor
)
162 return getmntent(cursor
->mtabp
);
165 static inline void platform_mntent_close(struct mntent_cursor
* cursor
)
167 endmntent(cursor
->mtabp
);
170 /* check whether we have to define FS_IOC_FS[GS]ETXATTR ourselves */
173 __u32 fsx_xflags
; /* xflags field value (get/set) */
174 __u32 fsx_extsize
; /* extsize field value (get/set)*/
175 __u32 fsx_nextents
; /* nextents field value (get) */
176 __u32 fsx_projid
; /* project identifier (get/set) */
177 __u32 fsx_cowextsize
; /* cow extsize field value (get/set) */
178 unsigned char fsx_pad
[8];
182 * Flags for the fsx_xflags field
184 #define FS_XFLAG_REALTIME 0x00000001 /* data in realtime volume */
185 #define FS_XFLAG_PREALLOC 0x00000002 /* preallocated file extents */
186 #define FS_XFLAG_IMMUTABLE 0x00000008 /* file cannot be modified */
187 #define FS_XFLAG_APPEND 0x00000010 /* all writes append */
188 #define FS_XFLAG_SYNC 0x00000020 /* all writes synchronous */
189 #define FS_XFLAG_NOATIME 0x00000040 /* do not update access time */
190 #define FS_XFLAG_NODUMP 0x00000080 /* do not include in backups */
191 #define FS_XFLAG_RTINHERIT 0x00000100 /* create with rt bit set */
192 #define FS_XFLAG_PROJINHERIT 0x00000200 /* create with parents projid */
193 #define FS_XFLAG_NOSYMLINKS 0x00000400 /* disallow symlink creation */
194 #define FS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */
195 #define FS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
196 #define FS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
197 #define FS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
198 #define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */
199 #define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
201 #define FS_IOC_FSGETXATTR _IOR ('X', 31, struct fsxattr)
202 #define FS_IOC_FSSETXATTR _IOW ('X', 32, struct fsxattr)
206 #ifndef FS_XFLAG_COWEXTSIZE
207 #define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */
210 #endif /* __XFS_FREEBSD_H__ */