btrfs-disk 0.13.0

Platform-independent parsing and writing of btrfs on-disk structures
Documentation
/* Portable shim for <linux/types.h>.
 *
 * On Linux this header is provided by the kernel; on other platforms we
 * supply the handful of typedefs that btrfs_tree.h and btrfs.h need.
 */
#ifndef _LINUX_TYPES_H
#define _LINUX_TYPES_H

#include <stdint.h>
#include <stddef.h>

typedef uint8_t  __u8;
typedef uint16_t __u16;
typedef uint32_t __u32;
typedef uint64_t __u64;

typedef int8_t   __s8;
typedef int16_t  __s16;
typedef int32_t  __s32;
typedef int64_t  __s64;

/* On-disk little-endian types.  bindgen treats these as their
 * underlying integer, which is what we want — we handle endianness
 * in Rust with from_le_bytes(). */
typedef __u16 __le16;
typedef __u32 __le32;
typedef __u64 __le64;

typedef __u16 __be16;
typedef __u32 __be32;
typedef __u64 __be64;

/* btrfs_tree.h uses __DECLARE_FLEX_ARRAY for trailing flex members.
 * The kernel exposes this via <linux/stddef.h>, which on Linux is
 * pulled in transitively from <linux/types.h>.  On other platforms
 * we provide it here so the same headers compile unchanged. */
#ifndef __DECLARE_FLEX_ARRAY
#define __DECLARE_FLEX_ARRAY(TYPE, NAME) \
    struct { \
        struct { } __empty_ ## NAME; \
        TYPE NAME[]; \
    }
#endif

#endif /* _LINUX_TYPES_H */