fs: btrfs: Crossport structure accessor into ctree.h

This brings all structure accessors from btrfs-progs/ctree.h, as in
kernel's ctree.h.

All these accessors handle the endian convert at runtime, and since all
of them are defined as static inline functions, those which aren't used
won't take space in resulting binary.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
This commit is contained in:
Qu Wenruo 2020-06-24 18:02:53 +02:00 committed by Tom Rini
parent 9a9be5ec17
commit be35942546
3 changed files with 1082 additions and 113 deletions

View file

@ -23,6 +23,20 @@
#define cpu_to_le8(v) (v)
#define __le8 u8
/*
* Macros to generate set/get funcs for the struct fields
* assume there is a lefoo_to_cpu for every type, so lets make a simple
* one for u8:
*/
#define le8_to_cpu(v) (v)
#define cpu_to_le8(v) (v)
#define __le8 u8
#define get_unaligned_le8(p) (*((u8 *)(p)))
#define get_unaligned_8(p) (*((u8 *)(p)))
#define put_unaligned_le8(val,p) ((*((u8 *)(p))) = (val))
#define put_unaligned_8(val,p) ((*((u8 *)(p))) = (val))
/*
* Read data from device specified by @desc and @part
*

File diff suppressed because it is too large Load diff

View file

@ -4,20 +4,11 @@
#include <linux/sizes.h>
#include <fs_internal.h>
#include "crypto/hash.h"
#include "ctree.h"
#include "disk-io.h"
#define BTRFS_SUPER_INFO_OFFSET SZ_64K
#define BTRFS_SUPER_INFO_SIZE SZ_4K
static inline u64 btrfs_name_hash(const char *name, int len)
{
u32 crc;
crc = crc32c((u32)~1, (unsigned char *)name, len);
return (u64)crc;
}
int btrfs_csum_data(u16 csum_type, const u8 *data, u8 *out, size_t len);