Skip to contentSkip to conversation

staging: apfs: init APFS filesystem support

RFC PATCH In review Ethan Carter Edwards 10 participants 25 messages Mar 20, 2025 – May 21, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover staging: apfs: init APFS filesystem support

Hello everyone,

In series 2, I have fixed the formatting with clang-format of the lzfse library and fixed the comments to use linux kernel styles. I also removed my Copyright from files where it was not appropriate. Additionally, I removed the encode.c files as they were unused and not compiled into the final module They should be easy enough to add back if needed. I also rebased on Linus's tree, just in case. Nothing broke! ;)

I am holding off on adding Ernesto's Co-developed-by and Signed-off-by tags until I get a better grasp of where this module is headed. I hope to here back from Christian and the LSFMMBPF folks sometime in the next few weeks.

I understand the jury is still out on supporting both reading and writing. As it stands, I have configured the code to support reading/writing on mount, but upstream auto-rw is configurable via a CONFIG option. Some people have expressed that they want the module upstreamed even if only read is supported. I will stay tuned and make changes as needed.

Additionally, I realize that staging/ may not be the correct location for the driver. However, I am basing my upstream process off of the erofs process. They started in staging. I understand that the correct tree and dir will be discussed as next weeks LSFMMBPF summit, so I will wait on their feedback before making any moves.

I am curious to hear everyone's thoughts on this and to start getting the ball rolling for the code-review process. Please feel free to include/CC anyone who may be interested in this driver/the review process. I have included a few people, but have certainly missed others.

Ernesto, the original author, encouraged me to submit any code improvements upstream instead of submitting here. I am upstreaming my code improvements to his tree, but I will continue the effort here in caes upstream fs folks are interested. In any case, my goal here is to create discussion around the project and make the code better while I am at it.

Some people on Asahi channels have mentioned that this driver could be helpful for implementing certain features like the fingerprint reader and simplify the boot process some. This feedback encourages me to continue with this effort. Asahi folks, keep at it, y'all are awesome.

[0]: https://lore.kernel.org/lkml/20250307165054.GA9774@eaf/

---
Changes in v2:
- remove Ethan copyright in files
- cleanup/format lzfse code and comments
- fix a few checkpatch problems
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Ethan Carter Edwards (8):
staging: apfs: init lzfse compression library for APFS
staging: apfs: init unicode.{c,h}
staging: apfs: init apfs_raw.h to handle on-disk structures
staging: apfs: init libzbitmap.{c,h} for decompression
staging: apfs: init APFS
staging: apfs: init build support for APFS
staging: apfs: init TODO and README.rst
MAINTAINERS: apfs: add entry and relevant information

 MAINTAINERS                                      |    6 +
 drivers/staging/Kconfig                          |    2 +
 drivers/staging/apfs/Kconfig                     |   13 +
 drivers/staging/apfs/Makefile                    |   10 +
 drivers/staging/apfs/README.rst                  |   87 +
 drivers/staging/apfs/TODO                        |    7 +
 drivers/staging/apfs/apfs.h                      | 1192 ++++++++
 drivers/staging/apfs/apfs_raw.h                  | 1566 +++++++++++
 drivers/staging/apfs/btree.c                     | 1174 ++++++++
 drivers/staging/apfs/compress.c                  |  441 +++
 drivers/staging/apfs/dir.c                       | 1439 ++++++++++
 drivers/staging/apfs/extents.c                   | 2370 ++++++++++++++++
 drivers/staging/apfs/file.c                      |  163 ++
 drivers/staging/apfs/inode.c                     | 2234 +++++++++++++++
 drivers/staging/apfs/key.c                       |  337 +++
 drivers/staging/apfs/libzbitmap.c                |  448 +++
 drivers/staging/apfs/libzbitmap.h                |   32 +
 drivers/staging/apfs/lzfse/lzfse.h               |   86 +
 drivers/staging/apfs/lzfse/lzfse_decode.c        |   66 +
 drivers/staging/apfs/lzfse/lzfse_decode_base.c   |  725 +++++
 drivers/staging/apfs/lzfse/lzfse_encode_tables.h |  224 ++
 drivers/staging/apfs/lzfse/lzfse_fse.c           |  214 ++
 drivers/staging/apfs/lzfse/lzfse_fse.h           |  632 +++++
 drivers/staging/apfs/lzfse/lzfse_internal.h      |  599 ++++
 drivers/staging/apfs/lzfse/lzfse_tunables.h      |   50 +
 drivers/staging/apfs/lzfse/lzvn_decode_base.c    |  721 +++++
 drivers/staging/apfs/lzfse/lzvn_decode_base.h    |   53 +
 drivers/staging/apfs/lzfse/lzvn_encode_base.h    |  105 +
 drivers/staging/apfs/message.c                   |   29 +
 drivers/staging/apfs/namei.c                     |  132 +
 drivers/staging/apfs/node.c                      | 2069 ++++++++++++++
 drivers/staging/apfs/object.c                    |  315 +++
 drivers/staging/apfs/snapshot.c                  |  683 +++++
 drivers/staging/apfs/spaceman.c                  | 1433 ++++++++++
 drivers/staging/apfs/super.c                     | 2098 ++++++++++++++
 drivers/staging/apfs/symlink.c                   |   77 +
 drivers/staging/apfs/transaction.c               |  959 +++++++
 drivers/staging/apfs/unicode.c                   | 3156 ++++++++++++++++++++++
 drivers/staging/apfs/unicode.h                   |   27 +
 drivers/staging/apfs/xattr.c                     |  911 +++++++
 drivers/staging/apfs/xfield.c                    |  171 ++
 41 files changed, 27056 insertions(+)

---
base-commit: a7f2e10ecd8f18b83951b0bab47ddaf48f93bf47
change-id: 20250210-apfs-9d4478785f80

Best regards,

Signature · 1 line
Ethan Carter Edwards <[email protected]>
#1 lore raw

RFC PATCH v2 1/8 staging: apfs: init lzfse compression library for APFS

This library was originally developed by Apple and is BSD3 licensed. It allows for the reading and writing of LZFSE and LZVN compressed files on APFS filesystems. Encode functionality is not included as the filesystem implementation does not yet support it but could be easily added later if needed.

---
 drivers/staging/apfs/lzfse/lzfse.h               |  86 +++
 drivers/staging/apfs/lzfse/lzfse_decode.c        |  66 +++
 drivers/staging/apfs/lzfse/lzfse_decode_base.c   | 725 +++++++++++++++++++++++
 drivers/staging/apfs/lzfse/lzfse_encode_tables.h | 224 +++++++
 drivers/staging/apfs/lzfse/lzfse_fse.c           | 214 +++++++
 drivers/staging/apfs/lzfse/lzfse_fse.h           | 632 ++++++++++++++++++++
 drivers/staging/apfs/lzfse/lzfse_internal.h      | 599 +++++++++++++++++++
 drivers/staging/apfs/lzfse/lzfse_tunables.h      |  50 ++
 drivers/staging/apfs/lzfse/lzvn_decode_base.c    | 721 ++++++++++++++++++++++
 drivers/staging/apfs/lzfse/lzvn_decode_base.h    |  53 ++
 drivers/staging/apfs/lzfse/lzvn_encode_base.h    | 105 ++++
 11 files changed, 3475 insertions(+)
drivers/staging/apfs/lzfse/lzfse.h new file +86 -0
new file mode 100644
index 0000000000000000000000000000000000000000..573c85b8c9a476291cd8ef89833ae13caf5eaeb6
@@ -0,0 +1,86 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (c) 2015-2016, Apple Inc. All rights reserved.
+ *
+ */
+
+#ifndef LZFSE_H
+#define LZFSE_H
+
+#include <linux/stddef.h>
+#include <linux/types.h>
+
+/*! @abstract Get the required scratch buffer size to compress using LZFSE.   */
+size_t lzfse_encode_scratch_size(void);
+
+/*! @abstract Compress a buffer using LZFSE.
+ *
+ *  @param dst_buffer
+ *  Pointer to the first byte of the destination buffer.
+ *
+ *  @param dst_size
+ *  Size of the destination buffer in bytes.
+ *
+ *  @param src_buffer
+ *  Pointer to the first byte of the source buffer.
+ *
+ *  @param src_size
+ *  Size of the source buffer in bytes.
+ *
+ *  @param scratch_buffer
+ *  If non-NULL, a pointer to scratch space for the routine to use as workspace;
+ *  the routine may use up to lzfse_encode_scratch_size( ) bytes of workspace
+ *  during its operation, and will not perform any internal allocations. If
+ *  NULL, the routine may allocate its own memory to use during operation via
+ *  a single call to malloc( ), and will release it by calling free( ) prior
+ *  to returning. For most use, passing NULL is perfectly satisfactory, but if
+ *  you require strict control over allocation, you will want to pass an
+ *  explicit scratch buffer.
+ *
+ *  @return
+ *  The number of bytes written to the destination buffer if the input is
+ *  successfully compressed. If the input cannot be compressed to fit into
+ *  the provided buffer, or an error occurs, zero is returned, and the
+ *  contents of dst_buffer are unspecified.                                   */
+size_t lzfse_encode_buffer(uint8_t *__restrict dst_buffer, size_t dst_size,
+			   const uint8_t *__restrict src_buffer,
+			   size_t src_size, void *__restrict scratch_buffer);
+
+/*! @abstract Get the required scratch buffer size to decompress using LZFSE. */
+size_t lzfse_decode_scratch_size(void);
+
+/*! @abstract Decompress a buffer using LZFSE.
+ *
+ *  @param dst_buffer
+ *  Pointer to the first byte of the destination buffer.
+ *
+ *  @param dst_size
+ *  Size of the destination buffer in bytes.
+ *
+ *  @param src_buffer
+ *  Pointer to the first byte of the source buffer.
+ *
+ *  @param src_size
+ *  Size of the source buffer in bytes.
+ *
+ *  @param scratch_buffer
+ *  If non-NULL, a pointer to scratch space for the routine to use as workspace;
+ *  the routine may use up to lzfse_decode_scratch_size( ) bytes of workspace
+ *  during its operation, and will not perform any internal allocations. If
+ *  NULL, the routine may allocate its own memory to use during operation via
+ *  a single call to malloc( ), and will release it by calling free( ) prior
+ *  to returning. For most use, passing NULL is perfectly satisfactory, but if
+ *  you require strict control over allocation, you will want to pass an
+ *  explicit scratch buffer.
+ *
+ *  @return
+ *  The number of bytes written to the destination buffer if the input is
+ *  successfully decompressed. If there is not enough space in the destination
+ *  buffer to hold the entire expanded output, only the first dst_size bytes
+ *  will be written to the buffer and dst_size is returned. Note that this
+ *  behavior differs from that of lzfse_encode_buffer.                        */
+size_t lzfse_decode_buffer(uint8_t *__restrict dst_buffer, size_t dst_size,
+			   const uint8_t *__restrict src_buffer,
+			   size_t src_size, void *__restrict scratch_buffer);
+
+#endif /* LZFSE_H */
drivers/staging/apfs/lzfse/lzfse_decode.c new file +66 -0

66 lines not on this page · raw message

drivers/staging/apfs/lzfse/lzfse_decode_base.c new file +725 -0

725 lines not on this page · raw message

drivers/staging/apfs/lzfse/lzfse_encode_tables.h new file +224 -0

224 lines not on this page · raw message

drivers/staging/apfs/lzfse/lzfse_fse.c new file +214 -0

214 lines not on this page · raw message

drivers/staging/apfs/lzfse/lzfse_fse.h new file +632 -0

632 lines not on this page · raw message

drivers/staging/apfs/lzfse/lzfse_internal.h new file +599 -0

599 lines not on this page · raw message

drivers/staging/apfs/lzfse/lzfse_tunables.h new file +50 -0

50 lines not on this page · raw message

drivers/staging/apfs/lzfse/lzvn_decode_base.c new file +721 -0

404 lines not on this page · raw message

drivers/staging/apfs/lzfse/lzvn_decode_base.h new file +53 -0

53 lines not on this page · raw message

drivers/staging/apfs/lzfse/lzvn_encode_base.h new file +105 -0

105 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.48.1

Part of the diff is not shown here. View the raw message.

#2 lore raw

Re: [PATCH RFC v2 1/8] staging: apfs: init lzfse compression library for APFS

Quoted 141 lines · Ethan Carter Edwards

This library was originally developed by Apple and is BSD3 licensed. It allows for the reading and writing of LZFSE and LZVN compressed files on APFS filesystems. Encode functionality is not included as the filesystem implementation does not yet support it but could be easily added later if needed.

---

drivers/staging/apfs/lzfse/lzfse.h               |  86 +++
drivers/staging/apfs/lzfse/lzfse_decode.c        |  66 +++
drivers/staging/apfs/lzfse/lzfse_decode_base.c   | 725 +++++++++++++++++++++++
drivers/staging/apfs/lzfse/lzfse_encode_tables.h | 224 +++++++
drivers/staging/apfs/lzfse/lzfse_fse.c           | 214 +++++++
drivers/staging/apfs/lzfse/lzfse_fse.h           | 632 ++++++++++++++++++++
drivers/staging/apfs/lzfse/lzfse_internal.h      | 599 +++++++++++++++++++
drivers/staging/apfs/lzfse/lzfse_tunables.h      |  50 ++
drivers/staging/apfs/lzfse/lzvn_decode_base.c    | 721 ++++++++++++++++++++++
drivers/staging/apfs/lzfse/lzvn_decode_base.h    |  53 ++
drivers/staging/apfs/lzfse/lzvn_encode_base.h    | 105 ++++
11 files changed, 3475 insertions(+)
drivers/staging/apfs/lzfse/lzfse.h new file +86 -0
new file mode 100644
index 0000000000000000000000000000000000000000..573c85b8c9a476291cd8ef89833ae13caf5eaeb6
@@ -0,0 +1,86 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (c) 2015-2016, Apple Inc. All rights reserved.
+ *
+ */
+
+#ifndef LZFSE_H
+#define LZFSE_H
+
+#include <linux/stddef.h>
+#include <linux/types.h>
+
+/*! @abstract Get the required scratch buffer size to compress using LZFSE.   */
+size_t lzfse_encode_scratch_size(void);
+
+/*! @abstract Compress a buffer using LZFSE.
+ *
+ *  @param dst_buffer
+ *  Pointer to the first byte of the destination buffer.
+ *
+ *  @param dst_size
+ *  Size of the destination buffer in bytes.
+ *
+ *  @param src_buffer
+ *  Pointer to the first byte of the source buffer.
+ *
+ *  @param src_size
+ *  Size of the source buffer in bytes.
+ *
+ *  @param scratch_buffer
+ *  If non-NULL, a pointer to scratch space for the routine to use as workspace;
+ *  the routine may use up to lzfse_encode_scratch_size( ) bytes of workspace
+ *  during its operation, and will not perform any internal allocations. If
+ *  NULL, the routine may allocate its own memory to use during operation via
+ *  a single call to malloc( ), and will release it by calling free( ) prior
+ *  to returning. For most use, passing NULL is perfectly satisfactory, but if
+ *  you require strict control over allocation, you will want to pass an
+ *  explicit scratch buffer.
+ *
+ *  @return
+ *  The number of bytes written to the destination buffer if the input is
+ *  successfully compressed. If the input cannot be compressed to fit into
+ *  the provided buffer, or an error occurs, zero is returned, and the
+ *  contents of dst_buffer are unspecified.                                   */
+size_t lzfse_encode_buffer(uint8_t *__restrict dst_buffer, size_t dst_size,
+               const uint8_t *__restrict src_buffer,
+               size_t src_size, void *__restrict scratch_buffer);
+
+/*! @abstract Get the required scratch buffer size to decompress using LZFSE. */
+size_t lzfse_decode_scratch_size(void);
+
+/*! @abstract Decompress a buffer using LZFSE.
+ *
+ *  @param dst_buffer
+ *  Pointer to the first byte of the destination buffer.
+ *
+ *  @param dst_size
+ *  Size of the destination buffer in bytes.
+ *
+ *  @param src_buffer
+ *  Pointer to the first byte of the source buffer.
+ *
+ *  @param src_size
+ *  Size of the source buffer in bytes.
+ *
+ *  @param scratch_buffer
+ *  If non-NULL, a pointer to scratch space for the routine to use as workspace;
+ *  the routine may use up to lzfse_decode_scratch_size( ) bytes of workspace
+ *  during its operation, and will not perform any internal allocations. If
+ *  NULL, the routine may allocate its own memory to use during operation via
+ *  a single call to malloc( ), and will release it by calling free( ) prior
+ *  to returning. For most use, passing NULL is perfectly satisfactory, but if
+ *  you require strict control over allocation, you will want to pass an
+ *  explicit scratch buffer.
+ *
+ *  @return
+ *  The number of bytes written to the destination buffer if the input is
+ *  successfully decompressed. If there is not enough space in the destination
+ *  buffer to hold the entire expanded output, only the first dst_size bytes
+ *  will be written to the buffer and dst_size is returned. Note that this
+ *  behavior differs from that of lzfse_encode_buffer.                        */
+size_t lzfse_decode_buffer(uint8_t *__restrict dst_buffer, size_t dst_size,
+               const uint8_t *__restrict src_buffer,
+               size_t src_size, void *__restrict scratch_buffer);
+
+#endif /* LZFSE_H */
drivers/staging/apfs/lzfse/lzfse_decode.c new file +18 -0
new file mode 100644
index 0000000000000000000000000000000000000000..ef7d3487343af5387a9a5dacc8ed95212ec641c0
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2015-2016, Apple Inc. All rights reserved.
+ *
+ */
+
+/*  LZFSE decode API
+ */
+
+#include <linux/slab.h>
+#include "lzfse.h"
+#include "lzfse_internal.h"
+
+size_t lzfse_decode_scratch_size(void)
+{
+    return sizeof(lzfse_decoder_state);
+}
+

drivers/staging/apfs/lzfse/lzfse_decode.c line 28

Quoted 10 lines
drivers/staging/apfs/lzfse/lzfse_decode.c new file +10 -0
+static size_t lzfse_decode_buffer_with_scratch(
+    uint8_t *__restrict dst_buffer, size_t dst_size,
+    const uint8_t *__restrict src_buffer, size_t src_size,
+    void *__restrict scratch_buffer)
+{
+    int status;
+    lzfse_decoder_state *s = (lzfse_decoder_state *)scratch_buffer;
+    memset(s, 0x00, sizeof(*s));
+
+    // Initialize state

This is not Linux styled comment. This is:

/* Initialize state */

Are you sure you ran check patch? That is something very basic you should do before submitting another revision.

I would suggest running sparse as well, and fix any errors if you get them.

Quoted 3,419 lines
drivers/staging/apfs/lzfse/lzfse_decode.c new file +38 -0
+    s->src = src_buffer;
+    s->src_begin = src_buffer;
+    s->src_end = s->src + src_size;
+    s->dst = dst_buffer;
+    s->dst_begin = dst_buffer;
+    s->dst_end = dst_buffer + dst_size;
+
+    // Decode
+    status = lzfse_decode(s);
+    if (status == LZFSE_STATUS_DST_FULL)
+        return dst_size;
+    if (status != LZFSE_STATUS_OK)
+        return 0; // failed
+    return (size_t)(s->dst - dst_buffer); // bytes written
+}
+
+size_t lzfse_decode_buffer(uint8_t *__restrict dst_buffer, size_t dst_size,
+               const uint8_t *__restrict src_buffer,
+               size_t src_size, void *__restrict scratch_buffer)
+{
+    int has_malloc = 0;
+    size_t ret = 0;
+
+    // Deal with the possible NULL pointer
+    if (scratch_buffer == NULL) {
+        // +1 in case scratch size could be zero
+        scratch_buffer =
+            kmalloc(lzfse_decode_scratch_size() + 1, GFP_KERNEL);
+        has_malloc = 1;
+    }
+    if (scratch_buffer == NULL)
+        return 0;
+    ret = lzfse_decode_buffer_with_scratch(dst_buffer, dst_size, src_buffer,
+                           src_size, scratch_buffer);
+    if (has_malloc)
+        kfree(scratch_buffer);
+    return ret;
+}
drivers/staging/apfs/lzfse/lzfse_decode_base.c new file +725 -0
new file mode 100644
index 0000000000000000000000000000000000000000..5fb9e374b40e7e7c11a27e2e3baf79886b3f0474
@@ -0,0 +1,725 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2015-2016, Apple Inc. All rights reserved.
+ *
+ */
+
+#include "lzfse_internal.h"
+#include "lzvn_decode_base.h"
+
+/*! @abstract Decode an entry value from next bits of stream.
+ *  Return \p value, and set \p *nbits to the number of bits to consume
+ *  (starting with LSB). */
+static inline int lzfse_decode_v1_freq_value(uint32_t bits, int *nbits)
+{
+    static const int8_t lzfse_freq_nbits_table[32] = {
+        2, 3, 2, 5, 2, 3, 2, 8, 2, 3, 2, 5, 2, 3, 2, 14,
+        2, 3, 2, 5, 2, 3, 2, 8, 2, 3, 2, 5, 2, 3, 2, 14
+    };
+    static const int8_t lzfse_freq_value_table[32] = {
+        0, 2, 1, 4, 0, 3, 1, -1, 0, 2, 1, 5, 0, 3, 1, -1,
+        0, 2, 1, 6, 0, 3, 1, -1, 0, 2, 1, 7, 0, 3, 1, -1
+    };
+
+    uint32_t b = bits & 31; // lower 5 bits
+    int n = lzfse_freq_nbits_table[b];
+    *nbits = n;
+
+    // Special cases for > 5 bits encoding
+    if (n == 8)
+        return 8 + ((bits >> 4) & 0xf);
+    if (n == 14)
+        return 24 + ((bits >> 4) & 0x3ff);
+
+    // <= 5 bits encoding from table
+    return lzfse_freq_value_table[b];
+}
+
+/*! @abstract Extracts up to 32 bits from a 64-bit field beginning at
+ *  \p offset, and zero-extends them to a \p uint32_t.
+ *
+ *  If we number the bits of \p v from 0 (least significant) to 63 (most
+ *  significant), the result is bits \p offset to \p offset+nbits-1. */
+static inline uint32_t get_field(uint64_t v, int offset, int nbits)
+{
+    if (nbits == 32)
+        return (uint32_t)(v >> offset);
+    return (uint32_t)((v >> offset) & ((1 << nbits) - 1));
+}
+
+/*! @abstract Return \c header_size field from a \c lzfse_compressed_block_header_v2. */
+static inline uint32_t
+lzfse_decode_v2_header_size(const lzfse_compressed_block_header_v2 *in)
+{
+    return get_field(in->packed_fields[2], 0, 32);
+}
+
+/*! @abstract Decode all fields from a \c lzfse_compressed_block_header_v2 to a
+ * \c lzfse_compressed_block_header_v1.
+ * @return 0 on success.
+ * @return -1 on failure. */
+static inline int lzfse_decode_v1(lzfse_compressed_block_header_v1 *out,
+                  const lzfse_compressed_block_header_v2 *in)
+{
+    uint64_t v0;
+    uint64_t v1;
+    uint64_t v2;
+    uint16_t *dst = NULL;
+    const uint8_t *src = NULL;
+    const uint8_t *src_end = NULL;
+    uint32_t accum = 0;
+    int accum_nbits = 0;
+    int nbits = 0;
+    int i;
+
+    // Clear all fields
+    memset(out, 0x00, sizeof(lzfse_compressed_block_header_v1));
+
+    v0 = in->packed_fields[0];
+    v1 = in->packed_fields[1];
+    v2 = in->packed_fields[2];
+
+    out->magic = LZFSE_COMPRESSEDV1_BLOCK_MAGIC;
+    out->n_raw_bytes = in->n_raw_bytes;
+
+    // Literal state
+    out->n_literals = get_field(v0, 0, 20);
+    out->n_literal_payload_bytes = get_field(v0, 20, 20);
+    out->literal_bits = (int)get_field(v0, 60, 3) - 7;
+    out->literal_state[0] = get_field(v1, 0, 10);
+    out->literal_state[1] = get_field(v1, 10, 10);
+    out->literal_state[2] = get_field(v1, 20, 10);
+    out->literal_state[3] = get_field(v1, 30, 10);
+
+    // L,M,D state
+    out->n_matches = get_field(v0, 40, 20);
+    out->n_lmd_payload_bytes = get_field(v1, 40, 20);
+    out->lmd_bits = (int)get_field(v1, 60, 3) - 7;
+    out->l_state = get_field(v2, 32, 10);
+    out->m_state = get_field(v2, 42, 10);
+    out->d_state = get_field(v2, 52, 10);
+
+    // Total payload size
+    out->n_payload_bytes =
+        out->n_literal_payload_bytes + out->n_lmd_payload_bytes;
+
+    // Freq tables
+    dst = &(out->l_freq[0]);
+    src = &(in->freq[0]);
+    src_end = (const uint8_t *)in +
+          get_field(v2, 0, 32); // first byte after header
+    accum = 0;
+    accum_nbits = 0;
+
+    // No freq tables?
+    if (src_end == src)
+        return 0; // OK, freq tables were omitted
+
+    for (i = 0;
+         i < LZFSE_ENCODE_L_SYMBOLS + LZFSE_ENCODE_M_SYMBOLS +
+             LZFSE_ENCODE_D_SYMBOLS + LZFSE_ENCODE_LITERAL_SYMBOLS;
+         i++) {
+        // Refill accum, one byte at a time, until we reach end of header, or accum
+        // is full
+        while (src < src_end && accum_nbits + 8 <= 32) {
+            accum |= (uint32_t)(*src) << accum_nbits;
+            accum_nbits += 8;
+            src++;
+        }
+
+        // Decode and store value
+        nbits = 0;
+        dst[i] = lzfse_decode_v1_freq_value(accum, &nbits);
+
+        if (nbits > accum_nbits)
+            return -1; // failed
+
+        // Consume nbits bits
+        accum >>= nbits;
+        accum_nbits -= nbits;
+    }
+
+    if (accum_nbits >= 8 || src != src_end)
+        return -1; // we need to end up exactly at the end of header, with less than
+            // 8 bits in accumulator
+
+    return 0;
+}
+
+static inline void copy(uint8_t *dst, const uint8_t *src, size_t length)
+{
+    const uint8_t *dst_end = dst + length;
+    do {
+        copy8(dst, src);
+        dst += 8;
+        src += 8;
+    } while (dst < dst_end);
+}
+
+static int lzfse_decode_lmd(lzfse_decoder_state *s)
+{
+    lzfse_compressed_block_decoder_state *bs =
+        &(s->compressed_lzfse_block_state);
+    fse_state l_state = bs->l_state;
+    fse_state m_state = bs->m_state;
+    fse_state d_state = bs->d_state;
+    fse_in_stream in = bs->lmd_in_stream;
+    const uint8_t *src_start = s->src_begin;
+    const uint8_t *src = s->src + bs->lmd_in_buf;
+    const uint8_t *lit = bs->current_literal;
+    uint8_t *dst = s->dst;
+    uint32_t symbols = bs->n_matches;
+    int32_t L = bs->l_value;
+    int32_t M = bs->m_value;
+    int32_t D = bs->d_value;
+    int32_t new_d;
+
+    //  Number of bytes remaining in the destination buffer, minus 32 to
+    //  provide a margin of safety for using overlarge copies on the fast path.
+    //  This is a signed quantity, and may go negative when we are close to the
+    //  end of the buffer.  That's OK; we're careful about how we handle it
+    //  in the slow-and-careful match execution path.
+    ptrdiff_t remaining_bytes = s->dst_end - dst - 32;
+
+    //  If L or M is non-zero, that means that we have already started decoding
+    //  this block, and that we needed to interrupt decoding to get more space
+    //  from the caller.  There's a pending L, M, D triplet that we weren't
+    //  able to completely process.  Jump ahead to finish executing that symbol
+    //  before decoding new values.
+    if (L || M)
+        goto ExecuteMatch;
+
+    while (symbols > 0) {
+        int res;
+        //  Decode the next L, M, D symbol from the input stream.
+        res = fse_in_flush(&in, &src, src_start);
+        if (res) {
+            return LZFSE_STATUS_ERROR;
+        }
+        L = fse_value_decode(&l_state, bs->l_decoder, &in);
+        if ((lit + L) >=
+            (bs->literals + LZFSE_LITERALS_PER_BLOCK + 64)) {
+            return LZFSE_STATUS_ERROR;
+        }
+        res = fse_in_flush2(&in, &src, src_start);
+        if (res) {
+            return LZFSE_STATUS_ERROR;
+        }
+        M = fse_value_decode(&m_state, bs->m_decoder, &in);
+        res = fse_in_flush2(&in, &src, src_start);
+        if (res) {
+            return LZFSE_STATUS_ERROR;
+        }
+        new_d = fse_value_decode(&d_state, bs->d_decoder, &in);
+        D = new_d ? new_d : D;
+        symbols--;
+
+ExecuteMatch:
+        //  Error if D is out of range, so that we avoid passing through
+        //  uninitialized data or accesssing memory out of the destination
+        //  buffer.
+        if ((uint32_t)D > dst + L - s->dst_begin)
+            return LZFSE_STATUS_ERROR;
+
+        if (L + M <= remaining_bytes) {
+            size_t i;
+            //  If we have plenty of space remaining, we can copy the literal
+            //  and match with 16- and 32-byte operations, without worrying
+            //  about writing off the end of the buffer.
+            remaining_bytes -= L + M;
+            copy(dst, lit, L);
+            dst += L;
+            lit += L;
+            //  For the match, we have two paths; a fast copy by 16-bytes if
+            //  the match distance is large enough to allow it, and a more
+            //  careful path that applies a permutation to account for the
+            //  possible overlap between source and destination if the distance
+            //  is small.
+            if (D >= 8 || D >= M)
+                copy(dst, dst - D, M);
+            else
+                for (i = 0; i < M; i++)
+                    dst[i] = dst[i - D];
+            dst += M;
+        }
+
+        else {
+            //  Otherwise, we are very close to the end of the destination
+            //  buffer, so we cannot use wide copies that slop off the end
+            //  of the region that we are copying to. First, we restore
+            //  the true length remaining, rather than the sham value we've
+            //  been using so far.
+            remaining_bytes += 32;
+            //  Now, we process the literal. Either there's space for it
+            //  or there isn't; if there is, we copy the whole thing and
+            //  update all the pointers and lengths to reflect the copy.
+            if (L <= remaining_bytes) {
+                size_t i;
+                for (i = 0; i < L; i++)
+                    dst[i] = lit[i];
+                dst += L;
+                lit += L;
+                remaining_bytes -= L;
+                L = 0;
+            }
+            //  There isn't enough space to fit the whole literal. Copy as
+            //  much of it as we can, update the pointers and the value of
+            //  L, and report that the destination buffer is full. Note that
+            //  we always write right up to the end of the destination buffer.
+            else {
+                size_t i;
+                for (i = 0; i < remaining_bytes; i++)
+                    dst[i] = lit[i];
+                dst += remaining_bytes;
+                lit += remaining_bytes;
+                L -= remaining_bytes;
+                goto DestinationBufferIsFull;
+            }
+            //  The match goes just like the literal does. We copy as much as
+            //  we can byte-by-byte, and if we reach the end of the buffer
+            //  before finishing, we return to the caller indicating that
+            //  the buffer is full.
+            if (M <= remaining_bytes) {
+                size_t i;
+                for (i = 0; i < M; i++)
+                    dst[i] = dst[i - D];
+                dst += M;
+                remaining_bytes -= M;
+                M = 0;
+                (void)M; // no dead store warning
+                    //  We don't need to update M = 0, because there's no partial
+                    //  symbol to continue executing. Either we're at the end of
+                    //  the block, in which case we will never need to resume with
+                    //  this state, or we're going to decode another L, M, D set,
+                    //  which will overwrite M anyway.
+                    //
+                    // But we still set M = 0, to maintain the post-condition.
+            } else {
+                size_t i;
+                for (i = 0; i < remaining_bytes; i++)
+                    dst[i] = dst[i - D];
+                dst += remaining_bytes;
+                M -= remaining_bytes;
+DestinationBufferIsFull:
+                //  Because we want to be able to resume decoding where we've left
+                //  off (even in the middle of a literal or match), we need to
+                //  update all of the block state fields with the current values
+                //  so that we can resume execution from this point once the
+                //  caller has given us more space to write into.
+                bs->l_value = L;
+                bs->m_value = M;
+                bs->d_value = D;
+                bs->l_state = l_state;
+                bs->m_state = m_state;
+                bs->d_state = d_state;
+                bs->lmd_in_stream = in;
+                bs->n_matches = symbols;
+                bs->lmd_in_buf = (uint32_t)(src - s->src);
+                bs->current_literal = lit;
+                s->dst = dst;
+                return LZFSE_STATUS_DST_FULL;
+            }
+            //  Restore the "sham" decremented value of remaining_bytes and
+            //  continue to the next L, M, D triple. We'll just be back in
+            //  the careful path again, but this only happens at the very end
+            //  of the buffer, so a little minor inefficiency here is a good
+            //  tradeoff for simpler code.
+            remaining_bytes -= 32;
+        }
+    }
+    //  Because we've finished with the whole block, we don't need to update
+    //  any of the blockstate fields; they will not be used again. We just
+    //  update the destination pointer in the state object and return.
+    s->dst = dst;
+    return LZFSE_STATUS_OK;
+}
+
+int lzfse_decode(lzfse_decoder_state *s)
+{
+    while (1) {
+        // Are we inside a block?
+        switch (s->block_magic) {
+        case LZFSE_NO_BLOCK_MAGIC: {
+            uint32_t magic;
+            // We need at least 4 bytes of magic number to identify next block
+            if (s->src + 4 > s->src_end)
+                return LZFSE_STATUS_SRC_EMPTY; // SRC truncated
+            magic = load4(s->src);
+
+            if (magic == LZFSE_ENDOFSTREAM_BLOCK_MAGIC) {
+                s->src += 4;
+                s->end_of_stream = 1;
+                return LZFSE_STATUS_OK; // done
+            }
+
+            if (magic == LZFSE_UNCOMPRESSED_BLOCK_MAGIC) {
+                uncompressed_block_decoder_state *bs = NULL;
+                if (s->src + sizeof(uncompressed_block_header) >
+                    s->src_end)
+                    return LZFSE_STATUS_SRC_EMPTY; // SRC truncated
+                // Setup state for uncompressed block
+                bs = &(s->uncompressed_block_state);
+                bs->n_raw_bytes = load4(
+                    s->src +
+                    offsetof(uncompressed_block_header,
+                         n_raw_bytes));
+                s->src += sizeof(uncompressed_block_header);
+                s->block_magic = magic;
+                break;
+            }
+
+            if (magic == LZFSE_COMPRESSEDLZVN_BLOCK_MAGIC) {
+                lzvn_compressed_block_decoder_state *bs = NULL;
+                if (s->src +
+                        sizeof(lzvn_compressed_block_header) >
+                    s->src_end)
+                    return LZFSE_STATUS_SRC_EMPTY; // SRC truncated
+                // Setup state for compressed LZVN block
+                bs = &(s->compressed_lzvn_block_state);
+                bs->n_raw_bytes = load4(
+                    s->src +
+                    offsetof(lzvn_compressed_block_header,
+                         n_raw_bytes));
+                bs->n_payload_bytes = load4(
+                    s->src +
+                    offsetof(lzvn_compressed_block_header,
+                         n_payload_bytes));
+                bs->d_prev = 0;
+                s->src += sizeof(lzvn_compressed_block_header);
+                s->block_magic = magic;
+                break;
+            }
+
+            if (magic == LZFSE_COMPRESSEDV1_BLOCK_MAGIC ||
+                magic == LZFSE_COMPRESSEDV2_BLOCK_MAGIC) {
+                lzfse_compressed_block_header_v1 header1;
+                size_t header_size = 0;
+                lzfse_compressed_block_decoder_state *bs = NULL;
+
+                // Decode compressed headers
+                if (magic == LZFSE_COMPRESSEDV2_BLOCK_MAGIC) {
+                    const lzfse_compressed_block_header_v2
+                        *header2;
+                    int decodeStatus;
+                    // Check we have the fixed part of the structure
+                    if (s->src +
+                            offsetof(
+                                lzfse_compressed_block_header_v2,
+                                freq) >
+                        s->src_end)
+                        return LZFSE_STATUS_SRC_EMPTY; // SRC truncated
+
+                    // Get size, and check we have the entire structure
+                    header2 =
+                        (const lzfse_compressed_block_header_v2
+                             *)s
+                            ->src; // not aligned, OK
+                    header_size =
+                        lzfse_decode_v2_header_size(
+                            header2);
+                    if (s->src + header_size > s->src_end)
+                        return LZFSE_STATUS_SRC_EMPTY; // SRC truncated
+                    decodeStatus = lzfse_decode_v1(&header1,
+                                       header2);
+                    if (decodeStatus != 0)
+                        return LZFSE_STATUS_ERROR; // failed
+                } else {
+                    if (s->src +
+                            sizeof(lzfse_compressed_block_header_v1) >
+                        s->src_end)
+                        return LZFSE_STATUS_SRC_EMPTY; // SRC truncated
+                    memcpy(&header1, s->src,
+                           sizeof(lzfse_compressed_block_header_v1));
+                    header_size = sizeof(
+                        lzfse_compressed_block_header_v1);
+                }
+
+                // We require the header + entire encoded block to be present in SRC
+                // during the entire block decoding.
+                // This can be relaxed somehow, if it becomes a limiting factor, at the
+                // price of a more complex state maintenance.
+                // For DST, we can't easily require space for the entire decoded block,
+                // because it may expand to something very very large.
+                if (s->src + header_size +
+                        header1.n_literal_payload_bytes +
+                        header1.n_lmd_payload_bytes >
+                    s->src_end)
+                    return LZFSE_STATUS_SRC_EMPTY; // need all encoded block
+
+                // Sanity checks
+                if (lzfse_check_block_header_v1(&header1) !=
+                    0) {
+                    return LZFSE_STATUS_ERROR;
+                }
+
+                // Skip header
+                s->src += header_size;
+
+                // Setup state for compressed V1 block from header
+                bs = &(s->compressed_lzfse_block_state);
+                bs->n_lmd_payload_bytes =
+                    header1.n_lmd_payload_bytes;
+                bs->n_matches = header1.n_matches;
+                fse_init_decoder_table(
+                    LZFSE_ENCODE_LITERAL_STATES,
+                    LZFSE_ENCODE_LITERAL_SYMBOLS,
+                    header1.literal_freq,
+                    bs->literal_decoder);
+                fse_init_value_decoder_table(
+                    LZFSE_ENCODE_L_STATES,
+                    LZFSE_ENCODE_L_SYMBOLS, header1.l_freq,
+                    l_extra_bits, l_base_value,
+                    bs->l_decoder);
+                fse_init_value_decoder_table(
+                    LZFSE_ENCODE_M_STATES,
+                    LZFSE_ENCODE_M_SYMBOLS, header1.m_freq,
+                    m_extra_bits, m_base_value,
+                    bs->m_decoder);
+                fse_init_value_decoder_table(
+                    LZFSE_ENCODE_D_STATES,
+                    LZFSE_ENCODE_D_SYMBOLS, header1.d_freq,
+                    d_extra_bits, d_base_value,
+                    bs->d_decoder);
+
+                // Decode literals
+                {
+                    fse_in_stream in;
+                    const uint8_t *buf_start = s->src_begin;
+                    const uint8_t *buf;
+                    fse_state state0;
+                    fse_state state1;
+                    fse_state state2;
+                    fse_state state3;
+                    uint32_t i;
+
+                    s->src +=
+                        header1.n_literal_payload_bytes; // skip literal payload
+                    buf = s->src; // read bits backwards from the end
+                    if (fse_in_init(&in,
+                            header1.literal_bits,
+                            &buf, buf_start) != 0)
+                        return LZFSE_STATUS_ERROR;
+
+                    state0 = header1.literal_state[0];
+                    state1 = header1.literal_state[1];
+                    state2 = header1.literal_state[2];
+                    state3 = header1.literal_state[3];
+
+                    for (i = 0; i < header1.n_literals;
+                         i +=
+                         4) // n_literals is multiple of 4
+                    {
+#if FSE_IOSTREAM_64
+                        if (fse_in_flush(&in, &buf,
+                                 buf_start) !=
+                            0)
+                            return LZFSE_STATUS_ERROR; // [57, 64] bits
+                        bs->literals[i + 0] = fse_decode(
+                            &state0,
+                            bs->literal_decoder,
+                            &in); // 10b max
+                        bs->literals[i + 1] = fse_decode(
+                            &state1,
+                            bs->literal_decoder,
+                            &in); // 10b max
+                        bs->literals[i + 2] = fse_decode(
+                            &state2,
+                            bs->literal_decoder,
+                            &in); // 10b max
+                        bs->literals[i + 3] = fse_decode(
+                            &state3,
+                            bs->literal_decoder,
+                            &in); // 10b max
+#else
+                        if (fse_in_flush(&in, &buf,
+                                 buf_start) !=
+                            0)
+                            return LZFSE_STATUS_ERROR; // [25, 23] bits
+                        bs->literals[i + 0] = fse_decode(
+                            &state0,
+                            bs->literal_decoder,
+                            &in); // 10b max
+                        bs->literals[i + 1] = fse_decode(
+                            &state1,
+                            bs->literal_decoder,
+                            &in); // 10b max
+                        if (fse_in_flush(&in, &buf,
+                                 buf_start) !=
+                            0)
+                            return LZFSE_STATUS_ERROR; // [25, 23] bits
+                        bs->literals[i + 2] = fse_decode(
+                            &state2,
+                            bs->literal_decoder,
+                            &in); // 10b max
+                        bs->literals[i + 3] = fse_decode(
+                            &state3,
+                            bs->literal_decoder,
+                            &in); // 10b max
+#endif
+                    }
+
+                    bs->current_literal = bs->literals;
+                } // literals
+
+                // SRC is not incremented to skip the LMD payload, since we need it
+                // during block decode.
+                // We will increment SRC at the end of the block only after this point.
+
+                // Initialize the L,M,D decode stream, do not start decoding matches
+                // yet, and store decoder state
+                {
+                    fse_in_stream in;
+                    // read bits backwards from the end
+                    const uint8_t *buf =
+                        s->src +
+                        header1.n_lmd_payload_bytes;
+                    if (fse_in_init(&in, header1.lmd_bits,
+                            &buf, s->src) != 0)
+                        return LZFSE_STATUS_ERROR;
+
+                    bs->l_state = header1.l_state;
+                    bs->m_state = header1.m_state;
+                    bs->d_state = header1.d_state;
+                    bs->lmd_in_buf =
+                        (uint32_t)(buf - s->src);
+                    bs->l_value = bs->m_value = 0;
+                    //  Initialize D to an illegal value so we can't erroneously use
+                    //  an uninitialized "previous" value.
+                    bs->d_value = -1;
+                    bs->lmd_in_stream = in;
+                }
+
+                s->block_magic = magic;
+                break;
+            }
+
+            // Here we have an invalid magic number
+            return LZFSE_STATUS_ERROR;
+        } // LZFSE_NO_BLOCK_MAGIC
+
+        case LZFSE_UNCOMPRESSED_BLOCK_MAGIC: {
+            uncompressed_block_decoder_state *bs =
+                &(s->uncompressed_block_state);
+
+            //  Compute the size (in bytes) of the data that we will actually copy.
+            //  This size is minimum(bs->n_raw_bytes, space in src, space in dst).
+
+            uint32_t copy_size =
+                bs->n_raw_bytes; // bytes left to copy
+            size_t src_space, dst_space;
+            if (copy_size == 0) {
+                s->block_magic = 0;
+                break;
+            } // end of block
+
+            if (s->src_end <= s->src)
+                return LZFSE_STATUS_SRC_EMPTY; // need more SRC data
+            src_space = s->src_end - s->src;
+            if (copy_size > src_space)
+                copy_size = (uint32_t)
+                    src_space; // limit to SRC data (> 0)
+
+            if (s->dst_end <= s->dst)
+                return LZFSE_STATUS_DST_FULL; // need more DST capacity
+            dst_space = s->dst_end - s->dst;
+            if (copy_size > dst_space)
+                copy_size = (uint32_t)
+                    dst_space; // limit to DST capacity (> 0)
+
+            // Now that we know that the copy size is bounded to the source and
+            // dest buffers, go ahead and copy the data.
+            // We always have copy_size > 0 here
+            memcpy(s->dst, s->src, copy_size);
+            s->src += copy_size;
+            s->dst += copy_size;
+            bs->n_raw_bytes -= copy_size;
+
+            break;
+        } // LZFSE_UNCOMPRESSED_BLOCK_MAGIC
+
+        case LZFSE_COMPRESSEDV1_BLOCK_MAGIC:
+        case LZFSE_COMPRESSEDV2_BLOCK_MAGIC: {
+            int status;
+            lzfse_compressed_block_decoder_state *bs =
+                &(s->compressed_lzfse_block_state);
+            // Require the entire LMD payload to be in SRC
+            if (s->src_end <= s->src ||
+                bs->n_lmd_payload_bytes >
+                    (size_t)(s->src_end - s->src))
+                return LZFSE_STATUS_SRC_EMPTY;
+
+            status = lzfse_decode_lmd(s);
+            if (status != LZFSE_STATUS_OK)
+                return status;
+
+            s->block_magic = LZFSE_NO_BLOCK_MAGIC;
+            s->src += bs->n_lmd_payload_bytes; // to next block
+            break;
+        } // LZFSE_COMPRESSEDV1_BLOCK_MAGIC || LZFSE_COMPRESSEDV2_BLOCK_MAGIC
+
+        case LZFSE_COMPRESSEDLZVN_BLOCK_MAGIC: {
+            lzvn_compressed_block_decoder_state *bs =
+                &(s->compressed_lzvn_block_state);
+            lzvn_decoder_state dstate;
+            size_t src_used, dst_used;
+            if (bs->n_payload_bytes > 0 && s->src_end <= s->src)
+                return LZFSE_STATUS_SRC_EMPTY; // need more SRC data
+
+            // Init LZVN decoder state
+            memset(&dstate, 0x00, sizeof(dstate));
+            dstate.src = s->src;
+            dstate.src_end = s->src_end;
+            if (dstate.src_end - s->src > bs->n_payload_bytes)
+                dstate.src_end =
+                    s->src +
+                    bs->n_payload_bytes; // limit to payload bytes
+            dstate.dst_begin = s->dst_begin;
+            dstate.dst = s->dst;
+            dstate.dst_end = s->dst_end;
+            if (dstate.dst_end - s->dst > bs->n_raw_bytes)
+                dstate.dst_end =
+                    s->dst +
+                    bs->n_raw_bytes; // limit to raw bytes
+            dstate.d_prev = bs->d_prev;
+            dstate.end_of_stream = 0;
+
+            // Run LZVN decoder
+            lzvn_decode(&dstate);
+
+            // Update our state
+            src_used = dstate.src - s->src;
+            dst_used = dstate.dst - s->dst;
+            if (src_used > bs->n_payload_bytes ||
+                dst_used > bs->n_raw_bytes)
+                return LZFSE_STATUS_ERROR; // sanity check
+            s->src = dstate.src;
+            s->dst = dstate.dst;
+            bs->n_payload_bytes -= (uint32_t)src_used;
+            bs->n_raw_bytes -= (uint32_t)dst_used;
+            bs->d_prev = (uint32_t)dstate.d_prev;
+
+            // Test end of block
+            if (bs->n_payload_bytes == 0 && bs->n_raw_bytes == 0 &&
+                dstate.end_of_stream) {
+                s->block_magic = 0;
+                break;
+            } // block done
+
+            // Check for invalid state
+            if (bs->n_payload_bytes == 0 || bs->n_raw_bytes == 0 ||
+                dstate.end_of_stream)
+                return LZFSE_STATUS_ERROR;
+
+            // Here, block is not done and state is valid, so we need more space in dst.
+            return LZFSE_STATUS_DST_FULL;
+        }
+
+        default:
+            return LZFSE_STATUS_ERROR; // invalid magic
+
+        } // switch magic
+
+    } // block loop
+
+    return LZFSE_STATUS_OK;
+}
drivers/staging/apfs/lzfse/lzfse_encode_tables.h new file +224 -0
new file mode 100644
index 0000000000000000000000000000000000000000..da8daac3c8be161a284ca570d60c7903c3703d75
@@ -0,0 +1,224 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (c) 2015-2016, Apple Inc. All rights reserved.
+ *
+ */
+
+#ifndef LZFSE_ENCODE_TABLES_H
+#define LZFSE_ENCODE_TABLES_H
+
+static inline uint8_t l_base_from_value(int32_t value)
+{
+    static const uint8_t sym[LZFSE_ENCODE_MAX_L_VALUE + 1] = {
+        0,  1,    2,  3,    4,  5,    6,  7,    8,  9,    10, 11, 12, 13, 14, 15,
+        16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19
+    };
+    return sym[value];
+}
+static inline uint8_t m_base_from_value(int32_t value)
+{
+    static const uint8_t sym[LZFSE_ENCODE_MAX_M_VALUE + 1] = {
+        0,  1,    2,  3,    4,  5,    6,  7,    8,  9,    10, 11, 12, 13, 14, 15,
+        16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17,
+        17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+        17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+        18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+        19, 19, 19, 19, 19, 19, 19, 19
+    };
+    return sym[value];
+}
+
+static inline uint8_t d_base_from_value(int32_t value)
+{
+    static const uint8_t sym[64 * 4] = {
+        0,  1,    2,  3,    4,  4,    5,  5,    6,  6,    7,  7,    8,  8,    8,  8,
+        9,  9,    9,  9,    10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12,
+        12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14,
+        14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16,
+        16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 24, 24,
+        25, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 27, 28, 28, 28, 28,
+        28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30,
+        30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
+        32, 33, 34, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 40, 40,
+        41, 41, 41, 41, 42, 42, 42, 42, 43, 43, 43, 43, 44, 44, 44, 44,
+        44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 46, 46, 46, 46,
+        46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 48,
+        48, 49, 50, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 56, 56,
+        57, 57, 57, 57, 58, 58, 58, 58, 59, 59, 59, 59, 60, 60, 60, 60,
+        60, 60, 60, 60, 61, 61, 61, 61, 61, 61, 61, 61, 62, 62, 62, 62,
+        62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 0,  0,    0,  0
+    };
+    int index = 0;
+    int in_range_k;
+    in_range_k = (value >= 0 && value < 60);
+    index |= (((value - 0) >> 0) + 0) & -in_range_k;
+    in_range_k = (value >= 60 && value < 1020);
+    index |= (((value - 60) >> 4) + 64) & -in_range_k;
+    in_range_k = (value >= 1020 && value < 16380);
+    index |= (((value - 1020) >> 8) + 128) & -in_range_k;
+    in_range_k = (value >= 16380 && value < 262140);
+    index |= (((value - 16380) >> 12) + 192) & -in_range_k;
+    return sym[index & 255];
+}
+
+#endif // LZFSE_ENCODE_TABLES_H
drivers/staging/apfs/lzfse/lzfse_fse.c new file +214 -0
new file mode 100644
index 0000000000000000000000000000000000000000..50329ccfae48d150b7b3c2322cc76bc8235fedd4
@@ -0,0 +1,214 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2015-2016, Apple Inc. All rights reserved.
+ *
+ */
+
+#include "lzfse_internal.h"
+
+/*  Initialize encoder table T[NSYMBOLS].
+ *  NSTATES = sum FREQ[i] is the number of states (a power of 2)
+ *  NSYMBOLS is the number of symbols.
+ *  FREQ[NSYMBOLS] is a normalized histogram of symbol frequencies, with FREQ[i]
+ *  >= 0.
+ *  Some symbols may have a 0 frequency.  In that case, they should not be
+ *  present in the data.
+ */
+void fse_init_encoder_table(int nstates, int nsymbols,
+                const uint16_t *__restrict freq,
+                fse_encoder_entry *__restrict t)
+{
+    int offset = 0; // current offset
+    int n_clz = __builtin_clz(nstates);
+    int i;
+    for (i = 0; i < nsymbols; i++) {
+        int f = (int)freq[i];
+        int k;
+        if (f == 0)
+            continue; // skip this symbol, no occurrences
+        k = __builtin_clz(f) -
+            n_clz; // shift needed to ensure N <= (F<<K) < 2*N
+        t[i].s0 = (int16_t)((f << k) - nstates);
+        t[i].k = (int16_t)k;
+        t[i].delta0 = (int16_t)(offset - f + (nstates >> k));
+        t[i].delta1 = (int16_t)(offset - f + (nstates >> (k - 1)));
+        offset += f;
+    }
+}
+
+/*  Initialize decoder table T[NSTATES].
+ *  NSTATES = sum FREQ[i] is the number of states (a power of 2)
+ *  NSYMBOLS is the number of symbols.
+ *  FREQ[NSYMBOLS] is a normalized histogram of symbol frequencies, with FREQ[i]
+ *  >= 0.
+ *  Some symbols may have a 0 frequency.  In that case, they should not be
+ *  present in the data.
+ */
+int fse_init_decoder_table(int nstates, int nsymbols,
+               const uint16_t *__restrict freq,
+               int32_t *__restrict t)
+{
+    int n_clz = __builtin_clz(nstates);
+    int sum_of_freq = 0;
+    int i, j0, j;
+    for (i = 0; i < nsymbols; i++) {
+        int f = (int)freq[i];
+        int k;
+        if (f == 0)
+            continue; // skip this symbol, no occurrences
+
+        sum_of_freq += f;
+
+        if (sum_of_freq > nstates) {
+            return -1;
+        }
+
+        k = __builtin_clz(f) -
+            n_clz; // shift needed to ensure N <= (F<<K) < 2*N
+        j0 = ((2 * nstates) >> k) - f;
+
+        // Initialize all states S reached by this symbol: OFFSET <= S < OFFSET + F
+        for (j = 0; j < f; j++) {
+            fse_decoder_entry e;
+
+            e.symbol = (uint8_t)i;
+            if (j < j0) {
+                e.k = (int8_t)k;
+                e.delta = (int16_t)(((f + j) << k) - nstates);
+            } else {
+                e.k = (int8_t)(k - 1);
+                e.delta = (int16_t)((j - j0) << (k - 1));
+            }
+
+            memcpy(t, &e, sizeof(e));
+            t++;
+        }
+    }
+
+    return 0; // OK
+}
+
+/*  Initialize value decoder table T[NSTATES].
+ *  NSTATES = sum FREQ[i] is the number of states (a power of 2)
+ *  NSYMBOLS is the number of symbols.
+ *  FREQ[NSYMBOLS] is a normalized histogram of symbol frequencies, with FREQ[i]
+ *  >= 0.
+ *  SYMBOL_VBITS[NSYMBOLS] and SYMBOLS_VBASE[NSYMBOLS] are the number of value
+ *  bits to read and the base value for each symbol.
+ *  Some symbols may have a 0 frequency.  In that case, they should not be
+ *  present in the data.
+ */
+void fse_init_value_decoder_table(int nstates, int nsymbols,
+                  const uint16_t *__restrict freq,
+                  const uint8_t *__restrict symbol_vbits,
+                  const int32_t *__restrict symbol_vbase,
+                  fse_value_decoder_entry *__restrict t)
+{
+    int n_clz = __builtin_clz(nstates);
+    int i;
+    for (i = 0; i < nsymbols; i++) {
+        fse_value_decoder_entry ei = { 0 };
+        int f = (int)freq[i];
+        int k, j0, j;
+        if (f == 0)
+            continue; // skip this symbol, no occurrences
+
+        k = __builtin_clz(f) -
+            n_clz; // shift needed to ensure N <= (F<<K) < 2*N
+        j0 = ((2 * nstates) >> k) - f;
+
+        ei.value_bits = symbol_vbits[i];
+        ei.vbase = symbol_vbase[i];
+
+        // Initialize all states S reached by this symbol: OFFSET <= S < OFFSET + F
+        for (j = 0; j < f; j++) {
+            fse_value_decoder_entry e = ei;
+
+            if (j < j0) {
+                e.total_bits = (uint8_t)k + e.value_bits;
+                e.delta = (int16_t)(((f + j) << k) - nstates);
+            } else {
+                e.total_bits = (uint8_t)(k - 1) + e.value_bits;
+                e.delta = (int16_t)((j - j0) << (k - 1));
+            }
+
+            memcpy(t, &e, 8);
+            t++;
+        }
+    }
+}
+
+/*  Remove states from symbols until the correct number of states is used.
+ */
+static void fse_adjust_freqs(uint16_t *freq, int overrun, int nsymbols)
+{
+    int shift;
+    for (shift = 3; overrun != 0; shift--) {
+        int sym;
+        for (sym = 0; sym < nsymbols; sym++) {
+            if (freq[sym] > 1) {
+                int n = (freq[sym] - 1) >> shift;
+                if (n > overrun)
+                    n = overrun;
+                freq[sym] -= n;
+                overrun -= n;
+                if (overrun == 0)
+                    break;
+            }
+        }
+    }
+}
+
+/*  Normalize a table T[NSYMBOLS] of occurrences to FREQ[NSYMBOLS].
+ */
+void fse_normalize_freq(int nstates, int nsymbols, const uint32_t *__restrict t,
+            uint16_t *__restrict freq)
+{
+    uint32_t s_count = 0;
+    int remaining = nstates; // must be signed; this may become < 0
+    int max_freq = 0;
+    int max_freq_sym = 0;
+    int shift = __builtin_clz(nstates) - 1;
+    uint32_t highprec_step;
+    int i;
+
+    // Compute the total number of symbol occurrences
+    for (i = 0; i < nsymbols; i++)
+        s_count += t[i];
+
+    if (s_count == 0)
+        highprec_step = 0; // no symbols used
+    else
+        highprec_step = ((uint32_t)1 << 31) / s_count;
+
+    for (i = 0; i < nsymbols; i++) {
+        // Rescale the occurrence count to get the normalized frequency.
+        // Round up if the fractional part is >= 0.5; otherwise round down.
+        // For efficiency, we do this calculation using integer arithmetic.
+        int f = (((t[i] * highprec_step) >> shift) + 1) >> 1;
+
+        // If a symbol was used, it must be given a nonzero normalized frequency.
+        if (f == 0 && t[i] != 0)
+            f = 1;
+
+        freq[i] = f;
+        remaining -= f;
+
+        // Remember the maximum frequency and which symbol had it.
+        if (f > max_freq) {
+            max_freq = f;
+            max_freq_sym = i;
+        }
+    }
+
+    // If there remain states to be assigned, then just assign them to the most
+    // frequent symbol.  Alternatively, if we assigned more states than were
+    // actually available, then either remove states from the most frequent symbol
+    // (for minor overruns) or use the slower adjustment algorithm (for major
+    // overruns).
+    if (-remaining < (max_freq >> 2)) {
+        freq[max_freq_sym] += remaining;
+    } else {
+        fse_adjust_freqs(freq, -remaining, nsymbols);
+    }
+}
drivers/staging/apfs/lzfse/lzfse_fse.h new file +632 -0
new file mode 100644
index 0000000000000000000000000000000000000000..c6a5e4342cba554e391d3b54d5983c659c4e06bb
@@ -0,0 +1,632 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (c) 2015-2016, Apple Inc. All rights reserved.
+ *
+ */
+
+/*  Finite state entropy coding (FSE)
+ *  This is an implementation of the tANS algorithm described by Jarek Duda,
+ *  we use the more descriptive name "Finite State Entropy".
+ */
+
+#ifndef LZFSE_FSE_H
+#define LZFSE_FSE_H
+
+#include <linux/types.h>
+#include <linux/string.h>
+
+/*   Select between 32/64-bit I/O streams for FSE. Note that the FSE stream
+ *   size need not match the word size of the machine, but in practice you
+ *   want to use 64b streams on 64b systems for better performance.
+ */
+#define FSE_IOSTREAM_64 0
+
+#define FSE_INLINE static inline __attribute__((__always_inline__))
+
+/*  MARK: - Bit utils
+ */
+
+/*! @abstract Signed type used to represent bit count. */
+typedef int32_t fse_bit_count;
+
+/*! @abstract Unsigned type used to represent FSE state. */
+typedef uint16_t fse_state;
+
+/*  Mask the NBITS lsb of X. 0 <= NBITS < 64
+ */
+static inline uint64_t fse_mask_lsb64(uint64_t x, fse_bit_count nbits)
+{
+    static const uint64_t mtable[65] = {
+        0x0000000000000000LLU, 0x0000000000000001LLU,
+        0x0000000000000003LLU, 0x0000000000000007LLU,
+        0x000000000000000fLLU, 0x000000000000001fLLU,
+        0x000000000000003fLLU, 0x000000000000007fLLU,
+        0x00000000000000ffLLU, 0x00000000000001ffLLU,
+        0x00000000000003ffLLU, 0x00000000000007ffLLU,
+        0x0000000000000fffLLU, 0x0000000000001fffLLU,
+        0x0000000000003fffLLU, 0x0000000000007fffLLU,
+        0x000000000000ffffLLU, 0x000000000001ffffLLU,
+        0x000000000003ffffLLU, 0x000000000007ffffLLU,
+        0x00000000000fffffLLU, 0x00000000001fffffLLU,
+        0x00000000003fffffLLU, 0x00000000007fffffLLU,
+        0x0000000000ffffffLLU, 0x0000000001ffffffLLU,
+        0x0000000003ffffffLLU, 0x0000000007ffffffLLU,
+        0x000000000fffffffLLU, 0x000000001fffffffLLU,
+        0x000000003fffffffLLU, 0x000000007fffffffLLU,
+        0x00000000ffffffffLLU, 0x00000001ffffffffLLU,
+        0x00000003ffffffffLLU, 0x00000007ffffffffLLU,
+        0x0000000fffffffffLLU, 0x0000001fffffffffLLU,
+        0x0000003fffffffffLLU, 0x0000007fffffffffLLU,
+        0x000000ffffffffffLLU, 0x000001ffffffffffLLU,
+        0x000003ffffffffffLLU, 0x000007ffffffffffLLU,
+        0x00000fffffffffffLLU, 0x00001fffffffffffLLU,
+        0x00003fffffffffffLLU, 0x00007fffffffffffLLU,
+        0x0000ffffffffffffLLU, 0x0001ffffffffffffLLU,
+        0x0003ffffffffffffLLU, 0x0007ffffffffffffLLU,
+        0x000fffffffffffffLLU, 0x001fffffffffffffLLU,
+        0x003fffffffffffffLLU, 0x007fffffffffffffLLU,
+        0x00ffffffffffffffLLU, 0x01ffffffffffffffLLU,
+        0x03ffffffffffffffLLU, 0x07ffffffffffffffLLU,
+        0x0fffffffffffffffLLU, 0x1fffffffffffffffLLU,
+        0x3fffffffffffffffLLU, 0x7fffffffffffffffLLU,
+        0xffffffffffffffffLLU,
+    };
+    return x & mtable[nbits];
+}
+
+/*  Mask the NBITS lsb of X. 0 <= NBITS < 32
+ */
+static inline uint32_t fse_mask_lsb32(uint32_t x, fse_bit_count nbits)
+{
+    static const uint32_t mtable[33] = {
+        0x0000000000000000U, 0x0000000000000001U, 0x0000000000000003U,
+        0x0000000000000007U, 0x000000000000000fU, 0x000000000000001fU,
+        0x000000000000003fU, 0x000000000000007fU, 0x00000000000000ffU,
+        0x00000000000001ffU, 0x00000000000003ffU, 0x00000000000007ffU,
+        0x0000000000000fffU, 0x0000000000001fffU, 0x0000000000003fffU,
+        0x0000000000007fffU, 0x000000000000ffffU, 0x000000000001ffffU,
+        0x000000000003ffffU, 0x000000000007ffffU, 0x00000000000fffffU,
+        0x00000000001fffffU, 0x00000000003fffffU, 0x00000000007fffffU,
+        0x0000000000ffffffU, 0x0000000001ffffffU, 0x0000000003ffffffU,
+        0x0000000007ffffffU, 0x000000000fffffffU, 0x000000001fffffffU,
+        0x000000003fffffffU, 0x000000007fffffffU, 0x00000000ffffffffU,
+    };
+    return x & mtable[nbits];
+}
+
+/*! @abstract Select \c nbits at index \c start from \c x.
+ *  0 <= start <= start+nbits <= 64 */
+FSE_INLINE uint64_t fse_extract_bits64(uint64_t x, fse_bit_count start,
+                       fse_bit_count nbits)
+{
+#if defined(__GNUC__)
+    // If START and NBITS are constants, map to bit-field extraction instructions
+    if (__builtin_constant_p(start) && __builtin_constant_p(nbits))
+        return (x >> start) & ((1LLU << nbits) - 1LLU);
+#endif
+
+    // Otherwise, shift and mask
+    return fse_mask_lsb64(x >> start, nbits);
+}
+
+/*! @abstract Select \c nbits at index \c start from \c x.
+ *  0 <= start <= start+nbits <= 32 */
+FSE_INLINE uint32_t fse_extract_bits32(uint32_t x, fse_bit_count start,
+                       fse_bit_count nbits)
+{
+#if defined(__GNUC__)
+    // If START and NBITS are constants, map to bit-field extraction instructions
+    if (__builtin_constant_p(start) && __builtin_constant_p(nbits))
+        return (x >> start) & ((1U << nbits) - 1U);
+#endif
+
+    // Otherwise, shift and mask
+    return fse_mask_lsb32(x >> start, nbits);
+}
+
+/*  MARK: - Bit stream
+ */
+
+/*  I/O streams
+ *  The streams can be shared between several FSE encoders/decoders, which is why
+ *  they are not in the state struct
+ */
+
+/*! @abstract Output stream, 64-bit accum. */
+typedef struct {
+    uint64_t accum; // Output bits
+    fse_bit_count
+        accum_nbits; // Number of valid bits in ACCUM, other bits are 0
+} fse_out_stream64;
+
+/*! @abstract Output stream, 32-bit accum. */
+typedef struct {
+    uint32_t accum; // Output bits
+    fse_bit_count
+        accum_nbits; // Number of valid bits in ACCUM, other bits are 0
+} fse_out_stream32;
+
+/*! @abstract Object representing an input stream. */
+typedef struct {
+    uint64_t accum; // Input bits
+    fse_bit_count
+        accum_nbits; // Number of valid bits in ACCUM, other bits are 0
+} fse_in_stream64;
+
+/*! @abstract Object representing an input stream. */
+typedef struct {
+    uint32_t accum; // Input bits
+    fse_bit_count
+        accum_nbits; // Number of valid bits in ACCUM, other bits are 0
+} fse_in_stream32;
+
+/*! @abstract Initialize an output stream object. */
+FSE_INLINE void fse_out_init64(fse_out_stream64 *s)
+{
+    s->accum = 0;
+    s->accum_nbits = 0;
+}
+
+/*! @abstract Initialize an output stream object. */
+FSE_INLINE void fse_out_init32(fse_out_stream32 *s)
+{
+    s->accum = 0;
+    s->accum_nbits = 0;
+}
+
+/*! @abstract Write full bytes from the accumulator to output buffer, ensuring
+ * accum_nbits is in [0, 7].
+ * We assume we can write 8 bytes to the output buffer \c (*pbuf[0..7]) in all
+ * cases.
+ * @note *pbuf is incremented by the number of written bytes. */
+FSE_INLINE void fse_out_flush64(fse_out_stream64 *s, uint8_t **pbuf)
+{
+    fse_bit_count nbits = s->accum_nbits &
+                  -8; // number of bits written, multiple of 8
+
+    // Write 8 bytes of current accumulator
+    memcpy(*pbuf, &(s->accum), 8);
+    *pbuf += (nbits >> 3); // bytes
+
+    // Update state
+    s->accum >>= nbits; // remove nbits
+    s->accum_nbits -= nbits;
+}
+
+/*! @abstract Write full bytes from the accumulator to output buffer, ensuring
+ * accum_nbits is in [0, 7].
+ * We assume we can write 4 bytes to the output buffer \c (*pbuf[0..3]) in all
+ * cases.
+ * @note *pbuf is incremented by the number of written bytes. */
+FSE_INLINE void fse_out_flush32(fse_out_stream32 *s, uint8_t **pbuf)
+{
+    fse_bit_count nbits = s->accum_nbits &
+                  -8; // number of bits written, multiple of 8
+
+    // Write 4 bytes of current accumulator
+    memcpy(*pbuf, &(s->accum), 4);
+    *pbuf += (nbits >> 3); // bytes
+
+    // Update state
+    s->accum >>= nbits; // remove nbits
+    s->accum_nbits -= nbits;
+}
+
+/*! @abstract Write the last bytes from the accumulator to output buffer,
+ * ensuring accum_nbits is in [-7, 0]. Bits are padded with 0 if needed.
+ * We assume we can write 8 bytes to the output buffer \c (*pbuf[0..7]) in all
+ * cases.
+ * @note *pbuf is incremented by the number of written bytes. */
+FSE_INLINE void fse_out_finish64(fse_out_stream64 *s, uint8_t **pbuf)
+{
+    fse_bit_count nbits = (s->accum_nbits + 7) &
+                  -8; // number of bits written, multiple of 8
+
+    // Write 8 bytes of current accumulator
+    memcpy(*pbuf, &(s->accum), 8);
+    *pbuf += (nbits >> 3); // bytes
+
+    // Update state
+    s->accum = 0; // remove nbits
+    s->accum_nbits -= nbits;
+}
+
+/*! @abstract Write the last bytes from the accumulator to output buffer,
+ * ensuring accum_nbits is in [-7, 0]. Bits are padded with 0 if needed.
+ * We assume we can write 4 bytes to the output buffer \c (*pbuf[0..3]) in all
+ * cases.
+ * @note *pbuf is incremented by the number of written bytes. */
+FSE_INLINE void fse_out_finish32(fse_out_stream32 *s, uint8_t **pbuf)
+{
+    fse_bit_count nbits = (s->accum_nbits + 7) &
+                  -8; // number of bits written, multiple of 8
+
+    // Write 8 bytes of current accumulator
+    memcpy(*pbuf, &(s->accum), 4);
+    *pbuf += (nbits >> 3); // bytes
+
+    // Update state
+    s->accum = 0; // remove nbits
+    s->accum_nbits -= nbits;
+}
+
+/*! @abstract Accumulate \c n bits \c b to output stream \c s. We \b must have:
+ * 0 <= b < 2^n, and N + s->accum_nbits <= 64.
+ * @note The caller must ensure out_flush is called \b before the accumulator
+ * overflows to more than 64 bits. */
+FSE_INLINE void fse_out_push64(fse_out_stream64 *s, fse_bit_count n, uint64_t b)
+{
+    s->accum |= b << s->accum_nbits;
+    s->accum_nbits += n;
+}
+
+/*! @abstract Accumulate \c n bits \c b to output stream \c s. We \b must have:
+ * 0 <= n < 2^n, and n + s->accum_nbits <= 32.
+ * @note The caller must ensure out_flush is called \b before the accumulator
+ * overflows to more than 32 bits. */
+FSE_INLINE void fse_out_push32(fse_out_stream32 *s, fse_bit_count n, uint32_t b)
+{
+    s->accum |= b << s->accum_nbits;
+    s->accum_nbits += n;
+}
+
+#define DEBUG_CHECK_INPUT_STREAM_PARAMETERS
+
+/*! @abstract   Initialize the fse input stream so that accum holds between 56
+ *  and 63 bits. We never want to have 64 bits in the stream, because that allows
+ *  us to avoid a special case in the fse_in_pull function (eliminating an
+ *  unpredictable branch), while not requiring any additional fse_flush
+ *  operations. This is why we have the special case for n == 0 (in which case
+ *  we want to load only 7 bytes instead of 8). */
+FSE_INLINE int fse_in_checked_init64(fse_in_stream64 *s, fse_bit_count n,
+                     const uint8_t **pbuf,
+                     const uint8_t *buf_start)
+{
+    if (n) {
+        if (*pbuf < buf_start + 8)
+            return -1; // out of range
+        *pbuf -= 8;
+        memcpy(&(s->accum), *pbuf, 8);
+        s->accum_nbits = n + 64;
+    } else {
+        if (*pbuf < buf_start + 7)
+            return -1; // out of range
+        *pbuf -= 7;
+        memcpy(&(s->accum), *pbuf, 7);
+        s->accum &= 0xffffffffffffff;
+        s->accum_nbits = n + 56;
+    }
+
+    if ((s->accum_nbits < 56 || s->accum_nbits >= 64) ||
+        ((s->accum >> s->accum_nbits) != 0)) {
+        return -1; // the incoming input is wrong (encoder should have zeroed the
+            // upper bits)
+    }
+
+    return 0; // OK
+}
+
+/*! @abstract Identical to previous function, but for 32-bit operation
+ * (resulting bit count is between 24 and 31 bits). */
+FSE_INLINE int fse_in_checked_init32(fse_in_stream32 *s, fse_bit_count n,
+                     const uint8_t **pbuf,
+                     const uint8_t *buf_start)
+{
+    if (n) {
+        if (*pbuf < buf_start + 4)
+            return -1; // out of range
+        *pbuf -= 4;
+        memcpy(&(s->accum), *pbuf, 4);
+        s->accum_nbits = n + 32;
+    } else {
+        if (*pbuf < buf_start + 3)
+            return -1; // out of range
+        *pbuf -= 3;
+        memcpy(&(s->accum), *pbuf, 3);
+        s->accum &= 0xffffff;
+        s->accum_nbits = n + 24;
+    }
+
+    if ((s->accum_nbits < 24 || s->accum_nbits >= 32) ||
+        ((s->accum >> s->accum_nbits) != 0)) {
+        return -1; // the incoming input is wrong (encoder should have zeroed the
+            // upper bits)
+    }
+
+    return 0; // OK
+}
+
+/*! @abstract  Read in new bytes from buffer to ensure that we have a full
+ * complement of bits in the stream object (again, between 56 and 63 bits).
+ * checking the new value of \c *pbuf remains >= \c buf_start.
+ * @return 0 if OK.
+ * @return -1 on failure. */
+FSE_INLINE int fse_in_checked_flush64(fse_in_stream64 *s, const uint8_t **pbuf,
+                      const uint8_t *buf_start)
+{
+    //  Get number of bits to add to bring us into the desired range.
+    fse_bit_count nbits = (63 - s->accum_nbits) & -8;
+    //  Convert bits to bytes and decrement buffer address, then load new data.
+    const uint8_t *buf = (*pbuf) - (nbits >> 3);
+    uint64_t incoming;
+    if (buf < buf_start) {
+        return -1; // out of range
+    }
+    *pbuf = buf;
+    memcpy(&incoming, buf, 8);
+    // Update the state object and verify its validity (in DEBUG).
+    s->accum = (s->accum << nbits) | fse_mask_lsb64(incoming, nbits);
+    s->accum_nbits += nbits;
+    DEBUG_CHECK_INPUT_STREAM_PARAMETERS
+    return 0; // OK
+}
+
+/*! @abstract Identical to previous function (but again, we're only filling
+ * a 32-bit field with between 24 and 31 bits). */
+FSE_INLINE int fse_in_checked_flush32(fse_in_stream32 *s, const uint8_t **pbuf,
+                      const uint8_t *buf_start)
+{
+    //  Get number of bits to add to bring us into the desired range.
+    fse_bit_count nbits = (31 - s->accum_nbits) & -8;
+
+    if (nbits > 0) {
+        //  Convert bits to bytes and decrement buffer address, then load new data.
+        const uint8_t *buf = (*pbuf) - (nbits >> 3);
+        uint32_t incoming;
+        if (buf < buf_start) {
+            return -1; // out of range
+        }
+
+        *pbuf = buf;
+
+        incoming = *((uint32_t *)buf);
+
+        // Update the state object and verify its validity (in DEBUG).
+        s->accum = (s->accum << nbits) |
+               fse_mask_lsb32(incoming, nbits);
+        s->accum_nbits += nbits;
+    }
+    DEBUG_CHECK_INPUT_STREAM_PARAMETERS
+    return 0; // OK
+}
+
+/*! @abstract Pull n bits out of the fse stream object. */
+FSE_INLINE uint64_t fse_in_pull64(fse_in_stream64 *s, fse_bit_count n)
+{
+    uint64_t result;
+    s->accum_nbits -= n;
+    result = s->accum >> s->accum_nbits;
+    s->accum = fse_mask_lsb64(s->accum, s->accum_nbits);
+    return result;
+}
+
+/*! @abstract Pull n bits out of the fse stream object. */
+FSE_INLINE uint32_t fse_in_pull32(fse_in_stream32 *s, fse_bit_count n)
+{
+    uint32_t result;
+    s->accum_nbits -= n;
+    result = s->accum >> s->accum_nbits;
+    s->accum = fse_mask_lsb32(s->accum, s->accum_nbits);
+    return result;
+}
+
+/*  MARK: - Encode/Decode
+ */
+
+/*  Map to 32/64-bit implementations and types for I/O
+ */
+#if FSE_IOSTREAM_64
+
+typedef uint64_t fse_bits;
+typedef fse_out_stream64 fse_out_stream;
+typedef fse_in_stream64 fse_in_stream;
+#define fse_mask_lsb fse_mask_lsb64
+#define fse_extract_bits fse_extract_bits64
+#define fse_out_init fse_out_init64
+#define fse_out_flush fse_out_flush64
+#define fse_out_finish fse_out_finish64
+#define fse_out_push fse_out_push64
+#define fse_in_init fse_in_checked_init64
+#define fse_in_checked_init fse_in_checked_init64
+#define fse_in_flush fse_in_checked_flush64
+#define fse_in_checked_flush fse_in_checked_flush64
+#define fse_in_flush2(_unused, _parameters, _unused2) 0 /* nothing */
+#define fse_in_checked_flush2(_unused, _parameters) /* nothing */
+#define fse_in_pull fse_in_pull64
+
+#else
+
+typedef uint32_t fse_bits;
+typedef fse_out_stream32 fse_out_stream;
+typedef fse_in_stream32 fse_in_stream;
+#define fse_mask_lsb fse_mask_lsb32
+#define fse_extract_bits fse_extract_bits32
+#define fse_out_init fse_out_init32
+#define fse_out_flush fse_out_flush32
+#define fse_out_finish fse_out_finish32
+#define fse_out_push fse_out_push32
+#define fse_in_init fse_in_checked_init32
+#define fse_in_checked_init fse_in_checked_init32
+#define fse_in_flush fse_in_checked_flush32
+#define fse_in_checked_flush fse_in_checked_flush32
+#define fse_in_flush2 fse_in_checked_flush32
+#define fse_in_checked_flush2 fse_in_checked_flush32
+#define fse_in_pull fse_in_pull32
+
+#endif
+
+/*! @abstract Entry for one symbol in the encoder table (64b). */
+typedef struct {
+    int16_t s0; // First state requiring a K-bit shift
+    int16_t k; // States S >= S0 are shifted K bits. States S < S0 are
+        // shifted K-1 bits
+    int16_t delta0; // Relative increment used to compute next state if S >= S0
+    int16_t delta1; // Relative increment used to compute next state if S < S0
+} fse_encoder_entry;
+
+/*! @abstract  Entry for one state in the decoder table (32b). */
+typedef struct { // DO NOT REORDER THE FIELDS
+    int8_t k; // Number of bits to read
+    uint8_t symbol; // Emitted symbol
+    int16_t delta; // Signed increment used to compute next state (+bias)
+} fse_decoder_entry;
+
+/*! @abstract  Entry for one state in the value decoder table (64b). */
+typedef struct { // DO NOT REORDER THE FIELDS
+    uint8_t total_bits; // state bits + extra value bits = shift for next decode
+    uint8_t value_bits; // extra value bits
+    int16_t delta; // state base (delta)
+    int32_t vbase; // value base
+} fse_value_decoder_entry;
+
+/*! @abstract Encode SYMBOL using the encoder table, and update \c *pstate,
+ *  \c out.
+ *  @note The caller must ensure we have enough bits available in the output
+ *  stream accumulator. */
+FSE_INLINE void fse_encode(fse_state *__restrict pstate,
+               const fse_encoder_entry *__restrict encoder_table,
+               fse_out_stream *__restrict out, uint8_t symbol)
+{
+    int s = *pstate;
+    fse_encoder_entry e = encoder_table[symbol];
+    int s0 = e.s0;
+    int k = e.k;
+    int delta0 = e.delta0;
+    int delta1 = e.delta1;
+
+    // Number of bits to write
+    int hi = s >= s0;
+    fse_bit_count nbits = hi ? k : (k - 1);
+    fse_state delta = hi ? delta0 : delta1;
+
+    // Write lower NBITS of state
+    fse_bits b = fse_mask_lsb(s, nbits);
+    fse_out_push(out, nbits, b);
+
+    // Update state with remaining bits and delta
+    *pstate = delta + (s >> nbits);
+}
+
+/*! @abstract Decode and return symbol using the decoder table, and update
+ *  \c *pstate, \c in.
+ *  @note The caller must ensure we have enough bits available in the input
+ *  stream accumulator. */
+FSE_INLINE uint8_t fse_decode(fse_state *__restrict pstate,
+                  const int32_t *__restrict decoder_table,
+                  fse_in_stream *__restrict in)
+{
+    int32_t e = decoder_table[*pstate];
+
+    // Update state from K bits of input + DELTA
+    *pstate = (fse_state)(e >> 16) + (fse_state)fse_in_pull(in, e & 0xff);
+
+    // Return the symbol for this state
+    return fse_extract_bits(e, 8, 8); // symbol
+}
+
+/*! @abstract Decode and return value using the decoder table, and update \c
+ *  *pstate, \c in.
+ * \c value_decoder_table[nstates]
+ * @note The caller must ensure we have enough bits available in the input
+ * stream accumulator. */
+FSE_INLINE int32_t
+fse_value_decode(fse_state *__restrict pstate,
+         const fse_value_decoder_entry *value_decoder_table,
+         fse_in_stream *__restrict in)
+{
+    fse_value_decoder_entry entry = value_decoder_table[*pstate];
+    uint32_t state_and_value_bits =
+        (uint32_t)fse_in_pull(in, entry.total_bits);
+    *pstate = (fse_state)(entry.delta +
+                  (state_and_value_bits >> entry.value_bits));
+    return (int32_t)(entry.vbase +
+             fse_mask_lsb(state_and_value_bits, entry.value_bits));
+}
+
+/*  MARK: - Tables
+ */
+
+/*  IMPORTANT: To properly decode an FSE encoded stream, both encoder/decoder
+ *  tables shall be initialized with the same parameters, including the
+ *  FREQ[NSYMBOL] array.
+ *
+ */
+
+/*! @abstract Sanity check on frequency table, verify sum of \c freq
+ *  is <= \c number_of_states. */
+FSE_INLINE int fse_check_freq(const uint16_t *freq_table,
+                  const size_t table_size,
+                  const size_t number_of_states)
+{
+    size_t sum_of_freq = 0;
+    int i;
+    for (i = 0; i < table_size; i++) {
+        sum_of_freq += freq_table[i];
+    }
+    return (sum_of_freq > number_of_states) ? -1 : 0;
+}
+
+/*! @abstract Initialize encoder table \c t[nsymbols].
+ *
+ * @param nstates
+ * sum \c freq[i]; the number of states (a power of 2).
+ *
+ * @param nsymbols
+ * the number of symbols.
+ *
+ * @param freq[nsymbols]
+ * is a normalized histogram of symbol frequencies, with \c freq[i] >= 0.
+ * Some symbols may have a 0 frequency. In that case they should not be
+ * present in the data.
+ */
+void fse_init_encoder_table(int nstates, int nsymbols,
+                const uint16_t *__restrict freq,
+                fse_encoder_entry *__restrict t);
+
+/*! @abstract Initialize decoder table \c t[nstates].
+ *
+ * @param nstates
+ * sum \c freq[i]; the number of states (a power of 2).
+ *
+ * @param nsymbols
+ * the number of symbols.
+ *
+ * @param feq[nsymbols]
+ * a normalized histogram of symbol frequencies, with \c freq[i] >= 0.
+ * Some symbols may have a 0 frequency. In that case they should not be
+ * present in the data.
+ *
+ * @return 0 if OK.
+ * @return -1 on failure.
+ */
+int fse_init_decoder_table(int nstates, int nsymbols,
+               const uint16_t *__restrict freq,
+               int32_t *__restrict t);
+
+/*! @abstract Initialize value decoder table \c t[nstates].
+ *
+ * @param nstates
+ * sum \cfreq[i]; the number of states (a power of 2).
+ *
+ * @param nsymbols
+ * the number of symbols.
+ *
+ * @param freq[nsymbols]
+ * a normalized histogram of symbol frequencies, with \c freq[i] >= 0.
+ * \c symbol_vbits[nsymbols] and \c symbol_vbase[nsymbols] are the number of
+ * value bits to read and the base value for each symbol.
+ * Some symbols may have a 0 frequency.  In that case they should not be
+ * present in the data.
+ */
+void fse_init_value_decoder_table(int nstates, int nsymbols,
+                  const uint16_t *__restrict freq,
+                  const uint8_t *__restrict symbol_vbits,
+                  const int32_t *__restrict symbol_vbase,
+                  fse_value_decoder_entry *__restrict t);
+
+/*! @abstract Normalize a table \c t[nsymbols] of occurrences to
+ *  \c freq[nsymbols]. */
+void fse_normalize_freq(int nstates, int nsymbols, const uint32_t *__restrict t,
+            uint16_t *__restrict freq);
+
+#endif /* LZFSE_FSE_H */
drivers/staging/apfs/lzfse/lzfse_internal.h new file +599 -0
new file mode 100644
index 0000000000000000000000000000000000000000..afca0b3eae410dc0ac4b93b319186a16c3441a4d
@@ -0,0 +1,599 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (c) 2015-2016, Apple Inc. All rights reserved.
+ *
+ */
+
+#ifndef LZFSE_INTERNAL_H
+#define LZFSE_INTERNAL_H
+
+/*   Unlike the tunable parameters defined in lzfse_tunables.h, you probably
+ *   should not modify the values defined in this header. Doing so will either
+ *   break the compressor, or result in a compressed data format that is
+ *   incompatible.
+ */
+
+#define LZFSE_INLINE static inline __attribute__((__always_inline__))
+
+#include "lzfse_fse.h"
+#include "lzfse_tunables.h"
+#include <linux/limits.h>
+#include <linux/stddef.h>
+
+/*   Throughout LZFSE we refer to "L", "M" and "D"; these will always appear as
+ *   a triplet, and represent a "usual" LZ-style literal and match pair.  "L"
+ *   is the number of literal bytes, "M" is the number of match bytes, and "D"
+ *   is the match "distance"; the distance in bytes between the current pointer
+ *   and the start of the match.
+ */
+#define LZFSE_ENCODE_HASH_VALUES (1 << LZFSE_ENCODE_HASH_BITS)
+#define LZFSE_ENCODE_L_SYMBOLS 20
+#define LZFSE_ENCODE_M_SYMBOLS 20
+#define LZFSE_ENCODE_D_SYMBOLS 64
+#define LZFSE_ENCODE_LITERAL_SYMBOLS 256
+#define LZFSE_ENCODE_L_STATES 64
+#define LZFSE_ENCODE_M_STATES 64
+#define LZFSE_ENCODE_D_STATES 256
+#define LZFSE_ENCODE_LITERAL_STATES 1024
+#define LZFSE_MATCHES_PER_BLOCK 10000
+#define LZFSE_LITERALS_PER_BLOCK (4 * LZFSE_MATCHES_PER_BLOCK)
+#define LZFSE_DECODE_LITERALS_PER_BLOCK (4 * LZFSE_DECODE_MATCHES_PER_BLOCK)
+
+/*   LZFSE internal status. These values are used by internal LZFSE routines
+ *   as return codes.  There should not be any good reason to change their
+ *   values; it is plausible that additional codes might be added in the
+ *   future.
+ */
+#define LZFSE_STATUS_OK 0
+#define LZFSE_STATUS_SRC_EMPTY -1
+#define LZFSE_STATUS_DST_FULL -2
+#define LZFSE_STATUS_ERROR -3
+
+/*   Type representing an offset between elements in a buffer. On 64-bit
+ *   systems, this is stored in a 64-bit container to avoid extra sign-
+ *   extension operations in addressing arithmetic, but the value is always
+ *   representable as a 32-bit signed value in LZFSE's usage.
+ */
+#if defined(_M_AMD64) || defined(__x86_64__) || defined(__arm64__)
+typedef int64_t lzfse_offset;
+#else
+typedef int32_t lzfse_offset;
+#endif
+
+typedef uint64_t uintmax_t;
+
+/*! @abstract History table set. Each line of the history table represents a set
+ *  of candidate match locations, each of which begins with four bytes with the
+ *  same hash. The table contains not only the positions, but also the first
+ *  four bytes at each position. This doubles the memory footprint of the
+ *  table, but allows us to quickly eliminate false-positive matches without
+ *  doing any pointer chasing and without pulling in any additional cachelines.
+ *  This provides a large performance win in practice. */
+typedef struct {
+    int32_t pos[LZFSE_ENCODE_HASH_WIDTH];
+    uint32_t value[LZFSE_ENCODE_HASH_WIDTH];
+} lzfse_history_set;
+
+/*! @abstract An lzfse match is a sequence of bytes in the source buffer that
+ *  exactly matches an earlier (but possibly overlapping) sequence of bytes in
+ *  the same buffer.
+ *  @code
+ *  exeMPLARYexaMPLE
+ *  |  |     | ||-|--- lzfse_match2.length=3
+ *  |  |     | ||----- lzfse_match2.pos
+ *  |  |     |-|------ lzfse_match1.length=3
+ *  |  |     |-------- lzfse_match1.pos
+ *  |  |-------------- lzfse_match2.ref
+ *  |----------------- lzfse_match1.ref
+ *  @endcode
+ */
+typedef struct {
+    //  Offset of the first byte in the match.
+    lzfse_offset pos;
+    //  First byte of the source -- the earlier location in the buffer with the
+    //  same contents.
+    lzfse_offset ref;
+    //  Length of the match.
+    uint32_t length;
+} lzfse_match;
+
+/*  MARK: - Encoder and Decoder state objects
+ */
+
+/*! @abstract Encoder state object. */
+typedef struct {
+    //  Pointer to first byte of the source buffer.
+    const uint8_t *src;
+    //  Length of the source buffer in bytes. Note that this is not a size_t,
+    //  but rather lzfse_offset, which is a signed type. The largest
+    //  representable buffer is 2GB, but arbitrarily large buffers may be
+    //  handled by repeatedly calling the encoder function and "translating"
+    //  the state between calls. When doing this, it is beneficial to use
+    //  blocks smaller than 2GB in order to maintain residency in the last-level
+    //  cache. Consult the implementation of lzfse_encode_buffer for details.
+    lzfse_offset src_end;
+    //  Offset of the first byte of the next literal to encode in the source
+    //  buffer.
+    lzfse_offset src_literal;
+    //  Offset of the byte currently being checked for a match.
+    lzfse_offset src_encode_i;
+    //  The last byte offset to consider for a match.  In some uses it makes
+    //  sense to use a smaller offset than src_end.
+    lzfse_offset src_encode_end;
+    //  Pointer to the next byte to be written in the destination buffer.
+    uint8_t *dst;
+    //  Pointer to the first byte of the destination buffer.
+    uint8_t *dst_begin;
+    //  Pointer to one byte past the end of the destination buffer.
+    uint8_t *dst_end;
+    //  Pending match; will be emitted unless a better match is found.
+    lzfse_match pending;
+    //  The number of matches written so far. Note that there is no problem in
+    //  using a 32-bit field for this quantity, because the state already limits
+    //  us to at most 2GB of data; there cannot possibly be more matches than
+    //  there are bytes in the input.
+    uint32_t n_matches;
+    //  The number of literals written so far.
+    uint32_t n_literals;
+    //  Lengths of found literals.
+    uint32_t l_values[LZFSE_MATCHES_PER_BLOCK];
+    //  Lengths of found matches.
+    uint32_t m_values[LZFSE_MATCHES_PER_BLOCK];
+    //  Distances of found matches.
+    uint32_t d_values[LZFSE_MATCHES_PER_BLOCK];
+    //  Concatenated literal bytes.
+    uint8_t literals[LZFSE_LITERALS_PER_BLOCK];
+    //  History table used to search for matches. Each entry of the table
+    //  corresponds to a group of four byte sequences in the input stream
+    //  that hash to the same value.
+    lzfse_history_set history_table[LZFSE_ENCODE_HASH_VALUES];
+} lzfse_encoder_state;
+
+/*! @abstract Decoder state object for lzfse compressed blocks. */
+typedef struct {
+    //  Number of matches remaining in the block.
+    uint32_t n_matches;
+    //  Number of bytes used to encode L, M, D triplets for the block.
+    uint32_t n_lmd_payload_bytes;
+    //  Pointer to the next literal to emit.
+    const uint8_t *current_literal;
+    //  L, M, D triplet for the match currently being emitted. This is used only
+    //  if we need to restart after reaching the end of the destination buffer in
+    //  the middle of a literal or match.
+    int32_t l_value, m_value, d_value;
+    //  FSE stream object.
+    fse_in_stream lmd_in_stream;
+    //  Offset of L,M,D encoding in the input buffer. Because we read through an
+    //  FSE stream *backwards* while decoding, this is decremented as we move
+    //  through a block.
+    uint32_t lmd_in_buf;
+    //  The current state of the L, M, and D FSE decoders.
+    uint16_t l_state, m_state, d_state;
+    //  Internal FSE decoder tables for the current block. These have
+    //  alignment forced to 8 bytes to guarantee that a single state's
+    //  entry cannot span two cachelines.
+    fse_value_decoder_entry l_decoder[LZFSE_ENCODE_L_STATES]
+        __attribute__((__aligned__(8)));
+    fse_value_decoder_entry m_decoder[LZFSE_ENCODE_M_STATES]
+        __attribute__((__aligned__(8)));
+    fse_value_decoder_entry d_decoder[LZFSE_ENCODE_D_STATES]
+        __attribute__((__aligned__(8)));
+    int32_t literal_decoder[LZFSE_ENCODE_LITERAL_STATES];
+    //  The literal stream for the block, plus padding to allow for faster copy
+    //  operations.
+    uint8_t literals[LZFSE_LITERALS_PER_BLOCK + 64];
+} lzfse_compressed_block_decoder_state;
+
+/*   Decoder state object for uncompressed blocks.
+ */
+typedef struct {
+    uint32_t n_raw_bytes;
+} uncompressed_block_decoder_state;
+
+/*! @abstract Decoder state object for lzvn-compressed blocks. */
+typedef struct {
+    uint32_t n_raw_bytes;
+    uint32_t n_payload_bytes;
+    uint32_t d_prev;
+} lzvn_compressed_block_decoder_state;
+
+/*! @abstract Decoder state object. */
+typedef struct {
+    //  Pointer to next byte to read from source buffer (this is advanced as we
+    //  decode; src_begin describe the buffer and do not change).
+    const uint8_t *src;
+    //  Pointer to first byte of source buffer.
+    const uint8_t *src_begin;
+    //  Pointer to one byte past the end of the source buffer.
+    const uint8_t *src_end;
+    //  Pointer to the next byte to write to destination buffer (this is advanced
+    //  as we decode; dst_begin and dst_end describe the buffer and do not change).
+    uint8_t *dst;
+    //  Pointer to first byte of destination buffer.
+    uint8_t *dst_begin;
+    //  Pointer to one byte past the end of the destination buffer.
+    uint8_t *dst_end;
+    //  1 if we have reached the end of the stream, 0 otherwise.
+    int end_of_stream;
+    //  magic number of the current block if we are within a block,
+    //  LZFSE_NO_BLOCK_MAGIC otherwise.
+    uint32_t block_magic;
+    lzfse_compressed_block_decoder_state compressed_lzfse_block_state;
+    lzvn_compressed_block_decoder_state compressed_lzvn_block_state;
+    uncompressed_block_decoder_state uncompressed_block_state;
+} lzfse_decoder_state;
+
+/*  MARK: - Block header objects
+ */
+
+#define LZFSE_NO_BLOCK_MAGIC 0x00000000 // 0    (invalid)
+#define LZFSE_ENDOFSTREAM_BLOCK_MAGIC 0x24787662 // bvx$ (end of stream)
+#define LZFSE_UNCOMPRESSED_BLOCK_MAGIC 0x2d787662 // bvx- (raw data)
+#define LZFSE_COMPRESSEDV1_BLOCK_MAGIC \
+    0x31787662 // bvx1 (lzfse compressed, uncompressed tables)
+#define LZFSE_COMPRESSEDV2_BLOCK_MAGIC \
+    0x32787662 // bvx2 (lzfse compressed, compressed tables)
+#define LZFSE_COMPRESSEDLZVN_BLOCK_MAGIC 0x6e787662 // bvxn (lzvn compressed)
+
+/*! @abstract Uncompressed block header in encoder stream. */
+typedef struct {
+    //  Magic number, always LZFSE_UNCOMPRESSED_BLOCK_MAGIC.
+    uint32_t magic;
+    //  Number of raw bytes in block.
+    uint32_t n_raw_bytes;
+} uncompressed_block_header;
+
+/*! @abstract Compressed block header with uncompressed tables. */
+typedef struct {
+    //  Magic number, always LZFSE_COMPRESSEDV1_BLOCK_MAGIC.
+    uint32_t magic;
+    //  Number of decoded (output) bytes in block.
+    uint32_t n_raw_bytes;
+    //  Number of encoded (source) bytes in block.
+    uint32_t n_payload_bytes;
+    //  Number of literal bytes output by block (*not* the number of literals).
+    uint32_t n_literals;
+    //  Number of matches in block (which is also the number of literals).
+    uint32_t n_matches;
+    //  Number of bytes used to encode literals.
+    uint32_t n_literal_payload_bytes;
+    //  Number of bytes used to encode matches.
+    uint32_t n_lmd_payload_bytes;
+
+    //  Final encoder states for the block, which will be the initial states for
+    //  the decoder:
+    //  Final accum_nbits for literals stream.
+    int32_t literal_bits;
+    //  There are four interleaved streams of literals, so there are four final
+    //  states.
+    uint16_t literal_state[4];
+    //  accum_nbits for the l, m, d stream.
+    int32_t lmd_bits;
+    //  Final L (literal length) state.
+    uint16_t l_state;
+    //  Final M (match length) state.
+    uint16_t m_state;
+    //  Final D (match distance) state.
+    uint16_t d_state;
+
+    //  Normalized frequency tables for each stream. Sum of values in each
+    //  array is the number of states.
+    uint16_t l_freq[LZFSE_ENCODE_L_SYMBOLS];
+    uint16_t m_freq[LZFSE_ENCODE_M_SYMBOLS];
+    uint16_t d_freq[LZFSE_ENCODE_D_SYMBOLS];
+    uint16_t literal_freq[LZFSE_ENCODE_LITERAL_SYMBOLS];
+} lzfse_compressed_block_header_v1;
+
+/*! @abstract Compressed block header with compressed tables. Note that because
+ *  freq[] is compressed, the structure-as-stored-in-the-stream is *truncated*;
+ *  we only store the used bytes of freq[]. This means that some extra care must
+ *  be taken when reading one of these headers from the stream. */
+typedef struct {
+    //  Magic number, always LZFSE_COMPRESSEDV2_BLOCK_MAGIC.
+    uint32_t magic;
+    //  Number of decoded (output) bytes in block.
+    uint32_t n_raw_bytes;
+    //  The fields n_payload_bytes ... d_state from the
+    //  lzfse_compressed_block_header_v1 object are packed into three 64-bit
+    //  fields in the compressed header, as follows:
+    //
+    //    offset  bits  value
+    //    0       20    n_literals
+    //    20      20    n_literal_payload_bytes
+    //    40      20    n_matches
+    //    60      3     literal_bits
+    //    63      1     --- unused ---
+    //
+    //    0       10    literal_state[0]
+    //    10      10    literal_state[1]
+    //    20      10    literal_state[2]
+    //    30      10    literal_state[3]
+    //    40      20    n_lmd_payload_bytes
+    //    60      3     lmd_bits
+    //    63      1     --- unused ---
+    //
+    //    0       32    header_size (total header size in bytes; this does not
+    //                  correspond to a field in the uncompressed header version,
+    //                  but is required; we wouldn't know the size of the
+    //                  compresssed header otherwise.
+    //    32      10    l_state
+    //    42      10    m_state
+    //    52      10    d_state
+    //    62      2     --- unused ---
+    uint64_t packed_fields[3];
+    //  Variable size freq tables, using a Huffman-style fixed encoding.
+    //  Size allocated here is an upper bound (all values stored on 16 bits).
+    uint8_t freq[2 *
+             (LZFSE_ENCODE_L_SYMBOLS + LZFSE_ENCODE_M_SYMBOLS +
+              LZFSE_ENCODE_D_SYMBOLS + LZFSE_ENCODE_LITERAL_SYMBOLS)];
+} __attribute__((__packed__, __aligned__(1))) lzfse_compressed_block_header_v2;
+
+/*! @abstract LZVN compressed block header. */
+typedef struct {
+    //  Magic number, always LZFSE_COMPRESSEDLZVN_BLOCK_MAGIC.
+    uint32_t magic;
+    //  Number of decoded (output) bytes.
+    uint32_t n_raw_bytes;
+    //  Number of encoded (source) bytes.
+    uint32_t n_payload_bytes;
+} lzvn_compressed_block_header;
+
+/*  MARK: - LZFSE encode/decode interfaces
+ */
+
+int lzfse_encode_init(lzfse_encoder_state *s);
+int lzfse_encode_translate(lzfse_encoder_state *s, lzfse_offset delta);
+int lzfse_encode_base(lzfse_encoder_state *s);
+int lzfse_encode_finish(lzfse_encoder_state *s);
+int lzfse_decode(lzfse_decoder_state *s);
+
+/*  MARK: - LZVN encode/decode interfaces
+ */
+
+/*   Minimum source buffer size for compression. Smaller buffers will not be
+ *   compressed; the lzvn encoder will simply return.
+ */
+#define LZVN_ENCODE_MIN_SRC_SIZE ((size_t)8)
+
+/*   Maximum source buffer size for compression. Larger buffers will be
+ *   compressed partially.
+ */
+#define LZVN_ENCODE_MAX_SRC_SIZE ((size_t)0xffffffffU)
+
+/*   Minimum destination buffer size for compression. No compression will take
+ *   place if smaller.
+ */
+#define LZVN_ENCODE_MIN_DST_SIZE ((size_t)8)
+
+size_t lzvn_decode_scratch_size(void);
+size_t lzvn_encode_scratch_size(void);
+size_t lzvn_encode_buffer(void *__restrict dst, size_t dst_size,
+              const void *__restrict src, size_t src_size,
+              void *__restrict work);
+size_t lzvn_decode_buffer(void *__restrict dst, size_t dst_size,
+              const void *__restrict src, size_t src_size);
+
+/*! @abstract Signed offset in buffers, stored on either 32 or 64 bits. */
+#if defined(_M_AMD64) || defined(__x86_64__) || defined(__arm64__)
+typedef int64_t lzvn_offset;
+#else
+typedef int32_t lzvn_offset;
+#endif
+
+/*  MARK: - LZFSE utility functions
+ */
+
+/*! @abstract Load bytes from memory location SRC. */
+LZFSE_INLINE uint16_t load2(const void *ptr)
+{
+    uint16_t data;
+    memcpy(&data, ptr, sizeof data);
+    return data;
+}
+
+LZFSE_INLINE uint32_t load4(const void *ptr)
+{
+    uint32_t data;
+    memcpy(&data, ptr, sizeof data);
+    return data;
+}
+
+LZFSE_INLINE uint64_t load8(const void *ptr)
+{
+    uint64_t data;
+    memcpy(&data, ptr, sizeof data);
+    return data;
+}
+
+/*! @abstract Store bytes to memory location DST. */
+LZFSE_INLINE void store2(void *ptr, uint16_t data)
+{
+    memcpy(ptr, &data, sizeof data);
+}
+
+LZFSE_INLINE void store4(void *ptr, uint32_t data)
+{
+    memcpy(ptr, &data, sizeof data);
+}
+
+LZFSE_INLINE void store8(void *ptr, uint64_t data)
+{
+    memcpy(ptr, &data, sizeof data);
+}
+
+/*! @abstract Load+store bytes from locations SRC to DST. Not intended for use
+ * with overlapping buffers. Note that for LZ-style compression, you need
+ * copies to behave like naive memcpy( ) implementations do, splatting the
+ * leading sequence if the buffers overlap. This copy does not do that, so
+ * should not be used with overlapping buffers. */
+LZFSE_INLINE void copy8(void *dst, const void *src)
+{
+    store8(dst, load8(src));
+}
+LZFSE_INLINE void copy16(void *dst, const void *src)
+{
+    uint64_t m0 = load8(src);
+    uint64_t m1 = load8((const unsigned char *)src + 8);
+    store8(dst, m0);
+    store8((unsigned char *)dst + 8, m1);
+}
+
+/*  ===============================================================
+ *  Bitfield Operations
+ */
+
+/*! @abstract Extracts \p width bits from \p container, starting with \p lsb; if
+ * we view \p container as a bit array, we extract \c container[lsb:lsb+width]. */
+LZFSE_INLINE uintmax_t extract(uintmax_t container, unsigned lsb,
+                   unsigned width)
+{
+    static const size_t container_width = sizeof container * 8;
+    if (width == container_width)
+        return container;
+    return (container >> lsb) & (((uintmax_t)1 << width) - 1);
+}
+
+/*! @abstract Inserts \p width bits from \p data into \p container, starting with \p lsb.
+ *  Viewed as bit arrays, the operations is:
+ * @code
+ * container[:lsb] is unchanged
+ * container[lsb:lsb+width] <-- data[0:width]
+ * container[lsb+width:] is unchanged
+ * @endcode
+ */
+LZFSE_INLINE uintmax_t insert(uintmax_t container, uintmax_t data, unsigned lsb,
+                  unsigned width)
+{
+    static const size_t container_width = sizeof container * 8;
+    uintmax_t mask;
+    if (width == container_width)
+        return container;
+    mask = ((uintmax_t)1 << width) - 1;
+    return (container & ~(mask << lsb)) | (data & mask) << lsb;
+}
+
+/*! @abstract Perform sanity checks on the values of lzfse_compressed_block_header_v1.
+ * Test that the field values are in the allowed limits, verify that the
+ * frequency tables sum to value less than total number of states.
+ * @return 0 if all tests passed.
+ * @return negative error code with 1 bit set for each failed test. */
+LZFSE_INLINE int
+lzfse_check_block_header_v1(const lzfse_compressed_block_header_v1 *header)
+{
+    int tests_results = 0;
+    uint16_t literal_state[4];
+    int res;
+    tests_results = tests_results |
+            ((header->magic == LZFSE_COMPRESSEDV1_BLOCK_MAGIC) ?
+                 0 :
+                 (1 << 0));
+    tests_results = tests_results |
+            ((header->n_literals <= LZFSE_LITERALS_PER_BLOCK) ?
+                 0 :
+                 (1 << 1));
+    tests_results =
+        tests_results |
+        ((header->n_matches <= LZFSE_MATCHES_PER_BLOCK) ? 0 : (1 << 2));
+
+    memcpy(literal_state, header->literal_state, sizeof(uint16_t) * 4);
+
+    tests_results = tests_results |
+            ((literal_state[0] < LZFSE_ENCODE_LITERAL_STATES) ?
+                 0 :
+                 (1 << 3));
+    tests_results = tests_results |
+            ((literal_state[1] < LZFSE_ENCODE_LITERAL_STATES) ?
+                 0 :
+                 (1 << 4));
+    tests_results = tests_results |
+            ((literal_state[2] < LZFSE_ENCODE_LITERAL_STATES) ?
+                 0 :
+                 (1 << 5));
+    tests_results = tests_results |
+            ((literal_state[3] < LZFSE_ENCODE_LITERAL_STATES) ?
+                 0 :
+                 (1 << 6));
+
+    tests_results =
+        tests_results |
+        ((header->l_state < LZFSE_ENCODE_L_STATES) ? 0 : (1 << 7));
+    tests_results =
+        tests_results |
+        ((header->m_state < LZFSE_ENCODE_M_STATES) ? 0 : (1 << 8));
+    tests_results =
+        tests_results |
+        ((header->d_state < LZFSE_ENCODE_D_STATES) ? 0 : (1 << 9));
+
+    res = fse_check_freq(header->l_freq, LZFSE_ENCODE_L_SYMBOLS,
+                 LZFSE_ENCODE_L_STATES);
+    tests_results = tests_results | ((res == 0) ? 0 : (1 << 10));
+    res = fse_check_freq(header->m_freq, LZFSE_ENCODE_M_SYMBOLS,
+                 LZFSE_ENCODE_M_STATES);
+    tests_results = tests_results | ((res == 0) ? 0 : (1 << 11));
+    res = fse_check_freq(header->d_freq, LZFSE_ENCODE_D_SYMBOLS,
+                 LZFSE_ENCODE_D_STATES);
+    tests_results = tests_results | ((res == 0) ? 0 : (1 << 12));
+    res = fse_check_freq(header->literal_freq, LZFSE_ENCODE_LITERAL_SYMBOLS,
+                 LZFSE_ENCODE_LITERAL_STATES);
+    tests_results = tests_results | ((res == 0) ? 0 : (1 << 13));
+
+    if (tests_results) {
+        return tests_results |
+               0x80000000; // each 1 bit is a test that failed
+            // (except for the sign bit)
+    }
+
+    return 0; // OK
+}
+
+/*  MARK: - L, M, D encoding constants for LZFSE
+ */
+
+/*   Largest encodable L (literal length), M (match length) and D (match
+ *   distance) values.
+ */
+#define LZFSE_ENCODE_MAX_L_VALUE 315
+#define LZFSE_ENCODE_MAX_M_VALUE 2359
+#define LZFSE_ENCODE_MAX_D_VALUE 262139
+
+/*! @abstract The L, M, D data streams are all encoded as a "base" value, which is
+ * FSE-encoded, and an "extra bits" value, which is the difference between
+ * value and base, and is simply represented as a raw bit value (because it
+ * is the low-order bits of a larger number, not much entropy can be
+ * extracted from these bits by more complex encoding schemes). The following
+ * tables represent the number of low-order bits to encode separately and the
+ * base values for each of L, M, and D.
+ *
+ * @note The inverse tables for mapping the other way are significantly larger.
+ * Those tables have been split out to lzfse_encode_tables.h in order to keep
+ * this file relatively small. */
+static const uint8_t l_extra_bits[LZFSE_ENCODE_L_SYMBOLS] = {
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 5, 8
+};
+static const int32_t l_base_value[LZFSE_ENCODE_L_SYMBOLS] = {
+    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 28, 60
+};
+static const uint8_t m_extra_bits[LZFSE_ENCODE_M_SYMBOLS] = {
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11
+};
+static const int32_t m_base_value[LZFSE_ENCODE_M_SYMBOLS] = {
+    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 24, 56, 312
+};
+static const uint8_t d_extra_bits[LZFSE_ENCODE_D_SYMBOLS] = {
+    0,  0,    0,  0,    1,  1,    1,  1,    2,  2,    2,  2,    3,  3,    3,  3,
+    4,  4,    4,  4,    5,  5,    5,  5,    6,  6,    6,  6,    7,  7,    7,  7,
+    8,  8,    8,  8,    9,  9,    9,  9,    10, 10, 10, 10, 11, 11, 11, 11,
+    12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15
+};
+static const int32_t d_base_value[LZFSE_ENCODE_D_SYMBOLS] = {
+    0,     1,     2,     3,         4,         6,         8,         10,
+    12,    16,    20,    24,     28,     36,     44,     52,
+    60,    76,    92,    108,    124,    156,    188,    220,
+    252,   316,   380,   444,    508,    636,    764,    892,
+    1020,  1276,  1532,  1788,   2044,   2556,   3068,   3580,
+    4092,  5116,  6140,  7164,   8188,   10236,  12284,  14332,
+    16380, 20476, 24572, 28668,  32764,  40956,  49148,  57340,
+    65532, 81916, 98300, 114684, 131068, 163836, 196604, 229372
+};
+
+#endif // LZFSE_INTERNAL_H
drivers/staging/apfs/lzfse/lzfse_tunables.h new file +50 -0
new file mode 100644
index 0000000000000000000000000000000000000000..cb699bba5bf175a4ad525403f958d0c29aaee4e4
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (c) 2015-2016, Apple Inc. All rights reserved.
+ *
+ */
+
+#ifndef LZFSE_TUNABLES_H
+#define LZFSE_TUNABLES_H
+
+/*   Parameters controlling details of the LZ-style match search. These values
+ *   may be modified to fine tune compression ratio vs. encoding speed, while
+ *   keeping the compressed format compatible with LZFSE. Note that
+ *   modifying them will also change the amount of work space required by
+ *   the encoder. The values here are those used in the compression library
+ *   on iOS and OS X.
+ */
+
+/*   Number of bits for hash function to produce. Should be in the range
+ *   [10, 16]. Larger values reduce the number of false-positive found during
+ *   the match search, and expand the history table, which may allow additional
+ *   matches to be found, generally improving the achieved compression ratio.
+ *   Larger values also increase the workspace size, and make it less likely
+ *   that the history table will be present in cache, which reduces performance.
+ */
+#define LZFSE_ENCODE_HASH_BITS 14
+
+/*   Number of positions to store for each line in the history table. May
+ *   be either 4 or 8. Using 8 doubles the size of the history table, which
+ *   increases the chance of finding matches (thus improving compression ratio),
+ *   but also increases the workspace size.
+ */
+#define LZFSE_ENCODE_HASH_WIDTH 4
+
+/*   Match length in bytes to cause immediate emission. Generally speaking,
+ *   LZFSE maintains multiple candidate matches and waits to decide which match
+ *   to emit until more information is available. When a match exceeds this
+ *   threshold, it is emitted immediately. Thus, smaller values may give
+ *   somewhat better performance, and larger values may give somewhat better
+ *   compression ratios.
+ */
+#define LZFSE_ENCODE_GOOD_MATCH 40
+
+/*   When the source buffer is very small, LZFSE doesn't compress as well as
+ *   some simpler algorithms. To maintain reasonable compression for these
+ *   cases, we transition to use LZVN instead if the size of the source buffer
+ *   is below this threshold.
+ */
+#define LZFSE_ENCODE_LZVN_THRESHOLD 4096
+
+#endif // LZFSE_TUNABLES_H
drivers/staging/apfs/lzfse/lzvn_decode_base.c new file +721 -0
new file mode 100644
index 0000000000000000000000000000000000000000..632bdd6e4da3c6e1db4a0e9fe45609b6d68a408e
@@ -0,0 +1,721 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2015-2016, Apple Inc. All rights reserved.
+ *
+ */
+
+/*  LZVN low-level decoder
+ */
+
+#include "lzvn_decode_base.h"
+
+#if !defined(HAVE_LABELS_AS_VALUES)
+#  if defined(__GNUC__) || defined(__clang__)
+#    define HAVE_LABELS_AS_VALUES 1
+#  else
+#    define HAVE_LABELS_AS_VALUES 0
+#  endif
+#endif
+
+/*   Both the source and destination buffers are represented by a pointer and
+ *   a length; they are *always* updated in concert using this macro; however
+ *   many bytes the pointer is advanced, the length is decremented by the same
+ *   amount. Thus, pointer + length always points to the byte one past the end
+ *   of the buffer.
+ */
+#define PTR_LEN_INC(_pointer, _length, _increment) \
+    (_pointer += _increment, _length -= _increment)
+
+/*   Update state with current positions and distance, corresponding to the
+ *   beginning of an instruction in both streams
+ */
+#define UPDATE_GOOD \
+    (state->src = src_ptr, state->dst = dst_ptr, state->d_prev = D)
+
+void lzvn_decode(lzvn_decoder_state *state)
+{
+#if HAVE_LABELS_AS_VALUES
+    // Jump table for all instructions
+    static const void *opc_tbl[256] = {
+        &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&eos,
+        &&lrg_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d,
+        &&nop,     &&lrg_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d,
+        &&sml_d, &&nop,      &&lrg_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d,
+        &&sml_d, &&sml_d, &&udef,  &&lrg_d, &&sml_d, &&sml_d, &&sml_d,
+        &&sml_d, &&sml_d, &&sml_d, &&udef,  &&lrg_d, &&sml_d, &&sml_d,
+        &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&udef,  &&lrg_d, &&sml_d,
+        &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&udef,  &&lrg_d,
+        &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&udef,
+        &&lrg_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d,
+        &&pre_d, &&lrg_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d,
+        &&sml_d, &&pre_d, &&lrg_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d,
+        &&sml_d, &&sml_d, &&pre_d, &&lrg_d, &&sml_d, &&sml_d, &&sml_d,
+        &&sml_d, &&sml_d, &&sml_d, &&pre_d, &&lrg_d, &&sml_d, &&sml_d,
+        &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&pre_d, &&lrg_d, &&sml_d,
+        &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&pre_d, &&lrg_d,
+        &&udef,     &&udef,  &&udef,  &&udef,  &&udef,  &&udef,  &&udef,
+        &&udef,     &&udef,  &&udef,  &&udef,  &&udef,  &&udef,  &&udef,
+        &&udef,     &&udef,  &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d,
+        &&sml_d, &&pre_d, &&lrg_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d,
+        &&sml_d, &&sml_d, &&pre_d, &&lrg_d, &&sml_d, &&sml_d, &&sml_d,
+        &&sml_d, &&sml_d, &&sml_d, &&pre_d, &&lrg_d, &&sml_d, &&sml_d,
+        &&sml_d, &&sml_d, &&sml_d, &&sml_d, &&pre_d, &&lrg_d, &&med_d,
+        &&med_d, &&med_d, &&med_d, &&med_d, &&med_d, &&med_d, &&med_d,
+        &&med_d, &&med_d, &&med_d, &&med_d, &&med_d, &&med_d, &&med_d,
+        &&med_d, &&med_d, &&med_d, &&med_d, &&med_d, &&med_d, &&med_d,
+        &&med_d, &&med_d, &&med_d, &&med_d, &&med_d, &&med_d, &&med_d,
+        &&med_d, &&med_d, &&med_d, &&sml_d, &&sml_d, &&sml_d, &&sml_d,
+        &&sml_d, &&sml_d, &&pre_d, &&lrg_d, &&sml_d, &&sml_d, &&sml_d,
+        &&sml_d, &&sml_d, &&sml_d, &&pre_d, &&lrg_d, &&udef,  &&udef,
+        &&udef,     &&udef,  &&udef,  &&udef,  &&udef,  &&udef,  &&udef,
+        &&udef,     &&udef,  &&udef,  &&udef,  &&udef,  &&udef,  &&udef,
+        &&lrg_l, &&sml_l, &&sml_l, &&sml_l, &&sml_l, &&sml_l, &&sml_l,
+        &&sml_l, &&sml_l, &&sml_l, &&sml_l, &&sml_l, &&sml_l, &&sml_l,
+        &&sml_l, &&sml_l, &&lrg_m, &&sml_m, &&sml_m, &&sml_m, &&sml_m,
+        &&sml_m, &&sml_m, &&sml_m, &&sml_m, &&sml_m, &&sml_m, &&sml_m,
+        &&sml_m, &&sml_m, &&sml_m, &&sml_m
+    };
+#endif
+    size_t src_len = state->src_end - state->src;
+    size_t dst_len = state->dst_end - state->dst;
+    const unsigned char *src_ptr = state->src;
+    unsigned char *dst_ptr = state->dst;
+    size_t D = state->d_prev;
+    size_t M;
+    size_t L;
+    size_t opc_len;
+    unsigned char opc;
+    uint16_t opc23;
+
+    if (src_len == 0 || dst_len == 0)
+        return; // empty buffer
+
+    // Do we have a partially expanded match saved in state?
+    if (state->L != 0 || state->M != 0) {
+        L = state->L;
+        M = state->M;
+        D = state->D;
+        opc_len = 0; // we already skipped the op
+        state->L = state->M = state->D = 0;
+        if (M == 0)
+            goto copy_literal;
+        if (L == 0)
+            goto copy_match;
+        goto copy_literal_and_match;
+    }
+
+    opc = src_ptr[0];
+
+#if HAVE_LABELS_AS_VALUES
+    goto *opc_tbl[opc];
+#else
+    for (;;) {
+        switch (opc) {
+#endif
+/*   ===============================================================
+ *   These four opcodes (sml_d, med_d, lrg_d, and pre_d) encode both a
+ *   literal and a match. The bulk of their implementations are shared;
+ *   each label here only does the work of setting the opcode length (not
+ *   including any literal bytes), and extracting the literal length, match
+ *   length, and match distance (except in pre_d). They then jump into the
+ *   shared implementation to actually output the literal and match bytes.
+ *
+ *   No error checking happens in the first stage, except for ensuring that
+ *   the source has enough length to represent the full opcode before
+ *   reading past the first byte.
+ */
+sml_d:
+#if !HAVE_LABELS_AS_VALUES
+case 0:
+case 1:
+case 2:
+case 3:
+case 4:
+case 5:
+case 8:
+case 9:
+case 10:
+case 11:
+case 12:
+case 13:
+case 16:
+case 17:
+case 18:
+case 19:
+case 20:
+case 21:
+case 24:
+case 25:
+case 26:
+case 27:
+case 28:
+case 29:
+case 32:
+case 33:
+case 34:
+case 35:
+case 36:
+case 37:
+case 40:
+case 41:
+case 42:
+case 43:
+case 44:
+case 45:
+case 48:
+case 49:
+case 50:
+case 51:
+case 52:
+case 53:
+case 56:
+case 57:
+case 58:
+case 59:
+case 60:
+case 61:
+case 64:
+case 65:
+case 66:
+case 67:
+case 68:
+case 69:
+case 72:
+case 73:
+case 74:
+case 75:
+case 76:
+case 77:
+case 80:
+case 81:
+case 82:
+case 83:
+case 84:
+case 85:
+case 88:
+case 89:
+case 90:
+case 91:
+case 92:
+case 93:
+case 96:
+case 97:
+case 98:
+case 99:
+case 100:
+case 101:
+case 104:
+case 105:
+case 106:
+case 107:
+case 108:
+case 109:
+case 128:
+case 129:
+case 130:
+case 131:
+case 132:
+case 133:
+case 136:
+case 137:
+case 138:
+case 139:
+case 140:
+case 141:
+case 144:
+case 145:
+case 146:
+case 147:
+case 148:
+case 149:
+case 152:
+case 153:
+case 154:
+case 155:
+case 156:
+case 157:
+case 192:
+case 193:
+case 194:
+case 195:
+case 196:
+case 197:
+case 200:
+case 201:
+case 202:
+case 203:
+case 204:
+case 205:
+#endif
+    UPDATE_GOOD;
+    // "small distance": This opcode has the structure LLMMMDDD DDDDDDDD LITERAL
+    //  where the length of literal (0-3 bytes) is encoded by the high 2 bits of
+    //  the first byte. We first extract the literal length so we know how long
+    //  the opcode is, then check that the source can hold both this opcode and
+    //  at least one byte of the next (because any valid input stream must be
+    //  terminated with an eos token).
+    opc_len = 2;
+    L = (size_t)extract(opc, 6, 2);
+    M = (size_t)extract(opc, 3, 3) + 3;
+    //  We need to ensure that the source buffer is long enough that we can
+    //  safely read this entire opcode, the literal that follows, and the first
+    //  byte of the next opcode.  Once we satisfy this requirement, we can
+    //  safely unpack the match distance. A check similar to this one is
+    //  present in all the opcode implementations.
+    if (src_len <= opc_len + L)
+        return; // source truncated
+    D = (size_t)extract(opc, 0, 3) << 8 | src_ptr[1];
+    goto copy_literal_and_match;
+
+med_d:
+#if !HAVE_LABELS_AS_VALUES
+case 160:
+case 161:
+case 162:
+case 163:
+case 164:
+case 165:
+case 166:
+case 167:
+case 168:
+case 169:
+case 170:
+case 171:
+case 172:
+case 173:
+case 174:
+case 175:
+case 176:
+case 177:
+case 178:
+case 179:
+case 180:
+case 181:
+case 182:
+case 183:
+case 184:
+case 185:
+case 186:
+case 187:
+case 188:
+case 189:
+case 190:
+case 191:
+#endif
+    UPDATE_GOOD;
+    //  "medium distance": This is a minor variant of the "small distance"
+    //  encoding, where we will now use two extra bytes instead of one to encode
+    //  the restof the match length and distance. This allows an extra two bits
+    //  for the match length, and an extra three bits for the match distance. The
+    //  full structure of the opcode is 101LLMMM DDDDDDMM DDDDDDDD LITERAL.
+    opc_len = 3;
+    L = (size_t)extract(opc, 3, 2);
+    if (src_len <= opc_len + L)
+        return; // source truncated
+    opc23 = load2(&src_ptr[1]);
+    M = (size_t)((extract(opc, 0, 3) << 2 | extract(opc23, 0, 2)) + 3);
+    D = (size_t)extract(opc23, 2, 14);
+    goto copy_literal_and_match;
+
+lrg_d:
+#if !HAVE_LABELS_AS_VALUES
+case 7:
+case 15:
+case 23:
+case 31:
+case 39:
+case 47:
+case 55:
+case 63:
+case 71:
+case 79:
+case 87:
+case 95:
+case 103:
+case 111:
+case 135:
+case 143:
+case 151:
+case 159:
+case 199:
+case 207:
+#endif
+    UPDATE_GOOD;
+    //  "large distance": This is another variant of the "small distance"
+    //  encoding, where we will now use two extra bytes to encode the match
+    //  distance, which allows distances up to 65535 to be represented. The full
+    //  structure of the opcode is LLMMM111 DDDDDDDD DDDDDDDD LITERAL.
+    opc_len = 3;
+    L = (size_t)extract(opc, 6, 2);
+    M = (size_t)extract(opc, 3, 3) + 3;
+    if (src_len <= opc_len + L)
+        return; // source truncated
+    D = load2(&src_ptr[1]);
+    goto copy_literal_and_match;
+
+pre_d:
+#if !HAVE_LABELS_AS_VALUES
+case 70:
+case 78:
+case 86:
+case 94:
+case 102:
+case 110:
+case 134:
+case 142:
+case 150:
+case 158:
+case 198:
+case 206:
+#endif
+    UPDATE_GOOD;
+    //  "previous distance": This opcode has the structure LLMMM110, where the
+    //  length of the literal (0-3 bytes) is encoded by the high 2 bits of the
+    //  first byte. We first extract the literal length so we know how long
+    //  the opcode is, then check that the source can hold both this opcode and
+    //  at least one byte of the next (because any valid input stream must be
+    //  terminated with an eos token).
+    opc_len = 1;
+    L = (size_t)extract(opc, 6, 2);
+    M = (size_t)extract(opc, 3, 3) + 3;
+    if (src_len <= opc_len + L)
+        return; // source truncated
+    goto copy_literal_and_match;
+
+copy_literal_and_match:
+    //  Common implementation of writing data for opcodes that have both a
+    //  literal and a match. We begin by advancing the source pointer past
+    //  the opcode, so that it points at the first literal byte (if L
+    //  is non-zero; otherwise it points at the next opcode).
+    PTR_LEN_INC(src_ptr, src_len, opc_len);
+    //  Now we copy the literal from the source pointer to the destination.
+    if (__builtin_expect(dst_len >= 4 && src_len >= 4, 1)) {
+        //  The literal is 0-3 bytes; if we are not near the end of the buffer,
+        //  we can safely just do a 4 byte copy (which is guaranteed to cover
+        //  the complete literal, and may include some other bytes as well).
+        store4(dst_ptr, load4(src_ptr));
+    } else if (L <= dst_len) {
+        //  We are too close to the end of either the input or output stream
+        //  to be able to safely use a four-byte copy, but we will not exhaust
+        //  either stream (we already know that the source will not be
+        //  exhausted from checks in the individual opcode implementations,
+        //  and we just tested that dst_len > L). Thus, we need to do a
+        //  byte-by-byte copy of the literal. This is slow, but it can only ever
+        //  happen near the very end of a buffer, so it is not an important case to
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

drivers/staging/apfs/lzfse/lzvn_decode_base.h new file +53 -0
new file mode 100644
index 0000000000000000000000000000000000000000..ef6b0244cbf8adb15a77a68c920753adce7d93b4

Lines of this file are not shown. View the raw message.

drivers/staging/apfs/lzfse/lzvn_encode_base.h new file +105 -1
new file mode 100644
index 0000000000000000000000000000000000000000..c65457143bb5d330c6172d690993250e3a6aab77

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

2.48.1

Part of the diff is not shown here. View the raw message.

#3 lore raw

RFC PATCH v2 2/8 staging: apfs: init unicode.{c,h}

In reply to Ethan Carter Edwards

These files handle the normalization and storing of unicode data within the APFS filesystem module

---
 drivers/staging/apfs/unicode.c | 3156 ++++++++++++++++++++++++++++++++++++++++
 drivers/staging/apfs/unicode.h |   27 +
 2 files changed, 3183 insertions(+)
drivers/staging/apfs/unicode.c new file +3156 -0
new file mode 100644
index 0000000000000000000000000000000000000000..fd1bbbea8e12afe553833271a8853a941511b3f1
@@ -0,0 +1,3156 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2018 Ernesto A. Fernández <[email protected]>
+ *
+ * Routines and data for the normalization of unicode strings.
+ * Somewhat based on linux/fs/hfsplus/unicode.c
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/nls.h>
+#include <linux/ctype.h>
+#include <linux/version.h>
+#include "unicode.h"
+
+/* The arrays of unicode data are defined at the bottom of the file */
+/* TODO: would a single trie with all the data be more efficient? */
+static u16 apfs_nfd_trie[];
+static unicode_t apfs_nfd[];
+static u16 apfs_cf_trie[];
+static unicode_t apfs_cf[];
+static u8 apfs_ccc_trie[];
+
+#define TRIE_HEIGHT		5
+
+/* A trie node has one child for each possible nibble in the key */
+#define TRIE_CHILD_SHIFT	4
+#define TRIE_CHILD_MASK		((1 << TRIE_CHILD_SHIFT) - 1)
+
+/* A trie value length is stored in the last three bits of its position */
+#define TRIE_POS_SHIFT		3
+#define TRIE_SIZE_MASK		((1 << TRIE_POS_SHIFT) - 1)
+
+/**
+ * apfs_trie_find - Look up a trie value
+ * @trie:	trie to search
+ * @key:	search key (a unicode character)
+ * @result:	on return, this either holds the value (on a ccc lookup) or its
+ *		position in the value array (on a cf or nfd lookup).
+ * @is_ccc:	true if this a ccc (canonical combining class) lookup
+ *
+ * Returns the length of the value (0 if it doesn't exist).
+ */
+static int apfs_trie_find(void *trie, unicode_t key, void *result, bool is_ccc)
+{
+	int node = 0;
+	int h;
+
+	for (h = TRIE_HEIGHT - 1; h >= 0; --h) {
+		int child = (key >> (TRIE_CHILD_SHIFT * h)) & TRIE_CHILD_MASK;
+		int child_index = (node << TRIE_CHILD_SHIFT) + child;
+
+		if (is_ccc)
+			node = ((u8 *)trie)[child_index];
+		else
+			node = ((u16 *)trie)[child_index];
+
+		if (node == 0) {
+			*(u8 *)result = 0;
+			return 0;
+		}
+	}
+
+	if (is_ccc) {
+		/* ccc values fit in one byte, so no need for a value array */
+		*(u8 *)result = node;
+		return 1;
+	}
+
+	*(u16 *)result = node >> TRIE_POS_SHIFT;
+	return node & TRIE_SIZE_MASK;
+}
+
+/**
+ * apfs_init_unicursor - Initialize an apfs_unicursor structure
+ * @cursor:	cursor to initialize
+ * @utf8str:	string to normalize
+ * @total_len:	length of the string
+ */
+void apfs_init_unicursor(struct apfs_unicursor *cursor, const char *utf8str, unsigned int total_len)
+{
+	cursor->utf8curr = utf8str;
+	cursor->total_len = total_len;
+	cursor->length = -1;
+	cursor->last_pos = -1;
+	cursor->last_ccc = 0;
+}
+
+#define HANGUL_S_BASE	0xac00
+#define HANGUL_L_BASE	0x1100
+#define HANGUL_V_BASE	0x1161
+#define HANGUL_T_BASE	0x11a7
+#define HANGUL_L_COUNT	19
+#define HANGUL_V_COUNT	21
+#define HANGUL_T_COUNT	28
+#define HANGUL_N_COUNT	(HANGUL_V_COUNT * HANGUL_T_COUNT)
+#define HANGUL_S_COUNT	(HANGUL_L_COUNT * HANGUL_N_COUNT)
+
+/**
+ * apfs_is_precomposed_hangul - Check if a character is a Hangul syllable
+ * @utf32char:	character to check
+ *
+ * This function was adapted from sample code in section 3.12 of the
+ * Unicode Standard, version 9.0.
+ *
+ * Copyright (C) 1991-2018 Unicode, Inc.  All rights reserved.  Distributed
+ * under the Terms of Use in http://www.unicode.org/copyright.html.
+ */
+static bool apfs_is_precomposed_hangul(unicode_t utf32char)
+{
+	int index;
+
+	index = utf32char - HANGUL_S_BASE;
+	return (index >= 0 && index < HANGUL_S_COUNT);
+}
+
+/* Signals the end of the normalization for a single character */
+#define NORM_END	((unicode_t)(-1))
+
+/**
+ * apfs_decompose_hangul - Decompose a Hangul syllable
+ * @utf32char:	Hangul syllable to decompose
+ * @off:	offset of the wanted character from the decomposition
+ *
+ * Returns the single character at offset @off in the decomposition of
+ * @utf32char, or NORM_END if this offset is past the end.
+ *
+ * This function was adapted from sample code in section 3.12 of the
+ * Unicode Standard, version 9.0.
+ *
+ * Copyright (C) 1991-2018 Unicode, Inc.  All rights reserved.  Distributed
+ * under the Terms of Use in http://www.unicode.org/copyright.html.
+ */
+static unicode_t apfs_decompose_hangul(unicode_t utf32char, int off)
+{
+	int index;
+	int l, v, t;
+
+	index = utf32char - HANGUL_S_BASE;
+
+	l = HANGUL_L_BASE + index / HANGUL_N_COUNT;
+	if (off == 0)
+		return l;
+
+	v = HANGUL_V_BASE + (index % HANGUL_N_COUNT) / HANGUL_T_COUNT;
+	if (off == 1)
+		return v;
+
+	t = HANGUL_T_BASE + index % HANGUL_T_COUNT;
+	if (off == 2 && t != HANGUL_T_BASE)
+		return t;
+
+	return NORM_END;
+}
+
+/**
+ * apfs_normalize_char - Normalize a unicode character
+ * @utf32char:	character to normalize
+ * @off:	offset of the wanted character from the normalization
+ * @case_fold:	case fold the char?
+ *
+ * Returns the single character at offset @off in the normalization of
+ * @utf32char, or NORM_END if this offset is past the end.
+ */
+static unicode_t apfs_normalize_char(unicode_t utf32char, int off,
+				     bool case_fold)
+{
+	int nfd_len;
+	unicode_t *nfd, *cf;
+	u16 pos;
+	int ret;
+
+	if (apfs_is_precomposed_hangul(utf32char)) /* Hangul has no case */
+		return apfs_decompose_hangul(utf32char, off);
+
+	ret = apfs_trie_find(apfs_nfd_trie, utf32char,
+			     &pos, false /* is_ccc */);
+	if (!ret) {
+		/* The decomposition is just the same character */
+		nfd_len = 1;
+		nfd = &utf32char;
+	} else {
+		nfd_len = ret;
+		nfd = &apfs_nfd[pos];
+	}
+
+	if (!case_fold) {
+		if (off < nfd_len)
+			return nfd[off];
+		return NORM_END;
+	}
+
+	for (; nfd_len > 0; nfd++, nfd_len--) {
+		int cf_len;
+
+		ret = apfs_trie_find(apfs_cf_trie, *nfd,
+				     &pos, false /* is_ccc */);
+		if (!ret) {
+			/* The case folding is just the same character */
+			cf_len = 1;
+			cf = nfd;
+		} else {
+			cf_len = ret;
+			cf = &apfs_cf[pos];
+		}
+
+		if (off < cf_len)
+			return cf[off];
+		off -= cf_len;
+	}
+
+	return NORM_END;
+}
+
+/**
+ * apfs_get_normalization_length - Count the characters until the next starter
+ * @utf8str:	string to normalize, may begin with several starters
+ * @total_len:	length of the string to normalize
+ * @case_fold:	true if the count should consider case folding
+ *
+ * Returns the number of unicode characters in the normalization of the
+ * substring that begins at @utf8str and ends at the first nonconsecutive
+ * starter. Or 0 if the substring has invalid UTF-8.
+ */
+static int apfs_get_normalization_length(const char *utf8str, unsigned int total_len, bool case_fold)
+{
+	int utf8len, pos, norm_len = 0;
+	bool starters_over = false;
+	unicode_t utf32char;
+
+	while (1) {
+		if (!total_len || !*utf8str)
+			return norm_len;
+		utf8len = utf8_to_utf32(utf8str, min(total_len, 4U), &utf32char);
+		if (utf8len < 0) /* Invalid unicode; don't normalize anything */
+			return 0;
+
+		for (pos = 0;; pos++, norm_len++) {
+			unicode_t utf32norm;
+			u8 ccc;
+
+			utf32norm = apfs_normalize_char(utf32char, pos,
+							case_fold);
+			if (utf32norm == NORM_END)
+				break;
+
+			apfs_trie_find(apfs_ccc_trie, utf32norm, &ccc,
+				       true /* is_ccc */);
+
+			if (ccc != 0)
+				starters_over = true;
+			else if (starters_over) /* Reached the next starter */
+				return norm_len;
+		}
+		utf8str += utf8len;
+		total_len -= utf8len;
+	}
+}
+
+/**
+ * apfs_normalize_next - Return the next normalized character from a string
+ * @cursor:	unicode cursor for the string
+ * @case_fold:	case fold the string?
+ *
+ * Sets @cursor->length to the length of the normalized substring between
+ * @cursor->utf8curr and the first nonconsecutive starter. Returns a single
+ * normalized character, setting @cursor->last_ccc and @cursor->last_pos to
+ * its CCC and position in the substring. When the end of the substring is
+ * reached, updates @cursor->utf8curr to point to the beginning of the next
+ * one.
+ *
+ * Returns 0 if the substring has invalid UTF-8.
+ */
+unicode_t apfs_normalize_next(struct apfs_unicursor *cursor, bool case_fold)
+{
+	const char *utf8str = cursor->utf8curr;
+	unsigned int total_len = cursor->total_len;
+	int str_pos, min_pos = -1;
+	unicode_t utf32min = 0;
+	u8 min_ccc;
+
+new_starter:
+	if (likely(isascii(*utf8str))) {
+		if (!total_len)
+			return 0;
+		cursor->utf8curr = utf8str + 1;
+		cursor->total_len = total_len - 1;
+		if (case_fold)
+			return tolower(*utf8str);
+		return *utf8str;
+	}
+
+	if (cursor->length < 0) {
+		cursor->length = apfs_get_normalization_length(utf8str, total_len, case_fold);
+		if (cursor->length == 0)
+			return 0;
+	}
+
+	str_pos = 0;
+	min_ccc = 0xFF;	/* Above all possible ccc's */
+
+	while (1) {
+		unicode_t utf32char;
+		int utf8len, pos;
+
+		utf8len = utf8_to_utf32(utf8str, min(total_len, 4U), &utf32char);
+		for (pos = 0;; pos++, str_pos++) {
+			unicode_t utf32norm;
+			u8 ccc;
+
+			utf32norm = apfs_normalize_char(utf32char, pos,
+							case_fold);
+			if (utf32norm == NORM_END)
+				break;
+
+			apfs_trie_find(apfs_ccc_trie, utf32norm, &ccc,
+				       true /* is_ccc */);
+
+			if (ccc >= min_ccc || ccc < cursor->last_ccc)
+				continue;
+			if (ccc > cursor->last_ccc ||
+			    str_pos > cursor->last_pos) {
+				utf32min = utf32norm;
+				min_ccc = ccc;
+				min_pos = str_pos;
+			}
+		}
+
+		utf8str += utf8len;
+		total_len -= utf8len;
+		if (str_pos == cursor->length) {
+			/* Reached the following starter */
+			if (min_ccc != 0xFF) {
+				/* Not done with this substring yet */
+				cursor->last_ccc = min_ccc;
+				cursor->last_pos = min_pos;
+				return utf32min;
+			}
+			/* Continue from the next starter */
+			apfs_init_unicursor(cursor, utf8str, total_len);
+			goto new_starter;
+		}
+	}
+}
+
+/*
+ * The following arrays were built with data provided by the Unicode Standard,
+ * version 9.0.
+ *
+ * Copyright (C) 1991-2018 Unicode, Inc.  All rights reserved.  Distributed
+ * under the Terms of Use in http://www.unicode.org/copyright.html.
+ */
+
+static u16 apfs_nfd_trie[] = {
+	/* Node for range 0x_____ */
+	0x0001, 0x0002, 0x0003, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0____ */
+	0x0004, 0x0005, 0x0006, 0x0007, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0008,
+	/* Node for range 0x1____ */
+	0x0000, 0x0009, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x000a, 0x0000, 0x0000,
+	/* Node for range 0x2____ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x000b,
+	/* Node for range 0x00___ */
+	0x000c, 0x000d, 0x000e, 0x000f, 0x0010, 0x0000, 0x0011, 0x0000,
+	0x0000, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0000, 0x0017,
+	/* Node for range 0x01___ */
+	0x0018, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0019, 0x0000, 0x0000, 0x001a, 0x001b,
+	/* Node for range 0x02___ */
+	0x001c, 0x001d, 0x001e, 0x001f, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x03___ */
+	0x0021, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0f___ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0022, 0x0023, 0x0024, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x11___ */
+	0x0025, 0x0026, 0x0000, 0x0027, 0x0028, 0x0029, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x1d___ */
+	0x0000, 0x002a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x2f___ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x002b, 0x002c, 0x002d, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x000__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x002e, 0x002f, 0x0030, 0x0031,
+	/* Node for range 0x001__ */
+	0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039,
+	0x0000, 0x0000, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
+	/* Node for range 0x002__ */
+	0x0040, 0x0041, 0x0042, 0x0043, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x003__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0044, 0x0000, 0x0000, 0x0045,
+	0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x0000, 0x0000,
+	/* Node for range 0x004__ */
+	0x004c, 0x004d, 0x0000, 0x004e, 0x0000, 0x004f, 0x0000, 0x0050,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0051, 0x0052, 0x0053, 0x0054,
+	/* Node for range 0x006__ */
+	0x0000, 0x0000, 0x0055, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0056, 0x0057, 0x0000, 0x0000,
+	/* Node for range 0x009__ */
+	0x0000, 0x0000, 0x0058, 0x0059, 0x0000, 0x005a, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x005b, 0x005c, 0x0000, 0x0000,
+	/* Node for range 0x00a__ */
+	0x0000, 0x0000, 0x0000, 0x005d, 0x0000, 0x005e, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00b__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x005f, 0x0060, 0x0000, 0x0000,
+	0x0000, 0x0061, 0x0000, 0x0000, 0x0062, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00c__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0063, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0064, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00d__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0065, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0066, 0x0000, 0x0000,
+	/* Node for range 0x00f__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0067, 0x0068, 0x0069, 0x006a,
+	0x006b, 0x006c, 0x006d, 0x006e, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x010__ */
+	0x0000, 0x0000, 0x006f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01b__ */
+	0x0070, 0x0071, 0x0000, 0x0072, 0x0073, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01e__ */
+	0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b,
+	0x007c, 0x007d, 0x007e, 0x007f, 0x0080, 0x0081, 0x0082, 0x0083,
+	/* Node for range 0x01f__ */
+	0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008a, 0x008b,
+	0x008c, 0x008d, 0x008e, 0x008f, 0x0090, 0x0091, 0x0092, 0x0093,
+	/* Node for range 0x020__ */
+	0x0094, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x021__ */
+	0x0000, 0x0000, 0x0095, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0096, 0x0097, 0x0000, 0x0098, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x022__ */
+	0x0099, 0x0000, 0x009a, 0x0000, 0x009b, 0x0000, 0x009c, 0x009d,
+	0x009e, 0x0000, 0x009f, 0x0000, 0x0000, 0x0000, 0x00a0, 0x0000,
+	/* Node for range 0x023__ */
+	0x0000, 0x0000, 0x00a1, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x02a__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00a2, 0x0000, 0x0000,
+	/* Node for range 0x030__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x00a3, 0x00a4, 0x00a5, 0x00a6,
+	0x0000, 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x0000, 0x00ac,
+	/* Node for range 0x0f9__ */
+	0x00ad, 0x00ae, 0x00af, 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4,
+	0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc,
+	/* Node for range 0x0fa__ */
+	0x00bd, 0x00be, 0x00bf, 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4,
+	0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x0000, 0x0000,
+	/* Node for range 0x0fb__ */
+	0x0000, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x110__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x00cf, 0x00d0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x111__ */
+	0x0000, 0x0000, 0x00d1, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x113__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x00d2, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x114__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x00d3, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x115__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x00d4, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x1d1__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00d5, 0x00d6, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x00d7, 0x00d8, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x2f8__ */
+	0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df, 0x00e0,
+	0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8,
+	/* Node for range 0x2f9__ */
+	0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, 0x00f0,
+	0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8,
+	/* Node for range 0x2fa__ */
+	0x00f9, 0x00fa, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x000c_ */
+	0x0002, 0x0012, 0x0022, 0x0032, 0x0042, 0x0052, 0x0000, 0x0062,
+	0x0072, 0x0082, 0x0092, 0x00a2, 0x00b2, 0x00c2, 0x00d2, 0x00e2,
+	/* Node for range 0x000d_ */
+	0x0000, 0x00f2, 0x0102, 0x0112, 0x0122, 0x0132, 0x0142, 0x0000,
+	0x0000, 0x0152, 0x0162, 0x0172, 0x0182, 0x0192, 0x0000, 0x0000,
+	/* Node for range 0x000e_ */
+	0x01a2, 0x01b2, 0x01c2, 0x01d2, 0x01e2, 0x01f2, 0x0000, 0x0202,
+	0x0212, 0x0222, 0x0232, 0x0242, 0x0252, 0x0262, 0x0272, 0x0282,
+	/* Node for range 0x000f_ */
+	0x0000, 0x0292, 0x02a2, 0x02b2, 0x02c2, 0x02d2, 0x02e2, 0x0000,
+	0x0000, 0x02f2, 0x0302, 0x0312, 0x0322, 0x0332, 0x0000, 0x0342,
+	/* Node for range 0x0010_ */
+	0x0352, 0x0362, 0x0372, 0x0382, 0x0392, 0x03a2, 0x03b2, 0x03c2,
+	0x03d2, 0x03e2, 0x03f2, 0x0402, 0x0412, 0x0422, 0x0432, 0x0442,
+	/* Node for range 0x0011_ */
+	0x0000, 0x0000, 0x0452, 0x0462, 0x0472, 0x0482, 0x0492, 0x04a2,
+	0x04b2, 0x04c2, 0x04d2, 0x04e2, 0x04f2, 0x0502, 0x0512, 0x0522,
+	/* Node for range 0x0012_ */
+	0x0532, 0x0542, 0x0552, 0x0562, 0x0572, 0x0582, 0x0000, 0x0000,
+	0x0592, 0x05a2, 0x05b2, 0x05c2, 0x05d2, 0x05e2, 0x05f2, 0x0602,
+	/* Node for range 0x0013_ */
+	0x0612, 0x0000, 0x0000, 0x0000, 0x0622, 0x0632, 0x0642, 0x0652,
+	0x0000, 0x0662, 0x0672, 0x0682, 0x0692, 0x06a2, 0x06b2, 0x0000,
+	/* Node for range 0x0014_ */
+	0x0000, 0x0000, 0x0000, 0x06c2, 0x06d2, 0x06e2, 0x06f2, 0x0702,
+	0x0712, 0x0000, 0x0000, 0x0000, 0x0722, 0x0732, 0x0742, 0x0752,
+	/* Node for range 0x0015_ */
+	0x0762, 0x0772, 0x0000, 0x0000, 0x0782, 0x0792, 0x07a2, 0x07b2,
+	0x07c2, 0x07d2, 0x07e2, 0x07f2, 0x0802, 0x0812, 0x0822, 0x0832,
+	/* Node for range 0x0016_ */
+	0x0842, 0x0852, 0x0862, 0x0872, 0x0882, 0x0892, 0x0000, 0x0000,
+	0x08a2, 0x08b2, 0x08c2, 0x08d2, 0x08e2, 0x08f2, 0x0902, 0x0912,
+	/* Node for range 0x0017_ */
+	0x0922, 0x0932, 0x0942, 0x0952, 0x0962, 0x0972, 0x0982, 0x0992,
+	0x09a2, 0x09b2, 0x09c2, 0x09d2, 0x09e2, 0x09f2, 0x0a02, 0x0000,
+	/* Node for range 0x001a_ */
+	0x0a12, 0x0a22, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0a32,
+	/* Node for range 0x001b_ */
+	0x0a42, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x001c_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0a52, 0x0a62, 0x0a72,
+	/* Node for range 0x001d_ */
+	0x0a82, 0x0a92, 0x0aa2, 0x0ab2, 0x0ac2, 0x0ad3, 0x0aeb, 0x0b03,
+	0x0b1b, 0x0b33, 0x0b4b, 0x0b63, 0x0b7b, 0x0000, 0x0b93, 0x0bab,
+	/* Node for range 0x001e_ */
+	0x0bc3, 0x0bdb, 0x0bf2, 0x0c02, 0x0000, 0x0000, 0x0c12, 0x0c22,
+	0x0c32, 0x0c42, 0x0c52, 0x0c62, 0x0c73, 0x0c8b, 0x0ca2, 0x0cb2,
+	/* Node for range 0x001f_ */
+	0x0cc2, 0x0000, 0x0000, 0x0000, 0x0cd2, 0x0ce2, 0x0000, 0x0000,
+	0x0cf2, 0x0d02, 0x0d13, 0x0d2b, 0x0d42, 0x0d52, 0x0d62, 0x0d72,
+	/* Node for range 0x0020_ */
+	0x0d82, 0x0d92, 0x0da2, 0x0db2, 0x0dc2, 0x0dd2, 0x0de2, 0x0df2,
+	0x0e02, 0x0e12, 0x0e22, 0x0e32, 0x0e42, 0x0e52, 0x0e62, 0x0e72,
+	/* Node for range 0x0021_ */
+	0x0e82, 0x0e92, 0x0ea2, 0x0eb2, 0x0ec2, 0x0ed2, 0x0ee2, 0x0ef2,
+	0x0f02, 0x0f12, 0x0f22, 0x0f32, 0x0000, 0x0000, 0x0f42, 0x0f52,
+	/* Node for range 0x0022_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f62, 0x0f72,
+	0x0f82, 0x0f92, 0x0fa3, 0x0fbb, 0x0fd3, 0x0feb, 0x1002, 0x1012,
+	/* Node for range 0x0023_ */
+	0x1023, 0x103b, 0x1052, 0x1062, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0034_ */
+	0x1071, 0x1079, 0x0000, 0x1081, 0x108a, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0037_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x1099, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x10a1, 0x0000,
+	/* Node for range 0x0038_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x10aa, 0x10ba, 0x10c9,
+	0x10d2, 0x10e2, 0x10f2, 0x0000, 0x1102, 0x0000, 0x1112, 0x1122,
+	/* Node for range 0x0039_ */
+	0x1133, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x003a_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x114a, 0x115a, 0x116a, 0x117a, 0x118a, 0x119a,
+	/* Node for range 0x003b_ */
+	0x11ab, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x003c_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x11c2, 0x11d2, 0x11e2, 0x11f2, 0x1202, 0x0000,
+	/* Node for range 0x003d_ */
+	0x0000, 0x0000, 0x0000, 0x1212, 0x1222, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0040_ */
+	0x1232, 0x1242, 0x0000, 0x1252, 0x0000, 0x0000, 0x0000, 0x1262,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x1272, 0x1282, 0x1292, 0x0000,
+	/* Node for range 0x0041_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x12a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0043_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x12b2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0045_ */
+	0x12c2, 0x12d2, 0x0000, 0x12e2, 0x0000, 0x0000, 0x0000, 0x12f2,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x1302, 0x1312, 0x1322, 0x0000,
+	/* Node for range 0x0047_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1332, 0x1342,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x004c_ */
+	0x0000, 0x1352, 0x1362, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x004d_ */
+	0x1372, 0x1382, 0x1392, 0x13a2, 0x0000, 0x0000, 0x13b2, 0x13c2,
+	0x0000, 0x0000, 0x13d2, 0x13e2, 0x13f2, 0x1402, 0x1412, 0x1422,
+	/* Node for range 0x004e_ */
+	0x0000, 0x0000, 0x1432, 0x1442, 0x1452, 0x1462, 0x1472, 0x1482,
+	0x0000, 0x0000, 0x1492, 0x14a2, 0x14b2, 0x14c2, 0x14d2, 0x14e2,
+	/* Node for range 0x004f_ */
+	0x14f2, 0x1502, 0x1512, 0x1522, 0x1532, 0x1542, 0x0000, 0x0000,
+	0x1552, 0x1562, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0062_ */
+	0x0000, 0x0000, 0x1572, 0x1582, 0x1592, 0x15a2, 0x15b2, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x006c_ */
+	0x15c2, 0x0000, 0x15d2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x006d_ */
+	0x0000, 0x0000, 0x0000, 0x15e2, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0092_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x15f2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0093_ */
+	0x0000, 0x1602, 0x0000, 0x0000, 0x1612, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0095_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x1622, 0x1632, 0x1642, 0x1652, 0x1662, 0x1672, 0x1682, 0x1692,
+	/* Node for range 0x009c_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x16a2, 0x16b2, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x009d_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x16c2, 0x16d2, 0x0000, 0x16e2,
+	/* Node for range 0x00a3_ */
+	0x0000, 0x0000, 0x0000, 0x16f2, 0x0000, 0x0000, 0x1702, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00a5_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x1712, 0x1722, 0x1732, 0x0000, 0x0000, 0x1742, 0x0000,
+	/* Node for range 0x00b4_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x1752, 0x0000, 0x0000, 0x1762, 0x1772, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00b5_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x1782, 0x1792, 0x0000, 0x0000,
+	/* Node for range 0x00b9_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x17a2, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00bc_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x17b2, 0x17c2, 0x17d2, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00c4_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x17e2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00cc_ */
+	0x17f2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1802,
+	0x1812, 0x0000, 0x1822, 0x1833, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00d4_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x184a, 0x185a, 0x186a, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00dd_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x187a, 0x0000, 0x188a, 0x189b, 0x18b2, 0x0000,
+	/* Node for range 0x00f4_ */
+	0x0000, 0x0000, 0x0000, 0x18c2, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x18d2, 0x0000, 0x0000,
+	/* Node for range 0x00f5_ */
+	0x0000, 0x0000, 0x18e2, 0x0000, 0x0000, 0x0000, 0x0000, 0x18f2,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x1902, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00f6_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x1912, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00f7_ */
+	0x0000, 0x0000, 0x0000, 0x1922, 0x0000, 0x1932, 0x1942, 0x0000,
+	0x1952, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00f8_ */
+	0x0000, 0x1962, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00f9_ */
+	0x0000, 0x0000, 0x0000, 0x1972, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1982, 0x0000, 0x0000,
+	/* Node for range 0x00fa_ */
+	0x0000, 0x0000, 0x1992, 0x0000, 0x0000, 0x0000, 0x0000, 0x19a2,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x19b2, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x00fb_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x19c2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0102_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x19d2, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01b0_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x19e2, 0x0000,
+	0x19f2, 0x0000, 0x1a02, 0x0000, 0x1a12, 0x0000, 0x1a22, 0x0000,
+	/* Node for range 0x01b1_ */
+	0x0000, 0x0000, 0x1a32, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01b3_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x1a42, 0x0000, 0x1a52, 0x0000, 0x0000,
+	/* Node for range 0x01b4_ */
+	0x1a62, 0x1a72, 0x0000, 0x1a82, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01e0_ */
+	0x1a92, 0x1aa2, 0x1ab2, 0x1ac2, 0x1ad2, 0x1ae2, 0x1af2, 0x1b02,
+	0x1b13, 0x1b2b, 0x1b42, 0x1b52, 0x1b62, 0x1b72, 0x1b82, 0x1b92,
+	/* Node for range 0x01e1_ */
+	0x1ba2, 0x1bb2, 0x1bc2, 0x1bd2, 0x1be3, 0x1bfb, 0x1c13, 0x1c2b,
+	0x1c42, 0x1c52, 0x1c62, 0x1c72, 0x1c83, 0x1c9b, 0x1cb2, 0x1cc2,
+	/* Node for range 0x01e2_ */
+	0x1cd2, 0x1ce2, 0x1cf2, 0x1d02, 0x1d12, 0x1d22, 0x1d32, 0x1d42,
+	0x1d52, 0x1d62, 0x1d72, 0x1d82, 0x1d92, 0x1da2, 0x1db3, 0x1dcb,
+	/* Node for range 0x01e3_ */
+	0x1de2, 0x1df2, 0x1e02, 0x1e12, 0x1e22, 0x1e32, 0x1e42, 0x1e52,
+	0x1e63, 0x1e7b, 0x1e92, 0x1ea2, 0x1eb2, 0x1ec2, 0x1ed2, 0x1ee2,
+	/* Node for range 0x01e4_ */
+	0x1ef2, 0x1f02, 0x1f12, 0x1f22, 0x1f32, 0x1f42, 0x1f52, 0x1f62,
+	0x1f72, 0x1f82, 0x1f92, 0x1fa2, 0x1fb3, 0x1fcb, 0x1fe3, 0x1ffb,
+	/* Node for range 0x01e5_ */
+	0x2013, 0x202b, 0x2043, 0x205b, 0x2072, 0x2082, 0x2092, 0x20a2,
+	0x20b2, 0x20c2, 0x20d2, 0x20e2, 0x20f3, 0x210b, 0x2122, 0x2132,
+	/* Node for range 0x01e6_ */
+	0x2142, 0x2152, 0x2162, 0x2172, 0x2183, 0x219b, 0x21b3, 0x21cb,
+	0x21e3, 0x21fb, 0x2212, 0x2222, 0x2232, 0x2242, 0x2252, 0x2262,
+	/* Node for range 0x01e7_ */
+	0x2272, 0x2282, 0x2292, 0x22a2, 0x22b2, 0x22c2, 0x22d2, 0x22e2,
+	0x22f3, 0x230b, 0x2323, 0x233b, 0x2352, 0x2362, 0x2372, 0x2382,
+	/* Node for range 0x01e8_ */
+	0x2392, 0x23a2, 0x23b2, 0x23c2, 0x23d2, 0x23e2, 0x23f2, 0x2402,
+	0x2412, 0x2422, 0x2432, 0x2442, 0x2452, 0x2462, 0x2472, 0x2482,
+	/* Node for range 0x01e9_ */
+	0x2492, 0x24a2, 0x24b2, 0x24c2, 0x24d2, 0x24e2, 0x24f2, 0x2502,
+	0x2512, 0x2522, 0x0000, 0x2532, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01ea_ */
+	0x2542, 0x2552, 0x2562, 0x2572, 0x2583, 0x259b, 0x25b3, 0x25cb,
+	0x25e3, 0x25fb, 0x2613, 0x262b, 0x2643, 0x265b, 0x2673, 0x268b,
+	/* Node for range 0x01eb_ */
+	0x26a3, 0x26bb, 0x26d3, 0x26eb, 0x2703, 0x271b, 0x2733, 0x274b,
+	0x2762, 0x2772, 0x2782, 0x2792, 0x27a2, 0x27b2, 0x27c3, 0x27db,
+	/* Node for range 0x01ec_ */
+	0x27f3, 0x280b, 0x2823, 0x283b, 0x2853, 0x286b, 0x2883, 0x289b,
+	0x28b2, 0x28c2, 0x28d2, 0x28e2, 0x28f2, 0x2902, 0x2912, 0x2922,
+	/* Node for range 0x01ed_ */
+	0x2933, 0x294b, 0x2963, 0x297b, 0x2993, 0x29ab, 0x29c3, 0x29db,
+	0x29f3, 0x2a0b, 0x2a23, 0x2a3b, 0x2a53, 0x2a6b, 0x2a83, 0x2a9b,
+	/* Node for range 0x01ee_ */
+	0x2ab3, 0x2acb, 0x2ae3, 0x2afb, 0x2b12, 0x2b22, 0x2b32, 0x2b42,
+	0x2b53, 0x2b6b, 0x2b83, 0x2b9b, 0x2bb3, 0x2bcb, 0x2be3, 0x2bfb,
+	/* Node for range 0x01ef_ */
+	0x2c13, 0x2c2b, 0x2c42, 0x2c52, 0x2c62, 0x2c72, 0x2c82, 0x2c92,
+	0x2ca2, 0x2cb2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01f0_ */
+	0x2cc2, 0x2cd2, 0x2ce3, 0x2cfb, 0x2d13, 0x2d2b, 0x2d43, 0x2d5b,
+	0x2d72, 0x2d82, 0x2d93, 0x2dab, 0x2dc3, 0x2ddb, 0x2df3, 0x2e0b,
+	/* Node for range 0x01f1_ */
+	0x2e22, 0x2e32, 0x2e43, 0x2e5b, 0x2e73, 0x2e8b, 0x0000, 0x0000,
+	0x2ea2, 0x2eb2, 0x2ec3, 0x2edb, 0x2ef3, 0x2f0b, 0x0000, 0x0000,
+	/* Node for range 0x01f2_ */
+	0x2f22, 0x2f32, 0x2f43, 0x2f5b, 0x2f73, 0x2f8b, 0x2fa3, 0x2fbb,
+	0x2fd2, 0x2fe2, 0x2ff3, 0x300b, 0x3023, 0x303b, 0x3053, 0x306b,
+	/* Node for range 0x01f3_ */
+	0x3082, 0x3092, 0x30a3, 0x30bb, 0x30d3, 0x30eb, 0x3103, 0x311b,
+	0x3132, 0x3142, 0x3153, 0x316b, 0x3183, 0x319b, 0x31b3, 0x31cb,
+	/* Node for range 0x01f4_ */
+	0x31e2, 0x31f2, 0x3203, 0x321b, 0x3233, 0x324b, 0x0000, 0x0000,
+	0x3262, 0x3272, 0x3283, 0x329b, 0x32b3, 0x32cb, 0x0000, 0x0000,
+	/* Node for range 0x01f5_ */
+	0x32e2, 0x32f2, 0x3303, 0x331b, 0x3333, 0x334b, 0x3363, 0x337b,
+	0x0000, 0x3392, 0x0000, 0x33a3, 0x0000, 0x33bb, 0x0000, 0x33d3,
+	/* Node for range 0x01f6_ */
+	0x33ea, 0x33fa, 0x340b, 0x3423, 0x343b, 0x3453, 0x346b, 0x3483,
+	0x349a, 0x34aa, 0x34bb, 0x34d3, 0x34eb, 0x3503, 0x351b, 0x3533,
+	/* Node for range 0x01f7_ */
+	0x354a, 0x355a, 0x356a, 0x357a, 0x358a, 0x359a, 0x35aa, 0x35ba,
+	0x35ca, 0x35da, 0x35ea, 0x35fa, 0x360a, 0x361a, 0x0000, 0x0000,
+	/* Node for range 0x01f8_ */
+	0x362b, 0x3643, 0x365c, 0x367c, 0x369c, 0x36bc, 0x36dc, 0x36fc,
+	0x371b, 0x3733, 0x374c, 0x376c, 0x378c, 0x37ac, 0x37cc, 0x37ec,
+	/* Node for range 0x01f9_ */
+	0x380b, 0x3823, 0x383c, 0x385c, 0x387c, 0x389c, 0x38bc, 0x38dc,
+	0x38fb, 0x3913, 0x392c, 0x394c, 0x396c, 0x398c, 0x39ac, 0x39cc,
+	/* Node for range 0x01fa_ */
+	0x39eb, 0x3a03, 0x3a1c, 0x3a3c, 0x3a5c, 0x3a7c, 0x3a9c, 0x3abc,
+	0x3adb, 0x3af3, 0x3b0c, 0x3b2c, 0x3b4c, 0x3b6c, 0x3b8c, 0x3bac,
+	/* Node for range 0x01fb_ */
+	0x3bca, 0x3bda, 0x3beb, 0x3c02, 0x3c13, 0x0000, 0x3c2a, 0x3c3b,
+	0x3c52, 0x3c62, 0x3c72, 0x3c82, 0x3c92, 0x0000, 0x3ca1, 0x0000,
+	/* Node for range 0x01fc_ */
+	0x0000, 0x3caa, 0x3cbb, 0x3cd2, 0x3ce3, 0x0000, 0x3cfa, 0x3d0b,
+	0x3d22, 0x3d32, 0x3d42, 0x3d52, 0x3d62, 0x3d72, 0x3d82, 0x3d92,
+	/* Node for range 0x01fd_ */
+	0x3da2, 0x3db2, 0x3dc3, 0x3ddb, 0x0000, 0x0000, 0x3df2, 0x3e03,
+	0x3e1a, 0x3e2a, 0x3e3a, 0x3e4a, 0x0000, 0x3e5a, 0x3e6a, 0x3e7a,
+	/* Node for range 0x01fe_ */
+	0x3e8a, 0x3e9a, 0x3eab, 0x3ec3, 0x3eda, 0x3eea, 0x3efa, 0x3f0b,
+	0x3f22, 0x3f32, 0x3f42, 0x3f52, 0x3f62, 0x3f72, 0x3f82, 0x3f91,
+	/* Node for range 0x01ff_ */
+	0x0000, 0x0000, 0x3f9b, 0x3fb2, 0x3fc3, 0x0000, 0x3fda, 0x3feb,
+	0x4002, 0x4012, 0x4022, 0x4032, 0x4042, 0x4051, 0x0000, 0x0000,
+	/* Node for range 0x0200_ */
+	0x4059, 0x4061, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0212_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4069, 0x0000,
+	0x0000, 0x0000, 0x4071, 0x407a, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0219_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x408a, 0x409a, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x021a_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x40aa, 0x0000,
+	/* Node for range 0x021c_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x40ba, 0x40ca, 0x40da,
+	/* Node for range 0x0220_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x40ea, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x40fa, 0x0000, 0x0000, 0x410a, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0222_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x411a, 0x0000, 0x412a, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0224_ */
+	0x0000, 0x413a, 0x0000, 0x0000, 0x414a, 0x0000, 0x0000, 0x415a,
+	0x0000, 0x416a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0226_ */
+	0x417a, 0x0000, 0x418a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x419a, 0x41aa, 0x41ba,
+	/* Node for range 0x0227_ */
+	0x41ca, 0x41da, 0x0000, 0x0000, 0x41ea, 0x41fa, 0x0000, 0x0000,
+	0x420a, 0x421a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0228_ */
+	0x422a, 0x423a, 0x0000, 0x0000, 0x424a, 0x425a, 0x0000, 0x0000,
+	0x426a, 0x427a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x022a_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x428a, 0x429a, 0x42aa, 0x42ba,
+	/* Node for range 0x022e_ */
+	0x42ca, 0x42da, 0x42ea, 0x42fa, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x430a, 0x431a, 0x432a, 0x433a, 0x0000, 0x0000,
+	/* Node for range 0x0232_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x4349, 0x4351, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x02ad_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x435a, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0304_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x436a, 0x0000, 0x437a, 0x0000,
+	/* Node for range 0x0305_ */
+	0x438a, 0x0000, 0x439a, 0x0000, 0x43aa, 0x0000, 0x43ba, 0x0000,
+	0x43ca, 0x0000, 0x43da, 0x0000, 0x43ea, 0x0000, 0x43fa, 0x0000,
+	/* Node for range 0x0306_ */
+	0x440a, 0x0000, 0x441a, 0x0000, 0x0000, 0x442a, 0x0000, 0x443a,
+	0x0000, 0x444a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0307_ */
+	0x445a, 0x446a, 0x0000, 0x447a, 0x448a, 0x0000, 0x449a, 0x44aa,
+	0x0000, 0x44ba, 0x44ca, 0x0000, 0x44da, 0x44ea, 0x0000, 0x0000,
+	/* Node for range 0x0309_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x44fa, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x450a, 0x0000,
+	/* Node for range 0x030a_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x451a, 0x0000, 0x452a, 0x0000,
+	/* Node for range 0x030b_ */
+	0x453a, 0x0000, 0x454a, 0x0000, 0x455a, 0x0000, 0x456a, 0x0000,
+	0x457a, 0x0000, 0x458a, 0x0000, 0x459a, 0x0000, 0x45aa, 0x0000,
+	/* Node for range 0x030c_ */
+	0x45ba, 0x0000, 0x45ca, 0x0000, 0x0000, 0x45da, 0x0000, 0x45ea,
+	0x0000, 0x45fa, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x030d_ */
+	0x460a, 0x461a, 0x0000, 0x462a, 0x463a, 0x0000, 0x464a, 0x465a,
+	0x0000, 0x466a, 0x467a, 0x0000, 0x468a, 0x469a, 0x0000, 0x0000,
+	/* Node for range 0x030f_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x46aa, 0x0000, 0x0000, 0x46ba,
+	0x46ca, 0x46da, 0x46ea, 0x0000, 0x0000, 0x0000, 0x46fa, 0x0000,
+	/* Node for range 0x0f90_ */
+	0x4709, 0x4711, 0x4719, 0x4721, 0x4729, 0x4731, 0x4739, 0x4741,
+	0x4749, 0x4751, 0x4759, 0x4761, 0x4769, 0x4771, 0x4779, 0x4781,
+	/* Node for range 0x0f91_ */
+	0x4789, 0x4791, 0x4799, 0x47a1, 0x47a9, 0x47b1, 0x47b9, 0x47c1,
+	0x47c9, 0x47d1, 0x47d9, 0x47e1, 0x47e9, 0x47f1, 0x47f9, 0x4801,
+	/* Node for range 0x0f92_ */
+	0x4809, 0x4811, 0x4819, 0x4821, 0x4829, 0x4831, 0x4839, 0x4841,
+	0x4849, 0x4851, 0x4859, 0x4861, 0x4869, 0x4871, 0x4879, 0x4881,
+	/* Node for range 0x0f93_ */
+	0x4889, 0x4891, 0x4899, 0x48a1, 0x48a9, 0x48b1, 0x48b9, 0x48c1,
+	0x48c9, 0x48d1, 0x48d9, 0x48e1, 0x48e9, 0x48f1, 0x48f9, 0x4901,
+	/* Node for range 0x0f94_ */
+	0x4909, 0x4911, 0x4919, 0x4921, 0x4929, 0x4931, 0x4939, 0x4941,
+	0x4949, 0x4951, 0x4959, 0x4961, 0x4969, 0x4971, 0x4979, 0x4981,
+	/* Node for range 0x0f95_ */
+	0x4989, 0x4991, 0x4999, 0x49a1, 0x49a9, 0x49b1, 0x49b9, 0x49c1,
+	0x49c9, 0x49d1, 0x49d9, 0x49e1, 0x49e9, 0x49f1, 0x49f9, 0x4a01,
+	/* Node for range 0x0f96_ */
+	0x4a09, 0x4a11, 0x4a19, 0x4a21, 0x4a29, 0x4a31, 0x4a39, 0x4a41,
+	0x4a49, 0x4a51, 0x4a59, 0x4a61, 0x4a69, 0x4a71, 0x4a79, 0x4a81,
+	/* Node for range 0x0f97_ */
+	0x4a89, 0x4a91, 0x4a99, 0x4aa1, 0x4aa9, 0x4ab1, 0x4ab9, 0x4ac1,
+	0x4ac9, 0x4ad1, 0x4ad9, 0x4ae1, 0x4ae9, 0x4af1, 0x4af9, 0x4b01,
+	/* Node for range 0x0f98_ */
+	0x4b09, 0x4b11, 0x4b19, 0x4b21, 0x4b29, 0x4b31, 0x4b39, 0x4b41,
+	0x4b49, 0x4b51, 0x4b59, 0x4b61, 0x4b69, 0x4b71, 0x4b79, 0x4b81,
+	/* Node for range 0x0f99_ */
+	0x4b89, 0x4b91, 0x4b99, 0x4ba1, 0x4ba9, 0x4bb1, 0x4bb9, 0x4bc1,
+	0x4bc9, 0x4bd1, 0x4bd9, 0x4be1, 0x4be9, 0x4bf1, 0x4bf9, 0x4c01,
+	/* Node for range 0x0f9a_ */
+	0x4c09, 0x4c11, 0x4c19, 0x4c21, 0x4c29, 0x4c31, 0x4c39, 0x4c41,
+	0x4c49, 0x4c51, 0x4c59, 0x4c61, 0x4c69, 0x4c71, 0x4c79, 0x4c81,
+	/* Node for range 0x0f9b_ */
+	0x4c89, 0x4c91, 0x4c99, 0x4ca1, 0x4ca9, 0x4cb1, 0x4cb9, 0x4cc1,
+	0x4cc9, 0x4cd1, 0x4cd9, 0x4ce1, 0x4ce9, 0x4cf1, 0x4cf9, 0x4d01,
+	/* Node for range 0x0f9c_ */
+	0x4d09, 0x4d11, 0x4d19, 0x4d21, 0x4d29, 0x4d31, 0x4d39, 0x4d41,
+	0x4d49, 0x4d51, 0x4d59, 0x4d61, 0x4d69, 0x4d71, 0x4d79, 0x4d81,
+	/* Node for range 0x0f9d_ */
+	0x4d89, 0x4d91, 0x4d99, 0x4da1, 0x4da9, 0x4db1, 0x4db9, 0x4dc1,
+	0x4dc9, 0x4dd1, 0x4dd9, 0x4de1, 0x4de9, 0x4df1, 0x4df9, 0x4e01,
+	/* Node for range 0x0f9e_ */
+	0x4e09, 0x4e11, 0x4e19, 0x4e21, 0x4e29, 0x4e31, 0x4e39, 0x4e41,
+	0x4e49, 0x4e51, 0x4e59, 0x4e61, 0x4e69, 0x4e71, 0x4e79, 0x4e81,
+	/* Node for range 0x0f9f_ */
+	0x4e89, 0x4e91, 0x4e99, 0x4ea1, 0x4ea9, 0x4eb1, 0x4eb9, 0x4ec1,
+	0x4ec9, 0x4ed1, 0x4ed9, 0x4ee1, 0x4ee9, 0x4ef1, 0x4ef9, 0x4f01,
+	/* Node for range 0x0fa0_ */
+	0x4f09, 0x4f11, 0x4f19, 0x4f21, 0x4f29, 0x4f31, 0x4f39, 0x4f41,
+	0x4f49, 0x4f51, 0x4f59, 0x4f61, 0x4f69, 0x4f71, 0x0000, 0x0000,
+	/* Node for range 0x0fa1_ */
+	0x4f79, 0x0000, 0x4f81, 0x0000, 0x0000, 0x4f89, 0x4f91, 0x4f99,
+	0x4fa1, 0x4fa9, 0x4fb1, 0x4fb9, 0x4fc1, 0x4fc9, 0x4fd1, 0x0000,
+	/* Node for range 0x0fa2_ */
+	0x4fd9, 0x0000, 0x4fe1, 0x0000, 0x0000, 0x4fe9, 0x4ff1, 0x0000,
+	0x0000, 0x0000, 0x4ff9, 0x5001, 0x5009, 0x5011, 0x5019, 0x5021,
+	/* Node for range 0x0fa3_ */
+	0x5029, 0x5031, 0x5039, 0x5041, 0x5049, 0x5051, 0x5059, 0x5061,
+	0x5069, 0x5071, 0x5079, 0x5081, 0x5089, 0x5091, 0x5099, 0x50a1,
+	/* Node for range 0x0fa4_ */
+	0x50a9, 0x50b1, 0x50b9, 0x50c1, 0x50c9, 0x50d1, 0x50d9, 0x50e1,
+	0x50e9, 0x50f1, 0x50f9, 0x5101, 0x5109, 0x5111, 0x5119, 0x5121,
+	/* Node for range 0x0fa5_ */
+	0x5129, 0x5131, 0x5139, 0x5141, 0x5149, 0x5151, 0x5159, 0x5161,
+	0x5169, 0x5171, 0x5179, 0x5181, 0x5189, 0x5191, 0x5199, 0x51a1,
+	/* Node for range 0x0fa6_ */
+	0x51a9, 0x51b1, 0x51b9, 0x51c1, 0x51c9, 0x51d1, 0x51d9, 0x51e1,
+	0x51e9, 0x51f1, 0x51f9, 0x5201, 0x5209, 0x5211, 0x0000, 0x0000,
+	/* Node for range 0x0fa7_ */
+	0x5219, 0x5221, 0x5229, 0x5231, 0x5239, 0x5241, 0x5249, 0x5251,
+	0x5259, 0x5261, 0x5269, 0x5271, 0x5279, 0x5281, 0x5289, 0x5291,
+	/* Node for range 0x0fa8_ */
+	0x5299, 0x52a1, 0x52a9, 0x52b1, 0x52b9, 0x52c1, 0x52c9, 0x52d1,
+	0x52d9, 0x52e1, 0x52e9, 0x52f1, 0x52f9, 0x5301, 0x5309, 0x5311,
+	/* Node for range 0x0fa9_ */
+	0x5319, 0x5321, 0x5329, 0x5331, 0x5339, 0x5341, 0x5349, 0x5351,
+	0x5359, 0x5361, 0x5369, 0x5371, 0x5379, 0x5381, 0x5389, 0x5391,
+	/* Node for range 0x0faa_ */
+	0x5399, 0x53a1, 0x53a9, 0x53b1, 0x53b9, 0x53c1, 0x53c9, 0x53d1,
+	0x53d9, 0x53e1, 0x53e9, 0x53f1, 0x53f9, 0x5401, 0x5409, 0x5411,
+	/* Node for range 0x0fab_ */
+	0x5419, 0x5421, 0x5429, 0x5431, 0x5439, 0x5441, 0x5449, 0x5451,
+	0x5459, 0x5461, 0x5469, 0x5471, 0x5479, 0x5481, 0x5489, 0x5491,
+	/* Node for range 0x0fac_ */
+	0x5499, 0x54a1, 0x54a9, 0x54b1, 0x54b9, 0x54c1, 0x54c9, 0x54d1,
+	0x54d9, 0x54e1, 0x54e9, 0x54f1, 0x54f9, 0x5501, 0x5509, 0x5511,
+	/* Node for range 0x0fad_ */
+	0x5519, 0x5521, 0x5529, 0x5531, 0x5539, 0x5541, 0x5549, 0x5551,
+	0x5559, 0x5561, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0fb1_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x556a, 0x0000, 0x557a,
+	/* Node for range 0x0fb2_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x558a, 0x559a, 0x55ab, 0x55c3, 0x55da, 0x55ea,
+	/* Node for range 0x0fb3_ */
+	0x55fa, 0x560a, 0x561a, 0x562a, 0x563a, 0x564a, 0x565a, 0x0000,
+	0x566a, 0x567a, 0x568a, 0x569a, 0x56aa, 0x0000, 0x56ba, 0x0000,
+	/* Node for range 0x0fb4_ */
+	0x56ca, 0x56da, 0x0000, 0x56ea, 0x56fa, 0x0000, 0x570a, 0x571a,
+	0x572a, 0x573a, 0x574a, 0x575a, 0x576a, 0x577a, 0x578a, 0x0000,
+	/* Node for range 0x1109_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x579a, 0x0000, 0x57aa, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x110a_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x57ba, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x1112_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x57ca, 0x57da,
+	/* Node for range 0x1134_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x57ea, 0x57fa, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x114b_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x580a, 0x581a, 0x0000, 0x582a, 0x0000,
+	/* Node for range 0x115b_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x583a, 0x584a, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x1d15_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x585a, 0x586a,
+	/* Node for range 0x1d16_ */
+	0x587b, 0x5893, 0x58ab, 0x58c3, 0x58db, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x1d1b_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x58f2, 0x5902, 0x5913, 0x592b, 0x5943,
+	/* Node for range 0x1d1c_ */
+	0x595b, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x2f80_ */
+	0x5971, 0x5979, 0x5981, 0x5989, 0x5991, 0x5999, 0x59a1, 0x59a9,
+	0x59b1, 0x59b9, 0x59c1, 0x59c9, 0x59d1, 0x59d9, 0x59e1, 0x59e9,
+	/* Node for range 0x2f81_ */
+	0x59f1, 0x59f9, 0x5a01, 0x5a09, 0x5a11, 0x5a19, 0x5a21, 0x5a29,
+	0x5a31, 0x5a39, 0x5a41, 0x5a49, 0x5a51, 0x5a59, 0x5a61, 0x5a69,
+	/* Node for range 0x2f82_ */
+	0x5a71, 0x5a79, 0x5a81, 0x5a89, 0x5a91, 0x5a99, 0x5aa1, 0x5aa9,
+	0x5ab1, 0x5ab9, 0x5ac1, 0x5ac9, 0x5ad1, 0x5ad9, 0x5ae1, 0x5ae9,
+	/* Node for range 0x2f83_ */
+	0x5af1, 0x5af9, 0x5b01, 0x5b09, 0x5b11, 0x5b19, 0x5b21, 0x5b29,
+	0x5b31, 0x5b39, 0x5b41, 0x5b49, 0x5b51, 0x5b59, 0x5b61, 0x5b69,
+	/* Node for range 0x2f84_ */
+	0x5b71, 0x5b79, 0x5b81, 0x5b89, 0x5b91, 0x5b99, 0x5ba1, 0x5ba9,
+	0x5bb1, 0x5bb9, 0x5bc1, 0x5bc9, 0x5bd1, 0x5bd9, 0x5be1, 0x5be9,
+	/* Node for range 0x2f85_ */
+	0x5bf1, 0x5bf9, 0x5c01, 0x5c09, 0x5c11, 0x5c19, 0x5c21, 0x5c29,
+	0x5c31, 0x5c39, 0x5c41, 0x5c49, 0x5c51, 0x5c59, 0x5c61, 0x5c69,
+	/* Node for range 0x2f86_ */
+	0x5c71, 0x5c79, 0x5c81, 0x5c89, 0x5c91, 0x5c99, 0x5ca1, 0x5ca9,
+	0x5cb1, 0x5cb9, 0x5cc1, 0x5cc9, 0x5cd1, 0x5cd9, 0x5ce1, 0x5ce9,
+	/* Node for range 0x2f87_ */
+	0x5cf1, 0x5cf9, 0x5d01, 0x5d09, 0x5d11, 0x5d19, 0x5d21, 0x5d29,
+	0x5d31, 0x5d39, 0x5d41, 0x5d49, 0x5d51, 0x5d59, 0x5d61, 0x5d69,
+	/* Node for range 0x2f88_ */
+	0x5d71, 0x5d79, 0x5d81, 0x5d89, 0x5d91, 0x5d99, 0x5da1, 0x5da9,
+	0x5db1, 0x5db9, 0x5dc1, 0x5dc9, 0x5dd1, 0x5dd9, 0x5de1, 0x5de9,
+	/* Node for range 0x2f89_ */
+	0x5df1, 0x5df9, 0x5e01, 0x5e09, 0x5e11, 0x5e19, 0x5e21, 0x5e29,
+	0x5e31, 0x5e39, 0x5e41, 0x5e49, 0x5e51, 0x5e59, 0x5e61, 0x5e69,
+	/* Node for range 0x2f8a_ */
+	0x5e71, 0x5e79, 0x5e81, 0x5e89, 0x5e91, 0x5e99, 0x5ea1, 0x5ea9,
+	0x5eb1, 0x5eb9, 0x5ec1, 0x5ec9, 0x5ed1, 0x5ed9, 0x5ee1, 0x5ee9,
+	/* Node for range 0x2f8b_ */
+	0x5ef1, 0x5ef9, 0x5f01, 0x5f09, 0x5f11, 0x5f19, 0x5f21, 0x5f29,
+	0x5f31, 0x5f39, 0x5f41, 0x5f49, 0x5f51, 0x5f59, 0x5f61, 0x5f69,
+	/* Node for range 0x2f8c_ */
+	0x5f71, 0x5f79, 0x5f81, 0x5f89, 0x5f91, 0x5f99, 0x5fa1, 0x5fa9,
+	0x5fb1, 0x5fb9, 0x5fc1, 0x5fc9, 0x5fd1, 0x5fd9, 0x5fe1, 0x5fe9,
+	/* Node for range 0x2f8d_ */
+	0x5ff1, 0x5ff9, 0x6001, 0x6009, 0x6011, 0x6019, 0x6021, 0x6029,
+	0x6031, 0x6039, 0x6041, 0x6049, 0x6051, 0x6059, 0x6061, 0x6069,
+	/* Node for range 0x2f8e_ */
+	0x6071, 0x6079, 0x6081, 0x6089, 0x6091, 0x6099, 0x60a1, 0x60a9,
+	0x60b1, 0x60b9, 0x60c1, 0x60c9, 0x60d1, 0x60d9, 0x60e1, 0x60e9,
+	/* Node for range 0x2f8f_ */
+	0x60f1, 0x60f9, 0x6101, 0x6109, 0x6111, 0x6119, 0x6121, 0x6129,
+	0x6131, 0x6139, 0x6141, 0x6149, 0x6151, 0x6159, 0x6161, 0x6169,
+	/* Node for range 0x2f90_ */
+	0x6171, 0x6179, 0x6181, 0x6189, 0x6191, 0x6199, 0x61a1, 0x61a9,
+	0x61b1, 0x61b9, 0x61c1, 0x61c9, 0x61d1, 0x61d9, 0x61e1, 0x61e9,
+	/* Node for range 0x2f91_ */
+	0x61f1, 0x61f9, 0x6201, 0x6209, 0x6211, 0x6219, 0x6221, 0x6229,
+	0x6231, 0x6239, 0x6241, 0x6249, 0x6251, 0x6259, 0x6261, 0x6269,
+	/* Node for range 0x2f92_ */
+	0x6271, 0x6279, 0x6281, 0x6289, 0x6291, 0x6299, 0x62a1, 0x62a9,
+	0x62b1, 0x62b9, 0x62c1, 0x62c9, 0x62d1, 0x62d9, 0x62e1, 0x62e9,
+	/* Node for range 0x2f93_ */
+	0x62f1, 0x62f9, 0x6301, 0x6309, 0x6311, 0x6319, 0x6321, 0x6329,
+	0x6331, 0x6339, 0x6341, 0x6349, 0x6351, 0x6359, 0x6361, 0x6369,
+	/* Node for range 0x2f94_ */
+	0x6371, 0x6379, 0x6381, 0x6389, 0x6391, 0x6399, 0x63a1, 0x63a9,
+	0x63b1, 0x63b9, 0x63c1, 0x63c9, 0x63d1, 0x63d9, 0x63e1, 0x63e9,
+	/* Node for range 0x2f95_ */
+	0x63f1, 0x63f9, 0x6401, 0x6409, 0x6411, 0x6419, 0x6421, 0x6429,
+	0x6431, 0x6439, 0x6441, 0x6449, 0x6451, 0x6459, 0x6461, 0x6469,
+	/* Node for range 0x2f96_ */
+	0x6471, 0x6479, 0x6481, 0x6489, 0x6491, 0x6499, 0x64a1, 0x64a9,
+	0x64b1, 0x64b9, 0x64c1, 0x64c9, 0x64d1, 0x64d9, 0x64e1, 0x64e9,
+	/* Node for range 0x2f97_ */
+	0x64f1, 0x64f9, 0x6501, 0x6509, 0x6511, 0x6519, 0x6521, 0x6529,
+	0x6531, 0x6539, 0x6541, 0x6549, 0x6551, 0x6559, 0x6561, 0x6569,
+	/* Node for range 0x2f98_ */
+	0x6571, 0x6579, 0x6581, 0x6589, 0x6591, 0x6599, 0x65a1, 0x65a9,
+	0x65b1, 0x65b9, 0x65c1, 0x65c9, 0x65d1, 0x65d9, 0x65e1, 0x65e9,
+	/* Node for range 0x2f99_ */
+	0x65f1, 0x65f9, 0x6601, 0x6609, 0x6611, 0x6619, 0x6621, 0x6629,
+	0x6631, 0x6639, 0x6641, 0x6649, 0x6651, 0x6659, 0x6661, 0x6669,
+	/* Node for range 0x2f9a_ */
+	0x6671, 0x6679, 0x6681, 0x6689, 0x6691, 0x6699, 0x66a1, 0x66a9,
+	0x66b1, 0x66b9, 0x66c1, 0x66c9, 0x66d1, 0x66d9, 0x66e1, 0x66e9,
+	/* Node for range 0x2f9b_ */
+	0x66f1, 0x66f9, 0x6701, 0x6709, 0x6711, 0x6719, 0x6721, 0x6729,
+	0x6731, 0x6739, 0x6741, 0x6749, 0x6751, 0x6759, 0x6761, 0x6769,
+	/* Node for range 0x2f9c_ */
+	0x6771, 0x6779, 0x6781, 0x6789, 0x6791, 0x6799, 0x67a1, 0x67a9,
+	0x67b1, 0x67b9, 0x67c1, 0x67c9, 0x67d1, 0x67d9, 0x67e1, 0x67e9,
+	/* Node for range 0x2f9d_ */
+	0x67f1, 0x67f9, 0x6801, 0x6809, 0x6811, 0x6819, 0x6821, 0x6829,
+	0x6831, 0x6839, 0x6841, 0x6849, 0x6851, 0x6859, 0x6861, 0x6869,
+	/* Node for range 0x2f9e_ */
+	0x6871, 0x6879, 0x6881, 0x6889, 0x6891, 0x6899, 0x68a1, 0x68a9,
+	0x68b1, 0x68b9, 0x68c1, 0x68c9, 0x68d1, 0x68d9, 0x68e1, 0x68e9,
+	/* Node for range 0x2f9f_ */
+	0x68f1, 0x68f9, 0x6901, 0x6909, 0x6911, 0x6919, 0x6921, 0x6929,
+	0x6931, 0x6939, 0x6941, 0x6949, 0x6951, 0x6959, 0x6961, 0x6969,
+	/* Node for range 0x2fa0_ */
+	0x6971, 0x6979, 0x6981, 0x6989, 0x6991, 0x6999, 0x69a1, 0x69a9,
+	0x69b1, 0x69b9, 0x69c1, 0x69c9, 0x69d1, 0x69d9, 0x69e1, 0x69e9,
+	/* Node for range 0x2fa1_ */
+	0x69f1, 0x69f9, 0x6a01, 0x6a09, 0x6a11, 0x6a19, 0x6a21, 0x6a29,
+	0x6a31, 0x6a39, 0x6a41, 0x6a49, 0x6a51, 0x6a59, 0x0000, 0x0000,
+};
+
+static unicode_t apfs_nfd[] = {
+	0x000041, 0x000300, 0x000041, 0x000301, 0x000041, 0x000302,
+	0x000041, 0x000303, 0x000041, 0x000308, 0x000041, 0x00030a,
+	0x000043, 0x000327, 0x000045, 0x000300, 0x000045, 0x000301,
+	0x000045, 0x000302, 0x000045, 0x000308, 0x000049, 0x000300,
+	0x000049, 0x000301, 0x000049, 0x000302, 0x000049, 0x000308,
+	0x00004e, 0x000303, 0x00004f, 0x000300, 0x00004f, 0x000301,
+	0x00004f, 0x000302, 0x00004f, 0x000303, 0x00004f, 0x000308,
+	0x000055, 0x000300, 0x000055, 0x000301, 0x000055, 0x000302,
+	0x000055, 0x000308, 0x000059, 0x000301, 0x000061, 0x000300,
+	0x000061, 0x000301, 0x000061, 0x000302, 0x000061, 0x000303,
+	0x000061, 0x000308, 0x000061, 0x00030a, 0x000063, 0x000327,
+	0x000065, 0x000300, 0x000065, 0x000301, 0x000065, 0x000302,
+	0x000065, 0x000308, 0x000069, 0x000300, 0x000069, 0x000301,
+	0x000069, 0x000302, 0x000069, 0x000308, 0x00006e, 0x000303,
+	0x00006f, 0x000300, 0x00006f, 0x000301, 0x00006f, 0x000302,
+	0x00006f, 0x000303, 0x00006f, 0x000308, 0x000075, 0x000300,
+	0x000075, 0x000301, 0x000075, 0x000302, 0x000075, 0x000308,
+	0x000079, 0x000301, 0x000079, 0x000308, 0x000041, 0x000304,
+	0x000061, 0x000304, 0x000041, 0x000306, 0x000061, 0x000306,
+	0x000041, 0x000328, 0x000061, 0x000328, 0x000043, 0x000301,
+	0x000063, 0x000301, 0x000043, 0x000302, 0x000063, 0x000302,
+	0x000043, 0x000307, 0x000063, 0x000307, 0x000043, 0x00030c,
+	0x000063, 0x00030c, 0x000044, 0x00030c, 0x000064, 0x00030c,
+	0x000045, 0x000304, 0x000065, 0x000304, 0x000045, 0x000306,
+	0x000065, 0x000306, 0x000045, 0x000307, 0x000065, 0x000307,
+	0x000045, 0x000328, 0x000065, 0x000328, 0x000045, 0x00030c,
+	0x000065, 0x00030c, 0x000047, 0x000302, 0x000067, 0x000302,
+	0x000047, 0x000306, 0x000067, 0x000306, 0x000047, 0x000307,
+	0x000067, 0x000307, 0x000047, 0x000327, 0x000067, 0x000327,
+	0x000048, 0x000302, 0x000068, 0x000302, 0x000049, 0x000303,
+	0x000069, 0x000303, 0x000049, 0x000304, 0x000069, 0x000304,
+	0x000049, 0x000306, 0x000069, 0x000306, 0x000049, 0x000328,
+	0x000069, 0x000328, 0x000049, 0x000307, 0x00004a, 0x000302,
+	0x00006a, 0x000302, 0x00004b, 0x000327, 0x00006b, 0x000327,
+	0x00004c, 0x000301, 0x00006c, 0x000301, 0x00004c, 0x000327,
+	0x00006c, 0x000327, 0x00004c, 0x00030c, 0x00006c, 0x00030c,
+	0x00004e, 0x000301, 0x00006e, 0x000301, 0x00004e, 0x000327,
+	0x00006e, 0x000327, 0x00004e, 0x00030c, 0x00006e, 0x00030c,
+	0x00004f, 0x000304, 0x00006f, 0x000304, 0x00004f, 0x000306,
+	0x00006f, 0x000306, 0x00004f, 0x00030b, 0x00006f, 0x00030b,
+	0x000052, 0x000301, 0x000072, 0x000301, 0x000052, 0x000327,
+	0x000072, 0x000327, 0x000052, 0x00030c, 0x000072, 0x00030c,
+	0x000053, 0x000301, 0x000073, 0x000301, 0x000053, 0x000302,
+	0x000073, 0x000302, 0x000053, 0x000327, 0x000073, 0x000327,
+	0x000053, 0x00030c, 0x000073, 0x00030c, 0x000054, 0x000327,
+	0x000074, 0x000327, 0x000054, 0x00030c, 0x000074, 0x00030c,
+	0x000055, 0x000303, 0x000075, 0x000303, 0x000055, 0x000304,
+	0x000075, 0x000304, 0x000055, 0x000306, 0x000075, 0x000306,
+	0x000055, 0x00030a, 0x000075, 0x00030a, 0x000055, 0x00030b,
+	0x000075, 0x00030b, 0x000055, 0x000328, 0x000075, 0x000328,
+	0x000057, 0x000302, 0x000077, 0x000302, 0x000059, 0x000302,
+	0x000079, 0x000302, 0x000059, 0x000308, 0x00005a, 0x000301,
+	0x00007a, 0x000301, 0x00005a, 0x000307, 0x00007a, 0x000307,
+	0x00005a, 0x00030c, 0x00007a, 0x00030c, 0x00004f, 0x00031b,
+	0x00006f, 0x00031b, 0x000055, 0x00031b, 0x000075, 0x00031b,
+	0x000041, 0x00030c, 0x000061, 0x00030c, 0x000049, 0x00030c,
+	0x000069, 0x00030c, 0x00004f, 0x00030c, 0x00006f, 0x00030c,
+	0x000055, 0x00030c, 0x000075, 0x00030c, 0x000055, 0x000308,
+	0x000304, 0x000075, 0x000308, 0x000304, 0x000055, 0x000308,
+	0x000301, 0x000075, 0x000308, 0x000301, 0x000055, 0x000308,
+	0x00030c, 0x000075, 0x000308, 0x00030c, 0x000055, 0x000308,
+	0x000300, 0x000075, 0x000308, 0x000300, 0x000041, 0x000308,
+	0x000304, 0x000061, 0x000308, 0x000304, 0x000041, 0x000307,
+	0x000304, 0x000061, 0x000307, 0x000304, 0x0000c6, 0x000304,
+	0x0000e6, 0x000304, 0x000047, 0x00030c, 0x000067, 0x00030c,
+	0x00004b, 0x00030c, 0x00006b, 0x00030c, 0x00004f, 0x000328,
+	0x00006f, 0x000328, 0x00004f, 0x000328, 0x000304, 0x00006f,
+	0x000328, 0x000304, 0x0001b7, 0x00030c, 0x000292, 0x00030c,
+	0x00006a, 0x00030c, 0x000047, 0x000301, 0x000067, 0x000301,
+	0x00004e, 0x000300, 0x00006e, 0x000300, 0x000041, 0x00030a,
+	0x000301, 0x000061, 0x00030a, 0x000301, 0x0000c6, 0x000301,
+	0x0000e6, 0x000301, 0x0000d8, 0x000301, 0x0000f8, 0x000301,
+	0x000041, 0x00030f, 0x000061, 0x00030f, 0x000041, 0x000311,
+	0x000061, 0x000311, 0x000045, 0x00030f, 0x000065, 0x00030f,
+	0x000045, 0x000311, 0x000065, 0x000311, 0x000049, 0x00030f,
+	0x000069, 0x00030f, 0x000049, 0x000311, 0x000069, 0x000311,
+	0x00004f, 0x00030f, 0x00006f, 0x00030f, 0x00004f, 0x000311,
+	0x00006f, 0x000311, 0x000052, 0x00030f, 0x000072, 0x00030f,
+	0x000052, 0x000311, 0x000072, 0x000311, 0x000055, 0x00030f,
+	0x000075, 0x00030f, 0x000055, 0x000311, 0x000075, 0x000311,
+	0x000053, 0x000326, 0x000073, 0x000326, 0x000054, 0x000326,
+	0x000074, 0x000326, 0x000048, 0x00030c, 0x000068, 0x00030c,
+	0x000041, 0x000307, 0x000061, 0x000307, 0x000045, 0x000327,
+	0x000065, 0x000327, 0x00004f, 0x000308, 0x000304, 0x00006f,
+	0x000308, 0x000304, 0x00004f, 0x000303, 0x000304, 0x00006f,
+	0x000303, 0x000304, 0x00004f, 0x000307, 0x00006f, 0x000307,
+	0x00004f, 0x000307, 0x000304, 0x00006f, 0x000307, 0x000304,
+	0x000059, 0x000304, 0x000079, 0x000304, 0x000300, 0x000301,
+	0x000313, 0x000308, 0x000301, 0x0002b9, 0x00003b, 0x0000a8,
+	0x000301, 0x000391, 0x000301, 0x0000b7, 0x000395, 0x000301,
+	0x000397, 0x000301, 0x000399, 0x000301, 0x00039f, 0x000301,
+	0x0003a5, 0x000301, 0x0003a9, 0x000301, 0x0003b9, 0x000308,
+	0x000301, 0x000399, 0x000308, 0x0003a5, 0x000308, 0x0003b1,
+	0x000301, 0x0003b5, 0x000301, 0x0003b7, 0x000301, 0x0003b9,
+	0x000301, 0x0003c5, 0x000308, 0x000301, 0x0003b9, 0x000308,
+	0x0003c5, 0x000308, 0x0003bf, 0x000301, 0x0003c5, 0x000301,
+	0x0003c9, 0x000301, 0x0003d2, 0x000301, 0x0003d2, 0x000308,
+	0x000415, 0x000300, 0x000415, 0x000308, 0x000413, 0x000301,
+	0x000406, 0x000308, 0x00041a, 0x000301, 0x000418, 0x000300,
+	0x000423, 0x000306, 0x000418, 0x000306, 0x000438, 0x000306,
+	0x000435, 0x000300, 0x000435, 0x000308, 0x000433, 0x000301,
+	0x000456, 0x000308, 0x00043a, 0x000301, 0x000438, 0x000300,
+	0x000443, 0x000306, 0x000474, 0x00030f, 0x000475, 0x00030f,
+	0x000416, 0x000306, 0x000436, 0x000306, 0x000410, 0x000306,
+	0x000430, 0x000306, 0x000410, 0x000308, 0x000430, 0x000308,
+	0x000415, 0x000306, 0x000435, 0x000306, 0x0004d8, 0x000308,
+	0x0004d9, 0x000308, 0x000416, 0x000308, 0x000436, 0x000308,
+	0x000417, 0x000308, 0x000437, 0x000308, 0x000418, 0x000304,
+	0x000438, 0x000304, 0x000418, 0x000308, 0x000438, 0x000308,
+	0x00041e, 0x000308, 0x00043e, 0x000308, 0x0004e8, 0x000308,
+	0x0004e9, 0x000308, 0x00042d, 0x000308, 0x00044d, 0x000308,
+	0x000423, 0x000304, 0x000443, 0x000304, 0x000423, 0x000308,
+	0x000443, 0x000308, 0x000423, 0x00030b, 0x000443, 0x00030b,
+	0x000427, 0x000308, 0x000447, 0x000308, 0x00042b, 0x000308,
+	0x00044b, 0x000308, 0x000627, 0x000653, 0x000627, 0x000654,
+	0x000648, 0x000654, 0x000627, 0x000655, 0x00064a, 0x000654,
+	0x0006d5, 0x000654, 0x0006c1, 0x000654, 0x0006d2, 0x000654,
+	0x000928, 0x00093c, 0x000930, 0x00093c, 0x000933, 0x00093c,
+	0x000915, 0x00093c, 0x000916, 0x00093c, 0x000917, 0x00093c,
+	0x00091c, 0x00093c, 0x000921, 0x00093c, 0x000922, 0x00093c,
+	0x00092b, 0x00093c, 0x00092f, 0x00093c, 0x0009c7, 0x0009be,
+	0x0009c7, 0x0009d7, 0x0009a1, 0x0009bc, 0x0009a2, 0x0009bc,
+	0x0009af, 0x0009bc, 0x000a32, 0x000a3c, 0x000a38, 0x000a3c,
+	0x000a16, 0x000a3c, 0x000a17, 0x000a3c, 0x000a1c, 0x000a3c,
+	0x000a2b, 0x000a3c, 0x000b47, 0x000b56, 0x000b47, 0x000b3e,
+	0x000b47, 0x000b57, 0x000b21, 0x000b3c, 0x000b22, 0x000b3c,
+	0x000b92, 0x000bd7, 0x000bc6, 0x000bbe, 0x000bc7, 0x000bbe,
+	0x000bc6, 0x000bd7, 0x000c46, 0x000c56, 0x000cbf, 0x000cd5,
+	0x000cc6, 0x000cd5, 0x000cc6, 0x000cd6, 0x000cc6, 0x000cc2,
+	0x000cc6, 0x000cc2, 0x000cd5, 0x000d46, 0x000d3e, 0x000d47,
+	0x000d3e, 0x000d46, 0x000d57, 0x000dd9, 0x000dca, 0x000dd9,
+	0x000dcf, 0x000dd9, 0x000dcf, 0x000dca, 0x000dd9, 0x000ddf,
+	0x000f42, 0x000fb7, 0x000f4c, 0x000fb7, 0x000f51, 0x000fb7,
+	0x000f56, 0x000fb7, 0x000f5b, 0x000fb7, 0x000f40, 0x000fb5,
+	0x000f71, 0x000f72, 0x000f71, 0x000f74, 0x000fb2, 0x000f80,
+	0x000fb3, 0x000f80, 0x000f71, 0x000f80, 0x000f92, 0x000fb7,
+	0x000f9c, 0x000fb7, 0x000fa1, 0x000fb7, 0x000fa6, 0x000fb7,
+	0x000fab, 0x000fb7, 0x000f90, 0x000fb5, 0x001025, 0x00102e,
+	0x001b05, 0x001b35, 0x001b07, 0x001b35, 0x001b09, 0x001b35,
+	0x001b0b, 0x001b35, 0x001b0d, 0x001b35, 0x001b11, 0x001b35,
+	0x001b3a, 0x001b35, 0x001b3c, 0x001b35, 0x001b3e, 0x001b35,
+	0x001b3f, 0x001b35, 0x001b42, 0x001b35, 0x000041, 0x000325,
+	0x000061, 0x000325, 0x000042, 0x000307, 0x000062, 0x000307,
+	0x000042, 0x000323, 0x000062, 0x000323, 0x000042, 0x000331,
+	0x000062, 0x000331, 0x000043, 0x000327, 0x000301, 0x000063,
+	0x000327, 0x000301, 0x000044, 0x000307, 0x000064, 0x000307,
+	0x000044, 0x000323, 0x000064, 0x000323, 0x000044, 0x000331,
+	0x000064, 0x000331, 0x000044, 0x000327, 0x000064, 0x000327,
+	0x000044, 0x00032d, 0x000064, 0x00032d, 0x000045, 0x000304,
+	0x000300, 0x000065, 0x000304, 0x000300, 0x000045, 0x000304,
+	0x000301, 0x000065, 0x000304, 0x000301, 0x000045, 0x00032d,
+	0x000065, 0x00032d, 0x000045, 0x000330, 0x000065, 0x000330,
+	0x000045, 0x000327, 0x000306, 0x000065, 0x000327, 0x000306,
+	0x000046, 0x000307, 0x000066, 0x000307, 0x000047, 0x000304,
+	0x000067, 0x000304, 0x000048, 0x000307, 0x000068, 0x000307,
+	0x000048, 0x000323, 0x000068, 0x000323, 0x000048, 0x000308,
+	0x000068, 0x000308, 0x000048, 0x000327, 0x000068, 0x000327,
+	0x000048, 0x00032e, 0x000068, 0x00032e, 0x000049, 0x000330,
+	0x000069, 0x000330, 0x000049, 0x000308, 0x000301, 0x000069,
+	0x000308, 0x000301, 0x00004b, 0x000301, 0x00006b, 0x000301,
+	0x00004b, 0x000323, 0x00006b, 0x000323, 0x00004b, 0x000331,
+	0x00006b, 0x000331, 0x00004c, 0x000323, 0x00006c, 0x000323,
+	0x00004c, 0x000323, 0x000304, 0x00006c, 0x000323, 0x000304,
+	0x00004c, 0x000331, 0x00006c, 0x000331, 0x00004c, 0x00032d,
+	0x00006c, 0x00032d, 0x00004d, 0x000301, 0x00006d, 0x000301,
+	0x00004d, 0x000307, 0x00006d, 0x000307, 0x00004d, 0x000323,
+	0x00006d, 0x000323, 0x00004e, 0x000307, 0x00006e, 0x000307,
+	0x00004e, 0x000323, 0x00006e, 0x000323, 0x00004e, 0x000331,
+	0x00006e, 0x000331, 0x00004e, 0x00032d, 0x00006e, 0x00032d,
+	0x00004f, 0x000303, 0x000301, 0x00006f, 0x000303, 0x000301,
+	0x00004f, 0x000303, 0x000308, 0x00006f, 0x000303, 0x000308,
+	0x00004f, 0x000304, 0x000300, 0x00006f, 0x000304, 0x000300,
+	0x00004f, 0x000304, 0x000301, 0x00006f, 0x000304, 0x000301,
+	0x000050, 0x000301, 0x000070, 0x000301, 0x000050, 0x000307,
+	0x000070, 0x000307, 0x000052, 0x000307, 0x000072, 0x000307,
+	0x000052, 0x000323, 0x000072, 0x000323, 0x000052, 0x000323,
+	0x000304, 0x000072, 0x000323, 0x000304, 0x000052, 0x000331,
+	0x000072, 0x000331, 0x000053, 0x000307, 0x000073, 0x000307,
+	0x000053, 0x000323, 0x000073, 0x000323, 0x000053, 0x000301,
+	0x000307, 0x000073, 0x000301, 0x000307, 0x000053, 0x00030c,
+	0x000307, 0x000073, 0x00030c, 0x000307, 0x000053, 0x000323,
+	0x000307, 0x000073, 0x000323, 0x000307, 0x000054, 0x000307,
+	0x000074, 0x000307, 0x000054, 0x000323, 0x000074, 0x000323,
+	0x000054, 0x000331, 0x000074, 0x000331, 0x000054, 0x00032d,
+	0x000074, 0x00032d, 0x000055, 0x000324, 0x000075, 0x000324,
+	0x000055, 0x000330, 0x000075, 0x000330, 0x000055, 0x00032d,
+	0x000075, 0x00032d, 0x000055, 0x000303, 0x000301, 0x000075,
+	0x000303, 0x000301, 0x000055, 0x000304, 0x000308, 0x000075,
+	0x000304, 0x000308, 0x000056, 0x000303, 0x000076, 0x000303,
+	0x000056, 0x000323, 0x000076, 0x000323, 0x000057, 0x000300,
+	0x000077, 0x000300, 0x000057, 0x000301, 0x000077, 0x000301,
+	0x000057, 0x000308, 0x000077, 0x000308, 0x000057, 0x000307,
+	0x000077, 0x000307, 0x000057, 0x000323, 0x000077, 0x000323,
+	0x000058, 0x000307, 0x000078, 0x000307, 0x000058, 0x000308,
+	0x000078, 0x000308, 0x000059, 0x000307, 0x000079, 0x000307,
+	0x00005a, 0x000302, 0x00007a, 0x000302, 0x00005a, 0x000323,
+	0x00007a, 0x000323, 0x00005a, 0x000331, 0x00007a, 0x000331,
+	0x000068, 0x000331, 0x000074, 0x000308, 0x000077, 0x00030a,
+	0x000079, 0x00030a, 0x00017f, 0x000307, 0x000041, 0x000323,
+	0x000061, 0x000323, 0x000041, 0x000309, 0x000061, 0x000309,
+	0x000041, 0x000302, 0x000301, 0x000061, 0x000302, 0x000301,
+	0x000041, 0x000302, 0x000300, 0x000061, 0x000302, 0x000300,
+	0x000041, 0x000302, 0x000309, 0x000061, 0x000302, 0x000309,
+	0x000041, 0x000302, 0x000303, 0x000061, 0x000302, 0x000303,
+	0x000041, 0x000323, 0x000302, 0x000061, 0x000323, 0x000302,
+	0x000041, 0x000306, 0x000301, 0x000061, 0x000306, 0x000301,
+	0x000041, 0x000306, 0x000300, 0x000061, 0x000306, 0x000300,
+	0x000041, 0x000306, 0x000309, 0x000061, 0x000306, 0x000309,
+	0x000041, 0x000306, 0x000303, 0x000061, 0x000306, 0x000303,
+	0x000041, 0x000323, 0x000306, 0x000061, 0x000323, 0x000306,
+	0x000045, 0x000323, 0x000065, 0x000323, 0x000045, 0x000309,
+	0x000065, 0x000309, 0x000045, 0x000303, 0x000065, 0x000303,
+	0x000045, 0x000302, 0x000301, 0x000065, 0x000302, 0x000301,
+	0x000045, 0x000302, 0x000300, 0x000065, 0x000302, 0x000300,
+	0x000045, 0x000302, 0x000309, 0x000065, 0x000302, 0x000309,
+	0x000045, 0x000302, 0x000303, 0x000065, 0x000302, 0x000303,
+	0x000045, 0x000323, 0x000302, 0x000065, 0x000323, 0x000302,
+	0x000049, 0x000309, 0x000069, 0x000309, 0x000049, 0x000323,
+	0x000069, 0x000323, 0x00004f, 0x000323, 0x00006f, 0x000323,
+	0x00004f, 0x000309, 0x00006f, 0x000309, 0x00004f, 0x000302,
+	0x000301, 0x00006f, 0x000302, 0x000301, 0x00004f, 0x000302,
+	0x000300, 0x00006f, 0x000302, 0x000300, 0x00004f, 0x000302,
+	0x000309, 0x00006f, 0x000302, 0x000309, 0x00004f, 0x000302,
+	0x000303, 0x00006f, 0x000302, 0x000303, 0x00004f, 0x000323,
+	0x000302, 0x00006f, 0x000323, 0x000302, 0x00004f, 0x00031b,
+	0x000301, 0x00006f, 0x00031b, 0x000301, 0x00004f, 0x00031b,
+	0x000300, 0x00006f, 0x00031b, 0x000300, 0x00004f, 0x00031b,
+	0x000309, 0x00006f, 0x00031b, 0x000309, 0x00004f, 0x00031b,
+	0x000303, 0x00006f, 0x00031b, 0x000303, 0x00004f, 0x00031b,
+	0x000323, 0x00006f, 0x00031b, 0x000323, 0x000055, 0x000323,
+	0x000075, 0x000323, 0x000055, 0x000309, 0x000075, 0x000309,
+	0x000055, 0x00031b, 0x000301, 0x000075, 0x00031b, 0x000301,
+	0x000055, 0x00031b, 0x000300, 0x000075, 0x00031b, 0x000300,
+	0x000055, 0x00031b, 0x000309, 0x000075, 0x00031b, 0x000309,
+	0x000055, 0x00031b, 0x000303, 0x000075, 0x00031b, 0x000303,
+	0x000055, 0x00031b, 0x000323, 0x000075, 0x00031b, 0x000323,
+	0x000059, 0x000300, 0x000079, 0x000300, 0x000059, 0x000323,
+	0x000079, 0x000323, 0x000059, 0x000309, 0x000079, 0x000309,
+	0x000059, 0x000303, 0x000079, 0x000303, 0x0003b1, 0x000313,
+	0x0003b1, 0x000314, 0x0003b1, 0x000313, 0x000300, 0x0003b1,
+	0x000314, 0x000300, 0x0003b1, 0x000313, 0x000301, 0x0003b1,
+	0x000314, 0x000301, 0x0003b1, 0x000313, 0x000342, 0x0003b1,
+	0x000314, 0x000342, 0x000391, 0x000313, 0x000391, 0x000314,
+	0x000391, 0x000313, 0x000300, 0x000391, 0x000314, 0x000300,
+	0x000391, 0x000313, 0x000301, 0x000391, 0x000314, 0x000301,
+	0x000391, 0x000313, 0x000342, 0x000391, 0x000314, 0x000342,
+	0x0003b5, 0x000313, 0x0003b5, 0x000314, 0x0003b5, 0x000313,
+	0x000300, 0x0003b5, 0x000314, 0x000300, 0x0003b5, 0x000313,
+	0x000301, 0x0003b5, 0x000314, 0x000301, 0x000395, 0x000313,
+	0x000395, 0x000314, 0x000395, 0x000313, 0x000300, 0x000395,
+	0x000314, 0x000300, 0x000395, 0x000313, 0x000301, 0x000395,
+	0x000314, 0x000301, 0x0003b7, 0x000313, 0x0003b7, 0x000314,
+	0x0003b7, 0x000313, 0x000300, 0x0003b7, 0x000314, 0x000300,
+	0x0003b7, 0x000313, 0x000301, 0x0003b7, 0x000314, 0x000301,
+	0x0003b7, 0x000313, 0x000342, 0x0003b7, 0x000314, 0x000342,
+	0x000397, 0x000313, 0x000397, 0x000314, 0x000397, 0x000313,
+	0x000300, 0x000397, 0x000314, 0x000300, 0x000397, 0x000313,
+	0x000301, 0x000397, 0x000314, 0x000301, 0x000397, 0x000313,
+	0x000342, 0x000397, 0x000314, 0x000342, 0x0003b9, 0x000313,
+	0x0003b9, 0x000314, 0x0003b9, 0x000313, 0x000300, 0x0003b9,
+	0x000314, 0x000300, 0x0003b9, 0x000313, 0x000301, 0x0003b9,
+	0x000314, 0x000301, 0x0003b9, 0x000313, 0x000342, 0x0003b9,
+	0x000314, 0x000342, 0x000399, 0x000313, 0x000399, 0x000314,
+	0x000399, 0x000313, 0x000300, 0x000399, 0x000314, 0x000300,
+	0x000399, 0x000313, 0x000301, 0x000399, 0x000314, 0x000301,
+	0x000399, 0x000313, 0x000342, 0x000399, 0x000314, 0x000342,
+	0x0003bf, 0x000313, 0x0003bf, 0x000314, 0x0003bf, 0x000313,
+	0x000300, 0x0003bf, 0x000314, 0x000300, 0x0003bf, 0x000313,
+	0x000301, 0x0003bf, 0x000314, 0x000301, 0x00039f, 0x000313,
+	0x00039f, 0x000314, 0x00039f, 0x000313, 0x000300, 0x00039f,
+	0x000314, 0x000300, 0x00039f, 0x000313, 0x000301, 0x00039f,
+	0x000314, 0x000301, 0x0003c5, 0x000313, 0x0003c5, 0x000314,
+	0x0003c5, 0x000313, 0x000300, 0x0003c5, 0x000314, 0x000300,
+	0x0003c5, 0x000313, 0x000301, 0x0003c5, 0x000314, 0x000301,
+	0x0003c5, 0x000313, 0x000342, 0x0003c5, 0x000314, 0x000342,
+	0x0003a5, 0x000314, 0x0003a5, 0x000314, 0x000300, 0x0003a5,
+	0x000314, 0x000301, 0x0003a5, 0x000314, 0x000342, 0x0003c9,
+	0x000313, 0x0003c9, 0x000314, 0x0003c9, 0x000313, 0x000300,
+	0x0003c9, 0x000314, 0x000300, 0x0003c9, 0x000313, 0x000301,
+	0x0003c9, 0x000314, 0x000301, 0x0003c9, 0x000313, 0x000342,
+	0x0003c9, 0x000314, 0x000342, 0x0003a9, 0x000313, 0x0003a9,
+	0x000314, 0x0003a9, 0x000313, 0x000300, 0x0003a9, 0x000314,
+	0x000300, 0x0003a9, 0x000313, 0x000301, 0x0003a9, 0x000314,
+	0x000301, 0x0003a9, 0x000313, 0x000342, 0x0003a9, 0x000314,
+	0x000342, 0x0003b1, 0x000300, 0x0003b1, 0x000301, 0x0003b5,
+	0x000300, 0x0003b5, 0x000301, 0x0003b7, 0x000300, 0x0003b7,
+	0x000301, 0x0003b9, 0x000300, 0x0003b9, 0x000301, 0x0003bf,
+	0x000300, 0x0003bf, 0x000301, 0x0003c5, 0x000300, 0x0003c5,
+	0x000301, 0x0003c9, 0x000300, 0x0003c9, 0x000301, 0x0003b1,
+	0x000313, 0x000345, 0x0003b1, 0x000314, 0x000345, 0x0003b1,
+	0x000313, 0x000300, 0x000345, 0x0003b1, 0x000314, 0x000300,
+	0x000345, 0x0003b1, 0x000313, 0x000301, 0x000345, 0x0003b1,
+	0x000314, 0x000301, 0x000345, 0x0003b1, 0x000313, 0x000342,
+	0x000345, 0x0003b1, 0x000314, 0x000342, 0x000345, 0x000391,
+	0x000313, 0x000345, 0x000391, 0x000314, 0x000345, 0x000391,
+	0x000313, 0x000300, 0x000345, 0x000391, 0x000314, 0x000300,
+	0x000345, 0x000391, 0x000313, 0x000301, 0x000345, 0x000391,
+	0x000314, 0x000301, 0x000345, 0x000391, 0x000313, 0x000342,
+	0x000345, 0x000391, 0x000314, 0x000342, 0x000345, 0x0003b7,
+	0x000313, 0x000345, 0x0003b7, 0x000314, 0x000345, 0x0003b7,
+	0x000313, 0x000300, 0x000345, 0x0003b7, 0x000314, 0x000300,
+	0x000345, 0x0003b7, 0x000313, 0x000301, 0x000345, 0x0003b7,
+	0x000314, 0x000301, 0x000345, 0x0003b7, 0x000313, 0x000342,
+	0x000345, 0x0003b7, 0x000314, 0x000342, 0x000345, 0x000397,
+	0x000313, 0x000345, 0x000397, 0x000314, 0x000345, 0x000397,
+	0x000313, 0x000300, 0x000345, 0x000397, 0x000314, 0x000300,
+	0x000345, 0x000397, 0x000313, 0x000301, 0x000345, 0x000397,
+	0x000314, 0x000301, 0x000345, 0x000397, 0x000313, 0x000342,
+	0x000345, 0x000397, 0x000314, 0x000342, 0x000345, 0x0003c9,
+	0x000313, 0x000345, 0x0003c9, 0x000314, 0x000345, 0x0003c9,
+	0x000313, 0x000300, 0x000345, 0x0003c9, 0x000314, 0x000300,
+	0x000345, 0x0003c9, 0x000313, 0x000301, 0x000345, 0x0003c9,
+	0x000314, 0x000301, 0x000345, 0x0003c9, 0x000313, 0x000342,
+	0x000345, 0x0003c9, 0x000314, 0x000342, 0x000345, 0x0003a9,
+	0x000313, 0x000345, 0x0003a9, 0x000314, 0x000345, 0x0003a9,
+	0x000313, 0x000300, 0x000345, 0x0003a9, 0x000314, 0x000300,
+	0x000345, 0x0003a9, 0x000313, 0x000301, 0x000345, 0x0003a9,
+	0x000314, 0x000301, 0x000345, 0x0003a9, 0x000313, 0x000342,
+	0x000345, 0x0003a9, 0x000314, 0x000342, 0x000345, 0x0003b1,
+	0x000306, 0x0003b1, 0x000304, 0x0003b1, 0x000300, 0x000345,
+	0x0003b1, 0x000345, 0x0003b1, 0x000301, 0x000345, 0x0003b1,
+	0x000342, 0x0003b1, 0x000342, 0x000345, 0x000391, 0x000306,
+	0x000391, 0x000304, 0x000391, 0x000300, 0x000391, 0x000301,
+	0x000391, 0x000345, 0x0003b9, 0x0000a8, 0x000342, 0x0003b7,
+	0x000300, 0x000345, 0x0003b7, 0x000345, 0x0003b7, 0x000301,
+	0x000345, 0x0003b7, 0x000342, 0x0003b7, 0x000342, 0x000345,
+	0x000395, 0x000300, 0x000395, 0x000301, 0x000397, 0x000300,
+	0x000397, 0x000301, 0x000397, 0x000345, 0x001fbf, 0x000300,
+	0x001fbf, 0x000301, 0x001fbf, 0x000342, 0x0003b9, 0x000306,
+	0x0003b9, 0x000304, 0x0003b9, 0x000308, 0x000300, 0x0003b9,
+	0x000308, 0x000301, 0x0003b9, 0x000342, 0x0003b9, 0x000308,
+	0x000342, 0x000399, 0x000306, 0x000399, 0x000304, 0x000399,
+	0x000300, 0x000399, 0x000301, 0x001ffe, 0x000300, 0x001ffe,
+	0x000301, 0x001ffe, 0x000342, 0x0003c5, 0x000306, 0x0003c5,
+	0x000304, 0x0003c5, 0x000308, 0x000300, 0x0003c5, 0x000308,
+	0x000301, 0x0003c1, 0x000313, 0x0003c1, 0x000314, 0x0003c5,
+	0x000342, 0x0003c5, 0x000308, 0x000342, 0x0003a5, 0x000306,
+	0x0003a5, 0x000304, 0x0003a5, 0x000300, 0x0003a5, 0x000301,
+	0x0003a1, 0x000314, 0x0000a8, 0x000300, 0x0000a8, 0x000301,
+	0x000060, 0x0003c9, 0x000300, 0x000345, 0x0003c9, 0x000345,
+	0x0003c9, 0x000301, 0x000345, 0x0003c9, 0x000342, 0x0003c9,
+	0x000342, 0x000345, 0x00039f, 0x000300, 0x00039f, 0x000301,
+	0x0003a9, 0x000300, 0x0003a9, 0x000301, 0x0003a9, 0x000345,
+	0x0000b4, 0x002002, 0x002003, 0x0003a9, 0x00004b, 0x000041,
+	0x00030a, 0x002190, 0x000338, 0x002192, 0x000338, 0x002194,
+	0x000338, 0x0021d0, 0x000338, 0x0021d4, 0x000338, 0x0021d2,
+	0x000338, 0x002203, 0x000338, 0x002208, 0x000338, 0x00220b,
+	0x000338, 0x002223, 0x000338, 0x002225, 0x000338, 0x00223c,
+	0x000338, 0x002243, 0x000338, 0x002245, 0x000338, 0x002248,
+	0x000338, 0x00003d, 0x000338, 0x002261, 0x000338, 0x00224d,
+	0x000338, 0x00003c, 0x000338, 0x00003e, 0x000338, 0x002264,
+	0x000338, 0x002265, 0x000338, 0x002272, 0x000338, 0x002273,
+	0x000338, 0x002276, 0x000338, 0x002277, 0x000338, 0x00227a,
+	0x000338, 0x00227b, 0x000338, 0x002282, 0x000338, 0x002283,
+	0x000338, 0x002286, 0x000338, 0x002287, 0x000338, 0x0022a2,
+	0x000338, 0x0022a8, 0x000338, 0x0022a9, 0x000338, 0x0022ab,
+	0x000338, 0x00227c, 0x000338, 0x00227d, 0x000338, 0x002291,
+	0x000338, 0x002292, 0x000338, 0x0022b2, 0x000338, 0x0022b3,
+	0x000338, 0x0022b4, 0x000338, 0x0022b5, 0x000338, 0x003008,
+	0x003009, 0x002add, 0x000338, 0x00304b, 0x003099, 0x00304d,
+	0x003099, 0x00304f, 0x003099, 0x003051, 0x003099, 0x003053,
+	0x003099, 0x003055, 0x003099, 0x003057, 0x003099, 0x003059,
+	0x003099, 0x00305b, 0x003099, 0x00305d, 0x003099, 0x00305f,
+	0x003099, 0x003061, 0x003099, 0x003064, 0x003099, 0x003066,
+	0x003099, 0x003068, 0x003099, 0x00306f, 0x003099, 0x00306f,
+	0x00309a, 0x003072, 0x003099, 0x003072, 0x00309a, 0x003075,
+	0x003099, 0x003075, 0x00309a, 0x003078, 0x003099, 0x003078,
+	0x00309a, 0x00307b, 0x003099, 0x00307b, 0x00309a, 0x003046,
+	0x003099, 0x00309d, 0x003099, 0x0030ab, 0x003099, 0x0030ad,
+	0x003099, 0x0030af, 0x003099, 0x0030b1, 0x003099, 0x0030b3,
+	0x003099, 0x0030b5, 0x003099, 0x0030b7, 0x003099, 0x0030b9,
+	0x003099, 0x0030bb, 0x003099, 0x0030bd, 0x003099, 0x0030bf,
+	0x003099, 0x0030c1, 0x003099, 0x0030c4, 0x003099, 0x0030c6,
+	0x003099, 0x0030c8, 0x003099, 0x0030cf, 0x003099, 0x0030cf,
+	0x00309a, 0x0030d2, 0x003099, 0x0030d2, 0x00309a, 0x0030d5,
+	0x003099, 0x0030d5, 0x00309a, 0x0030d8, 0x003099, 0x0030d8,
+	0x00309a, 0x0030db, 0x003099, 0x0030db, 0x00309a, 0x0030a6,
+	0x003099, 0x0030ef, 0x003099, 0x0030f0, 0x003099, 0x0030f1,
+	0x003099, 0x0030f2, 0x003099, 0x0030fd, 0x003099, 0x008c48,
+	0x0066f4, 0x008eca, 0x008cc8, 0x006ed1, 0x004e32, 0x0053e5,
+	0x009f9c, 0x009f9c, 0x005951, 0x0091d1, 0x005587, 0x005948,
+	0x0061f6, 0x007669, 0x007f85, 0x00863f, 0x0087ba, 0x0088f8,
+	0x00908f, 0x006a02, 0x006d1b, 0x0070d9, 0x0073de, 0x00843d,
+	0x00916a, 0x0099f1, 0x004e82, 0x005375, 0x006b04, 0x00721b,
+	0x00862d, 0x009e1e, 0x005d50, 0x006feb, 0x0085cd, 0x008964,
+	0x0062c9, 0x0081d8, 0x00881f, 0x005eca, 0x006717, 0x006d6a,
+	0x0072fc, 0x0090ce, 0x004f86, 0x0051b7, 0x0052de, 0x0064c4,
+	0x006ad3, 0x007210, 0x0076e7, 0x008001, 0x008606, 0x00865c,
+	0x008def, 0x009732, 0x009b6f, 0x009dfa, 0x00788c, 0x00797f,
+	0x007da0, 0x0083c9, 0x009304, 0x009e7f, 0x008ad6, 0x0058df,
+	0x005f04, 0x007c60, 0x00807e, 0x007262, 0x0078ca, 0x008cc2,
+	0x0096f7, 0x0058d8, 0x005c62, 0x006a13, 0x006dda, 0x006f0f,
+	0x007d2f, 0x007e37, 0x00964b, 0x0052d2, 0x00808b, 0x0051dc,
+	0x0051cc, 0x007a1c, 0x007dbe, 0x0083f1, 0x009675, 0x008b80,
+	0x0062cf, 0x006a02, 0x008afe, 0x004e39, 0x005be7, 0x006012,
+	0x007387, 0x007570, 0x005317, 0x0078fb, 0x004fbf, 0x005fa9,
+	0x004e0d, 0x006ccc, 0x006578, 0x007d22, 0x0053c3, 0x00585e,
+	0x007701, 0x008449, 0x008aaa, 0x006bba, 0x008fb0, 0x006c88,
+	0x0062fe, 0x0082e5, 0x0063a0, 0x007565, 0x004eae, 0x005169,
+	0x0051c9, 0x006881, 0x007ce7, 0x00826f, 0x008ad2, 0x0091cf,
+	0x0052f5, 0x005442, 0x005973, 0x005eec, 0x0065c5, 0x006ffe,
+	0x00792a, 0x0095ad, 0x009a6a, 0x009e97, 0x009ece, 0x00529b,
+	0x0066c6, 0x006b77, 0x008f62, 0x005e74, 0x006190, 0x006200,
+	0x00649a, 0x006f23, 0x007149, 0x007489, 0x0079ca, 0x007df4,
+	0x00806f, 0x008f26, 0x0084ee, 0x009023, 0x00934a, 0x005217,
+	0x0052a3, 0x0054bd, 0x0070c8, 0x0088c2, 0x008aaa, 0x005ec9,
+	0x005ff5, 0x00637b, 0x006bae, 0x007c3e, 0x007375, 0x004ee4,
+	0x0056f9, 0x005be7, 0x005dba, 0x00601c, 0x0073b2, 0x007469,
+	0x007f9a, 0x008046, 0x009234, 0x0096f6, 0x009748, 0x009818,
+	0x004f8b, 0x0079ae, 0x0091b4, 0x0096b8, 0x0060e1, 0x004e86,
+	0x0050da, 0x005bee, 0x005c3f, 0x006599, 0x006a02, 0x0071ce,
+	0x007642, 0x0084fc, 0x00907c, 0x009f8d, 0x006688, 0x00962e,
+	0x005289, 0x00677b, 0x0067f3, 0x006d41, 0x006e9c, 0x007409,
+	0x007559, 0x00786b, 0x007d10, 0x00985e, 0x00516d, 0x00622e,
+	0x009678, 0x00502b, 0x005d19, 0x006dea, 0x008f2a, 0x005f8b,
+	0x006144, 0x006817, 0x007387, 0x009686, 0x005229, 0x00540f,
+	0x005c65, 0x006613, 0x00674e, 0x0068a8, 0x006ce5, 0x007406,
+	0x0075e2, 0x007f79, 0x0088cf, 0x0088e1, 0x0091cc, 0x0096e2,
+	0x00533f, 0x006eba, 0x00541d, 0x0071d0, 0x007498, 0x0085fa,
+	0x0096a3, 0x009c57, 0x009e9f, 0x006797, 0x006dcb, 0x0081e8,
+	0x007acb, 0x007b20, 0x007c92, 0x0072c0, 0x007099, 0x008b58,
+	0x004ec0, 0x008336, 0x00523a, 0x005207, 0x005ea6, 0x0062d3,
+	0x007cd6, 0x005b85, 0x006d1e, 0x0066b4, 0x008f3b, 0x00884c,
+	0x00964d, 0x00898b, 0x005ed3, 0x005140, 0x0055c0, 0x00585a,
+	0x006674, 0x0051de, 0x00732a, 0x0076ca, 0x00793c, 0x00795e,
+	0x007965, 0x00798f, 0x009756, 0x007cbe, 0x007fbd, 0x008612,
+	0x008af8, 0x009038, 0x0090fd, 0x0098ef, 0x0098fc, 0x009928,
+	0x009db4, 0x0090de, 0x0096b7, 0x004fae, 0x0050e7, 0x00514d,
+	0x0052c9, 0x0052e4, 0x005351, 0x00559d, 0x005606, 0x005668,
+	0x005840, 0x0058a8, 0x005c64, 0x005c6e, 0x006094, 0x006168,
+	0x00618e, 0x0061f2, 0x00654f, 0x0065e2, 0x006691, 0x006885,
+	0x006d77, 0x006e1a, 0x006f22, 0x00716e, 0x00722b, 0x007422,
+	0x007891, 0x00793e, 0x007949, 0x007948, 0x007950, 0x007956,
+	0x00795d, 0x00798d, 0x00798e, 0x007a40, 0x007a81, 0x007bc0,
+	0x007df4, 0x007e09, 0x007e41, 0x007f72, 0x008005, 0x0081ed,
+	0x008279, 0x008279, 0x008457, 0x008910, 0x008996, 0x008b01,
+	0x008b39, 0x008cd3, 0x008d08, 0x008fb6, 0x009038, 0x0096e3,
+	0x0097ff, 0x00983b, 0x006075, 0x0242ee, 0x008218, 0x004e26,
+	0x0051b5, 0x005168, 0x004f80, 0x005145, 0x005180, 0x0052c7,
+	0x0052fa, 0x00559d, 0x005555, 0x005599, 0x0055e2, 0x00585a,
+	0x0058b3, 0x005944, 0x005954, 0x005a62, 0x005b28, 0x005ed2,
+	0x005ed9, 0x005f69, 0x005fad, 0x0060d8, 0x00614e, 0x006108,
+	0x00618e, 0x006160, 0x0061f2, 0x006234, 0x0063c4, 0x00641c,
+	0x006452, 0x006556, 0x006674, 0x006717, 0x00671b, 0x006756,
+	0x006b79, 0x006bba, 0x006d41, 0x006edb, 0x006ecb, 0x006f22,
+	0x00701e, 0x00716e, 0x0077a7, 0x007235, 0x0072af, 0x00732a,
+	0x007471, 0x007506, 0x00753b, 0x00761d, 0x00761f, 0x0076ca,
+	0x0076db, 0x0076f4, 0x00774a, 0x007740, 0x0078cc, 0x007ab1,
+	0x007bc0, 0x007c7b, 0x007d5b, 0x007df4, 0x007f3e, 0x008005,
+	0x008352, 0x0083ef, 0x008779, 0x008941, 0x008986, 0x008996,
+	0x008abf, 0x008af8, 0x008acb, 0x008b01, 0x008afe, 0x008aed,
+	0x008b39, 0x008b8a, 0x008d08, 0x008f38, 0x009072, 0x009199,
+	0x009276, 0x00967c, 0x0096e3, 0x009756, 0x0097db, 0x0097ff,
+	0x00980b, 0x00983b, 0x009b12, 0x009f9c, 0x02284a, 0x022844,
+	0x0233d5, 0x003b9d, 0x004018, 0x004039, 0x025249, 0x025cd0,
+	0x027ed3, 0x009f43, 0x009f8e, 0x0005d9, 0x0005b4, 0x0005f2,
+	0x0005b7, 0x0005e9, 0x0005c1, 0x0005e9, 0x0005c2, 0x0005e9,
+	0x0005bc, 0x0005c1, 0x0005e9, 0x0005bc, 0x0005c2, 0x0005d0,
+	0x0005b7, 0x0005d0, 0x0005b8, 0x0005d0, 0x0005bc, 0x0005d1,
+	0x0005bc, 0x0005d2, 0x0005bc, 0x0005d3, 0x0005bc, 0x0005d4,
+	0x0005bc, 0x0005d5, 0x0005bc, 0x0005d6, 0x0005bc, 0x0005d8,
+	0x0005bc, 0x0005d9, 0x0005bc, 0x0005da, 0x0005bc, 0x0005db,
+	0x0005bc, 0x0005dc, 0x0005bc, 0x0005de, 0x0005bc, 0x0005e0,
+	0x0005bc, 0x0005e1, 0x0005bc, 0x0005e3, 0x0005bc, 0x0005e4,
+	0x0005bc, 0x0005e6, 0x0005bc, 0x0005e7, 0x0005bc, 0x0005e8,
+	0x0005bc, 0x0005e9, 0x0005bc, 0x0005ea, 0x0005bc, 0x0005d5,
+	0x0005b9, 0x0005d1, 0x0005bf, 0x0005db, 0x0005bf, 0x0005e4,
+	0x0005bf, 0x011099, 0x0110ba, 0x01109b, 0x0110ba, 0x0110a5,
+	0x0110ba, 0x011131, 0x011127, 0x011132, 0x011127, 0x011347,
+	0x01133e, 0x011347, 0x011357, 0x0114b9, 0x0114ba, 0x0114b9,
+	0x0114b0, 0x0114b9, 0x0114bd, 0x0115b8, 0x0115af, 0x0115b9,
+	0x0115af, 0x01d157, 0x01d165, 0x01d158, 0x01d165, 0x01d158,
+	0x01d165, 0x01d16e, 0x01d158, 0x01d165, 0x01d16f, 0x01d158,
+	0x01d165, 0x01d170, 0x01d158, 0x01d165, 0x01d171, 0x01d158,
+	0x01d165, 0x01d172, 0x01d1b9, 0x01d165, 0x01d1ba, 0x01d165,
+	0x01d1b9, 0x01d165, 0x01d16e, 0x01d1ba, 0x01d165, 0x01d16e,
+	0x01d1b9, 0x01d165, 0x01d16f, 0x01d1ba, 0x01d165, 0x01d16f,
+	0x004e3d, 0x004e38, 0x004e41, 0x020122, 0x004f60, 0x004fae,
+	0x004fbb, 0x005002, 0x00507a, 0x005099, 0x0050e7, 0x0050cf,
+	0x00349e, 0x02063a, 0x00514d, 0x005154, 0x005164, 0x005177,
+	0x02051c, 0x0034b9, 0x005167, 0x00518d, 0x02054b, 0x005197,
+	0x0051a4, 0x004ecc, 0x0051ac, 0x0051b5, 0x0291df, 0x0051f5,
+	0x005203, 0x0034df, 0x00523b, 0x005246, 0x005272, 0x005277,
+	0x003515, 0x0052c7, 0x0052c9, 0x0052e4, 0x0052fa, 0x005305,
+	0x005306, 0x005317, 0x005349, 0x005351, 0x00535a, 0x005373,
+	0x00537d, 0x00537f, 0x00537f, 0x00537f, 0x020a2c, 0x007070,
+	0x0053ca, 0x0053df, 0x020b63, 0x0053eb, 0x0053f1, 0x005406,
+	0x00549e, 0x005438, 0x005448, 0x005468, 0x0054a2, 0x0054f6,
+	0x005510, 0x005553, 0x005563, 0x005584, 0x005584, 0x005599,
+	0x0055ab, 0x0055b3, 0x0055c2, 0x005716, 0x005606, 0x005717,
+	0x005651, 0x005674, 0x005207, 0x0058ee, 0x0057ce, 0x0057f4,
+	0x00580d, 0x00578b, 0x005832, 0x005831, 0x0058ac, 0x0214e4,
+	0x0058f2, 0x0058f7, 0x005906, 0x00591a, 0x005922, 0x005962,
+	0x0216a8, 0x0216ea, 0x0059ec, 0x005a1b, 0x005a27, 0x0059d8,
+	0x005a66, 0x0036ee, 0x0036fc, 0x005b08, 0x005b3e, 0x005b3e,
+	0x0219c8, 0x005bc3, 0x005bd8, 0x005be7, 0x005bf3, 0x021b18,
+	0x005bff, 0x005c06, 0x005f53, 0x005c22, 0x003781, 0x005c60,
+	0x005c6e, 0x005cc0, 0x005c8d, 0x021de4, 0x005d43, 0x021de6,
+	0x005d6e, 0x005d6b, 0x005d7c, 0x005de1, 0x005de2, 0x00382f,
+	0x005dfd, 0x005e28, 0x005e3d, 0x005e69, 0x003862, 0x022183,
+	0x00387c, 0x005eb0, 0x005eb3, 0x005eb6, 0x005eca, 0x02a392,
+	0x005efe, 0x022331, 0x022331, 0x008201, 0x005f22, 0x005f22,
+	0x0038c7, 0x0232b8, 0x0261da, 0x005f62, 0x005f6b, 0x0038e3,
+	0x005f9a, 0x005fcd, 0x005fd7, 0x005ff9, 0x006081, 0x00393a,
+	0x00391c, 0x006094, 0x0226d4, 0x0060c7, 0x006148, 0x00614c,
+	0x00614e, 0x00614c, 0x00617a, 0x00618e, 0x0061b2, 0x0061a4,
+	0x0061af, 0x0061de, 0x0061f2, 0x0061f6, 0x006210, 0x00621b,
+	0x00625d, 0x0062b1, 0x0062d4, 0x006350, 0x022b0c, 0x00633d,
+	0x0062fc, 0x006368, 0x006383, 0x0063e4, 0x022bf1, 0x006422,
+	0x0063c5, 0x0063a9, 0x003a2e, 0x006469, 0x00647e, 0x00649d,
+	0x006477, 0x003a6c, 0x00654f, 0x00656c, 0x02300a, 0x0065e3,
+	0x0066f8, 0x006649, 0x003b19, 0x006691, 0x003b08, 0x003ae4,
+	0x005192, 0x005195, 0x006700, 0x00669c, 0x0080ad, 0x0043d9,
+	0x006717, 0x00671b, 0x006721, 0x00675e, 0x006753, 0x0233c3,
+	0x003b49, 0x0067fa, 0x006785, 0x006852, 0x006885, 0x02346d,
+	0x00688e, 0x00681f, 0x006914, 0x003b9d, 0x006942, 0x0069a3,
+	0x0069ea, 0x006aa8, 0x0236a3, 0x006adb, 0x003c18, 0x006b21,
+	0x0238a7, 0x006b54, 0x003c4e, 0x006b72, 0x006b9f, 0x006bba,
+	0x006bbb, 0x023a8d, 0x021d0b, 0x023afa, 0x006c4e, 0x023cbc,
+	0x006cbf, 0x006ccd, 0x006c67, 0x006d16, 0x006d3e, 0x006d77,
+	0x006d41, 0x006d69, 0x006d78, 0x006d85, 0x023d1e, 0x006d34,
+	0x006e2f, 0x006e6e, 0x003d33, 0x006ecb, 0x006ec7, 0x023ed1,
+	0x006df9, 0x006f6e, 0x023f5e, 0x023f8e, 0x006fc6, 0x007039,
+	0x00701e, 0x00701b, 0x003d96, 0x00704a, 0x00707d, 0x007077,
+	0x0070ad, 0x020525, 0x007145, 0x024263, 0x00719c, 0x0243ab,
+	0x007228, 0x007235, 0x007250, 0x024608, 0x007280, 0x007295,
+	0x024735, 0x024814, 0x00737a, 0x00738b, 0x003eac, 0x0073a5,
+	0x003eb8, 0x003eb8, 0x007447, 0x00745c, 0x007471, 0x007485,
+	0x0074ca, 0x003f1b, 0x007524, 0x024c36, 0x00753e, 0x024c92,
+	0x007570, 0x02219f, 0x007610, 0x024fa1, 0x024fb8, 0x025044,
+	0x003ffc, 0x004008, 0x0076f4, 0x0250f3, 0x0250f2, 0x025119,
+	0x025133, 0x00771e, 0x00771f, 0x00771f, 0x00774a, 0x004039,
+	0x00778b, 0x004046, 0x004096, 0x02541d, 0x00784e, 0x00788c,
+	0x0078cc, 0x0040e3, 0x025626, 0x007956, 0x02569a, 0x0256c5,
+	0x00798f, 0x0079eb, 0x00412f, 0x007a40, 0x007a4a, 0x007a4f,
+	0x02597c, 0x025aa7, 0x025aa7, 0x007aee, 0x004202, 0x025bab,
+	0x007bc6, 0x007bc9, 0x004227, 0x025c80, 0x007cd2, 0x0042a0,
+	0x007ce8, 0x007ce3, 0x007d00, 0x025f86, 0x007d63, 0x004301,
+	0x007dc7, 0x007e02, 0x007e45, 0x004334, 0x026228, 0x026247,
+	0x004359, 0x0262d9, 0x007f7a, 0x02633e, 0x007f95, 0x007ffa,
+	0x008005, 0x0264da, 0x026523, 0x008060, 0x0265a8, 0x008070,
+	0x02335f, 0x0043d5, 0x0080b2, 0x008103, 0x00440b, 0x00813e,
+	0x005ab5, 0x0267a7, 0x0267b5, 0x023393, 0x02339c, 0x008201,
+	0x008204, 0x008f9e, 0x00446b, 0x008291, 0x00828b, 0x00829d,
+	0x0052b3, 0x0082b1, 0x0082b3, 0x0082bd, 0x0082e6, 0x026b3c,
+	0x0082e5, 0x00831d, 0x008363, 0x0083ad, 0x008323, 0x0083bd,
+	0x0083e7, 0x008457, 0x008353, 0x0083ca, 0x0083cc, 0x0083dc,
+	0x026c36, 0x026d6b, 0x026cd5, 0x00452b, 0x0084f1, 0x0084f3,
+	0x008516, 0x0273ca, 0x008564, 0x026f2c, 0x00455d, 0x004561,
+	0x026fb1, 0x0270d2, 0x00456b, 0x008650, 0x00865c, 0x008667,
+	0x008669, 0x0086a9, 0x008688, 0x00870e, 0x0086e2, 0x008779,
+	0x008728, 0x00876b, 0x008786, 0x0045d7, 0x0087e1, 0x008801,
+	0x0045f9, 0x008860, 0x008863, 0x027667, 0x0088d7, 0x0088de,
+	0x004635, 0x0088fa, 0x0034bb, 0x0278ae, 0x027966, 0x0046be,
+	0x0046c7, 0x008aa0, 0x008aed, 0x008b8a, 0x008c55, 0x027ca8,
+	0x008cab, 0x008cc1, 0x008d1b, 0x008d77, 0x027f2f, 0x020804,
+	0x008dcb, 0x008dbc, 0x008df0, 0x0208de, 0x008ed4, 0x008f38,
+	0x0285d2, 0x0285ed, 0x009094, 0x0090f1, 0x009111, 0x02872e,
+	0x00911b, 0x009238, 0x0092d7, 0x0092d8, 0x00927c, 0x0093f9,
+	0x009415, 0x028bfa, 0x00958b, 0x004995, 0x0095b7, 0x028d77,
+	0x0049e6, 0x0096c3, 0x005db2, 0x009723, 0x029145, 0x02921a,
+	0x004a6e, 0x004a76, 0x0097e0, 0x02940a, 0x004ab2, 0x029496,
+	0x00980b, 0x00980b, 0x009829, 0x0295b6, 0x0098e2, 0x004b33,
+	0x009929, 0x0099a7, 0x0099c2, 0x0099fe, 0x004bce, 0x029b30,
+	0x009b12, 0x009c40, 0x009cfd, 0x004cce, 0x004ced, 0x009d67,
+	0x02a0ce, 0x004cf8, 0x02a105, 0x02a20e, 0x02a291, 0x009ebb,
+	0x004d56, 0x009ef9, 0x009efe, 0x009f05, 0x009f0f, 0x009f16,
+	0x009f3b, 0x02a600,
+};
+
+static u16 apfs_cf_trie[] = {
+	/* Node for range 0x_____ */
+	0x0001, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0____ */
+	0x0003, 0x0004, 0x0005, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0007,
+	/* Node for range 0x1____ */
+	0x0008, 0x0009, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x000a, 0x0000,
+	/* Node for range 0x00___ */
+	0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01___ */
+	0x0011, 0x0000, 0x0000, 0x0012, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0013, 0x0000, 0x0014, 0x0015,
+	/* Node for range 0x02___ */
+	0x0000, 0x0016, 0x0000, 0x0000, 0x0017, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0018, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0a___ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0019, 0x001a,
+	0x0000, 0x0000, 0x0000, 0x001b, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0f___ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x001c, 0x0000, 0x0000, 0x0000, 0x001d,
+	/* Node for range 0x10___ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x001e, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x001f, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x11___ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x1e___ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0021, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x000__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0022, 0x0023, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0024, 0x0025, 0x0026, 0x0000, 0x0000,
+	/* Node for range 0x001__ */
+	0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e,
+	0x002f, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036,
+	/* Node for range 0x002__ */
+	0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x003__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x003c, 0x0000, 0x0000, 0x003d,
+	0x003e, 0x003f, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045,
+	/* Node for range 0x004__ */
+	0x0046, 0x0047, 0x0048, 0x0000, 0x0000, 0x0000, 0x0049, 0x004a,
+	0x004b, 0x004c, 0x004d, 0x004e, 0x004f, 0x0050, 0x0051, 0x0052,
+	/* Node for range 0x005__ */
+	0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0000, 0x0000,
+	0x0059, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x010__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x005a, 0x005b, 0x005c, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x013__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x005d,
+	/* Node for range 0x01c__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x005e, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01e__ */
+	0x005f, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066,
+	0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e,
+	/* Node for range 0x01f__ */
+	0x006f, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0000,
+	0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d,
+	/* Node for range 0x021__ */
+	0x0000, 0x0000, 0x007e, 0x007f, 0x0000, 0x0000, 0x0080, 0x0000,
+	0x0081, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x024__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0082, 0x0083, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x02c__ */
+	0x0084, 0x0085, 0x0086, 0x0000, 0x0000, 0x0000, 0x0087, 0x0088,
+	0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f, 0x0090,
+	/* Node for range 0x0a6__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0091, 0x0092, 0x0093, 0x0000,
+	0x0094, 0x0095, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0a7__ */
+	0x0000, 0x0000, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b,
+	0x009c, 0x009d, 0x009e, 0x009f, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0ab__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00a0,
+	0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0fb__ */
+	0x00a5, 0x00a6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0ff__ */
+	0x0000, 0x0000, 0x00a7, 0x00a8, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x104__ */
+	0x00a9, 0x00aa, 0x00ab, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x00ac, 0x00ad, 0x00ae, 0x0000, 0x0000,
+	/* Node for range 0x10c__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x00af, 0x00b0, 0x00b1, 0x00b2, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x118__ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x00b3, 0x00b4, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x1e9__ */
+	0x00b5, 0x00b6, 0x00b7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0004_ */
+	0x0000, 0x0001, 0x0009, 0x0011, 0x0019, 0x0021, 0x0029, 0x0031,
+	0x0039, 0x0041, 0x0049, 0x0051, 0x0059, 0x0061, 0x0069, 0x0071,
+	/* Node for range 0x0005_ */
+	0x0079, 0x0081, 0x0089, 0x0091, 0x0099, 0x00a1, 0x00a9, 0x00b1,
+	0x00b9, 0x00c1, 0x00c9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x000b_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00d1, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x000c_ */
+	0x00d9, 0x00e1, 0x00e9, 0x00f1, 0x00f9, 0x0101, 0x0109, 0x0111,
+	0x0119, 0x0121, 0x0129, 0x0131, 0x0139, 0x0141, 0x0149, 0x0151,
+	/* Node for range 0x000d_ */
+	0x0159, 0x0161, 0x0169, 0x0171, 0x0179, 0x0181, 0x0189, 0x0000,
+	0x0191, 0x0199, 0x01a1, 0x01a9, 0x01b1, 0x01b9, 0x01c1, 0x01ca,
+	/* Node for range 0x0010_ */
+	0x01d9, 0x0000, 0x01e1, 0x0000, 0x01e9, 0x0000, 0x01f1, 0x0000,
+	0x01f9, 0x0000, 0x0201, 0x0000, 0x0209, 0x0000, 0x0211, 0x0000,
+	/* Node for range 0x0011_ */
+	0x0219, 0x0000, 0x0221, 0x0000, 0x0229, 0x0000, 0x0231, 0x0000,
+	0x0239, 0x0000, 0x0241, 0x0000, 0x0249, 0x0000, 0x0251, 0x0000,
+	/* Node for range 0x0012_ */
+	0x0259, 0x0000, 0x0261, 0x0000, 0x0269, 0x0000, 0x0271, 0x0000,
+	0x0279, 0x0000, 0x0281, 0x0000, 0x0289, 0x0000, 0x0291, 0x0000,
+	/* Node for range 0x0013_ */
+	0x029a, 0x0000, 0x02a9, 0x0000, 0x02b1, 0x0000, 0x02b9, 0x0000,
+	0x0000, 0x02c1, 0x0000, 0x02c9, 0x0000, 0x02d1, 0x0000, 0x02d9,
+	/* Node for range 0x0014_ */
+	0x0000, 0x02e1, 0x0000, 0x02e9, 0x0000, 0x02f1, 0x0000, 0x02f9,
+	0x0000, 0x0302, 0x0311, 0x0000, 0x0319, 0x0000, 0x0321, 0x0000,
+	/* Node for range 0x0015_ */
+	0x0329, 0x0000, 0x0331, 0x0000, 0x0339, 0x0000, 0x0341, 0x0000,
+	0x0349, 0x0000, 0x0351, 0x0000, 0x0359, 0x0000, 0x0361, 0x0000,
+	/* Node for range 0x0016_ */
+	0x0369, 0x0000, 0x0371, 0x0000, 0x0379, 0x0000, 0x0381, 0x0000,
+	0x0389, 0x0000, 0x0391, 0x0000, 0x0399, 0x0000, 0x03a1, 0x0000,
+	/* Node for range 0x0017_ */
+	0x03a9, 0x0000, 0x03b1, 0x0000, 0x03b9, 0x0000, 0x03c1, 0x0000,
+	0x03c9, 0x03d1, 0x0000, 0x03d9, 0x0000, 0x03e1, 0x0000, 0x03e9,
+	/* Node for range 0x0018_ */
+	0x0000, 0x03f1, 0x03f9, 0x0000, 0x0401, 0x0000, 0x0409, 0x0411,
+	0x0000, 0x0419, 0x0421, 0x0429, 0x0000, 0x0000, 0x0431, 0x0439,
+	/* Node for range 0x0019_ */
+	0x0441, 0x0449, 0x0000, 0x0451, 0x0459, 0x0000, 0x0461, 0x0469,
+	0x0471, 0x0000, 0x0000, 0x0000, 0x0479, 0x0481, 0x0000, 0x0489,
+	/* Node for range 0x001a_ */
+	0x0491, 0x0000, 0x0499, 0x0000, 0x04a1, 0x0000, 0x04a9, 0x04b1,
+	0x0000, 0x04b9, 0x0000, 0x0000, 0x04c1, 0x0000, 0x04c9, 0x04d1,
+	/* Node for range 0x001b_ */
+	0x0000, 0x04d9, 0x04e1, 0x04e9, 0x0000, 0x04f1, 0x0000, 0x04f9,
+	0x0501, 0x0000, 0x0000, 0x0000, 0x0509, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x001c_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0511, 0x0519, 0x0000, 0x0521,
+	0x0529, 0x0000, 0x0531, 0x0539, 0x0000, 0x0541, 0x0000, 0x0549,
+	/* Node for range 0x001d_ */
+	0x0000, 0x0551, 0x0000, 0x0559, 0x0000, 0x0561, 0x0000, 0x0569,
+	0x0000, 0x0571, 0x0000, 0x0579, 0x0000, 0x0000, 0x0581, 0x0000,
+	/* Node for range 0x001e_ */
+	0x0589, 0x0000, 0x0591, 0x0000, 0x0599, 0x0000, 0x05a1, 0x0000,
+	0x05a9, 0x0000, 0x05b1, 0x0000, 0x05b9, 0x0000, 0x05c1, 0x0000,
+	/* Node for range 0x001f_ */
+	0x05ca, 0x05d9, 0x05e1, 0x0000, 0x05e9, 0x0000, 0x05f1, 0x05f9,
+	0x0601, 0x0000, 0x0609, 0x0000, 0x0611, 0x0000, 0x0619, 0x0000,
+	/* Node for range 0x0020_ */
+	0x0621, 0x0000, 0x0629, 0x0000, 0x0631, 0x0000, 0x0639, 0x0000,
+	0x0641, 0x0000, 0x0649, 0x0000, 0x0651, 0x0000, 0x0659, 0x0000,
+	/* Node for range 0x0021_ */
+	0x0661, 0x0000, 0x0669, 0x0000, 0x0671, 0x0000, 0x0679, 0x0000,
+	0x0681, 0x0000, 0x0689, 0x0000, 0x0691, 0x0000, 0x0699, 0x0000,
+	/* Node for range 0x0022_ */
+	0x06a1, 0x0000, 0x06a9, 0x0000, 0x06b1, 0x0000, 0x06b9, 0x0000,
+	0x06c1, 0x0000, 0x06c9, 0x0000, 0x06d1, 0x0000, 0x06d9, 0x0000,
+	/* Node for range 0x0023_ */
+	0x06e1, 0x0000, 0x06e9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x06f1, 0x06f9, 0x0000, 0x0701, 0x0709, 0x0000,
+	/* Node for range 0x0024_ */
+	0x0000, 0x0711, 0x0000, 0x0719, 0x0721, 0x0729, 0x0731, 0x0000,
+	0x0739, 0x0000, 0x0741, 0x0000, 0x0749, 0x0000, 0x0751, 0x0000,
+	/* Node for range 0x0034_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0759, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0037_ */
+	0x0761, 0x0000, 0x0769, 0x0000, 0x0000, 0x0000, 0x0771, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0779,
+	/* Node for range 0x0038_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0781, 0x0000,
+	0x0789, 0x0791, 0x0799, 0x0000, 0x07a1, 0x0000, 0x07a9, 0x07b1,
+	/* Node for range 0x0039_ */
+	0x07bb, 0x07d1, 0x07d9, 0x07e1, 0x07e9, 0x07f1, 0x07f9, 0x0801,
+	0x0809, 0x0811, 0x0819, 0x0821, 0x0829, 0x0831, 0x0839, 0x0841,
+	/* Node for range 0x003a_ */
+	0x0849, 0x0851, 0x0000, 0x0859, 0x0861, 0x0869, 0x0871, 0x0879,
+	0x0881, 0x0889, 0x0891, 0x0899, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x003b_ */
+	0x08a3, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x003c_ */
+	0x0000, 0x0000, 0x08b9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x08c1,
+	/* Node for range 0x003d_ */
+	0x08c9, 0x08d1, 0x0000, 0x0000, 0x0000, 0x08d9, 0x08e1, 0x0000,
+	0x08e9, 0x0000, 0x08f1, 0x0000, 0x08f9, 0x0000, 0x0901, 0x0000,
+	/* Node for range 0x003e_ */
+	0x0909, 0x0000, 0x0911, 0x0000, 0x0919, 0x0000, 0x0921, 0x0000,
+	0x0929, 0x0000, 0x0931, 0x0000, 0x0939, 0x0000, 0x0941, 0x0000,
+	/* Node for range 0x003f_ */
+	0x0949, 0x0951, 0x0000, 0x0000, 0x0959, 0x0961, 0x0000, 0x0969,
+	0x0000, 0x0971, 0x0979, 0x0000, 0x0000, 0x0981, 0x0989, 0x0991,
+	/* Node for range 0x0040_ */
+	0x0999, 0x09a1, 0x09a9, 0x09b1, 0x09b9, 0x09c1, 0x09c9, 0x09d1,
+	0x09d9, 0x09e1, 0x09e9, 0x09f1, 0x09f9, 0x0a01, 0x0a09, 0x0a11,
+	/* Node for range 0x0041_ */
+	0x0a19, 0x0a21, 0x0a29, 0x0a31, 0x0a39, 0x0a41, 0x0a49, 0x0a51,
+	0x0a59, 0x0a61, 0x0a69, 0x0a71, 0x0a79, 0x0a81, 0x0a89, 0x0a91,
+	/* Node for range 0x0042_ */
+	0x0a99, 0x0aa1, 0x0aa9, 0x0ab1, 0x0ab9, 0x0ac1, 0x0ac9, 0x0ad1,
+	0x0ad9, 0x0ae1, 0x0ae9, 0x0af1, 0x0af9, 0x0b01, 0x0b09, 0x0b11,
+	/* Node for range 0x0046_ */
+	0x0b19, 0x0000, 0x0b21, 0x0000, 0x0b29, 0x0000, 0x0b31, 0x0000,
+	0x0b39, 0x0000, 0x0b41, 0x0000, 0x0b49, 0x0000, 0x0b51, 0x0000,
+	/* Node for range 0x0047_ */
+	0x0b59, 0x0000, 0x0b61, 0x0000, 0x0b69, 0x0000, 0x0b71, 0x0000,
+	0x0b79, 0x0000, 0x0b81, 0x0000, 0x0b89, 0x0000, 0x0b91, 0x0000,
+	/* Node for range 0x0048_ */
+	0x0b99, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0ba1, 0x0000, 0x0ba9, 0x0000, 0x0bb1, 0x0000,
+	/* Node for range 0x0049_ */
+	0x0bb9, 0x0000, 0x0bc1, 0x0000, 0x0bc9, 0x0000, 0x0bd1, 0x0000,
+	0x0bd9, 0x0000, 0x0be1, 0x0000, 0x0be9, 0x0000, 0x0bf1, 0x0000,
+	/* Node for range 0x004a_ */
+	0x0bf9, 0x0000, 0x0c01, 0x0000, 0x0c09, 0x0000, 0x0c11, 0x0000,
+	0x0c19, 0x0000, 0x0c21, 0x0000, 0x0c29, 0x0000, 0x0c31, 0x0000,
+	/* Node for range 0x004b_ */
+	0x0c39, 0x0000, 0x0c41, 0x0000, 0x0c49, 0x0000, 0x0c51, 0x0000,
+	0x0c59, 0x0000, 0x0c61, 0x0000, 0x0c69, 0x0000, 0x0c71, 0x0000,
+	/* Node for range 0x004c_ */
+	0x0c79, 0x0c81, 0x0000, 0x0c89, 0x0000, 0x0c91, 0x0000, 0x0c99,
+	0x0000, 0x0ca1, 0x0000, 0x0ca9, 0x0000, 0x0cb1, 0x0000, 0x0000,
+	/* Node for range 0x004d_ */
+	0x0cb9, 0x0000, 0x0cc1, 0x0000, 0x0cc9, 0x0000, 0x0cd1, 0x0000,
+	0x0cd9, 0x0000, 0x0ce1, 0x0000, 0x0ce9, 0x0000, 0x0cf1, 0x0000,
+	/* Node for range 0x004e_ */
+	0x0cf9, 0x0000, 0x0d01, 0x0000, 0x0d09, 0x0000, 0x0d11, 0x0000,
+	0x0d19, 0x0000, 0x0d21, 0x0000, 0x0d29, 0x0000, 0x0d31, 0x0000,
+	/* Node for range 0x004f_ */
+	0x0d39, 0x0000, 0x0d41, 0x0000, 0x0d49, 0x0000, 0x0d51, 0x0000,
+	0x0d59, 0x0000, 0x0d61, 0x0000, 0x0d69, 0x0000, 0x0d71, 0x0000,
+	/* Node for range 0x0050_ */
+	0x0d79, 0x0000, 0x0d81, 0x0000, 0x0d89, 0x0000, 0x0d91, 0x0000,
+	0x0d99, 0x0000, 0x0da1, 0x0000, 0x0da9, 0x0000, 0x0db1, 0x0000,
+	/* Node for range 0x0051_ */
+	0x0db9, 0x0000, 0x0dc1, 0x0000, 0x0dc9, 0x0000, 0x0dd1, 0x0000,
+	0x0dd9, 0x0000, 0x0de1, 0x0000, 0x0de9, 0x0000, 0x0df1, 0x0000,
+	/* Node for range 0x0052_ */
+	0x0df9, 0x0000, 0x0e01, 0x0000, 0x0e09, 0x0000, 0x0e11, 0x0000,
+	0x0e19, 0x0000, 0x0e21, 0x0000, 0x0e29, 0x0000, 0x0e31, 0x0000,
+	/* Node for range 0x0053_ */
+	0x0000, 0x0e39, 0x0e41, 0x0e49, 0x0e51, 0x0e59, 0x0e61, 0x0e69,
+	0x0e71, 0x0e79, 0x0e81, 0x0e89, 0x0e91, 0x0e99, 0x0ea1, 0x0ea9,
+	/* Node for range 0x0054_ */
+	0x0eb1, 0x0eb9, 0x0ec1, 0x0ec9, 0x0ed1, 0x0ed9, 0x0ee1, 0x0ee9,
+	0x0ef1, 0x0ef9, 0x0f01, 0x0f09, 0x0f11, 0x0f19, 0x0f21, 0x0f29,
+	/* Node for range 0x0055_ */
+	0x0f31, 0x0f39, 0x0f41, 0x0f49, 0x0f51, 0x0f59, 0x0f61, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0058_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0f6a,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x010a_ */
+	0x0f79, 0x0f81, 0x0f89, 0x0f91, 0x0f99, 0x0fa1, 0x0fa9, 0x0fb1,
+	0x0fb9, 0x0fc1, 0x0fc9, 0x0fd1, 0x0fd9, 0x0fe1, 0x0fe9, 0x0ff1,
+	/* Node for range 0x010b_ */
+	0x0ff9, 0x1001, 0x1009, 0x1011, 0x1019, 0x1021, 0x1029, 0x1031,
+	0x1039, 0x1041, 0x1049, 0x1051, 0x1059, 0x1061, 0x1069, 0x1071,
+	/* Node for range 0x010c_ */
+	0x1079, 0x1081, 0x1089, 0x1091, 0x1099, 0x10a1, 0x0000, 0x10a9,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x10b1, 0x0000, 0x0000,
+	/* Node for range 0x013f_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x10b9, 0x10c1, 0x10c9, 0x10d1, 0x10d9, 0x10e1, 0x0000, 0x0000,
+	/* Node for range 0x01c8_ */
+	0x10e9, 0x10f1, 0x10f9, 0x1101, 0x1109, 0x1111, 0x1119, 0x1121,
+	0x1129, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01e0_ */
+	0x1131, 0x0000, 0x1139, 0x0000, 0x1141, 0x0000, 0x1149, 0x0000,
+	0x1151, 0x0000, 0x1159, 0x0000, 0x1161, 0x0000, 0x1169, 0x0000,
+	/* Node for range 0x01e1_ */
+	0x1171, 0x0000, 0x1179, 0x0000, 0x1181, 0x0000, 0x1189, 0x0000,
+	0x1191, 0x0000, 0x1199, 0x0000, 0x11a1, 0x0000, 0x11a9, 0x0000,
+	/* Node for range 0x01e2_ */
+	0x11b1, 0x0000, 0x11b9, 0x0000, 0x11c1, 0x0000, 0x11c9, 0x0000,
+	0x11d1, 0x0000, 0x11d9, 0x0000, 0x11e1, 0x0000, 0x11e9, 0x0000,
+	/* Node for range 0x01e3_ */
+	0x11f1, 0x0000, 0x11f9, 0x0000, 0x1201, 0x0000, 0x1209, 0x0000,
+	0x1211, 0x0000, 0x1219, 0x0000, 0x1221, 0x0000, 0x1229, 0x0000,
+	/* Node for range 0x01e4_ */
+	0x1231, 0x0000, 0x1239, 0x0000, 0x1241, 0x0000, 0x1249, 0x0000,
+	0x1251, 0x0000, 0x1259, 0x0000, 0x1261, 0x0000, 0x1269, 0x0000,
+	/* Node for range 0x01e5_ */
+	0x1271, 0x0000, 0x1279, 0x0000, 0x1281, 0x0000, 0x1289, 0x0000,
+	0x1291, 0x0000, 0x1299, 0x0000, 0x12a1, 0x0000, 0x12a9, 0x0000,
+	/* Node for range 0x01e6_ */
+	0x12b1, 0x0000, 0x12b9, 0x0000, 0x12c1, 0x0000, 0x12c9, 0x0000,
+	0x12d1, 0x0000, 0x12d9, 0x0000, 0x12e1, 0x0000, 0x12e9, 0x0000,
+	/* Node for range 0x01e7_ */
+	0x12f1, 0x0000, 0x12f9, 0x0000, 0x1301, 0x0000, 0x1309, 0x0000,
+	0x1311, 0x0000, 0x1319, 0x0000, 0x1321, 0x0000, 0x1329, 0x0000,
+	/* Node for range 0x01e8_ */
+	0x1331, 0x0000, 0x1339, 0x0000, 0x1341, 0x0000, 0x1349, 0x0000,
+	0x1351, 0x0000, 0x1359, 0x0000, 0x1361, 0x0000, 0x1369, 0x0000,
+	/* Node for range 0x01e9_ */
+	0x1371, 0x0000, 0x1379, 0x0000, 0x1381, 0x0000, 0x138a, 0x139a,
+	0x13aa, 0x13ba, 0x13ca, 0x13d9, 0x0000, 0x0000, 0x13e2, 0x0000,
+	/* Node for range 0x01ea_ */
+	0x13f1, 0x0000, 0x13f9, 0x0000, 0x1401, 0x0000, 0x1409, 0x0000,
+	0x1411, 0x0000, 0x1419, 0x0000, 0x1421, 0x0000, 0x1429, 0x0000,
+	/* Node for range 0x01eb_ */
+	0x1431, 0x0000, 0x1439, 0x0000, 0x1441, 0x0000, 0x1449, 0x0000,
+	0x1451, 0x0000, 0x1459, 0x0000, 0x1461, 0x0000, 0x1469, 0x0000,
+	/* Node for range 0x01ec_ */
+	0x1471, 0x0000, 0x1479, 0x0000, 0x1481, 0x0000, 0x1489, 0x0000,
+	0x1491, 0x0000, 0x1499, 0x0000, 0x14a1, 0x0000, 0x14a9, 0x0000,
+	/* Node for range 0x01ed_ */
+	0x14b1, 0x0000, 0x14b9, 0x0000, 0x14c1, 0x0000, 0x14c9, 0x0000,
+	0x14d1, 0x0000, 0x14d9, 0x0000, 0x14e1, 0x0000, 0x14e9, 0x0000,
+	/* Node for range 0x01ee_ */
+	0x14f1, 0x0000, 0x14f9, 0x0000, 0x1501, 0x0000, 0x1509, 0x0000,
+	0x1511, 0x0000, 0x1519, 0x0000, 0x1521, 0x0000, 0x1529, 0x0000,
+	/* Node for range 0x01ef_ */
+	0x1531, 0x0000, 0x1539, 0x0000, 0x1541, 0x0000, 0x1549, 0x0000,
+	0x1551, 0x0000, 0x1559, 0x0000, 0x1561, 0x0000, 0x1569, 0x0000,
+	/* Node for range 0x01f0_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x1571, 0x1579, 0x1581, 0x1589, 0x1591, 0x1599, 0x15a1, 0x15a9,
+	/* Node for range 0x01f1_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x15b1, 0x15b9, 0x15c1, 0x15c9, 0x15d1, 0x15d9, 0x0000, 0x0000,
+	/* Node for range 0x01f2_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x15e1, 0x15e9, 0x15f1, 0x15f9, 0x1601, 0x1609, 0x1611, 0x1619,
+	/* Node for range 0x01f3_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x1621, 0x1629, 0x1631, 0x1639, 0x1641, 0x1649, 0x1651, 0x1659,
+	/* Node for range 0x01f4_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x1661, 0x1669, 0x1671, 0x1679, 0x1681, 0x1689, 0x0000, 0x0000,
+	/* Node for range 0x01f5_ */
+	0x1692, 0x0000, 0x16a3, 0x0000, 0x16bb, 0x0000, 0x16d3, 0x0000,
+	0x0000, 0x16e9, 0x0000, 0x16f1, 0x0000, 0x16f9, 0x0000, 0x1701,
+	/* Node for range 0x01f6_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x1709, 0x1711, 0x1719, 0x1721, 0x1729, 0x1731, 0x1739, 0x1741,
+	/* Node for range 0x01f8_ */
+	0x174a, 0x175a, 0x176a, 0x177a, 0x178a, 0x179a, 0x17aa, 0x17ba,
+	0x17ca, 0x17da, 0x17ea, 0x17fa, 0x180a, 0x181a, 0x182a, 0x183a,
+	/* Node for range 0x01f9_ */
+	0x184a, 0x185a, 0x186a, 0x187a, 0x188a, 0x189a, 0x18aa, 0x18ba,
+	0x18ca, 0x18da, 0x18ea, 0x18fa, 0x190a, 0x191a, 0x192a, 0x193a,
+	/* Node for range 0x01fa_ */
+	0x194a, 0x195a, 0x196a, 0x197a, 0x198a, 0x199a, 0x19aa, 0x19ba,
+	0x19ca, 0x19da, 0x19ea, 0x19fa, 0x1a0a, 0x1a1a, 0x1a2a, 0x1a3a,
+	/* Node for range 0x01fb_ */
+	0x0000, 0x0000, 0x1a4a, 0x1a5a, 0x1a6a, 0x0000, 0x1a7a, 0x1a8b,
+	0x1aa1, 0x1aa9, 0x1ab1, 0x1ab9, 0x1ac2, 0x0000, 0x1ad1, 0x0000,
+	/* Node for range 0x01fc_ */
+	0x0000, 0x0000, 0x1ada, 0x1aea, 0x1afa, 0x0000, 0x1b0a, 0x1b1b,
+	0x1b31, 0x1b39, 0x1b41, 0x1b49, 0x1b52, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01fd_ */
+	0x0000, 0x0000, 0x1b63, 0x1b7b, 0x0000, 0x0000, 0x1b92, 0x1ba3,
+	0x1bb9, 0x1bc1, 0x1bc9, 0x1bd1, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01fe_ */
+	0x0000, 0x0000, 0x1bdb, 0x1bf3, 0x1c0a, 0x0000, 0x1c1a, 0x1c2b,
+	0x1c41, 0x1c49, 0x1c51, 0x1c59, 0x1c61, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x01ff_ */
+	0x0000, 0x0000, 0x1c6a, 0x1c7a, 0x1c8a, 0x0000, 0x1c9a, 0x1cab,
+	0x1cc1, 0x1cc9, 0x1cd1, 0x1cd9, 0x1ce2, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0212_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1cf1, 0x0000,
+	0x0000, 0x0000, 0x1cf9, 0x1d01, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0213_ */
+	0x0000, 0x0000, 0x1d09, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0216_ */
+	0x1d11, 0x1d19, 0x1d21, 0x1d29, 0x1d31, 0x1d39, 0x1d41, 0x1d49,
+	0x1d51, 0x1d59, 0x1d61, 0x1d69, 0x1d71, 0x1d79, 0x1d81, 0x1d89,
+	/* Node for range 0x0218_ */
+	0x0000, 0x0000, 0x0000, 0x1d91, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x024b_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1d99, 0x1da1,
+	0x1da9, 0x1db1, 0x1db9, 0x1dc1, 0x1dc9, 0x1dd1, 0x1dd9, 0x1de1,
+	/* Node for range 0x024c_ */
+	0x1de9, 0x1df1, 0x1df9, 0x1e01, 0x1e09, 0x1e11, 0x1e19, 0x1e21,
+	0x1e29, 0x1e31, 0x1e39, 0x1e41, 0x1e49, 0x1e51, 0x1e59, 0x1e61,
+	/* Node for range 0x02c0_ */
+	0x1e69, 0x1e71, 0x1e79, 0x1e81, 0x1e89, 0x1e91, 0x1e99, 0x1ea1,
+	0x1ea9, 0x1eb1, 0x1eb9, 0x1ec1, 0x1ec9, 0x1ed1, 0x1ed9, 0x1ee1,
+	/* Node for range 0x02c1_ */
+	0x1ee9, 0x1ef1, 0x1ef9, 0x1f01, 0x1f09, 0x1f11, 0x1f19, 0x1f21,
+	0x1f29, 0x1f31, 0x1f39, 0x1f41, 0x1f49, 0x1f51, 0x1f59, 0x1f61,
+	/* Node for range 0x02c2_ */
+	0x1f69, 0x1f71, 0x1f79, 0x1f81, 0x1f89, 0x1f91, 0x1f99, 0x1fa1,
+	0x1fa9, 0x1fb1, 0x1fb9, 0x1fc1, 0x1fc9, 0x1fd1, 0x1fd9, 0x0000,
+	/* Node for range 0x02c6_ */
+	0x1fe1, 0x0000, 0x1fe9, 0x1ff1, 0x1ff9, 0x0000, 0x0000, 0x2001,
+	0x0000, 0x2009, 0x0000, 0x2011, 0x0000, 0x2019, 0x2021, 0x2029,
+	/* Node for range 0x02c7_ */
+	0x2031, 0x0000, 0x2039, 0x0000, 0x0000, 0x2041, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2049, 0x2051,
+	/* Node for range 0x02c8_ */
+	0x2059, 0x0000, 0x2061, 0x0000, 0x2069, 0x0000, 0x2071, 0x0000,
+	0x2079, 0x0000, 0x2081, 0x0000, 0x2089, 0x0000, 0x2091, 0x0000,
+	/* Node for range 0x02c9_ */
+	0x2099, 0x0000, 0x20a1, 0x0000, 0x20a9, 0x0000, 0x20b1, 0x0000,
+	0x20b9, 0x0000, 0x20c1, 0x0000, 0x20c9, 0x0000, 0x20d1, 0x0000,
+	/* Node for range 0x02ca_ */
+	0x20d9, 0x0000, 0x20e1, 0x0000, 0x20e9, 0x0000, 0x20f1, 0x0000,
+	0x20f9, 0x0000, 0x2101, 0x0000, 0x2109, 0x0000, 0x2111, 0x0000,
+	/* Node for range 0x02cb_ */
+	0x2119, 0x0000, 0x2121, 0x0000, 0x2129, 0x0000, 0x2131, 0x0000,
+	0x2139, 0x0000, 0x2141, 0x0000, 0x2149, 0x0000, 0x2151, 0x0000,
+	/* Node for range 0x02cc_ */
+	0x2159, 0x0000, 0x2161, 0x0000, 0x2169, 0x0000, 0x2171, 0x0000,
+	0x2179, 0x0000, 0x2181, 0x0000, 0x2189, 0x0000, 0x2191, 0x0000,
+	/* Node for range 0x02cd_ */
+	0x2199, 0x0000, 0x21a1, 0x0000, 0x21a9, 0x0000, 0x21b1, 0x0000,
+	0x21b9, 0x0000, 0x21c1, 0x0000, 0x21c9, 0x0000, 0x21d1, 0x0000,
+	/* Node for range 0x02ce_ */
+	0x21d9, 0x0000, 0x21e1, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x21e9, 0x0000, 0x21f1, 0x0000, 0x0000,
+	/* Node for range 0x02cf_ */
+	0x0000, 0x0000, 0x21f9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0a64_ */
+	0x2201, 0x0000, 0x2209, 0x0000, 0x2211, 0x0000, 0x2219, 0x0000,
+	0x2221, 0x0000, 0x2229, 0x0000, 0x2231, 0x0000, 0x2239, 0x0000,
+	/* Node for range 0x0a65_ */
+	0x2241, 0x0000, 0x2249, 0x0000, 0x2251, 0x0000, 0x2259, 0x0000,
+	0x2261, 0x0000, 0x2269, 0x0000, 0x2271, 0x0000, 0x2279, 0x0000,
+	/* Node for range 0x0a66_ */
+	0x2281, 0x0000, 0x2289, 0x0000, 0x2291, 0x0000, 0x2299, 0x0000,
+	0x22a1, 0x0000, 0x22a9, 0x0000, 0x22b1, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0a68_ */
+	0x22b9, 0x0000, 0x22c1, 0x0000, 0x22c9, 0x0000, 0x22d1, 0x0000,
+	0x22d9, 0x0000, 0x22e1, 0x0000, 0x22e9, 0x0000, 0x22f1, 0x0000,
+	/* Node for range 0x0a69_ */
+	0x22f9, 0x0000, 0x2301, 0x0000, 0x2309, 0x0000, 0x2311, 0x0000,
+	0x2319, 0x0000, 0x2321, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0a72_ */
+	0x0000, 0x0000, 0x2329, 0x0000, 0x2331, 0x0000, 0x2339, 0x0000,
+	0x2341, 0x0000, 0x2349, 0x0000, 0x2351, 0x0000, 0x2359, 0x0000,
+	/* Node for range 0x0a73_ */
+	0x0000, 0x0000, 0x2361, 0x0000, 0x2369, 0x0000, 0x2371, 0x0000,
+	0x2379, 0x0000, 0x2381, 0x0000, 0x2389, 0x0000, 0x2391, 0x0000,
+	/* Node for range 0x0a74_ */
+	0x2399, 0x0000, 0x23a1, 0x0000, 0x23a9, 0x0000, 0x23b1, 0x0000,
+	0x23b9, 0x0000, 0x23c1, 0x0000, 0x23c9, 0x0000, 0x23d1, 0x0000,
+	/* Node for range 0x0a75_ */
+	0x23d9, 0x0000, 0x23e1, 0x0000, 0x23e9, 0x0000, 0x23f1, 0x0000,
+	0x23f9, 0x0000, 0x2401, 0x0000, 0x2409, 0x0000, 0x2411, 0x0000,
+	/* Node for range 0x0a76_ */
+	0x2419, 0x0000, 0x2421, 0x0000, 0x2429, 0x0000, 0x2431, 0x0000,
+	0x2439, 0x0000, 0x2441, 0x0000, 0x2449, 0x0000, 0x2451, 0x0000,
+	/* Node for range 0x0a77_ */
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x2459, 0x0000, 0x2461, 0x0000, 0x2469, 0x2471, 0x0000,
+	/* Node for range 0x0a78_ */
+	0x2479, 0x0000, 0x2481, 0x0000, 0x2489, 0x0000, 0x2491, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x2499, 0x0000, 0x24a1, 0x0000, 0x0000,
+	/* Node for range 0x0a79_ */
+	0x24a9, 0x0000, 0x24b1, 0x0000, 0x0000, 0x0000, 0x24b9, 0x0000,
+	0x24c1, 0x0000, 0x24c9, 0x0000, 0x24d1, 0x0000, 0x24d9, 0x0000,
+	/* Node for range 0x0a7a_ */
+	0x24e1, 0x0000, 0x24e9, 0x0000, 0x24f1, 0x0000, 0x24f9, 0x0000,
+	0x2501, 0x0000, 0x2509, 0x2511, 0x2519, 0x2521, 0x2529, 0x0000,
+	/* Node for range 0x0a7b_ */
+	0x2531, 0x2539, 0x2541, 0x2549, 0x2551, 0x0000, 0x2559, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0ab7_ */
+	0x2561, 0x2569, 0x2571, 0x2579, 0x2581, 0x2589, 0x2591, 0x2599,
+	0x25a1, 0x25a9, 0x25b1, 0x25b9, 0x25c1, 0x25c9, 0x25d1, 0x25d9,
+	/* Node for range 0x0ab8_ */
+	0x25e1, 0x25e9, 0x25f1, 0x25f9, 0x2601, 0x2609, 0x2611, 0x2619,
+	0x2621, 0x2629, 0x2631, 0x2639, 0x2641, 0x2649, 0x2651, 0x2659,
+	/* Node for range 0x0ab9_ */
+	0x2661, 0x2669, 0x2671, 0x2679, 0x2681, 0x2689, 0x2691, 0x2699,
+	0x26a1, 0x26a9, 0x26b1, 0x26b9, 0x26c1, 0x26c9, 0x26d1, 0x26d9,
+	/* Node for range 0x0aba_ */
+	0x26e1, 0x26e9, 0x26f1, 0x26f9, 0x2701, 0x2709, 0x2711, 0x2719,
+	0x2721, 0x2729, 0x2731, 0x2739, 0x2741, 0x2749, 0x2751, 0x2759,
+	/* Node for range 0x0abb_ */
+	0x2761, 0x2769, 0x2771, 0x2779, 0x2781, 0x2789, 0x2791, 0x2799,
+	0x27a1, 0x27a9, 0x27b1, 0x27b9, 0x27c1, 0x27c9, 0x27d1, 0x27d9,
+	/* Node for range 0x0fb0_ */
+	0x27e2, 0x27f2, 0x2802, 0x2813, 0x282b, 0x2842, 0x2852, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0fb1_ */
+	0x0000, 0x0000, 0x0000, 0x2862, 0x2872, 0x2882, 0x2892, 0x28a2,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x0ff2_ */
+	0x0000, 0x28b1, 0x28b9, 0x28c1, 0x28c9, 0x28d1, 0x28d9, 0x28e1,
+	0x28e9, 0x28f1, 0x28f9, 0x2901, 0x2909, 0x2911, 0x2919, 0x2921,
+	/* Node for range 0x0ff3_ */
+	0x2929, 0x2931, 0x2939, 0x2941, 0x2949, 0x2951, 0x2959, 0x2961,
+	0x2969, 0x2971, 0x2979, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x1040_ */
+	0x2981, 0x2989, 0x2991, 0x2999, 0x29a1, 0x29a9, 0x29b1, 0x29b9,
+	0x29c1, 0x29c9, 0x29d1, 0x29d9, 0x29e1, 0x29e9, 0x29f1, 0x29f9,
+	/* Node for range 0x1041_ */
+	0x2a01, 0x2a09, 0x2a11, 0x2a19, 0x2a21, 0x2a29, 0x2a31, 0x2a39,
+	0x2a41, 0x2a49, 0x2a51, 0x2a59, 0x2a61, 0x2a69, 0x2a71, 0x2a79,
+	/* Node for range 0x1042_ */
+	0x2a81, 0x2a89, 0x2a91, 0x2a99, 0x2aa1, 0x2aa9, 0x2ab1, 0x2ab9,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x104b_ */
+	0x2ac1, 0x2ac9, 0x2ad1, 0x2ad9, 0x2ae1, 0x2ae9, 0x2af1, 0x2af9,
+	0x2b01, 0x2b09, 0x2b11, 0x2b19, 0x2b21, 0x2b29, 0x2b31, 0x2b39,
+	/* Node for range 0x104c_ */
+	0x2b41, 0x2b49, 0x2b51, 0x2b59, 0x2b61, 0x2b69, 0x2b71, 0x2b79,
+	0x2b81, 0x2b89, 0x2b91, 0x2b99, 0x2ba1, 0x2ba9, 0x2bb1, 0x2bb9,
+	/* Node for range 0x104d_ */
+	0x2bc1, 0x2bc9, 0x2bd1, 0x2bd9, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x10c8_ */
+	0x2be1, 0x2be9, 0x2bf1, 0x2bf9, 0x2c01, 0x2c09, 0x2c11, 0x2c19,
+	0x2c21, 0x2c29, 0x2c31, 0x2c39, 0x2c41, 0x2c49, 0x2c51, 0x2c59,
+	/* Node for range 0x10c9_ */
+	0x2c61, 0x2c69, 0x2c71, 0x2c79, 0x2c81, 0x2c89, 0x2c91, 0x2c99,
+	0x2ca1, 0x2ca9, 0x2cb1, 0x2cb9, 0x2cc1, 0x2cc9, 0x2cd1, 0x2cd9,
+	/* Node for range 0x10ca_ */
+	0x2ce1, 0x2ce9, 0x2cf1, 0x2cf9, 0x2d01, 0x2d09, 0x2d11, 0x2d19,
+	0x2d21, 0x2d29, 0x2d31, 0x2d39, 0x2d41, 0x2d49, 0x2d51, 0x2d59,
+	/* Node for range 0x10cb_ */
+	0x2d61, 0x2d69, 0x2d71, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	/* Node for range 0x118a_ */
+	0x2d79, 0x2d81, 0x2d89, 0x2d91, 0x2d99, 0x2da1, 0x2da9, 0x2db1,
+	0x2db9, 0x2dc1, 0x2dc9, 0x2dd1, 0x2dd9, 0x2de1, 0x2de9, 0x2df1,
+	/* Node for range 0x118b_ */
+	0x2df9, 0x2e01, 0x2e09, 0x2e11, 0x2e19, 0x2e21, 0x2e29, 0x2e31,
+	0x2e39, 0x2e41, 0x2e49, 0x2e51, 0x2e59, 0x2e61, 0x2e69, 0x2e71,
+	/* Node for range 0x1e90_ */
+	0x2e79, 0x2e81, 0x2e89, 0x2e91, 0x2e99, 0x2ea1, 0x2ea9, 0x2eb1,
+	0x2eb9, 0x2ec1, 0x2ec9, 0x2ed1, 0x2ed9, 0x2ee1, 0x2ee9, 0x2ef1,
+	/* Node for range 0x1e91_ */
+	0x2ef9, 0x2f01, 0x2f09, 0x2f11, 0x2f19, 0x2f21, 0x2f29, 0x2f31,
+	0x2f39, 0x2f41, 0x2f49, 0x2f51, 0x2f59, 0x2f61, 0x2f69, 0x2f71,
+	/* Node for range 0x1e92_ */
+	0x2f79, 0x2f81, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+};
+
+static unicode_t apfs_cf[] = {
+	0x000061, 0x000062, 0x000063, 0x000064, 0x000065, 0x000066,
+	0x000067, 0x000068, 0x000069, 0x00006a, 0x00006b, 0x00006c,
+	0x00006d, 0x00006e, 0x00006f, 0x000070, 0x000071, 0x000072,
+	0x000073, 0x000074, 0x000075, 0x000076, 0x000077, 0x000078,
+	0x000079, 0x00007a, 0x0003bc, 0x0000e0, 0x0000e1, 0x0000e2,
+	0x0000e3, 0x0000e4, 0x0000e5, 0x0000e6, 0x0000e7, 0x0000e8,
+	0x0000e9, 0x0000ea, 0x0000eb, 0x0000ec, 0x0000ed, 0x0000ee,
+	0x0000ef, 0x0000f0, 0x0000f1, 0x0000f2, 0x0000f3, 0x0000f4,
+	0x0000f5, 0x0000f6, 0x0000f8, 0x0000f9, 0x0000fa, 0x0000fb,
+	0x0000fc, 0x0000fd, 0x0000fe, 0x000073, 0x000073, 0x000101,
+	0x000103, 0x000105, 0x000107, 0x000109, 0x00010b, 0x00010d,
+	0x00010f, 0x000111, 0x000113, 0x000115, 0x000117, 0x000119,
+	0x00011b, 0x00011d, 0x00011f, 0x000121, 0x000123, 0x000125,
+	0x000127, 0x000129, 0x00012b, 0x00012d, 0x00012f, 0x000069,
+	0x000307, 0x000133, 0x000135, 0x000137, 0x00013a, 0x00013c,
+	0x00013e, 0x000140, 0x000142, 0x000144, 0x000146, 0x000148,
+	0x0002bc, 0x00006e, 0x00014b, 0x00014d, 0x00014f, 0x000151,
+	0x000153, 0x000155, 0x000157, 0x000159, 0x00015b, 0x00015d,
+	0x00015f, 0x000161, 0x000163, 0x000165, 0x000167, 0x000169,
+	0x00016b, 0x00016d, 0x00016f, 0x000171, 0x000173, 0x000175,
+	0x000177, 0x0000ff, 0x00017a, 0x00017c, 0x00017e, 0x000073,
+	0x000253, 0x000183, 0x000185, 0x000254, 0x000188, 0x000256,
+	0x000257, 0x00018c, 0x0001dd, 0x000259, 0x00025b, 0x000192,
+	0x000260, 0x000263, 0x000269, 0x000268, 0x000199, 0x00026f,
+	0x000272, 0x000275, 0x0001a1, 0x0001a3, 0x0001a5, 0x000280,
+	0x0001a8, 0x000283, 0x0001ad, 0x000288, 0x0001b0, 0x00028a,
+	0x00028b, 0x0001b4, 0x0001b6, 0x000292, 0x0001b9, 0x0001bd,
+	0x0001c6, 0x0001c6, 0x0001c9, 0x0001c9, 0x0001cc, 0x0001cc,
+	0x0001ce, 0x0001d0, 0x0001d2, 0x0001d4, 0x0001d6, 0x0001d8,
+	0x0001da, 0x0001dc, 0x0001df, 0x0001e1, 0x0001e3, 0x0001e5,
+	0x0001e7, 0x0001e9, 0x0001eb, 0x0001ed, 0x0001ef, 0x00006a,
+	0x00030c, 0x0001f3, 0x0001f3, 0x0001f5, 0x000195, 0x0001bf,
+	0x0001f9, 0x0001fb, 0x0001fd, 0x0001ff, 0x000201, 0x000203,
+	0x000205, 0x000207, 0x000209, 0x00020b, 0x00020d, 0x00020f,
+	0x000211, 0x000213, 0x000215, 0x000217, 0x000219, 0x00021b,
+	0x00021d, 0x00021f, 0x00019e, 0x000223, 0x000225, 0x000227,
+	0x000229, 0x00022b, 0x00022d, 0x00022f, 0x000231, 0x000233,
+	0x002c65, 0x00023c, 0x00019a, 0x002c66, 0x000242, 0x000180,
+	0x000289, 0x00028c, 0x000247, 0x000249, 0x00024b, 0x00024d,
+	0x00024f, 0x0003b9, 0x000371, 0x000373, 0x000377, 0x0003f3,
+	0x0003ac, 0x0003ad, 0x0003ae, 0x0003af, 0x0003cc, 0x0003cd,
+	0x0003ce, 0x0003b9, 0x000308, 0x000301, 0x0003b1, 0x0003b2,
+	0x0003b3, 0x0003b4, 0x0003b5, 0x0003b6, 0x0003b7, 0x0003b8,
+	0x0003b9, 0x0003ba, 0x0003bb, 0x0003bc, 0x0003bd, 0x0003be,
+	0x0003bf, 0x0003c0, 0x0003c1, 0x0003c3, 0x0003c4, 0x0003c5,
+	0x0003c6, 0x0003c7, 0x0003c8, 0x0003c9, 0x0003ca, 0x0003cb,
+	0x0003c5, 0x000308, 0x000301, 0x0003c3, 0x0003d7, 0x0003b2,
+	0x0003b8, 0x0003c6, 0x0003c0, 0x0003d9, 0x0003db, 0x0003dd,
+	0x0003df, 0x0003e1, 0x0003e3, 0x0003e5, 0x0003e7, 0x0003e9,
+	0x0003eb, 0x0003ed, 0x0003ef, 0x0003ba, 0x0003c1, 0x0003b8,
+	0x0003b5, 0x0003f8, 0x0003f2, 0x0003fb, 0x00037b, 0x00037c,
+	0x00037d, 0x000450, 0x000451, 0x000452, 0x000453, 0x000454,
+	0x000455, 0x000456, 0x000457, 0x000458, 0x000459, 0x00045a,
+	0x00045b, 0x00045c, 0x00045d, 0x00045e, 0x00045f, 0x000430,
+	0x000431, 0x000432, 0x000433, 0x000434, 0x000435, 0x000436,
+	0x000437, 0x000438, 0x000439, 0x00043a, 0x00043b, 0x00043c,
+	0x00043d, 0x00043e, 0x00043f, 0x000440, 0x000441, 0x000442,
+	0x000443, 0x000444, 0x000445, 0x000446, 0x000447, 0x000448,
+	0x000449, 0x00044a, 0x00044b, 0x00044c, 0x00044d, 0x00044e,
+	0x00044f, 0x000461, 0x000463, 0x000465, 0x000467, 0x000469,
+	0x00046b, 0x00046d, 0x00046f, 0x000471, 0x000473, 0x000475,
+	0x000477, 0x000479, 0x00047b, 0x00047d, 0x00047f, 0x000481,
+	0x00048b, 0x00048d, 0x00048f, 0x000491, 0x000493, 0x000495,
+	0x000497, 0x000499, 0x00049b, 0x00049d, 0x00049f, 0x0004a1,
+	0x0004a3, 0x0004a5, 0x0004a7, 0x0004a9, 0x0004ab, 0x0004ad,
+	0x0004af, 0x0004b1, 0x0004b3, 0x0004b5, 0x0004b7, 0x0004b9,
+	0x0004bb, 0x0004bd, 0x0004bf, 0x0004cf, 0x0004c2, 0x0004c4,
+	0x0004c6, 0x0004c8, 0x0004ca, 0x0004cc, 0x0004ce, 0x0004d1,
+	0x0004d3, 0x0004d5, 0x0004d7, 0x0004d9, 0x0004db, 0x0004dd,
+	0x0004df, 0x0004e1, 0x0004e3, 0x0004e5, 0x0004e7, 0x0004e9,
+	0x0004eb, 0x0004ed, 0x0004ef, 0x0004f1, 0x0004f3, 0x0004f5,
+	0x0004f7, 0x0004f9, 0x0004fb, 0x0004fd, 0x0004ff, 0x000501,
+	0x000503, 0x000505, 0x000507, 0x000509, 0x00050b, 0x00050d,
+	0x00050f, 0x000511, 0x000513, 0x000515, 0x000517, 0x000519,
+	0x00051b, 0x00051d, 0x00051f, 0x000521, 0x000523, 0x000525,
+	0x000527, 0x000529, 0x00052b, 0x00052d, 0x00052f, 0x000561,
+	0x000562, 0x000563, 0x000564, 0x000565, 0x000566, 0x000567,
+	0x000568, 0x000569, 0x00056a, 0x00056b, 0x00056c, 0x00056d,
+	0x00056e, 0x00056f, 0x000570, 0x000571, 0x000572, 0x000573,
+	0x000574, 0x000575, 0x000576, 0x000577, 0x000578, 0x000579,
+	0x00057a, 0x00057b, 0x00057c, 0x00057d, 0x00057e, 0x00057f,
+	0x000580, 0x000581, 0x000582, 0x000583, 0x000584, 0x000585,
+	0x000586, 0x000565, 0x000582, 0x002d00, 0x002d01, 0x002d02,
+	0x002d03, 0x002d04, 0x002d05, 0x002d06, 0x002d07, 0x002d08,
+	0x002d09, 0x002d0a, 0x002d0b, 0x002d0c, 0x002d0d, 0x002d0e,
+	0x002d0f, 0x002d10, 0x002d11, 0x002d12, 0x002d13, 0x002d14,
+	0x002d15, 0x002d16, 0x002d17, 0x002d18, 0x002d19, 0x002d1a,
+	0x002d1b, 0x002d1c, 0x002d1d, 0x002d1e, 0x002d1f, 0x002d20,
+	0x002d21, 0x002d22, 0x002d23, 0x002d24, 0x002d25, 0x002d27,
+	0x002d2d, 0x0013f0, 0x0013f1, 0x0013f2, 0x0013f3, 0x0013f4,
+	0x0013f5, 0x000432, 0x000434, 0x00043e, 0x000441, 0x000442,
+	0x000442, 0x00044a, 0x000463, 0x00a64b, 0x001e01, 0x001e03,
+	0x001e05, 0x001e07, 0x001e09, 0x001e0b, 0x001e0d, 0x001e0f,
+	0x001e11, 0x001e13, 0x001e15, 0x001e17, 0x001e19, 0x001e1b,
+	0x001e1d, 0x001e1f, 0x001e21, 0x001e23, 0x001e25, 0x001e27,
+	0x001e29, 0x001e2b, 0x001e2d, 0x001e2f, 0x001e31, 0x001e33,
+	0x001e35, 0x001e37, 0x001e39, 0x001e3b, 0x001e3d, 0x001e3f,
+	0x001e41, 0x001e43, 0x001e45, 0x001e47, 0x001e49, 0x001e4b,
+	0x001e4d, 0x001e4f, 0x001e51, 0x001e53, 0x001e55, 0x001e57,
+	0x001e59, 0x001e5b, 0x001e5d, 0x001e5f, 0x001e61, 0x001e63,
+	0x001e65, 0x001e67, 0x001e69, 0x001e6b, 0x001e6d, 0x001e6f,
+	0x001e71, 0x001e73, 0x001e75, 0x001e77, 0x001e79, 0x001e7b,
+	0x001e7d, 0x001e7f, 0x001e81, 0x001e83, 0x001e85, 0x001e87,
+	0x001e89, 0x001e8b, 0x001e8d, 0x001e8f, 0x001e91, 0x001e93,
+	0x001e95, 0x000068, 0x000331, 0x000074, 0x000308, 0x000077,
+	0x00030a, 0x000079, 0x00030a, 0x000061, 0x0002be, 0x001e61,
+	0x000073, 0x000073, 0x001ea1, 0x001ea3, 0x001ea5, 0x001ea7,
+	0x001ea9, 0x001eab, 0x001ead, 0x001eaf, 0x001eb1, 0x001eb3,
+	0x001eb5, 0x001eb7, 0x001eb9, 0x001ebb, 0x001ebd, 0x001ebf,
+	0x001ec1, 0x001ec3, 0x001ec5, 0x001ec7, 0x001ec9, 0x001ecb,
+	0x001ecd, 0x001ecf, 0x001ed1, 0x001ed3, 0x001ed5, 0x001ed7,
+	0x001ed9, 0x001edb, 0x001edd, 0x001edf, 0x001ee1, 0x001ee3,
+	0x001ee5, 0x001ee7, 0x001ee9, 0x001eeb, 0x001eed, 0x001eef,
+	0x001ef1, 0x001ef3, 0x001ef5, 0x001ef7, 0x001ef9, 0x001efb,
+	0x001efd, 0x001eff, 0x001f00, 0x001f01, 0x001f02, 0x001f03,
+	0x001f04, 0x001f05, 0x001f06, 0x001f07, 0x001f10, 0x001f11,
+	0x001f12, 0x001f13, 0x001f14, 0x001f15, 0x001f20, 0x001f21,
+	0x001f22, 0x001f23, 0x001f24, 0x001f25, 0x001f26, 0x001f27,
+	0x001f30, 0x001f31, 0x001f32, 0x001f33, 0x001f34, 0x001f35,
+	0x001f36, 0x001f37, 0x001f40, 0x001f41, 0x001f42, 0x001f43,
+	0x001f44, 0x001f45, 0x0003c5, 0x000313, 0x0003c5, 0x000313,
+	0x000300, 0x0003c5, 0x000313, 0x000301, 0x0003c5, 0x000313,
+	0x000342, 0x001f51, 0x001f53, 0x001f55, 0x001f57, 0x001f60,
+	0x001f61, 0x001f62, 0x001f63, 0x001f64, 0x001f65, 0x001f66,
+	0x001f67, 0x001f00, 0x0003b9, 0x001f01, 0x0003b9, 0x001f02,
+	0x0003b9, 0x001f03, 0x0003b9, 0x001f04, 0x0003b9, 0x001f05,
+	0x0003b9, 0x001f06, 0x0003b9, 0x001f07, 0x0003b9, 0x001f00,
+	0x0003b9, 0x001f01, 0x0003b9, 0x001f02, 0x0003b9, 0x001f03,
+	0x0003b9, 0x001f04, 0x0003b9, 0x001f05, 0x0003b9, 0x001f06,
+	0x0003b9, 0x001f07, 0x0003b9, 0x001f20, 0x0003b9, 0x001f21,
+	0x0003b9, 0x001f22, 0x0003b9, 0x001f23, 0x0003b9, 0x001f24,
+	0x0003b9, 0x001f25, 0x0003b9, 0x001f26, 0x0003b9, 0x001f27,
+	0x0003b9, 0x001f20, 0x0003b9, 0x001f21, 0x0003b9, 0x001f22,
+	0x0003b9, 0x001f23, 0x0003b9, 0x001f24, 0x0003b9, 0x001f25,
+	0x0003b9, 0x001f26, 0x0003b9, 0x001f27, 0x0003b9, 0x001f60,
+	0x0003b9, 0x001f61, 0x0003b9, 0x001f62, 0x0003b9, 0x001f63,
+	0x0003b9, 0x001f64, 0x0003b9, 0x001f65, 0x0003b9, 0x001f66,
+	0x0003b9, 0x001f67, 0x0003b9, 0x001f60, 0x0003b9, 0x001f61,
+	0x0003b9, 0x001f62, 0x0003b9, 0x001f63, 0x0003b9, 0x001f64,
+	0x0003b9, 0x001f65, 0x0003b9, 0x001f66, 0x0003b9, 0x001f67,
+	0x0003b9, 0x001f70, 0x0003b9, 0x0003b1, 0x0003b9, 0x0003ac,
+	0x0003b9, 0x0003b1, 0x000342, 0x0003b1, 0x000342, 0x0003b9,
+	0x001fb0, 0x001fb1, 0x001f70, 0x001f71, 0x0003b1, 0x0003b9,
+	0x0003b9, 0x001f74, 0x0003b9, 0x0003b7, 0x0003b9, 0x0003ae,
+	0x0003b9, 0x0003b7, 0x000342, 0x0003b7, 0x000342, 0x0003b9,
+	0x001f72, 0x001f73, 0x001f74, 0x001f75, 0x0003b7, 0x0003b9,
+	0x0003b9, 0x000308, 0x000300, 0x0003b9, 0x000308, 0x000301,
+	0x0003b9, 0x000342, 0x0003b9, 0x000308, 0x000342, 0x001fd0,
+	0x001fd1, 0x001f76, 0x001f77, 0x0003c5, 0x000308, 0x000300,
+	0x0003c5, 0x000308, 0x000301, 0x0003c1, 0x000313, 0x0003c5,
+	0x000342, 0x0003c5, 0x000308, 0x000342, 0x001fe0, 0x001fe1,
+	0x001f7a, 0x001f7b, 0x001fe5, 0x001f7c, 0x0003b9, 0x0003c9,
+	0x0003b9, 0x0003ce, 0x0003b9, 0x0003c9, 0x000342, 0x0003c9,
+	0x000342, 0x0003b9, 0x001f78, 0x001f79, 0x001f7c, 0x001f7d,
+	0x0003c9, 0x0003b9, 0x0003c9, 0x00006b, 0x0000e5, 0x00214e,
+	0x002170, 0x002171, 0x002172, 0x002173, 0x002174, 0x002175,
+	0x002176, 0x002177, 0x002178, 0x002179, 0x00217a, 0x00217b,
+	0x00217c, 0x00217d, 0x00217e, 0x00217f, 0x002184, 0x0024d0,
+	0x0024d1, 0x0024d2, 0x0024d3, 0x0024d4, 0x0024d5, 0x0024d6,
+	0x0024d7, 0x0024d8, 0x0024d9, 0x0024da, 0x0024db, 0x0024dc,
+	0x0024dd, 0x0024de, 0x0024df, 0x0024e0, 0x0024e1, 0x0024e2,
+	0x0024e3, 0x0024e4, 0x0024e5, 0x0024e6, 0x0024e7, 0x0024e8,
+	0x0024e9, 0x002c30, 0x002c31, 0x002c32, 0x002c33, 0x002c34,
+	0x002c35, 0x002c36, 0x002c37, 0x002c38, 0x002c39, 0x002c3a,
+	0x002c3b, 0x002c3c, 0x002c3d, 0x002c3e, 0x002c3f, 0x002c40,
+	0x002c41, 0x002c42, 0x002c43, 0x002c44, 0x002c45, 0x002c46,
+	0x002c47, 0x002c48, 0x002c49, 0x002c4a, 0x002c4b, 0x002c4c,
+	0x002c4d, 0x002c4e, 0x002c4f, 0x002c50, 0x002c51, 0x002c52,
+	0x002c53, 0x002c54, 0x002c55, 0x002c56, 0x002c57, 0x002c58,
+	0x002c59, 0x002c5a, 0x002c5b, 0x002c5c, 0x002c5d, 0x002c5e,
+	0x002c61, 0x00026b, 0x001d7d, 0x00027d, 0x002c68, 0x002c6a,
+	0x002c6c, 0x000251, 0x000271, 0x000250, 0x000252, 0x002c73,
+	0x002c76, 0x00023f, 0x000240, 0x002c81, 0x002c83, 0x002c85,
+	0x002c87, 0x002c89, 0x002c8b, 0x002c8d, 0x002c8f, 0x002c91,
+	0x002c93, 0x002c95, 0x002c97, 0x002c99, 0x002c9b, 0x002c9d,
+	0x002c9f, 0x002ca1, 0x002ca3, 0x002ca5, 0x002ca7, 0x002ca9,
+	0x002cab, 0x002cad, 0x002caf, 0x002cb1, 0x002cb3, 0x002cb5,
+	0x002cb7, 0x002cb9, 0x002cbb, 0x002cbd, 0x002cbf, 0x002cc1,
+	0x002cc3, 0x002cc5, 0x002cc7, 0x002cc9, 0x002ccb, 0x002ccd,
+	0x002ccf, 0x002cd1, 0x002cd3, 0x002cd5, 0x002cd7, 0x002cd9,
+	0x002cdb, 0x002cdd, 0x002cdf, 0x002ce1, 0x002ce3, 0x002cec,
+	0x002cee, 0x002cf3, 0x00a641, 0x00a643, 0x00a645, 0x00a647,
+	0x00a649, 0x00a64b, 0x00a64d, 0x00a64f, 0x00a651, 0x00a653,
+	0x00a655, 0x00a657, 0x00a659, 0x00a65b, 0x00a65d, 0x00a65f,
+	0x00a661, 0x00a663, 0x00a665, 0x00a667, 0x00a669, 0x00a66b,
+	0x00a66d, 0x00a681, 0x00a683, 0x00a685, 0x00a687, 0x00a689,
+	0x00a68b, 0x00a68d, 0x00a68f, 0x00a691, 0x00a693, 0x00a695,
+	0x00a697, 0x00a699, 0x00a69b, 0x00a723, 0x00a725, 0x00a727,
+	0x00a729, 0x00a72b, 0x00a72d, 0x00a72f, 0x00a733, 0x00a735,
+	0x00a737, 0x00a739, 0x00a73b, 0x00a73d, 0x00a73f, 0x00a741,
+	0x00a743, 0x00a745, 0x00a747, 0x00a749, 0x00a74b, 0x00a74d,
+	0x00a74f, 0x00a751, 0x00a753, 0x00a755, 0x00a757, 0x00a759,
+	0x00a75b, 0x00a75d, 0x00a75f, 0x00a761, 0x00a763, 0x00a765,
+	0x00a767, 0x00a769, 0x00a76b, 0x00a76d, 0x00a76f, 0x00a77a,
+	0x00a77c, 0x001d79, 0x00a77f, 0x00a781, 0x00a783, 0x00a785,
+	0x00a787, 0x00a78c, 0x000265, 0x00a791, 0x00a793, 0x00a797,
+	0x00a799, 0x00a79b, 0x00a79d, 0x00a79f, 0x00a7a1, 0x00a7a3,
+	0x00a7a5, 0x00a7a7, 0x00a7a9, 0x000266, 0x00025c, 0x000261,
+	0x00026c, 0x00026a, 0x00029e, 0x000287, 0x00029d, 0x00ab53,
+	0x00a7b5, 0x00a7b7, 0x0013a0, 0x0013a1, 0x0013a2, 0x0013a3,
+	0x0013a4, 0x0013a5, 0x0013a6, 0x0013a7, 0x0013a8, 0x0013a9,
+	0x0013aa, 0x0013ab, 0x0013ac, 0x0013ad, 0x0013ae, 0x0013af,
+	0x0013b0, 0x0013b1, 0x0013b2, 0x0013b3, 0x0013b4, 0x0013b5,
+	0x0013b6, 0x0013b7, 0x0013b8, 0x0013b9, 0x0013ba, 0x0013bb,
+	0x0013bc, 0x0013bd, 0x0013be, 0x0013bf, 0x0013c0, 0x0013c1,
+	0x0013c2, 0x0013c3, 0x0013c4, 0x0013c5, 0x0013c6, 0x0013c7,
+	0x0013c8, 0x0013c9, 0x0013ca, 0x0013cb, 0x0013cc, 0x0013cd,
+	0x0013ce, 0x0013cf, 0x0013d0, 0x0013d1, 0x0013d2, 0x0013d3,
+	0x0013d4, 0x0013d5, 0x0013d6, 0x0013d7, 0x0013d8, 0x0013d9,
+	0x0013da, 0x0013db, 0x0013dc, 0x0013dd, 0x0013de, 0x0013df,
+	0x0013e0, 0x0013e1, 0x0013e2, 0x0013e3, 0x0013e4, 0x0013e5,
+	0x0013e6, 0x0013e7, 0x0013e8, 0x0013e9, 0x0013ea, 0x0013eb,
+	0x0013ec, 0x0013ed, 0x0013ee, 0x0013ef, 0x000066, 0x000066,
+	0x000066, 0x000069, 0x000066, 0x00006c, 0x000066, 0x000066,
+	0x000069, 0x000066, 0x000066, 0x00006c, 0x000073, 0x000074,
+	0x000073, 0x000074, 0x000574, 0x000576, 0x000574, 0x000565,
+	0x000574, 0x00056b, 0x00057e, 0x000576, 0x000574, 0x00056d,
+	0x00ff41, 0x00ff42, 0x00ff43, 0x00ff44, 0x00ff45, 0x00ff46,
+	0x00ff47, 0x00ff48, 0x00ff49, 0x00ff4a, 0x00ff4b, 0x00ff4c,
+	0x00ff4d, 0x00ff4e, 0x00ff4f, 0x00ff50, 0x00ff51, 0x00ff52,
+	0x00ff53, 0x00ff54, 0x00ff55, 0x00ff56, 0x00ff57, 0x00ff58,
+	0x00ff59, 0x00ff5a, 0x010428, 0x010429, 0x01042a, 0x01042b,
+	0x01042c, 0x01042d, 0x01042e, 0x01042f, 0x010430, 0x010431,
+	0x010432, 0x010433, 0x010434, 0x010435, 0x010436, 0x010437,
+	0x010438, 0x010439, 0x01043a, 0x01043b, 0x01043c, 0x01043d,
+	0x01043e, 0x01043f, 0x010440, 0x010441, 0x010442, 0x010443,
+	0x010444, 0x010445, 0x010446, 0x010447, 0x010448, 0x010449,
+	0x01044a, 0x01044b, 0x01044c, 0x01044d, 0x01044e, 0x01044f,
+	0x0104d8, 0x0104d9, 0x0104da, 0x0104db, 0x0104dc, 0x0104dd,
+	0x0104de, 0x0104df, 0x0104e0, 0x0104e1, 0x0104e2, 0x0104e3,
+	0x0104e4, 0x0104e5, 0x0104e6, 0x0104e7, 0x0104e8, 0x0104e9,
+	0x0104ea, 0x0104eb, 0x0104ec, 0x0104ed, 0x0104ee, 0x0104ef,
+	0x0104f0, 0x0104f1, 0x0104f2, 0x0104f3, 0x0104f4, 0x0104f5,
+	0x0104f6, 0x0104f7, 0x0104f8, 0x0104f9, 0x0104fa, 0x0104fb,
+	0x010cc0, 0x010cc1, 0x010cc2, 0x010cc3, 0x010cc4, 0x010cc5,
+	0x010cc6, 0x010cc7, 0x010cc8, 0x010cc9, 0x010cca, 0x010ccb,
+	0x010ccc, 0x010ccd, 0x010cce, 0x010ccf, 0x010cd0, 0x010cd1,
+	0x010cd2, 0x010cd3, 0x010cd4, 0x010cd5, 0x010cd6, 0x010cd7,
+	0x010cd8, 0x010cd9, 0x010cda, 0x010cdb, 0x010cdc, 0x010cdd,
+	0x010cde, 0x010cdf, 0x010ce0, 0x010ce1, 0x010ce2, 0x010ce3,
+	0x010ce4, 0x010ce5, 0x010ce6, 0x010ce7, 0x010ce8, 0x010ce9,
+	0x010cea, 0x010ceb, 0x010cec, 0x010ced, 0x010cee, 0x010cef,
+	0x010cf0, 0x010cf1, 0x010cf2, 0x0118c0, 0x0118c1, 0x0118c2,
+	0x0118c3, 0x0118c4, 0x0118c5, 0x0118c6, 0x0118c7, 0x0118c8,
+	0x0118c9, 0x0118ca, 0x0118cb, 0x0118cc, 0x0118cd, 0x0118ce,
+	0x0118cf, 0x0118d0, 0x0118d1, 0x0118d2, 0x0118d3, 0x0118d4,
+	0x0118d5, 0x0118d6, 0x0118d7, 0x0118d8, 0x0118d9, 0x0118da,
+	0x0118db, 0x0118dc, 0x0118dd, 0x0118de, 0x0118df, 0x01e922,
+	0x01e923, 0x01e924, 0x01e925, 0x01e926, 0x01e927, 0x01e928,
+	0x01e929, 0x01e92a, 0x01e92b, 0x01e92c, 0x01e92d, 0x01e92e,
+	0x01e92f, 0x01e930, 0x01e931, 0x01e932, 0x01e933, 0x01e934,
+	0x01e935, 0x01e936, 0x01e937, 0x01e938, 0x01e939, 0x01e93a,
+	0x01e93b, 0x01e93c, 0x01e93d, 0x01e93e, 0x01e93f, 0x01e940,
+	0x01e941, 0x01e942, 0x01e943,
+};
+
+static u8 apfs_ccc_trie[] = {
+	/* Node for range 0x_____ */
+	0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0____ */
+	0x03, 0x04, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
+	/* Node for range 0x1____ */
+	0x09, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00,
+	0x00, 0x00, 0x00, 0x0c, 0x00, 0x0d, 0x0e, 0x00,
+	/* Node for range 0x00___ */
+	0x00, 0x00, 0x00, 0x0f, 0x10, 0x11, 0x12, 0x13,
+	0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+	/* Node for range 0x01___ */
+	0x1c, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x1e,
+	0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x00, 0x00,
+	/* Node for range 0x02___ */
+	0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x26, 0x27, 0x00, 0x00,
+	/* Node for range 0x03___ */
+	0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0a___ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x00,
+	0x2a, 0x2b, 0x2c, 0x2d, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0f___ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x2f, 0x00,
+	/* Node for range 0x10___ */
+	0x00, 0x30, 0x31, 0x32, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x11___ */
+	0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
+	0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
+	/* Node for range 0x16___ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x3d, 0x3e, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x1b___ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
+	/* Node for range 0x1d___ */
+	0x00, 0x40, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x1e___ */
+	0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x43, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x003__ */
+	0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x004__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x005__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x4d, 0x4e, 0x4f, 0x50, 0x00, 0x00, 0x00,
+	/* Node for range 0x006__ */
+	0x00, 0x51, 0x00, 0x00, 0x52, 0x53, 0x00, 0x54,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x56, 0x00,
+	/* Node for range 0x007__ */
+	0x00, 0x57, 0x00, 0x58, 0x59, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x5b,
+	/* Node for range 0x008__ */
+	0x00, 0x5c, 0x5d, 0x00, 0x00, 0x5e, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x60, 0x61,
+	/* Node for range 0x009__ */
+	0x00, 0x00, 0x00, 0x62, 0x63, 0x64, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x65, 0x66, 0x00, 0x00, 0x00,
+	/* Node for range 0x00a__ */
+	0x00, 0x00, 0x00, 0x67, 0x68, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x69, 0x6a, 0x00, 0x00, 0x00,
+	/* Node for range 0x00b__ */
+	0x00, 0x00, 0x00, 0x6b, 0x6c, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00,
+	/* Node for range 0x00c__ */
+	0x00, 0x00, 0x00, 0x00, 0x6e, 0x6f, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x70, 0x71, 0x00, 0x00, 0x00,
+	/* Node for range 0x00d__ */
+	0x00, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00,
+	/* Node for range 0x00e__ */
+	0x00, 0x00, 0x00, 0x74, 0x75, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x76, 0x77, 0x00, 0x00, 0x00,
+	/* Node for range 0x00f__ */
+	0x00, 0x78, 0x00, 0x79, 0x00, 0x00, 0x00, 0x7a,
+	0x7b, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,
+	/* Node for range 0x010__ */
+	0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x00,
+	0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x013__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x017__ */
+	0x00, 0x80, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00,
+	/* Node for range 0x018__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x019__ */
+	0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01a__ */
+	0x00, 0x85, 0x00, 0x00, 0x00, 0x00, 0x86, 0x87,
+	0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01b__ */
+	0x00, 0x00, 0x00, 0x89, 0x8a, 0x00, 0x8b, 0x8c,
+	0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x8e, 0x8f,
+	/* Node for range 0x01c__ */
+	0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0x92, 0x93,
+	/* Node for range 0x01d__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x94, 0x95, 0x96, 0x97,
+	/* Node for range 0x020__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x99, 0x9a,
+	/* Node for range 0x02c__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9b, 0x9c,
+	/* Node for range 0x02d__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9d,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9e, 0x9f,
+	/* Node for range 0x030__ */
+	0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0a6__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa2, 0xa3,
+	0x00, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5,
+	/* Node for range 0x0a8__ */
+	0xa6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0xa7, 0x00, 0xa8, 0xa9,
+	/* Node for range 0x0a9__ */
+	0x00, 0x00, 0xaa, 0x00, 0x00, 0xab, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0xac, 0xad, 0x00, 0x00, 0x00,
+	/* Node for range 0x0aa__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0xae, 0xaf, 0x00, 0x00, 0xb0,
+	/* Node for range 0x0ab__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb1, 0x00,
+	/* Node for range 0x0fb__ */
+	0x00, 0xb2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0fe__ */
+	0x00, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x101__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4,
+	/* Node for range 0x102__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0x00,
+	/* Node for range 0x103__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb6,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x10a__ */
+	0xb7, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb9, 0x00,
+	/* Node for range 0x110__ */
+	0x00, 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0xbb,
+	0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x111__ */
+	0xbd, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbf,
+	0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00,
+	/* Node for range 0x112__ */
+	0x00, 0x00, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc2, 0x00,
+	/* Node for range 0x113__ */
+	0x00, 0x00, 0x00, 0xc3, 0xc4, 0x00, 0xc5, 0xc6,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x114__ */
+	0x00, 0x00, 0x00, 0x00, 0xc7, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00,
+	/* Node for range 0x115__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0xc9, 0xca, 0x00, 0x00, 0x00,
+	/* Node for range 0x116__ */
+	0x00, 0x00, 0x00, 0xcb, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x117__ */
+	0x00, 0x00, 0xcd, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x11c__ */
+	0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x16a__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcf,
+	/* Node for range 0x16b__ */
+	0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x1bc__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0xd1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x1d1__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd2, 0xd3,
+	0xd4, 0x00, 0xd5, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x1d2__ */
+	0x00, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x1e0__ */
+	0xd7, 0xd8, 0xd9, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x1e8__ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00,
+	/* Node for range 0x1e9__ */
+	0x00, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0030_ */
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x0031_ */
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe8, 0xdc, 0xdc,
+	0xdc, 0xdc, 0xe8, 0xd8, 0xdc, 0xdc, 0xdc, 0xdc,
+	/* Node for range 0x0032_ */
+	0xdc, 0xca, 0xca, 0xdc, 0xdc, 0xdc, 0xdc, 0xca,
+	0xca, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+	/* Node for range 0x0033_ */
+	0xdc, 0xdc, 0xdc, 0xdc, 0x01, 0x01, 0x01, 0x01,
+	0x01, 0xdc, 0xdc, 0xdc, 0xdc, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x0034_ */
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xf0, 0xe6, 0xdc,
+	0xdc, 0xdc, 0xe6, 0xe6, 0xe6, 0xdc, 0xdc, 0x00,
+	/* Node for range 0x0035_ */
+	0xe6, 0xe6, 0xe6, 0xdc, 0xdc, 0xdc, 0xdc, 0xe6,
+	0xe8, 0xdc, 0xdc, 0xe6, 0xe9, 0xea, 0xea, 0xe9,
+	/* Node for range 0x0036_ */
+	0xea, 0xea, 0xe9, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x0048_ */
+	0x00, 0x00, 0x00, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0059_ */
+	0x00, 0xdc, 0xe6, 0xe6, 0xe6, 0xe6, 0xdc, 0xe6,
+	0xe6, 0xe6, 0xde, 0xdc, 0xe6, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x005a_ */
+	0xe6, 0xe6, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc, 0xdc,
+	0xe6, 0xe6, 0xdc, 0xe6, 0xe6, 0xde, 0xe4, 0xe6,
+	/* Node for range 0x005b_ */
+	0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
+	0x12, 0x13, 0x13, 0x14, 0x15, 0x16, 0x00, 0x17,
+	/* Node for range 0x005c_ */
+	0x00, 0x18, 0x19, 0x00, 0xe6, 0xdc, 0x00, 0x12,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0061_ */
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	0x1e, 0x1f, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0064_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+	/* Node for range 0x0065_ */
+	0x20, 0x21, 0x22, 0xe6, 0xe6, 0xdc, 0xdc, 0xe6,
+	0xe6, 0xe6, 0xe6, 0xe6, 0xdc, 0xe6, 0xe6, 0xdc,
+	/* Node for range 0x0067_ */
+	0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x006d_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0xe6,
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0x00, 0x00, 0xe6,
+	/* Node for range 0x006e_ */
+	0xe6, 0xe6, 0xe6, 0xdc, 0xe6, 0x00, 0x00, 0xe6,
+	0xe6, 0x00, 0xdc, 0xe6, 0xe6, 0xdc, 0x00, 0x00,
+	/* Node for range 0x0071_ */
+	0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0073_ */
+	0xe6, 0xdc, 0xe6, 0xe6, 0xdc, 0xe6, 0xe6, 0xdc,
+	0xdc, 0xdc, 0xe6, 0xdc, 0xdc, 0xe6, 0xdc, 0xe6,
+	/* Node for range 0x0074_ */
+	0xe6, 0xe6, 0xdc, 0xe6, 0xdc, 0xe6, 0xdc, 0xe6,
+	0xdc, 0xe6, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x007e_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x007f_ */
+	0xe6, 0xe6, 0xdc, 0xe6, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0081_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0xe6,
+	0xe6, 0xe6, 0x00, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x0082_ */
+	0xe6, 0xe6, 0xe6, 0xe6, 0x00, 0xe6, 0xe6, 0xe6,
+	0x00, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0x00, 0x00,
+	/* Node for range 0x0085_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0xdc, 0xdc, 0xdc, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x008d_ */
+	0x00, 0x00, 0x00, 0x00, 0xe6, 0xe6, 0xe6, 0xe6,
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x008e_ */
+	0xe6, 0xe6, 0x00, 0xdc, 0xe6, 0xe6, 0xdc, 0xe6,
+	0xe6, 0xdc, 0xe6, 0xe6, 0xe6, 0xdc, 0xdc, 0xdc,
+	/* Node for range 0x008f_ */
+	0x1b, 0x1c, 0x1d, 0xe6, 0xe6, 0xe6, 0xdc, 0xe6,
+	0xe6, 0xdc, 0xdc, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x0093_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+	/* Node for range 0x0094_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
+	/* Node for range 0x0095_ */
+	0x00, 0xe6, 0xdc, 0xe6, 0xe6, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x009b_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+	/* Node for range 0x009c_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
+	/* Node for range 0x00a3_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+	/* Node for range 0x00a4_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
+	/* Node for range 0x00ab_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+	/* Node for range 0x00ac_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
+	/* Node for range 0x00b3_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+	/* Node for range 0x00b4_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
+	/* Node for range 0x00bc_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
+	/* Node for range 0x00c4_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
+	/* Node for range 0x00c5_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x5b, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x00cb_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+	/* Node for range 0x00cc_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
+	/* Node for range 0x00d4_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
+	/* Node for range 0x00dc_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x00e3_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x67, 0x67, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x00e4_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x6b, 0x6b, 0x6b, 0x6b, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x00eb_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x76, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x00ec_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x7a, 0x7a, 0x7a, 0x7a, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x00f1_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0xdc, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x00f3_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00, 0xdc,
+	0x00, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x00f7_ */
+	0x00, 0x81, 0x82, 0x00, 0x84, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00,
+	/* Node for range 0x00f8_ */
+	0x82, 0x00, 0xe6, 0xe6, 0x09, 0x00, 0xe6, 0xe6,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x00fc_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0103_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
+	0x00, 0x09, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0108_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00,
+	/* Node for range 0x0135_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x0171_ */
+	0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0173_ */
+	0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x017d_ */
+	0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x00, 0x00,
+	/* Node for range 0x018a_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0xe4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0193_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0xde, 0xe6, 0xdc, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01a1_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6,
+	0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01a6_ */
+	0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01a7_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0xe6, 0xe6,
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0x00, 0x00, 0xdc,
+	/* Node for range 0x01ab_ */
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xdc, 0xdc, 0xdc,
+	0xdc, 0xdc, 0xdc, 0xe6, 0xe6, 0xdc, 0x00, 0x00,
+	/* Node for range 0x01b3_ */
+	0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01b4_ */
+	0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01b6_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0xe6, 0xdc, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x01b7_ */
+	0xe6, 0xe6, 0xe6, 0xe6, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01ba_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x09, 0x09, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01be_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01bf_ */
+	0x00, 0x00, 0x09, 0x09, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01c3_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01cd_ */
+	0xe6, 0xe6, 0xe6, 0x00, 0x01, 0xdc, 0xdc, 0xdc,
+	0xdc, 0xdc, 0xe6, 0xe6, 0xdc, 0xdc, 0xdc, 0xdc,
+	/* Node for range 0x01ce_ */
+	0xe6, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+	0x01, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00,
+	/* Node for range 0x01cf_ */
+	0x00, 0x00, 0x00, 0x00, 0xe6, 0x00, 0x00, 0x00,
+	0xe6, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x01dc_ */
+	0xe6, 0xe6, 0xdc, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	0xe6, 0xe6, 0xdc, 0xe6, 0xe6, 0xea, 0xd6, 0xdc,
+	/* Node for range 0x01dd_ */
+	0xca, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x01de_ */
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x01df_ */
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0xe6, 0xe9, 0xdc, 0xe6, 0xdc,
+	/* Node for range 0x020d_ */
+	0xe6, 0xe6, 0x01, 0x01, 0xe6, 0xe6, 0xe6, 0xe6,
+	0x01, 0x01, 0x01, 0xe6, 0xe6, 0x00, 0x00, 0x00,
+	/* Node for range 0x020e_ */
+	0x00, 0xe6, 0x00, 0x00, 0x00, 0x01, 0x01, 0xe6,
+	0xdc, 0xe6, 0x01, 0x01, 0xdc, 0xdc, 0xdc, 0xdc,
+	/* Node for range 0x020f_ */
+	0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x02ce_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6,
+	/* Node for range 0x02cf_ */
+	0xe6, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x02d7_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
+	/* Node for range 0x02de_ */
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x02df_ */
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6,
+	/* Node for range 0x0302_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0xda, 0xe4, 0xe8, 0xde, 0xe0, 0xe0,
+	/* Node for range 0x0309_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0a66_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6,
+	/* Node for range 0x0a67_ */
+	0x00, 0x00, 0x00, 0x00, 0xe6, 0xe6, 0xe6, 0xe6,
+	0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0x00, 0x00,
+	/* Node for range 0x0a69_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0xe6,
+	/* Node for range 0x0a6f_ */
+	0xe6, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0a80_ */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0a8c_ */
+	0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* Node for range 0x0a8e_ */
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

drivers/staging/apfs/unicode.h new file +27 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e3b7edc51cf5759bcd0de49a59613355f29de5d4

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.48.1

Part of the diff is not shown here. View the raw message.

#4 lore raw

RFC PATCH v2 3/8 staging: apfs: init apfs_raw.h to handle on-disk structures

In reply to Ethan Carter Edwards

This file handles and stores information regarding on disk structures. It includes some magic numbers and bits of information.

---
 drivers/staging/apfs/apfs_raw.h | 1566 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 1566 insertions(+)
drivers/staging/apfs/apfs_raw.h new file +1566 -0
new file mode 100644
index 0000000000000000000000000000000000000000..af31258c5f3b1e6e73986d59b545fe4e2fa52fa6
@@ -0,0 +1,1566 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2019 Ernesto A. Fernández <[email protected]>
+ *
+ * Definitions for all on-disk data structures.
+ */
+
+#ifndef _APFS_RAW_H
+#define _APFS_RAW_H
+
+#include <linux/types.h>
+#include <linux/uuid.h>
+
+/* Object identifiers constants */
+#define APFS_OID_NX_SUPERBLOCK			1
+#define APFS_OID_INVALID			0ULL
+#define APFS_OID_RESERVED_COUNT			1024
+
+/* Object type masks */
+#define APFS_OBJECT_TYPE_MASK			0x0000ffff
+#define APFS_OBJECT_TYPE_FLAGS_MASK		0xffff0000
+#define APFS_OBJ_STORAGETYPE_MASK		0xc0000000
+#define APFS_OBJECT_TYPE_FLAGS_DEFINED_MASK	0xf8000000
+
+/* Object types */
+#define APFS_OBJECT_TYPE_NX_SUPERBLOCK		0x00000001
+#define APFS_OBJECT_TYPE_BTREE			0x00000002
+#define APFS_OBJECT_TYPE_BTREE_NODE		0x00000003
+#define APFS_OBJECT_TYPE_SPACEMAN		0x00000005
+#define APFS_OBJECT_TYPE_SPACEMAN_CAB		0x00000006
+#define APFS_OBJECT_TYPE_SPACEMAN_CIB		0x00000007
+#define APFS_OBJECT_TYPE_SPACEMAN_BITMAP	0x00000008
+#define APFS_OBJECT_TYPE_SPACEMAN_FREE_QUEUE	0x00000009
+#define APFS_OBJECT_TYPE_EXTENT_LIST_TREE	0x0000000a
+#define APFS_OBJECT_TYPE_OMAP			0x0000000b
+#define APFS_OBJECT_TYPE_CHECKPOINT_MAP		0x0000000c
+#define APFS_OBJECT_TYPE_FS			0x0000000d
+#define APFS_OBJECT_TYPE_FSTREE			0x0000000e
+#define APFS_OBJECT_TYPE_BLOCKREFTREE		0x0000000f
+#define APFS_OBJECT_TYPE_SNAPMETATREE		0x00000010
+#define APFS_OBJECT_TYPE_NX_REAPER		0x00000011
+#define APFS_OBJECT_TYPE_NX_REAP_LIST		0x00000012
+#define APFS_OBJECT_TYPE_OMAP_SNAPSHOT		0x00000013
+#define APFS_OBJECT_TYPE_EFI_JUMPSTART		0x00000014
+#define APFS_OBJECT_TYPE_FUSION_MIDDLE_TREE	0x00000015
+#define APFS_OBJECT_TYPE_NX_FUSION_WBC		0x00000016
+#define APFS_OBJECT_TYPE_NX_FUSION_WBC_LIST	0x00000017
+#define APFS_OBJECT_TYPE_ER_STATE		0x00000018
+#define APFS_OBJECT_TYPE_GBITMAP		0x00000019
+#define APFS_OBJECT_TYPE_GBITMAP_TREE		0x0000001a
+#define APFS_OBJECT_TYPE_GBITMAP_BLOCK		0x0000001b
+#define APFS_OBJECT_TYPE_ER_RECOVERY_BLOCK	0x0000001c
+#define APFS_OBJECT_TYPE_SNAP_META_EXT		0x0000001d
+#define APFS_OBJECT_TYPE_INTEGRITY_META		0x0000001e
+#define APFS_OBJECT_TYPE_FEXT_TREE		0x0000001f
+#define APFS_OBJECT_TYPE_RESERVED_20		0x00000020
+#define APFS_OBJECT_TYPE_INVALID		0x00000000
+#define APFS_OBJECT_TYPE_TEST			0x000000ff
+
+/* Object type flags */
+#define APFS_OBJ_VIRTUAL			0x00000000
+#define APFS_OBJ_EPHEMERAL			0x80000000
+#define APFS_OBJ_PHYSICAL			0x40000000
+#define APFS_OBJ_NOHEADER			0x20000000
+#define APFS_OBJ_ENCRYPTED			0x10000000
+#define APFS_OBJ_NONPERSISTENT			0x08000000
+
+#define APFS_MAX_CKSUM_SIZE 8
+
+/*
+ * On-disk representation of an APFS object
+ */
+struct apfs_obj_phys {
+/*00*/	__le64 o_cksum;		/* Fletcher checksum */
+	__le64 o_oid;		/* Object-id */
+/*10*/	__le64 o_xid;		/* Transaction ID */
+	__le32 o_type;		/* Object type */
+	__le32 o_subtype;	/* Object subtype */
+} __packed;
+
+/* Flags for the object map structure */
+#define APFS_OMAP_MANUALLY_MANAGED	0x00000001
+#define APFS_OMAP_ENCRYPTING		0x00000002
+#define APFS_OMAP_DECRYPTING		0x00000004
+#define APFS_OMAP_KEYROLLING		0x00000008
+#define APFS_OMAP_CRYPTO_GENERATION	0x00000010
+#define APFS_OMAP_FLAGS_VALID_MASK	(APFS_OMAP_MANUALLY_MANAGED \
+					| APFS_OMAP_ENCRYPTING \
+					| APFS_OMAP_DECRYPTING \
+					| APFS_OMAP_KEYROLLING \
+					| APFS_OMAP_CRYPTO_GENERATION)
+
+/*
+ * On-disk representation of an object map
+ */
+struct apfs_omap_phys {
+/*00*/	struct apfs_obj_phys om_o;
+/*20*/	__le32 om_flags;
+	__le32 om_snap_count;
+	__le32 om_tree_type;
+	__le32 om_snapshot_tree_type;
+/*30*/	__le64 om_tree_oid;
+	__le64 om_snapshot_tree_oid;
+/*40*/	__le64 om_most_recent_snap;
+	__le64 om_pending_revert_min;
+	__le64 om_pending_revert_max;
+} __packed;
+
+/* Object map value flags */
+#define APFS_OMAP_VAL_DELETED		0x00000001
+#define APFS_OMAP_VAL_SAVED		0x00000002
+#define APFS_OMAP_VAL_ENCRYPTED		0x00000004
+#define APFS_OMAP_VAL_NOHEADER		0x00000008
+#define APFS_OMAP_VAL_CRYPTO_GENERATION	0x00000010
+#define APFS_OMAP_VAL_FLAGS_VALID_MASK	(APFS_OMAP_VAL_DELETED \
+					| APFS_OMAP_VAL_SAVED \
+					| APFS_OMAP_VAL_ENCRYPTED \
+					| APFS_OMAP_VAL_NOHEADER \
+					| APFS_OMAP_VAL_CRYPTO_GENERATION)
+
+/*
+ * Structure of a value in an object map B-tree
+ */
+struct apfs_omap_val {
+	__le32 ov_flags;
+	__le32 ov_size;
+	__le64 ov_paddr;
+} __packed;
+
+/*
+ * Structure of a value in an omap's snapshot tree
+ */
+struct apfs_omap_snapshot {
+	__le32 oms_flags;
+	__le32 oms_pad;
+	__le64 oms_oid;
+} __packed;
+
+/* B-tree node flags */
+#define APFS_BTNODE_ROOT		0x0001
+#define APFS_BTNODE_LEAF		0x0002
+#define APFS_BTNODE_FIXED_KV_SIZE	0x0004
+#define APFS_BTNODE_CHECK_KOFF_INVAL	0x8000
+#define APFS_BTNODE_MASK		0x0007	/* Valid on-disk flags */
+
+/* B-tree location constants */
+#define APFS_BTOFF_INVALID		0xffff
+
+/*
+ * Structure storing a location inside a B-tree node
+ */
+struct apfs_nloc {
+	__le16 off;
+	__le16 len;
+} __packed;
+
+/*
+ * Structure storing the location of a key/value pair within a B-tree node
+ */
+struct apfs_kvloc {
+	struct apfs_nloc k;
+	struct apfs_nloc v;
+} __packed;
+
+/*
+ * Structure storing the location of a key/value pair within a B-tree node
+ * having fixed-size key and value (flag APFS_BTNODE_FIXED_KV_SIZE is present)
+ */
+struct apfs_kvoff {
+	__le16 k;
+	__le16 v;
+} __packed;
+
+/*
+ * On-disk representation of a B-tree node
+ */
+struct apfs_btree_node_phys {
+/*00*/	struct apfs_obj_phys btn_o;
+/*20*/	__le16 btn_flags;
+	__le16 btn_level;
+	__le32 btn_nkeys;
+/*28*/	struct apfs_nloc btn_table_space;
+	struct apfs_nloc btn_free_space;
+	struct apfs_nloc btn_key_free_list;
+	struct apfs_nloc btn_val_free_list;
+/*38*/	__le64 btn_data[];
+} __packed;
+
+/* B-tree info flags */
+#define APFS_BTREE_UINT64_KEYS		0x00000001
+#define APFS_BTREE_SEQUENTIAL_INSERT	0x00000002
+#define APFS_BTREE_ALLOW_GHOSTS		0x00000004
+#define APFS_BTREE_EPHEMERAL		0x00000008
+#define APFS_BTREE_PHYSICAL		0x00000010
+#define APFS_BTREE_NONPERSISTENT	0x00000020
+#define APFS_BTREE_KV_NONALIGNED	0x00000040
+#define APFS_BTREE_FLAGS_VALID_MASK	(APFS_BTREE_UINT64_KEYS \
+					| APFS_BTREE_SEQUENTIAL_INSERT \
+					| APFS_BTREE_ALLOW_GHOSTS \
+					| APFS_BTREE_EPHEMERAL \
+					| APFS_BTREE_PHYSICAL \
+					| APFS_BTREE_NONPERSISTENT \
+					| APFS_BTREE_KV_NONALIGNED)
+
+/*
+ * Structure used to store information about a B-tree that won't change
+ * over time
+ */
+struct apfs_btree_info_fixed {
+	__le32 bt_flags;
+	__le32 bt_node_size;
+	__le32 bt_key_size;
+	__le32 bt_val_size;
+} __packed;
+
+/*
+ * Structure used to store information about a B-tree (located at the end of
+ * a B-tree root node block)
+ */
+struct apfs_btree_info {
+	struct apfs_btree_info_fixed bt_fixed;
+	__le32 bt_longest_key;			/* Longest key ever stored */
+	__le32 bt_longest_val;			/* Longest value ever stored */
+	__le64 bt_key_count;
+	__le64 bt_node_count;
+} __packed;
+
+/*
+ * Structure of the value of a directory entry. This is the data in
+ * the catalog nodes for record type APFS_TYPE_DIR_REC.
+ */
+struct apfs_drec_val {
+	__le64 file_id;
+	__le64 date_added;
+	__le16 flags;
+	u8 xfields[];
+} __packed;
+
+/* Physical extent records */
+#define APFS_PEXT_LEN_MASK	0x0fffffffffffffffULL
+#define APFS_PEXT_KIND_MASK	0xf000000000000000ULL
+#define APFS_PEXT_KIND_SHIFT	60
+
+/* The kind of a physical extent record */
+enum {
+	APFS_KIND_ANY		= 0,
+	APFS_KIND_NEW		= 1,
+	APFS_KIND_UPDATE	= 2,
+	APFS_KIND_DEAD		= 3,
+	APFS_KIND_UPDATE_REFCNT	= 4,
+
+	APFS_KIND_INVALID	= 255 /* This is weird, won't fit in 4 bits */
+};
+
+#define APFS_OWNING_OBJ_ID_INVALID	(~0ULL)
+#define APFS_OWNING_OBJ_ID_UNKNOWN	(~1ULL)
+
+/*
+ * Structure of a physical extent record
+ */
+struct apfs_phys_ext_val {
+	__le64 len_and_kind;
+	__le64 owning_obj_id;
+	__le32 refcnt;
+} __packed;
+
+/* File extent records */
+#define APFS_FILE_EXTENT_LEN_MASK	0x00ffffffffffffffULL
+#define APFS_FILE_EXTENT_FLAG_MASK	0xff00000000000000ULL
+#define APFS_FILE_EXTENT_FLAG_SHIFT	56
+#define APFS_FILE_EXTENT_CRYPTO_FLAG	0x01	/* Made-up name */
+#define APFS_FILE_EXTENT_PREALLOCATED	0x02	/* Made-up name */
+#define APFS_VALID_FILE_EXTENT_FLAGS	(APFS_FILE_EXTENT_CRYPTO_FLAG \
+					| APFS_FILE_EXTENT_PREALLOCATED)
+
+/*
+ * Put a bound on maximum file size so that a growing truncation will always
+ * produce a single hole extent, even if 64k block sizes were in use. Larger
+ * file sizes could be supported with multiple extents of course, but it takes
+ * some work and I don't see the point.
+ */
+#define APFS_MAX_FILE_SIZE		0x00ffffffffff0000ULL
+
+/*
+ * Structure of a file extent record
+ */
+struct apfs_file_extent_val {
+	__le64 len_and_flags;
+	__le64 phys_block_num;
+	__le64 crypto_id;
+} __packed;
+
+/*
+ * Structure of a data stream record
+ */
+struct apfs_dstream_id_val {
+	__le32 refcnt;
+} __packed;
+
+#define APFS_CP_MAX_WRAPPEDKEYSIZE	128
+
+/*
+ * Structure used to store the encryption state for PFKs
+ */
+struct apfs_wrapped_crypto_state {
+	__le16 major_version;
+	__le16 minor_version;
+	__le32 cpflags;
+	__le32 persistent_class;
+	__le32 key_os_version;
+	__le16 key_revision;
+	__le16 key_len;
+	u8 persistent_key[];
+} __packed;
+
+/*
+ * Structure of a crypto state record
+ */
+struct apfs_crypto_state_val {
+	__le32 refcnt;
+	struct apfs_wrapped_crypto_state state;
+} __packed;
+
+/* Inode numbers for special inodes */
+#define APFS_INVALID_INO_NUM		0
+
+#define APFS_ROOT_DIR_PARENT		1	/* Root directory parent */
+#define APFS_ROOT_DIR_INO_NUM		2	/* Root directory */
+#define APFS_PRIV_DIR_INO_NUM		3	/* Private directory */
+#define APFS_SNAP_DIR_INO_NUM		6	/* Snapshots metadata */
+#define APFS_PURGEABLE_DIR_INO_NUM	7	/* Parent of purgeable files */
+
+/* Smallest inode number available for user content */
+#define APFS_MIN_USER_INO_NUM		16
+
+#define APFS_UNIFIED_ID_SPACE_MARK	0x0800000000000000
+
+/* Inode internal flags */
+#define APFS_INODE_IS_APFS_PRIVATE		0x00000001
+#define APFS_INODE_MAINTAIN_DIR_STATS		0x00000002
+#define APFS_INODE_DIR_STATS_ORIGIN		0x00000004
+#define APFS_INODE_PROT_CLASS_EXPLICIT		0x00000008
+#define APFS_INODE_WAS_CLONED			0x00000010
+#define APFS_INODE_FLAG_UNUSED			0x00000020
+#define APFS_INODE_HAS_SECURITY_EA		0x00000040
+#define APFS_INODE_BEING_TRUNCATED		0x00000080
+#define APFS_INODE_HAS_FINDER_INFO		0x00000100
+#define APFS_INODE_IS_SPARSE			0x00000200
+#define APFS_INODE_WAS_EVER_CLONED		0x00000400
+#define APFS_INODE_ACTIVE_FILE_TRIMMED		0x00000800
+#define APFS_INODE_PINNED_TO_MAIN		0x00001000
+#define APFS_INODE_PINNED_TO_TIER2		0x00002000
+#define APFS_INODE_HAS_RSRC_FORK		0x00004000
+#define APFS_INODE_NO_RSRC_FORK			0x00008000
+#define APFS_INODE_ALLOCATION_SPILLEDOVER	0x00010000
+#define APFS_INODE_FAST_PROMOTE			0x00020000
+#define APFS_INODE_HAS_UNCOMPRESSED_SIZE	0x00040000
+#define APFS_INODE_IS_PURGEABLE			0x00080000
+#define APFS_INODE_WANTS_TO_BE_PURGEABLE	0x00100000
+#define APFS_INODE_IS_SYNC_ROOT			0x00200000
+#define APFS_INODE_SNAPSHOT_COW_EXEMPTION	0x00400000
+/* This flag is not documented */
+#define APFS_INODE_HAS_PURGEABLE_FLAGS		0x02000000
+
+/* Masks for internal flags */
+#define APFS_VALID_INTERNAL_INODE_FLAGS	(APFS_INODE_IS_APFS_PRIVATE \
+					| APFS_INODE_MAINTAIN_DIR_STATS \
+					| APFS_INODE_DIR_STATS_ORIGIN \
+					| APFS_INODE_PROT_CLASS_EXPLICIT \
+					| APFS_INODE_WAS_CLONED \
+					| APFS_INODE_HAS_SECURITY_EA \
+					| APFS_INODE_BEING_TRUNCATED \
+					| APFS_INODE_HAS_FINDER_INFO \
+					| APFS_INODE_IS_SPARSE \
+					| APFS_INODE_WAS_EVER_CLONED \
+					| APFS_INODE_ACTIVE_FILE_TRIMMED \
+					| APFS_INODE_PINNED_TO_MAIN \
+					| APFS_INODE_PINNED_TO_TIER2 \
+					| APFS_INODE_HAS_RSRC_FORK \
+					| APFS_INODE_NO_RSRC_FORK \
+					| APFS_INODE_ALLOCATION_SPILLEDOVER \
+					| APFS_INODE_FAST_PROMOTE \
+					| APFS_INODE_HAS_UNCOMPRESSED_SIZE \
+					| APFS_INODE_IS_PURGEABLE \
+					| APFS_INODE_WANTS_TO_BE_PURGEABLE \
+					| APFS_INODE_IS_SYNC_ROOT \
+					| APFS_INODE_SNAPSHOT_COW_EXEMPTION \
+					| APFS_INODE_HAS_PURGEABLE_FLAGS)
+#define APFS_INODE_INHERITED_INTERNAL_FLAGS	(APFS_INODE_MAINTAIN_DIR_STATS)
+#define APFS_INDOE_CLONED_INTERNAL_FLAGS	(APFS_INODE_HAS_RSRC_FORK \
+						| APFS_INODE_NO_RSRC_FORK \
+						| APFS_INODE_HAS_FINDER_INFO)
+#define APFS_INODE_PINNED_MASK			(APFS_INODE_PINNED_TO_MAIN \
+						| APFS_INODE_PINNED_TO_TIER2)
+
+/* BSD flags */
+#define APFS_INOBSD_NODUMP			0x00000001
+#define APFS_INOBSD_IMMUTABLE			0x00000002
+#define APFS_INOBSD_APPEND			0x00000004
+#define APFS_INOBSD_COMPRESSED			0x00000020
+
+/*
+ * Structure of an inode as stored as a B-tree value
+ */
+struct apfs_inode_val {
+/*00*/	__le64 parent_id;
+	__le64 private_id;
+/*10*/	__le64 create_time;
+	__le64 mod_time;
+	__le64 change_time;
+	__le64 access_time;
+/*30*/	__le64 internal_flags;
+	union {
+		__le32 nchildren;
+		__le32 nlink;
+	};
+	__le32 default_protection_class;
+/*40*/	__le32 write_generation_counter;
+	__le32 bsd_flags;
+	__le32 owner;
+	__le32 group;
+/*50*/	__le16 mode;
+	__le16 pad1;
+	__le64 uncompressed_size;
+/*5C*/	u8 xfields[];
+} __packed;
+
+/* Extended field types for dentries */
+#define APFS_DREC_EXT_TYPE_SIBLING_ID 1
+
+/* Extended field types for inodes */
+#define APFS_INO_EXT_TYPE_SNAP_XID 1
+#define APFS_INO_EXT_TYPE_DELTA_TREE_OID 2
+#define APFS_INO_EXT_TYPE_DOCUMENT_ID 3
+#define APFS_INO_EXT_TYPE_NAME 4
+#define APFS_INO_EXT_TYPE_PREV_FSIZE 5
+#define APFS_INO_EXT_TYPE_RESERVED_6 6
+#define APFS_INO_EXT_TYPE_FINDER_INFO 7
+#define APFS_INO_EXT_TYPE_DSTREAM 8
+#define APFS_INO_EXT_TYPE_RESERVED_9 9
+#define APFS_INO_EXT_TYPE_DIR_STATS_KEY 10
+#define APFS_INO_EXT_TYPE_FS_UUID 11
+#define APFS_INO_EXT_TYPE_RESERVED_12 12
+#define APFS_INO_EXT_TYPE_SPARSE_BYTES 13
+#define APFS_INO_EXT_TYPE_RDEV 14
+#define APFS_INO_EXT_TYPE_PURGEABLE_FLAGS 15
+#define APFS_INO_EXT_TYPE_ORIG_SYNC_ROOT_ID 16
+
+/* Extended field flags */
+#define APFS_XF_DATA_DEPENDENT		0x01
+#define APFS_XF_DO_NOT_COPY		0x02
+#define APFS_XF_RESERVED_4		0x04
+#define APFS_XF_CHILDREN_INHERIT	0x08
+#define APFS_XF_USER_FIELD		0x10
+#define APFS_XF_SYSTEM_FIELD		0x20
+#define APFS_XF_RESERVED_40		0x40
+#define APFS_XF_RESERVED_80		0x80
+
+/* Constants for extended fields */
+#define APFS_MIN_DOC_ID 3	/* Smallest not reserved document id */
+
+/*
+ * Structure used to store the number and size of an xfield collection.  The
+ * official reference seems to be wrong about @xf_used_data: it's the size of
+ * the xfield values alone, without the metadata.
+ */
+struct apfs_xf_blob {
+	__le16 xf_num_exts;
+	__le16 xf_used_data;
+	u8 xf_data[];
+} __packed;
+
+/*
+ * Structure used to describe an extended field
+ */
+struct apfs_x_field {
+	u8 x_type;
+	u8 x_flags;
+	__le16 x_size;
+} __packed;
+
+/*
+ * Structure used to store information about a data stream
+ */
+struct apfs_dstream {
+	__le64 size;
+	__le64 alloced_size;
+	__le64 default_crypto_id;
+	__le64 total_bytes_written;
+	__le64 total_bytes_read;
+} __packed;
+
+/*
+ * Structure used to store directory information
+ */
+struct apfs_dir_stats_val {
+	__le64 num_children;
+	__le64 total_size;
+	__le64 chained_key;
+	__le64 gen_count;
+} __packed;
+
+/*
+ * Structure of the value for a sibling link record.  These are used to
+ * list the hard links for a given inode.
+ */
+struct apfs_sibling_val {
+	__le64 parent_id;
+	__le16 name_len;
+	u8 name[];
+} __packed;
+
+/*
+ * Structure of the value for a sibling map record.  No idea what these are for.
+ */
+struct apfs_sibling_map_val {
+	__le64 file_id;
+} __packed;
+
+/*
+ * Structure of a key in an object map B-tree
+ */
+struct apfs_omap_key {
+	__le64 ok_oid;
+	__le64 ok_xid;
+} __packed;
+
+/*
+ * Structure of a key in a free-space queue b-tree
+ */
+struct apfs_spaceman_free_queue_key {
+	__le64 sfqk_xid;
+	__le64 sfqk_paddr;
+} __packed;
+
+/* Catalog records types */
+enum {
+	APFS_TYPE_ANY			= 0,
+	APFS_TYPE_SNAP_METADATA		= 1,
+	APFS_TYPE_EXTENT		= 2,
+	APFS_TYPE_INODE			= 3,
+	APFS_TYPE_XATTR			= 4,
+	APFS_TYPE_SIBLING_LINK		= 5,
+	APFS_TYPE_DSTREAM_ID		= 6,
+	APFS_TYPE_CRYPTO_STATE		= 7,
+	APFS_TYPE_FILE_EXTENT		= 8,
+	APFS_TYPE_DIR_REC		= 9,
+	APFS_TYPE_DIR_STATS		= 10,
+	APFS_TYPE_SNAP_NAME		= 11,
+	APFS_TYPE_SIBLING_MAP		= 12,
+	APFS_TYPE_MAX_VALID		= 12,
+	APFS_TYPE_MAX			= 15,
+	APFS_TYPE_INVALID		= 15,
+};
+
+/* Bit masks for the 'obj_id_and_type' field of a key header */
+#define APFS_OBJ_ID_MASK		0x0fffffffffffffffULL
+#define APFS_OBJ_TYPE_MASK		0xf000000000000000ULL
+#define APFS_OBJ_TYPE_SHIFT		60
+
+/* Key header for filesystem-object keys */
+struct apfs_key_header {
+	__le64 obj_id_and_type;
+} __packed;
+
+/*
+ * Structure of the key for a physical extent record
+ */
+struct apfs_phys_ext_key {
+	struct apfs_key_header hdr;
+} __packed;
+
+/*
+ * Structure of the key for an inode record
+ */
+struct apfs_inode_key {
+	struct apfs_key_header hdr;
+} __packed;
+
+/*
+ * Structure of the key for a file extent record
+ */
+struct apfs_file_extent_key {
+	struct apfs_key_header hdr;
+	__le64 logical_addr;
+} __packed;
+
+/*
+ * Structure of the key for a data stream record
+ */
+struct apfs_dstream_id_key {
+	struct apfs_key_header hdr;
+} __packed;
+
+/*
+ * Structure of the key for a crypto state record
+ */
+struct apfs_crypto_state_key {
+	struct apfs_key_header hdr;
+} __packed;
+
+/* Bit masks for the 'name_len_and_hash' field of a directory entry */
+#define APFS_DREC_LEN_MASK	0x000003ff
+#define APFS_DREC_HASH_MASK	0xfffffc00
+#define APFS_DREC_HASH_SHIFT	10
+
+/* We could support bigger filenames, but I don't know if Linux allows it */
+#define APFS_NAME_LEN		NAME_MAX
+
+/* Bit masks for the 'type' field of a directory entry */
+enum {
+	APFS_DREC_TYPE_MASK	= 0x000f,
+	APFS_DREC_RESERVED_10	= 0x0010,
+
+	/* These flags are not documented */
+	APFS_DREC_PURGEABLE_2	= 0x0200,
+	APFS_DREC_PURGEABLE_8	= 0x0800,
+};
+
+#define APFS_DREC_PURGEABLE	(APFS_DREC_PURGEABLE_2 | APFS_DREC_PURGEABLE_8)
+
+/*
+ * Structure of the key for a directory entry - no hash, used on normalization
+ * sensitive volumes
+ */
+struct apfs_drec_key {
+	struct apfs_key_header hdr;
+	__le16 name_len;
+	u8 name[];
+} __packed;
+
+/*
+ * Structure of the key for a directory entry, including a precomputed
+ * hash of its name
+ */
+struct apfs_drec_hashed_key {
+	struct apfs_key_header hdr;
+	__le32 name_len_and_hash;
+	u8 name[];
+} __packed;
+
+/*
+ * Structure of the key for an extended attributes record
+ */
+struct apfs_xattr_key {
+	struct apfs_key_header hdr;
+	__le16 name_len;
+	u8 name[];
+} __packed;
+
+/*
+ * Structure of the key for a snapshot metadata record
+ */
+struct apfs_snap_metadata_key {
+	struct apfs_key_header hdr;
+} __packed;
+
+/* The snapshot name headers always have this placeholder object id */
+#define APFS_SNAP_NAME_OBJ_ID	(~0ULL & APFS_OBJ_ID_MASK)
+
+/*
+ * Structure of the key for a snapshot name record
+ */
+struct apfs_snap_name_key {
+	struct apfs_key_header hdr;
+	__le16 name_len;
+	u8 name[];
+} __packed;
+
+/*
+ * Structure of the key for a sibling link record
+ */
+struct apfs_sibling_link_key {
+	struct apfs_key_header hdr;
+	__le64 sibling_id;
+} __packed;
+
+/*
+ * Structure of the key for a siblink map record
+ */
+struct apfs_sibling_map_key {
+	struct apfs_key_header hdr;
+} __packed;
+
+/*
+ * On-disk allocation info for a chunk of blocks
+ */
+struct apfs_chunk_info {
+	__le64	ci_xid;
+	__le64	ci_addr;
+	__le32	ci_block_count;
+	__le32	ci_free_count;
+	__le64	ci_bitmap_addr;
+} __packed;
+
+/* Constants for the chunk info block */
+#define	APFS_CI_COUNT_MASK		0x000FFFFF
+#define	APFS_CI_COUNT_RESERVED_MASK	0xFFF00000
+
+/*
+ * Structure of a block with an array of chunk allocation info structures
+ */
+struct apfs_chunk_info_block {
+	struct apfs_obj_phys	cib_o;
+	__le32			cib_index;
+	__le32			cib_chunk_info_count;
+	struct apfs_chunk_info	cib_chunk_info[];
+} __packed;
+
+/*
+ * Structure of a block with an array of addresses to chunk information blocks
+ */
+struct apfs_cib_addr_block {
+	struct apfs_obj_phys	cab_o;
+	__le32			cab_index;
+	__le32			cab_cib_count;
+	__le64			cab_cib_addr[];
+} __packed;
+
+/*
+ * On-disk structure for a free queue
+ */
+struct apfs_spaceman_free_queue {
+	__le64	sfq_count;
+	__le64	sfq_tree_oid;
+	__le64	sfq_oldest_xid;
+	__le16	sfq_tree_node_limit;
+	__le16	sfq_pad16;
+	__le32	sfq_pad32;
+	__le64	sfq_reserved;
+} __packed;
+
+/* Indexes for a free queue array */
+enum {
+	APFS_SFQ_IP	= 0,
+	APFS_SFQ_MAIN	= 1,
+	APFS_SFQ_TIER2	= 2,
+	APFS_SFQ_COUNT	= 3
+};
+
+/*
+ * On-disk structure for device allocation information
+ */
+struct apfs_spaceman_device {
+	__le64	sm_block_count;
+	__le64	sm_chunk_count;
+	__le32	sm_cib_count;
+	__le32	sm_cab_count;
+	__le64	sm_free_count;
+	__le32	sm_addr_offset;
+	__le32	sm_reserved;
+	__le64	sm_reserved2;
+} __packed;
+
+/* Indexes for a device array */
+enum {
+	APFS_SD_MAIN	= 0,
+	APFS_SD_TIER2	= 1,
+	APFS_SD_COUNT	= 2
+};
+
+/*
+ * On-disk structure to describe allocation zone boundaries
+ */
+struct apfs_spaceman_allocation_zone_boundaries {
+	__le64	saz_zone_start;
+	__le64	saz_zone_end;
+} __packed;
+
+/* Allocation zone constants */
+#define	APFS_SM_ALLOCZONE_INVALID_END_BOUNDARY		0
+#define	APFS_SM_ALLOCZONE_NUM_PREVIOUS_BOUNDARIES	7
+
+struct apfs_spaceman_allocation_zone_info_phys {
+	struct apfs_spaceman_allocation_zone_boundaries	saz_current_boundaries;
+	struct apfs_spaceman_allocation_zone_boundaries
+	     saz_previous_boundaries[APFS_SM_ALLOCZONE_NUM_PREVIOUS_BOUNDARIES];
+
+	__le16	saz_zone_id;
+	__le16	saz_previous_boundary_index;
+	__le32	saz_reserved;
+} __packed;
+
+/* Datazone constants */
+#define	APFS_SM_DATAZONE_ALLOCZONE_COUNT	8
+
+struct apfs_spaceman_datazone_info_phys {
+	struct apfs_spaceman_allocation_zone_info_phys
+	  sdz_allocation_zones[APFS_SD_COUNT][APFS_SM_DATAZONE_ALLOCZONE_COUNT];
+} __packed;
+
+/* Internal-pool bitmap constants */
+#define	APFS_SPACEMAN_IP_BM_TX_MULTIPLIER	16
+#define	APFS_SPACEMAN_IP_BM_INDEX_INVALID	0xFFFF
+#define	APFS_SPACEMAN_IP_BM_BLOCK_COUNT_MAX	0xFFFE
+
+/* Space manager flags */
+#define	APFS_SM_FLAG_VERSIONED		0x00000001
+#define	APFS_SM_FLAGS_VALID_MASK	APFS_SM_FLAG_VERSIONED
+
+/*
+ * On-disk structure for the space manager
+ */
+struct apfs_spaceman_phys {
+	struct apfs_obj_phys			sm_o;
+	__le32					sm_block_size;
+	__le32					sm_blocks_per_chunk;
+	__le32					sm_chunks_per_cib;
+	__le32					sm_cibs_per_cab;
+	struct apfs_spaceman_device		sm_dev[APFS_SD_COUNT];
+	__le32					sm_flags;
+	__le32					sm_ip_bm_tx_multiplier;
+	__le64					sm_ip_block_count;
+	__le32					sm_ip_bm_size_in_blocks;
+	__le32					sm_ip_bm_block_count;
+	__le64					sm_ip_bm_base;
+	__le64					sm_ip_base;
+	__le64					sm_fs_reserve_block_count;
+	__le64					sm_fs_reserve_alloc_count;
+	struct apfs_spaceman_free_queue		sm_fq[APFS_SFQ_COUNT];
+	__le16					sm_ip_bm_free_head;
+	__le16					sm_ip_bm_free_tail;
+	__le32					sm_ip_bm_xid_offset;
+	__le32					sm_ip_bitmap_offset;
+	__le32					sm_ip_bm_free_next_offset;
+	__le32					sm_version;
+	__le32					sm_struct_size;
+	struct apfs_spaceman_datazone_info_phys	sm_datazone;
+} __packed;
+
+/*
+ * Structure used to store a range of physical blocks
+ */
+struct apfs_prange {
+	__le64 pr_start_paddr;
+	__le64 pr_block_count;
+} __packed;
+
+/* Reaper flags */
+#define	APFS_NR_BHM_FLAG		0x00000001
+#define	APFS_NR_CONTINUE		0x00000002
+#define APFS_NR_FLAGS_VALID_MASK	(APFS_NR_BHM_FLAG | APFS_NR_CONTINUE)
+
+/*
+ * On-disk reaper structure
+ */
+struct apfs_nx_reaper_phys {
+	struct apfs_obj_phys	nr_o;
+	__le64			nr_next_reap_id;
+	__le64			nr_completed_id;
+	__le64			nr_head;
+	__le64			nr_tail;
+	__le32			nr_flags;
+	__le32			nr_rlcount;
+	__le32			nr_type;
+	__le32			nr_size;
+	__le64			nr_fs_oid;
+	__le64			nr_oid;
+	__le64			nr_xid;
+	__le32			nr_nrle_flags;
+	__le32			nr_state_buffer_size;
+	u8			nr_state_buffer[];
+} __packed;
+
+struct apfs_nx_reap_list_entry {
+	__le32	nrle_next;
+	__le32	nrle_flags;
+	__le32	nrle_type;
+	__le32	nrle_size;
+	__le64	nrle_fs_oid;
+	__le64	nrle_oid;
+	__le64	nrle_xid;
+} __packed;
+
+struct apfs_nx_reap_list_phys {
+	struct apfs_obj_phys		nrl_o;
+	__le64				nrl_next;
+	__le32				nrl_flags;
+	__le32				nrl_max;
+	__le32				nrl_count;
+	__le32				nrl_first;
+	__le32				nrl_last;
+	__le32				nrl_free;
+	struct apfs_nx_reap_list_entry	nrl_entries[];
+} __packed;
+
+/* EFI constants */
+#define APFS_NX_EFI_JUMPSTART_MAGIC	0x5244534A
+#define APFS_NX_EFI_JUMPSTART_VERSION	1
+
+/*
+ * Information about the embedded EFI driver
+ */
+struct apfs_nx_efi_jumpstart {
+	struct apfs_obj_phys	nej_o;
+	__le32			nej_magic;
+	__le32			nej_version;
+	__le32			nej_efi_file_len;
+	__le32			nej_num_extents;
+	__le64			nej_reserved[16];
+	struct apfs_prange	nej_rec_extents[];
+} __packed;
+
+/* Main container */
+
+/* Container constants */
+#define APFS_NX_MAGIC				0x4253584E
+#define APFS_NX_BLOCK_NUM			0
+#define APFS_NX_MAX_FILE_SYSTEMS		100
+
+#define APFS_NX_EPH_INFO_COUNT			4
+#define APFS_NX_EPH_MIN_BLOCK_COUNT		8
+#define APFS_NX_MAX_FILE_SYSTEM_EPH_STRUCTS	4
+#define APFS_NX_TX_MIN_CHECKPOINT_COUNT		4
+#define APFS_NX_EPH_INFO_VERSION_1		1
+
+/* Container flags */
+#define APFS_NX_RESERVED_1			0x00000001LL
+#define APFS_NX_RESERVED_2			0x00000002LL
+#define APFS_NX_CRYPTO_SW			0x00000004LL
+#define APFS_NX_FLAGS_VALID_MASK		(APFS_NX_RESERVED_1 \
+						| APFS_NX_RESERVED_2 \
+						| APFS_NX_CRYPTO_SW)
+
+/* Optional container feature flags */
+#define APFS_NX_FEATURE_DEFRAG			0x0000000000000001ULL
+#define APFS_NX_FEATURE_LCFD			0x0000000000000002ULL
+#define APFS_NX_SUPPORTED_FEATURES_MASK		(APFS_NX_FEATURE_DEFRAG | \
+						APFS_NX_FEATURE_LCFD)
+
+/* Read-only compatible container feature flags */
+#define APFS_NX_SUPPORTED_ROCOMPAT_MASK		(0x0ULL)
+
+/* Incompatible container feature flags */
+#define APFS_NX_INCOMPAT_VERSION1		0x0000000000000001ULL
+#define APFS_NX_INCOMPAT_VERSION2		0x0000000000000002ULL
+#define APFS_NX_INCOMPAT_FUSION			0x0000000000000100ULL
+#define APFS_NX_SUPPORTED_INCOMPAT_MASK		(APFS_NX_INCOMPAT_VERSION2 \
+						| APFS_NX_INCOMPAT_FUSION)
+
+/* Block and container sizes */
+#define APFS_NX_MINIMUM_BLOCK_SIZE		4096
+#define APFS_NX_DEFAULT_BLOCK_SIZE		4096
+#define APFS_NX_MAXIMUM_BLOCK_SIZE		65536
+#define APFS_NX_MINIMUM_CONTAINER_SIZE		1048576
+
+/* Indexes into a container superblock's array of counters */
+enum {
+	APFS_NX_CNTR_OBJ_CKSUM_SET	= 0,
+	APFS_NX_CNTR_OBJ_CKSUM_FAIL	= 1,
+
+	APFS_NX_NUM_COUNTERS		= 32
+};
+
+/*
+ * On-disk representation of the container superblock
+ */
+struct apfs_nx_superblock {
+/*00*/	struct apfs_obj_phys nx_o;
+/*20*/	__le32 nx_magic;
+	__le32 nx_block_size;
+	__le64 nx_block_count;
+
+/*30*/	__le64 nx_features;
+	__le64 nx_readonly_compatible_features;
+	__le64 nx_incompatible_features;
+
+/*48*/	char nx_uuid[UUID_SIZE];
+
+/*58*/	__le64 nx_next_oid;
+	__le64 nx_next_xid;
+
+/*68*/	__le32 nx_xp_desc_blocks;
+	__le32 nx_xp_data_blocks;
+/*70*/	__le64 nx_xp_desc_base;
+	__le64 nx_xp_data_base;
+	__le32 nx_xp_desc_next;
+	__le32 nx_xp_data_next;
+/*88*/	__le32 nx_xp_desc_index;
+	__le32 nx_xp_desc_len;
+	__le32 nx_xp_data_index;
+	__le32 nx_xp_data_len;
+
+/*98*/	__le64 nx_spaceman_oid;
+	__le64 nx_omap_oid;
+	__le64 nx_reaper_oid;
+
+/*B0*/	__le32 nx_test_type;
+
+	__le32 nx_max_file_systems;
+/*B8*/	__le64 nx_fs_oid[APFS_NX_MAX_FILE_SYSTEMS];
+/*3D8*/	__le64 nx_counters[APFS_NX_NUM_COUNTERS];
+/*4D8*/	struct apfs_prange nx_blocked_out_prange;
+	__le64 nx_evict_mapping_tree_oid;
+/*4F0*/	__le64 nx_flags;
+	__le64 nx_efi_jumpstart;
+/*500*/	char nx_fusion_uuid[UUID_SIZE];
+	struct apfs_prange nx_keylocker;
+/*520*/	__le64 nx_ephemeral_info[APFS_NX_EPH_INFO_COUNT];
+
+/*540*/	__le64 nx_test_oid;
+
+	__le64 nx_fusion_mt_oid;
+/*550*/	__le64 nx_fusion_wbc_oid;
+	struct apfs_prange nx_fusion_wbc;
+
+	__le64 nx_newest_mounted_version;
+
+/*570*/	struct apfs_prange nx_mkb_locker;
+} __packed;
+
+/*
+ * A mapping from an ephemeral object id to its physical address
+ */
+struct apfs_checkpoint_mapping {
+	__le32 cpm_type;
+	__le32 cpm_subtype;
+	__le32 cpm_size;
+	__le32 cpm_pad;
+	__le64 cpm_fs_oid;
+	__le64 cpm_oid;
+	__le64 cpm_paddr;
+} __packed;
+
+/* Checkpoint flags */
+#define	APFS_CHECKPOINT_MAP_LAST	0x00000001
+
+/*
+ * A checkpoint-mapping block
+ */
+struct apfs_checkpoint_map_phys {
+	struct apfs_obj_phys		cpm_o;
+	__le32				cpm_flags;
+	__le32				cpm_count;
+	struct apfs_checkpoint_mapping	cpm_map[];
+} __packed;
+
+/* Volume */
+
+/* Volume constants */
+#define APFS_MAGIC				0x42535041
+
+#define APFS_MAX_HIST				8
+#define APFS_VOLNAME_LEN			256
+
+/* Volume flags */
+#define APFS_FS_UNENCRYPTED			0x00000001LL
+#define APFS_FS_EFFACEABLE			0x00000002LL
+#define APFS_FS_RESERVED_4			0x00000004LL
+#define APFS_FS_ONEKEY				0x00000008LL
+#define APFS_FS_SPILLEDOVER			0x00000010LL
+#define APFS_FS_RUN_SPILLOVER_CLEANER		0x00000020LL
+#define APFS_FS_ALWAYS_CHECK_EXTENTREF		0x00000040LL
+#define APFS_FS_PREVIOUSLY_SEALED		0x00000080LL /* Made-up name */
+#define APFS_FS_PFK				0x00000100LL /* Made-up name */
+#define APFS_FS_UNKNOWN_200			0x00000200LL
+#define APFS_FS_FLAGS_VALID_MASK		(APFS_FS_UNENCRYPTED \
+						| APFS_FS_EFFACEABLE \
+						| APFS_FS_RESERVED_4 \
+						| APFS_FS_ONEKEY \
+						| APFS_FS_SPILLEDOVER \
+						| APFS_FS_RUN_SPILLOVER_CLEANER \
+						| APFS_FS_ALWAYS_CHECK_EXTENTREF \
+						| APFS_FS_PREVIOUSLY_SEALED \
+						| APFS_FS_PFK \
+						| APFS_FS_UNKNOWN_200)
+
+#define APFS_FS_CRYPTOFLAGS			(APFS_FS_UNENCRYPTED \
+						| APFS_FS_EFFACEABLE \
+						| APFS_FS_ONEKEY)
+
+/* Volume roles */
+#define APFS_VOLUME_ENUM_SHIFT		6
+#define APFS_VOL_ROLE_NONE		0x0000
+#define APFS_VOL_ROLE_SYSTEM		0x0001
+#define APFS_VOL_ROLE_USER		0x0002
+#define APFS_VOL_ROLE_RECOVERY		0x0004
+#define APFS_VOL_ROLE_VM		0x0008
+#define APFS_VOL_ROLE_PREBOOT		0x0010
+#define APFS_VOL_ROLE_INSTALLER		0x0020
+#define APFS_VOL_ROLE_DATA		(1 << APFS_VOLUME_ENUM_SHIFT)
+#define APFS_VOL_ROLE_BASEBAND		(2 << APFS_VOLUME_ENUM_SHIFT)
+#define APFS_VOL_ROLE_UPDATE		(3 << APFS_VOLUME_ENUM_SHIFT)
+#define APFS_VOL_ROLE_XART		(4 << APFS_VOLUME_ENUM_SHIFT)
+#define APFS_VOL_ROLE_HARDWARE		(5 << APFS_VOLUME_ENUM_SHIFT)
+#define APFS_VOL_ROLE_BACKUP		(6 << APFS_VOLUME_ENUM_SHIFT)
+#define APFS_VOL_ROLE_RESERVED_7	(7 << APFS_VOLUME_ENUM_SHIFT)
+#define APFS_VOL_ROLE_RESERVED_8	(8 << APFS_VOLUME_ENUM_SHIFT)
+#define APFS_VOL_ROLE_ENTERPRISE	(9 << APFS_VOLUME_ENUM_SHIFT)
+#define APFS_VOL_ROLE_RESERVED_10	(10 << APFS_VOLUME_ENUM_SHIFT)
+#define APFS_VOL_ROLE_PRELOGIN		(11 << APFS_VOLUME_ENUM_SHIFT)
+#define APFS_VOL_ROLES_VALID_MASK	(APFS_VOL_ROLE_SYSTEM \
+					| APFS_VOL_ROLE_USER \
+					| APFS_VOL_ROLE_RECOVERY \
+					| APFS_VOL_ROLE_VM \
+					| APFS_VOL_ROLE_PREBOOT \
+					| APFS_VOL_ROLE_INSTALLER \
+					| APFS_VOL_ROLE_DATA \
+					| APFS_VOL_ROLE_BASEBAND \
+					| APFS_VOL_ROLE_UPDATE \
+					| APFS_VOL_ROLE_XART \
+					| APFS_VOL_ROLE_HARDWARE \
+					| APFS_VOL_ROLE_BACKUP \
+					| APFS_VOL_ROLE_RESERVED_7 \
+					| APFS_VOL_ROLE_RESERVED_8 \
+					| APFS_VOL_ROLE_ENTERPRISE \
+					| APFS_VOL_ROLE_RESERVED_10 \
+					| APFS_VOL_ROLE_PRELOGIN)
+
+/* Optional volume feature flags */
+#define APFS_FEATURE_DEFRAG_PRERELEASE		0x00000001LL
+#define APFS_FEATURE_HARDLINK_MAP_RECORDS	0x00000002LL
+#define APFS_FEATURE_DEFRAG			0x00000004LL
+#define APFS_FEATURE_STRICTATIME		0x00000008LL
+#define APFS_FEATURE_VOLGRP_SYSTEM_INO_SPACE	0x00000010LL
+
+#define APFS_SUPPORTED_FEATURES_MASK	(APFS_FEATURE_DEFRAG \
+					| APFS_FEATURE_DEFRAG_PRERELEASE \
+					| APFS_FEATURE_HARDLINK_MAP_RECORDS \
+					| APFS_FEATURE_STRICTATIME \
+					| APFS_FEATURE_VOLGRP_SYSTEM_INO_SPACE)
+
+/* Read-only compatible volume feature flags */
+#define APFS_SUPPORTED_ROCOMPAT_MASK		(0x0ULL)
+
+/* Incompatible volume feature flags */
+#define APFS_INCOMPAT_CASE_INSENSITIVE		0x00000001LL
+#define APFS_INCOMPAT_DATALESS_SNAPS		0x00000002LL
+#define APFS_INCOMPAT_ENC_ROLLED		0x00000004LL
+#define APFS_INCOMPAT_NORMALIZATION_INSENSITIVE	0x00000008LL
+#define APFS_INCOMPAT_INCOMPLETE_RESTORE	0x00000010LL
+#define APFS_INCOMPAT_SEALED_VOLUME		0x00000020LL
+#define APFS_INCOMPAT_PFK			0x00000040LL /* Made-up name */
+#define APFS_INCOMPAT_EXTENT_PREALLOC_FLAG	0x00000080LL /* Made-up name */
+#define APFS_INCOMPAT_SECONDARY_FSROOT		0x00000100LL /* Made-up name */
+
+#define APFS_SUPPORTED_INCOMPAT_MASK (APFS_INCOMPAT_CASE_INSENSITIVE \
+				     | APFS_INCOMPAT_DATALESS_SNAPS \
+				     | APFS_INCOMPAT_ENC_ROLLED \
+				     | APFS_INCOMPAT_NORMALIZATION_INSENSITIVE \
+				     | APFS_INCOMPAT_INCOMPLETE_RESTORE \
+				     | APFS_INCOMPAT_SEALED_VOLUME \
+				     | APFS_INCOMPAT_PFK \
+				     | APFS_INCOMPAT_EXTENT_PREALLOC_FLAG \
+				     | APFS_INCOMPAT_SECONDARY_FSROOT)
+
+#define APFS_MODIFIED_NAMELEN	      32
+
+/*
+ * Structure containing information about a program that modified the volume
+ */
+struct apfs_modified_by {
+	u8 id[APFS_MODIFIED_NAMELEN];
+	__le64 timestamp;
+	__le64 last_xid;
+} __packed;
+
+/* Version constants for wrapped meta crypto state */
+#define APFS_WMCS_MAJOR_VERSION		5
+#define APFS_WMCS_MINOR_VERSION		0
+
+/* Protection classes */
+#define APFS_PROTECTION_CLASS_DIR_NONE	0 /* Inherits the directory's default */
+#define APFS_PROTECTION_CLASS_A		1
+#define APFS_PROTECTION_CLASS_B		2
+#define APFS_PROTECTION_CLASS_C		3
+#define APFS_PROTECTION_CLASS_D		4 /* No protection */
+#define APFS_PROTECTION_CLASS_F		6 /* No protection, nonpersistent key */
+
+/* Encryption identifiers */
+#define APFS_CRYPTO_SW_ID		4
+#define APFS_CRYPTO_RESERVED_5		5
+#define APFS_UNASSIGNED_CRYPTO_ID	(~0ULL)
+
+/* Doc id index flags. I'm making up the names for now. */
+#define APFS_DOC_ID_HAS_PREV_TREE	0x00000001
+#define APFS_DOC_ID_UNKNOWN_02		0x00000002
+#define APFS_DOC_ID_UNKNOWN_04		0x00000004
+#define APFS_DOC_ID_UNKNOWN_08		0x00000008
+#define APFS_DOC_ID_UNKNOWN_10		0x00000010
+#define APFS_DOC_ID_VALID_FLAGS		(APFS_DOC_ID_HAS_PREV_TREE \
+					| APFS_DOC_ID_UNKNOWN_02 \
+					| APFS_DOC_ID_UNKNOWN_04 \
+					| APFS_DOC_ID_UNKNOWN_08 \
+					| APFS_DOC_ID_UNKNOWN_10)
+
+/*
+ * Structure used to store the encryption state
+ */
+struct apfs_wrapped_meta_crypto_state {
+	__le16 major_version;
+	__le16 minor_version;
+	__le32 cpflags;
+	__le32 persistent_class;
+	__le32 key_os_version;
+	__le16 key_revision;
+	__le16 unused;
+} __packed;
+
+/*
+ * On-disk representation of a volume superblock
+ */
+struct apfs_superblock {
+/*00*/	struct apfs_obj_phys apfs_o;
+
+/*20*/	__le32 apfs_magic;
+	__le32 apfs_fs_index;
+
+/*28*/	__le64 apfs_features;
+	__le64 apfs_readonly_compatible_features;
+	__le64 apfs_incompatible_features;
+
+/*40*/	__le64 apfs_unmount_time;
+
+	__le64 apfs_fs_reserve_block_count;
+	__le64 apfs_fs_quota_block_count;
+	__le64 apfs_fs_alloc_count;
+
+/*60*/	struct apfs_wrapped_meta_crypto_state apfs_meta_crypto;
+
+/*74*/	__le32 apfs_root_tree_type;
+	__le32 apfs_extentref_tree_type;
+	__le32 apfs_snap_meta_tree_type;
+
+/*80*/	__le64 apfs_omap_oid;
+	__le64 apfs_root_tree_oid;
+	__le64 apfs_extentref_tree_oid;
+	__le64 apfs_snap_meta_tree_oid;
+
+/*A0*/	__le64 apfs_revert_to_xid;
+	__le64 apfs_revert_to_sblock_oid;
+
+/*B0*/	__le64 apfs_next_obj_id;
+
+/*B8*/	__le64 apfs_num_files;
+	__le64 apfs_num_directories;
+	__le64 apfs_num_symlinks;
+	__le64 apfs_num_other_fsobjects;
+	__le64 apfs_num_snapshots;
+
+/*E0*/	__le64 apfs_total_blocks_alloced;
+	__le64 apfs_total_blocks_freed;
+
+/*F0*/	char apfs_vol_uuid[UUID_SIZE];
+/*100*/	__le64 apfs_last_mod_time;
+
+	__le64 apfs_fs_flags;
+
+/*110*/	struct apfs_modified_by apfs_formatted_by;
+/*140*/	struct apfs_modified_by apfs_modified_by[APFS_MAX_HIST];
+
+/*2C0*/	u8 apfs_volname[APFS_VOLNAME_LEN];
+/*3C0*/	__le32 apfs_next_doc_id;
+
+	__le16 apfs_role;
+	__le16 reserved;
+
+/*3C8*/	__le64 apfs_root_to_xid;
+	__le64 apfs_er_state_oid;
+
+	__le64 apfs_cloneinfo_id_epoch;
+	__le64 apfs_cloneinfo_xid;
+
+	__le64 apfs_snap_meta_ext_oid;
+
+/*3F0*/	char apfs_volume_group_id[UUID_SIZE];
+
+/*400*/	__le64 apfs_integrity_meta_oid;
+
+	__le64 apfs_fext_tree_oid;
+/*410*/	__le32 apfs_fext_tree_type;
+
+	__le32 reserved_type;
+	__le64 reserved_oid;
+
+/*420*/	__le64 apfs_doc_id_index_xid;
+	__le32 apfs_doc_id_index_flags;
+	__le32 apfs_doc_id_tree_type;
+/*430*/	__le64 apfs_doc_id_tree_oid; /* Made-up name */
+	__le64 apfs_prev_doc_id_tree_oid;
+	__le64 apfs_doc_id_fixup_cursor;
+	__le64 apfs_sec_root_tree_oid;
+/*450*/	__le32 apfs_sec_root_tree_type;
+} __packed;
+
+/* Extended attributes constants */
+#define APFS_XATTR_MAX_EMBEDDED_SIZE	3804
+
+/* Extended attributes names */
+#define APFS_XATTR_NAME_SYMLINK		"com.apple.fs.symlink"
+#define APFS_XATTR_NAME_COMPRESSED	"com.apple.decmpfs"
+#define APFS_XATTR_NAME_RSRC_FORK	"com.apple.ResourceFork"
+#define APFS_XATTR_NAME_SECURITY	"com.apple.system.Security"
+#define APFS_XATTR_NAME_FINDER_INFO	"com.apple.FinderInfo"
+
+/* Extended attributes flags */
+enum {
+	APFS_XATTR_DATA_STREAM		= 0x00000001,
+	APFS_XATTR_DATA_EMBEDDED	= 0x00000002,
+	APFS_XATTR_FILE_SYSTEM_OWNED	= 0x00000004,
+	APFS_XATTR_RESERVED_8		= 0x00000008,
+	APFS_XATTR_UNKNOWN_10		= 0x00000010,
+};
+
+#define APFS_XATTR_VALID_FLAGS 0x0000001f
+
+/*
+ * Structure of the value of an extended attributes record
+ */
+struct apfs_xattr_val {
+	__le16 flags;
+	__le16 xdata_len;
+	u8 xdata[];
+} __packed;
+
+/*
+ * Structure used to store the data of an extended attributes record
+ */
+struct apfs_xattr_dstream {
+	__le64 xattr_obj_id;
+	struct apfs_dstream dstream;
+} __packed;
+
+/*
+ * Integrity metadata for a sealed volume
+ */
+struct apfs_integrity_meta_phys {
+	struct apfs_obj_phys im_o;
+
+	__le32	im_version;
+	__le32	im_flags;
+	__le32	im_hash_type;
+	__le32	im_root_hash_offset;
+	__le64	im_broken_xid;
+	__le64	im_reserved[9];
+} __packed;
+
+/*
+ * Version numbers for the integrity metadata structure
+ */
+enum {
+	APFS_INTEGRITY_META_VERSION_INVALID	= 0,
+	APFS_INTEGRITY_META_VERSION_1		= 1,
+	APFS_INTEGRITY_META_VERSION_2		= 2,
+	APFS_INTEGRITY_META_VERSION_HIGHEST	= APFS_INTEGRITY_META_VERSION_2
+};
+
+/* Flags used by integrity metadata */
+#define APFS_SEAL_BROKEN (1U << 0)
+
+/*
+ * Constants used to identify hash algorithms
+ */
+enum {
+	APFS_HASH_INVALID	= 0,
+	APFS_HASH_SHA256	= 0x1,
+	APFS_HASH_SHA512_256	= 0x2,
+	APFS_HASH_SHA384	= 0x3,
+	APFS_HASH_SHA512	= 0x4,
+
+	APFS_HASH_MIN		= APFS_HASH_SHA256,
+	APFS_HASH_MAX		= APFS_HASH_SHA512,
+	APFS_HASH_DEFAULT	= APFS_HASH_SHA256,
+};
+
+#define APFS_HASH_CCSHA256_SIZE		32
+#define APFS_HASH_CCSHA512_256_SIZE	32
+#define APFS_HASH_CCSHA384_SIZE		48
+#define APFS_HASH_CCSHA512_SIZE		64
+
+#define APFS_HASH_MAX_SIZE		64
+
+/*
+ * Structure of a key in a fext tree
+ */
+struct apfs_fext_tree_key {
+	__le64 private_id;
+	__le64 logical_addr;
+} __packed;
+
+/*
+ * Structure of a value in a fext tree
+ */
+struct apfs_fext_tree_val {
+	__le64 len_and_flags;
+	__le64 phys_block_num;
+} __packed;
+
+/*
+ * Structure of the key for a file info record
+ */
+struct apfs_file_info_key {
+	struct apfs_key_header hdr;
+	__le64 info_and_lba;
+} __packed;
+
+#define APFS_FILE_INFO_LBA_MASK		0x00ffffffffffffffULL
+#define APFS_FILE_INFO_TYPE_MASK	0xff00000000000000ULL
+#define APFS_FILE_INFO_TYPE_SHIFT	56
+
+/*
+ * A hash of file data
+ */
+struct apfs_file_data_hash_val {
+	__le16	hashed_len;
+	u8	hash_size;
+	u8	hash[];
+} __packed;
+
+#define APFS_FILE_INFO_DATA_HASH	1
+
+/*
+ * Structure of the value for a file info record
+ */
+struct apfs_file_info_val {
+	union {
+		struct apfs_file_data_hash_val dhash;
+	};
+} __packed;
+
+#define APFS_BTREE_NODE_HASH_SIZE_MAX	64
+
+/*
+ * Structure of the value of an index record for a hashed catalog tree
+ */
+struct apfs_btn_index_node_val {
+	__le64	binv_child_oid;
+	/*
+	 * The reference seems to be wrong about the hash size, at least for
+	 * SHA-256. TODO: check what happens with other hash functions.
+	 */
+	u8	binv_child_hash[APFS_HASH_CCSHA256_SIZE];
+} __packed;
+
+/*
+ * Compressed file header
+ */
+struct apfs_compress_hdr {
+	__le32 signature;
+	__le32 algo;
+	__le64 size;
+} __packed;
+
+#define APFS_COMPRESS_ZLIB_ATTR		3
+#define APFS_COMPRESS_ZLIB_RSRC		4
+#define APFS_COMPRESS_LZVN_ATTR		7
+#define APFS_COMPRESS_LZVN_RSRC		8
+#define APFS_COMPRESS_PLAIN_ATTR	9
+#define APFS_COMPRESS_PLAIN_RSRC	10
+#define APFS_COMPRESS_LZFSE_ATTR	11
+#define APFS_COMPRESS_LZFSE_RSRC	12
+#define APFS_COMPRESS_LZBITMAP_ATTR	13
+#define APFS_COMPRESS_LZBITMAP_RSRC	14
+
+struct apfs_compress_rsrc_hdr {
+	__be32 data_offs;
+	__be32 mgmt_offs;
+	__be32 data_size;
+	__be32 mgmt_size;
+} __packed;
+
+#define APFS_COMPRESS_BLOCK		0x10000
+
+struct apfs_compress_rsrc_data {
+	__le32 unknown;
+	__le32 num;
+	struct apfs_compress_rsrc_block {
+		__le32 offs;
+		__le32 size;
+	} __packed block[];
+} __packed;
+
+#define APFS_FUSION_TIER2_DEVICE_BYTE_ADDR	0x4000000000000000ULL
+
+/*
+ * TODO: this is a placeholder, create some snapshots with the official
+ * implementation to find the actual limit.
+ */
+#define APFS_SNAP_MAX_NAMELEN		255
+
+/*
+ * Structure of the value of a snapshot metadata record
+ */
+struct apfs_snap_metadata_val {
+	__le64 extentref_tree_oid;
+	__le64 sblock_oid;
+	__le64 create_time;
+	__le64 change_time;
+	__le64 inum;
+	__le32 extentref_tree_type;
+	__le32 flags;
+	__le16 name_len;
+	u8 name[];
+} __packed;
+
+/* Snapshot metadata record flags */
+enum {
+	APFS_SNAP_META_PENDING_DATALESS	= 0x00000001,
+	APFS_SNAP_MERGE_IN_PROGRESS	= 0x00000002,
+};
+
+/*
+ * Structure of the value of a snapshot name record
+ */
+struct apfs_snap_name_val {
+	__le64 snap_xid;
+} __packed;
+
+/*
+ * Structure of the extended snapshot metadata
+ */
+struct apfs_snap_meta_ext {
+	struct apfs_obj_phys sme_o;
+
+	__le32	sme_version;
+	__le32	sme_flags;
+	__le64	sme_snap_xid;
+	char	sme_uuid[UUID_SIZE];
+	__le64	sme_token;
+} __packed;
+
+#define APFS_OBJECT_TYPE_KEYBAG	0x6b657973 /* Spells 'syek' */
+
+#define	APFS_VOL_KEYBAG_ENTRY_MAX_SIZE		512
+#define APFS_FV_PERSONAL_RECOVERY_KEY_UUID	"EBC6C064-0000-11AA-AA11-00306543ECAC"
+
+/* Keybag entry types */
+enum {
+	KB_TAG_UNKNOWN			= 0,
+	KB_TAG_RESERVED_1		= 1,
+
+	KB_TAG_VOLUME_KEY		= 2,
+	KB_TAG_VOLUME_UNLOCK_RECORDS	= 3,
+	KB_TAG_VOLUME_PASSPHRASE_HINT	= 4,
+
+	KB_TAG_WRAPPING_M_KEY		= 5,
+	KB_TAG_VOLUME_M_KEY		= 6,
+
+	KB_TAG_RESERVED_F8		= 0xF8
+};
+
+/*
+ * Structure of a single entry in the keybag
+ */
+struct apfs_keybag_entry {
+	char	ke_uuid[UUID_SIZE];
+	__le16	ke_tag;
+	__le16	ke_keylen;
+	__le32	padding;
+	u8	ke_keydata[];
+} __packed;
+
+#define APFS_KEYBAG_VERSION	2
+
+/*
+ * Structure of the locker in the keybag
+ */
+struct apfs_kb_locker {
+	__le16				kl_version;
+	__le16				kl_nkeys;
+	__le32				kl_nbytes;
+	__le64				padding;
+	struct apfs_keybag_entry	kl_entries[];
+} __packed;
+
+#endif	/* _APFS_RAW_H */
Signature · 1 line
2.48.1
#5 lore raw

RFC PATCH v2 4/8 staging: apfs: init libzbitmap.{c,h} for decompression

In reply to Ethan Carter Edwards

This code handles lzbitmap decompression in filesystem reads. Write support is not yet implemented.

---
 drivers/staging/apfs/libzbitmap.c | 448 ++++++++++++++++++++++++++++++++++++++
 drivers/staging/apfs/libzbitmap.h |  32 +++
 2 files changed, 480 insertions(+)
drivers/staging/apfs/libzbitmap.c new file +448 -0
new file mode 100644
index 0000000000000000000000000000000000000000..26e8827b7b1b8d40684127a735743ffc8da7d8de
@@ -0,0 +1,448 @@
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+/*
+ * Copyright (C) 2022 Corellium LLC
+ *
+ * Author: Ernesto A. Fernández <[email protected]>
+ *
+ * Ported from libzbitmap (https://github.com/eafer/libzbitmap). Only the
+ * decompression code is included.
+ */
+
+#include <linux/errno.h>
+#include <linux/string.h>
+#include "libzbitmap.h"
+
+#define ZBM_MAGIC "ZBM\x09"
+#define ZBM_MAGIC_SZ 4
+
+#define ZBM_MAX_DECMP_CHUNK_SIZE 0x8000
+#define ZBM_MAX_DECMP_CHUNK_SIZE_BITS 15
+
+struct uint24 {
+	uint8_t low;
+	uint8_t mid;
+	uint8_t hig;
+};
+
+/* This header is shared by both compressed and decompressed chunks */
+struct zbm_chunk_hdr {
+	struct uint24 len; /* Length of the chunk */
+	struct uint24 decmp_len; /* Length of the chunk after decompression */
+};
+
+/* The full header for compressed chunks */
+struct zbm_cmp_chunk_hdr {
+	/* Shared with decompressed chunks */
+	struct zbm_chunk_hdr hdr;
+
+	/* Offset for each of the three metadata areas */
+	struct uint24 meta_off_1;
+	struct uint24 meta_off_2;
+	struct uint24 meta_off_3;
+};
+
+/* Pointer to a half-byte */
+struct nybl_ptr {
+	uint8_t *addr; /* Address of the byte */
+	int nibble; /* Which of the two nibbles? */
+};
+
+/* 0-2 and 0xf are not real bitmap indexes */
+#define ZBM_BITMAP_COUNT (16 - 1 - 3)
+#define ZBM_BITMAP_BASE 3
+#define ZBM_BITMAP_BYTECNT 17
+#define ZBM_MAX_PERIOD_BYTECNT 2
+
+struct zbm_bmap {
+	uint8_t bitmap; /* The bitmap */
+	uint8_t period_bytecnt; /* Read this many bytes to get the new period */
+};
+
+struct zbm_state {
+	/* Updated during a chunk read */
+	uint8_t *dest; /* Write the next byte here */
+	size_t dest_left; /* Room left in destination buffer */
+	uint32_t written; /* Bytes written so far for current chunk */
+	uint16_t period; /* Repetition period for decompression, in bytes */
+
+	/* Updated right before a chunk read */
+	const uint8_t *src_end; /* End of current chunk */
+	uint32_t len; /* Length of the chunk */
+	uint32_t decmp_len; /* Expected chunk length after decompression */
+
+	/* Updated after a chunk read */
+	const uint8_t *src; /* Start of buffer, or current chunk if any */
+	size_t src_left; /* Room left in the source buffer */
+	size_t prewritten; /* Bytes written for previous chunks */
+
+	/* Current position in data and metadata areas for this chunk */
+	const uint8_t *data;
+	const uint8_t *meta_1;
+	const uint8_t *meta_2;
+	struct nybl_ptr meta_3;
+
+	/* Array of bitmaps for the current chunk */
+	struct zbm_bmap bitmaps[ZBM_BITMAP_COUNT];
+};
+
+static int zbm_check_magic(struct zbm_state *state)
+{
+	if (state->src_left < ZBM_MAGIC_SZ)
+		return -EINVAL;
+
+	if (memcmp(state->src, ZBM_MAGIC, ZBM_MAGIC_SZ))
+		return -EINVAL;
+
+	state->src += ZBM_MAGIC_SZ;
+	state->src_left -= ZBM_MAGIC_SZ;
+	return 0;
+}
+
+static uint32_t zbm_u24_to_u32(struct uint24 n)
+{
+	uint32_t res;
+
+	res = n.hig;
+	res <<= 8;
+	res += n.mid;
+	res <<= 8;
+	res += n.low;
+	return res;
+}
+
+/* Some chunks just have regular uncompressed data, but with a header */
+static int zbm_chunk_is_uncompressed(struct zbm_state *state)
+{
+	return state->len == state->decmp_len + sizeof(struct zbm_chunk_hdr);
+}
+
+static int zbm_handle_uncompressed_chunk(struct zbm_state *state)
+{
+	state->meta_1 = state->meta_2 = NULL;
+	state->meta_3.addr = NULL;
+	state->meta_3.nibble = 0;
+	state->data = state->src + sizeof(struct zbm_chunk_hdr);
+	memcpy(state->dest, state->data, state->decmp_len);
+
+	state->dest += state->decmp_len;
+	state->dest_left -= state->decmp_len;
+	state->written = state->decmp_len;
+	return 0;
+}
+
+static int zbm_read_nibble(struct nybl_ptr *nybl, const uint8_t *limit,
+			   uint8_t *result)
+{
+	if (nybl->addr >= limit)
+		return -EINVAL;
+
+	if (nybl->nibble == 0) {
+		*result = *nybl->addr & 0xf;
+		nybl->nibble = 1;
+	} else {
+		*result = (*nybl->addr >> 4) & 0xf;
+		nybl->nibble = 0;
+		++nybl->addr;
+	}
+	return 0;
+}
+
+static void zbm_rewind_nibble(struct nybl_ptr *nybl)
+{
+	if (nybl->nibble == 0) {
+		nybl->nibble = 1;
+		--nybl->addr;
+	} else {
+		nybl->nibble = 0;
+	}
+}
+
+static int zbm_apply_bitmap(struct zbm_state *state, struct zbm_bmap *bitmap)
+{
+	int i;
+
+	/* The periods are stored in the first metadata area */
+	if (bitmap->period_bytecnt) {
+		state->period = 0;
+		for (i = 0; i < bitmap->period_bytecnt; ++i) {
+			if (state->meta_1 >= state->src_end)
+				return -EINVAL;
+			state->period |= *state->meta_1 << i * 8;
+			++state->meta_1;
+		}
+	}
+	if (state->period == 0)
+		return -EINVAL;
+
+	for (i = 0; i < 8; ++i) {
+		if (state->written == state->decmp_len)
+			break;
+		if (bitmap->bitmap & 1 << i) {
+			if (state->data >= state->src_end)
+				return -EINVAL;
+			*state->dest = *state->data;
+			++state->data;
+		} else {
+			if (state->prewritten + state->written < state->period)
+				return -EINVAL;
+			*state->dest = *(state->dest - state->period);
+		}
+		++state->dest;
+		--state->dest_left;
+		++state->written;
+	}
+
+	return 0;
+}
+
+static int zbm_apply_bitmap_number(struct zbm_state *state, uint8_t bmp_num)
+{
+	struct zbm_bmap next = { 0 };
+
+	/* Not a valid bitmap number (it signals a repetition) */
+	if (bmp_num == 0xf)
+		return -EINVAL;
+
+	/* An actual index in the bitmap array */
+	if (bmp_num > ZBM_MAX_PERIOD_BYTECNT)
+		return zbm_apply_bitmap(
+			state, &state->bitmaps[bmp_num - ZBM_BITMAP_BASE]);
+
+	/* For < 2, use the next bitmap in the second metadata area */
+	if (state->meta_2 >= state->src_end)
+		return -EINVAL;
+	next.bitmap = *state->meta_2;
+	next.period_bytecnt = bmp_num;
+	++state->meta_2;
+	return zbm_apply_bitmap(state, &next);
+}
+
+/* Find out how many times we need to repeat the current bitmap operation */
+static int zbm_read_repetition_count(struct zbm_state *state, uint16_t *repeat)
+{
+	uint8_t nibble;
+	uint16_t total;
+	int err;
+
+	/* Don't confuse the trailing bitmaps with a repetition count */
+	if (state->decmp_len - state->written <= 8) {
+		*repeat = 1;
+		return 0;
+	}
+
+	err = zbm_read_nibble(&state->meta_3, state->src_end, &nibble);
+	if (err)
+		return err;
+
+	if (nibble != 0xf) {
+		/* No repetition count: the previous bitmap number gets applied once */
+		zbm_rewind_nibble(&state->meta_3);
+		*repeat = 1;
+		return 0;
+	}
+
+	/*
+     * Under this scheme, repeating a bitmap number 3 times wouldn't save any
+     * space, so the repetition count starts from 4.
+     */
+	total = 4;
+	while (nibble == 0xf) {
+		err = zbm_read_nibble(&state->meta_3, state->src_end, &nibble);
+		if (err)
+			return err;
+		total += nibble;
+		if (total < nibble)
+			return -EINVAL;
+	}
+
+	*repeat = total;
+	return 0;
+}
+
+static int zbm_decompress_single_bitmap(struct zbm_state *state)
+{
+	uint8_t bmp_num;
+	uint16_t repeat;
+	int i;
+	int err;
+
+	/* The current nibble is the offset of the next bitmap to apply */
+	err = zbm_read_nibble(&state->meta_3, state->src_end, &bmp_num);
+	if (err)
+		return err;
+
+	err = zbm_read_repetition_count(state, &repeat);
+	if (err)
+		return err;
+
+	for (i = 0; i < repeat; ++i) {
+		err = zbm_apply_bitmap_number(state, bmp_num);
+		if (err)
+			return err;
+	}
+	return 0;
+}
+
+/* Pointer to a bit */
+struct bit_ptr {
+	uint8_t *addr; /* Address of the byte */
+	int offset; /* Bit number */
+};
+
+/* This function does not perform boundary checks, the caller must do it */
+static int zbm_read_single_bit(struct bit_ptr *bit)
+{
+	int res = *bit->addr >> bit->offset & 1;
+
+	++bit->offset;
+	if (bit->offset != 8)
+		return res;
+	bit->offset = 0;
+	++bit->addr;
+	return res;
+}
+
+static int zbm_read_single_bitmap(struct bit_ptr *bit, const uint8_t *limit,
+				  struct zbm_bmap *result)
+{
+	int i;
+
+	result->bitmap = 0;
+	result->period_bytecnt = 0;
+
+	/* The bitmap itself */
+	for (i = 0; i < 8; ++i) {
+		if (bit->addr >= limit)
+			return -EINVAL;
+		result->bitmap |= zbm_read_single_bit(bit) << i;
+	}
+
+	/*
+     * The two trailing bits tell us how many bytes to read for the next
+     * repetition period
+     */
+	for (i = 0; i < 2; ++i) {
+		if (bit->addr >= limit)
+			return -EINVAL;
+		result->period_bytecnt |= zbm_read_single_bit(bit) << i;
+	}
+
+	return 0;
+}
+
+static int zbm_read_bitmaps(struct zbm_state *state)
+{
+	struct bit_ptr bmap = { 0 };
+	int err, i;
+
+	if (state->len < ZBM_BITMAP_BYTECNT)
+		return -EINVAL;
+
+	bmap.addr = (uint8_t *)state->src_end - ZBM_BITMAP_BYTECNT;
+	bmap.offset = 0;
+
+	for (i = 0; i < ZBM_BITMAP_COUNT; ++i) {
+		err = zbm_read_single_bitmap(&bmap, state->src_end,
+					     &state->bitmaps[i]);
+		if (err)
+			return err;
+		if (state->bitmaps[i].period_bytecnt > ZBM_MAX_PERIOD_BYTECNT)
+			return -EINVAL;
+	}
+	return 0;
+}
+
+static int zbm_handle_compressed_chunk(struct zbm_state *state)
+{
+	const struct zbm_cmp_chunk_hdr *hdr = NULL;
+	uint32_t meta_off_1, meta_off_2, meta_off_3;
+	int err;
+
+	state->written = 0;
+	state->period = 8;
+
+	if (state->len < sizeof(*hdr))
+		return -EINVAL;
+	hdr = (struct zbm_cmp_chunk_hdr *)state->src;
+	state->data = state->src + sizeof(*hdr);
+
+	meta_off_1 = zbm_u24_to_u32(hdr->meta_off_1);
+	meta_off_2 = zbm_u24_to_u32(hdr->meta_off_2);
+	meta_off_3 = zbm_u24_to_u32(hdr->meta_off_3);
+	if (meta_off_1 >= state->len || meta_off_2 >= state->len ||
+	    meta_off_3 >= state->len)
+		return -EINVAL;
+	state->meta_1 = state->src + meta_off_1;
+	state->meta_2 = state->src + meta_off_2;
+	state->meta_3.addr = (uint8_t *)state->src + meta_off_3;
+	state->meta_3.nibble = 0;
+
+	err = zbm_read_bitmaps(state);
+	if (err)
+		return err;
+
+	while (state->written < state->decmp_len) {
+		err = zbm_decompress_single_bitmap(state);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
+
+static int zbm_handle_chunk(struct zbm_state *state)
+{
+	const struct zbm_chunk_hdr *decmp_hdr = NULL;
+
+	if (state->src_left < sizeof(*decmp_hdr))
+		return -EINVAL;
+	decmp_hdr = (struct zbm_chunk_hdr *)state->src;
+
+	state->len = zbm_u24_to_u32(decmp_hdr->len);
+	if (state->len > state->src_left)
+		return -EINVAL;
+	state->src_end = state->src + state->len;
+
+	state->decmp_len = zbm_u24_to_u32(decmp_hdr->decmp_len);
+	if (state->decmp_len > ZBM_MAX_DECMP_CHUNK_SIZE)
+		return -EINVAL;
+	if (!state->dest) /* We just wanted the length, so we are done */
+		return 0;
+	if (state->decmp_len > state->dest_left)
+		return -ERANGE;
+
+	if (zbm_chunk_is_uncompressed(state))
+		return zbm_handle_uncompressed_chunk(state);
+
+	return zbm_handle_compressed_chunk(state);
+}
+
+int zbm_decompress(void *dest, size_t dest_size, const void *src,
+		   size_t src_size, size_t *out_len)
+{
+	struct zbm_state state = { 0 };
+	int err;
+
+	state.src = src;
+	state.src_left = src_size;
+	state.dest = dest;
+	state.dest_left = dest_size;
+	state.prewritten = 0;
+
+	err = zbm_check_magic(&state);
+	if (err)
+		return err;
+
+	/* The final chunk has zero decompressed length */
+	do {
+		err = zbm_handle_chunk(&state);
+		if (err)
+			return err;
+		state.src += state.len;
+		state.src_left -= state.len;
+		state.prewritten += state.decmp_len;
+	} while (state.decmp_len != 0);
+
+	*out_len = state.prewritten;
+	return 0;
+}
drivers/staging/apfs/libzbitmap.h new file +32 -0
new file mode 100644
index 0000000000000000000000000000000000000000..3b5ac4d828ad5dddc6fbcf32a99ade19ae06046f
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR MIT */
+/*
+ * Copyright (c) 2022 Corellium LLC
+ *
+ * Author: Ernesto A. Fernández <[email protected]>
+ *
+ * Ported from libzbitmap (https://github.com/eafer/libzbitmap). Only the
+ * decompression code is included.
+ */
+
+#ifndef _LIBZBITMAP_H
+#define _LIBZBITMAP_H
+
+#include <linux/errno.h>
+#include <linux/types.h>
+
+/**
+ * zbm_decompress - Decompress an LZBITMAP buffer
+ * @dest:       destination buffer (may be NULL)
+ * @dest_size:  size of the destination buffer
+ * @src:        source buffer
+ * @src_size:   size of the source buffer
+ * @out_len:    on return, the length of the decompressed output
+ *
+ * May be called with a NULL destination buffer to retrieve the expected length
+ * of the decompressed data. Returns 0 on success, or a negative error code in
+ * case of failure.
+ */
+int zbm_decompress(void *dest, size_t dest_size, const void *src,
+		   size_t src_size, size_t *out_len);
+
+#endif /* _LIBZBITMAP_H */
Signature · 1 line
2.48.1
#6 lore raw

RFC PATCH v2 5/8 staging: apfs: init APFS

In reply to Ethan Carter Edwards

This adds read support and experimental write support for the APFS filesystem.

Please note that this is all included in one commit in order to maintain git-bisect functionality and not break the build.

---
 drivers/staging/apfs/apfs.h        | 1192 ++++++++++++++++++
 drivers/staging/apfs/btree.c       | 1174 ++++++++++++++++++
 drivers/staging/apfs/compress.c    |  441 +++++++
 drivers/staging/apfs/dir.c         | 1439 ++++++++++++++++++++++
 drivers/staging/apfs/extents.c     | 2370 ++++++++++++++++++++++++++++++++++++
 drivers/staging/apfs/file.c        |  163 +++
 drivers/staging/apfs/inode.c       | 2234 +++++++++++++++++++++++++++++++++
 drivers/staging/apfs/key.c         |  337 +++++
 drivers/staging/apfs/message.c     |   29 +
 drivers/staging/apfs/namei.c       |  132 ++
 drivers/staging/apfs/node.c        | 2069 +++++++++++++++++++++++++++++++
 drivers/staging/apfs/object.c      |  315 +++++
 drivers/staging/apfs/snapshot.c    |  683 +++++++++++
 drivers/staging/apfs/spaceman.c    | 1433 ++++++++++++++++++++++
 drivers/staging/apfs/super.c       | 2098 +++++++++++++++++++++++++++++++
 drivers/staging/apfs/symlink.c     |   77 ++
 drivers/staging/apfs/transaction.c |  959 +++++++++++++++
 drivers/staging/apfs/xattr.c       |  911 ++++++++++++++
 drivers/staging/apfs/xfield.c      |  171 +++
 19 files changed, 18227 insertions(+)
drivers/staging/apfs/apfs.h new file +1192 -0
new file mode 100644
index 0000000000000000000000000000000000000000..f09440516636c8f3fb12bb70c365af2f32915907
@@ -0,0 +1,1192 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2018 Ernesto A. Fernández <[email protected]>
+ */
+
+#ifndef _APFS_H
+#define _APFS_H
+
+#include <linux/buffer_head.h>
+#include <linux/fs.h>
+#include <linux/list.h>
+#include <linux/types.h>
+#include <linux/version.h>
+
+#include "apfs_raw.h"
+
+#define EFSBADCRC	EBADMSG		/* Bad CRC detected */
+#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
+
+#define apfs_submit_bh(op, op_flags, bh) submit_bh(op | op_flags, bh)
+
+/*
+ * Parameter for the snapshot creation ioctl
+ */
+struct apfs_ioctl_snap_name {
+	char name[APFS_SNAP_MAX_NAMELEN + 1];
+};
+
+#define APFS_IOC_SET_DFLT_PFK	_IOW('@', 0x80, struct apfs_wrapped_crypto_state)
+#define APFS_IOC_SET_DIR_CLASS	_IOW('@', 0x81, u32)
+#define APFS_IOC_SET_PFK	_IOW('@', 0x82, struct apfs_wrapped_crypto_state)
+#define APFS_IOC_GET_CLASS	_IOR('@', 0x83, u32)
+#define APFS_IOC_GET_PFK	_IOR('@', 0x84, struct apfs_wrapped_crypto_state)
+#define APFS_IOC_TAKE_SNAPSHOT	_IOW('@', 0x85, struct apfs_ioctl_snap_name)
+
+/*
+ * In-memory representation of an APFS object
+ */
+struct apfs_object {
+	struct super_block *sb;
+	u64 block_nr;
+	u64 oid;
+
+	/*
+	 * Buffer head containing the one block of the object, may be NULL if
+	 * the object is only in memory. TODO: support objects with more than
+	 * one block.
+	 */
+	struct buffer_head *o_bh;
+	char *data; /* The raw object */
+	bool ephemeral; /* Is this an ephemeral object? */
+};
+
+/* Constants used in managing the size of a node's table of contents */
+#define APFS_BTREE_TOC_ENTRY_INCREMENT	8
+#define APFS_BTREE_TOC_ENTRY_MAX_UNUSED	(2 * BTREE_TOC_ENTRY_INCREMENT)
+
+/*
+ * In-memory representation of an APFS node
+ */
+struct apfs_node {
+	u32 tree_type;		/* Tree type (subtype of the node object) */
+	u16 flags;		/* Node flags */
+	u32 records;		/* Number of records in the node */
+
+	int key;		/* Offset of the key area in the block */
+	int free;		/* Offset of the free area in the block */
+	int val;		/* Offset of the value area in the block */
+
+	int key_free_list_len;	/* Length of the fragmented free key space */
+	int val_free_list_len;	/* Length of the fragmented free value space */
+
+	struct apfs_object object; /* Object holding the node */
+};
+
+/**
+ * apfs_node_is_leaf - Check if a b-tree node is a leaf
+ * @node: the node to check
+ */
+static inline bool apfs_node_is_leaf(struct apfs_node *node)
+{
+	return (node->flags & APFS_BTNODE_LEAF) != 0;
+}
+
+/**
+ * apfs_node_is_root - Check if a b-tree node is the root
+ * @node: the node to check
+ */
+static inline bool apfs_node_is_root(struct apfs_node *node)
+{
+	return (node->flags & APFS_BTNODE_ROOT) != 0;
+}
+
+/**
+ * apfs_node_has_fixed_kv_size - Check if a b-tree node has fixed key/value
+ * sizes
+ * @node: the node to check
+ */
+static inline bool apfs_node_has_fixed_kv_size(struct apfs_node *node)
+{
+	return (node->flags & APFS_BTNODE_FIXED_KV_SIZE) != 0;
+}
+
+struct apfs_ip_bitmap_block_info {
+	bool	dirty;		/* Do we need to commit this block to disk? */
+	void	*block;		/* In-memory address of the bitmap block */
+};
+
+/*
+ * Space manager data in memory.
+ */
+struct apfs_spaceman {
+	struct apfs_spaceman_phys *sm_raw; /* On-disk spaceman structure */
+	struct apfs_nxsb_info	  *sm_nxi; /* Container superblock */
+	u32			  sm_size; /* Size of @sm_raw in bytes */
+
+	u32 sm_blocks_per_chunk;	/* Blocks covered by a bitmap block */
+	u32 sm_chunks_per_cib;		/* Chunk count in a chunk-info block */
+	u64 sm_block_count;		/* Block count for the container */
+	u64 sm_chunk_count;		/* Number of bitmap blocks */
+	u32 sm_cib_count;		/* Number of chunk-info blocks */
+	u64 sm_free_count;		/* Number of free blocks */
+	u32 sm_addr_offset;		/* Offset of cib addresses in @sm_raw */
+
+	/*
+	 * A range of freed blocks not yet put in the free queue. Extend this as
+	 * much as possible before creating an actual record.
+	 */
+	u64 sm_free_cache_base;
+	u64 sm_free_cache_blkcnt;
+
+	/* Shift to match an ip block with its bitmap in the array */
+	int sm_ip_bmaps_shift;
+	/* Mask to find an ip block's offset inside its ip bitmap */
+	u32 sm_ip_bmaps_mask;
+	/* Number of ip bitmaps */
+	u32 sm_ip_bmaps_count;
+	/* List of ip bitmaps, in order */
+	struct apfs_ip_bitmap_block_info sm_ip_bmaps[];
+};
+
+#define APFS_TRANS_MAIN_QUEUE_MAX	10000
+#define APFS_TRANS_BUFFERS_MAX		65536
+#define APFS_TRANS_STARTS_MAX		65536
+
+/* Possible states for the container transaction structure */
+#define APFS_NX_TRANS_FORCE_COMMIT	1	/* Commit guaranteed */
+#define APFS_NX_TRANS_DEFER_COMMIT	2	/* Commit banned right now */
+#define APFS_NX_TRANS_COMMITTING	4	/* Commit ongoing */
+#define APFS_NX_TRANS_INCOMPLETE_BLOCK	8	/* A data block is not written in full */
+
+/*
+ * Structure that keeps track of a container transaction.
+ */
+struct apfs_nx_transaction {
+	unsigned int t_state;
+
+	struct delayed_work t_work;	/* Work task for transaction commits */
+	struct super_block *t_work_sb;	/* sb that last queued a commit */
+
+	struct list_head t_inodes;	/* List of inodes in the transaction */
+	struct list_head t_buffers;	/* List of buffers in the transaction */
+	size_t t_buffers_count;		/* Count of items on the list */
+	int t_starts_count;		/* Count of starts for transaction */
+};
+
+/* State bits for buffer heads in a transaction */
+#define BH_TRANS	BH_PrivateStart		/* Attached to a transaction */
+#define BH_CSUM		(BH_PrivateStart + 1)	/* Requires checksum update */
+BUFFER_FNS(TRANS, trans);
+BUFFER_FNS(CSUM, csum);
+
+/*
+ * Additional information for a buffer in a transaction.
+ */
+struct apfs_bh_info {
+	struct buffer_head	*bh;	/* The buffer head */
+	struct list_head	list;	/* List of buffers in the transaction */
+};
+
+/*
+ * Used to report how many operations may be needed for a transaction
+ */
+struct apfs_max_ops {
+	int cat;	/* Maximum catalog records that may need changing */
+	int blks;	/* Maximum extent blocks that may need changing */
+};
+
+/*
+ * List entry for an in-memory ephemeral object
+ */
+struct apfs_ephemeral_object_info {
+	u64	oid;		/* Ephemeral object id */
+	u32	size;		/* Size of the object in bytes */
+	void	*object;	/* In-memory address of the object */
+};
+
+/*
+ * We allocate a fixed space for the list of ephemeral objects. I don't
+ * actually know how big this should be allowed to get, but all the objects
+ * must be written down with each transaction commit, so probably not too big.
+ */
+#define APFS_EPHEMERAL_LIST_SIZE	32768
+#define APFS_EPHEMERAL_LIST_LIMIT	(APFS_EPHEMERAL_LIST_SIZE / sizeof(struct apfs_ephemeral_object_info))
+
+/* Mount option flags for a container */
+#define APFS_CHECK_NODES	1
+#define APFS_READWRITE		2
+/*
+ * Mount options for a container are decided on its first mount. This flag lets
+ * future mounts know that has happened already.
+ */
+#define APFS_FLAGS_SET		4
+
+/*
+ * Wrapper around block devices for portability.
+ */
+struct apfs_blkdev_info {
+	struct block_device *blki_bdev;
+	struct file *blki_bdev_file;
+
+	/*
+	 * For tier 2, we need to remember the mount path for show_options().
+	 * We don't need this for the main device of course, but better to
+	 * keep things consistent.
+	 */
+	char *blki_path;
+};
+
+/*
+ * Container superblock data in memory
+ */
+struct apfs_nxsb_info {
+	/* Block device info for the container */
+	struct apfs_blkdev_info *nx_blkdev_info;
+	struct apfs_blkdev_info *nx_tier2_info;
+	u64 nx_tier2_bno; /* Offset for tier 2 block numbers */
+
+	struct apfs_nx_superblock *nx_raw; /* On-disk main sb */
+	u64 nx_bno; /* Current block number for the checkpoint superblock */
+	u64 nx_xid; /* Latest transaction id */
+
+	/* List of ephemeral objects in memory (except the superblock) */
+	struct apfs_ephemeral_object_info *nx_eph_list;
+	int nx_eph_count;
+
+	struct list_head vol_list;	/* List of mounted volumes in container */
+
+	unsigned int nx_flags;	/* Mount options shared by all volumes */
+	unsigned int nx_refcnt; /* Number of mounted volumes in container */
+
+	/* TODO: handle block sizes above the maximum of PAGE_SIZE? */
+	unsigned long nx_blocksize;
+	unsigned char nx_blocksize_bits;
+
+	struct apfs_spaceman *nx_spaceman;
+	struct apfs_nx_transaction nx_transaction;
+	int nx_trans_buffers_max;
+
+	/* For now, a single semaphore for every operation */
+	struct rw_semaphore nx_big_sem;
+
+	/* List of currently mounted containers */
+	struct list_head nx_list;
+};
+
+extern struct mutex nxs_mutex;
+
+/*
+ * Omap mapping in memory.
+ * TODO: could this and apfs_omap_rec be the same struct?
+ */
+struct apfs_omap_map {
+	u64 xid;
+	u64 bno;
+	u32 flags;
+};
+
+/*
+ * Omap record data in memory
+ */
+struct apfs_omap_rec {
+	u64 oid;
+	u64 bno;
+};
+
+#define APFS_OMAP_CACHE_SLOTS		128
+#define APFS_OMAP_CACHE_SLOT_MASK	(APFS_OMAP_CACHE_SLOTS - 1)
+
+/**
+ * Cache of omap records
+ */
+struct apfs_omap_cache {
+	struct apfs_omap_rec recs[APFS_OMAP_CACHE_SLOTS];
+	bool disabled;
+	spinlock_t lock;
+};
+
+/*
+ * Omap structure shared by all snapshots for the same volume.
+ */
+struct apfs_omap {
+	struct apfs_node *omap_root;
+	struct apfs_omap_cache omap_cache;
+
+	/* Transaction id for most recent snapshot */
+	u64 omap_latest_snap;
+
+	/* Number of snapshots sharing this omap */
+	unsigned int omap_refcnt;
+};
+
+/*
+ * Volume superblock data in memory
+ */
+struct apfs_sb_info {
+	struct apfs_nxsb_info *s_nxi; /* In-memory container sb for volume */
+	struct list_head list;		/* List of mounted volumes in container */
+	struct apfs_superblock *s_vsb_raw; /* On-disk volume sb */
+
+	dev_t s_anon_dev; /* Anonymous device for this volume-snapshot */
+
+	char *s_tier2_path; /* Path to the tier 2 device */
+
+	char *s_snap_name; /* Label for the mounted snapshot */
+	u64 s_snap_xid; /* Transaction id for mounted snapshot */
+
+	struct apfs_node *s_cat_root;	/* Root of the catalog tree */
+	struct apfs_omap *s_omap;	/* The object map */
+
+	struct apfs_object s_vobject;	/* Volume superblock object */
+
+	/* Mount options */
+	unsigned int s_vol_nr;		/* Index of the volume in the sb list */
+	kuid_t s_uid;			/* uid to override on-disk uid */
+	kgid_t s_gid;			/* gid to override on-disk gid */
+
+	struct apfs_crypto_state_val *s_dflt_pfk; /* default per-file key */
+
+	struct inode *s_private_dir;	/* Inode for the private directory */
+	struct work_struct s_orphan_cleanup_work;
+};
+
+static inline struct apfs_sb_info *APFS_SB(struct super_block *sb)
+{
+	return sb->s_fs_info;
+}
+
+static inline bool apfs_is_sealed(struct super_block *sb)
+{
+	u64 flags = le64_to_cpu(APFS_SB(sb)->s_vsb_raw->apfs_incompatible_features);
+
+	return flags & APFS_INCOMPAT_SEALED_VOLUME;
+}
+
+/**
+ * apfs_vol_is_encrypted - Check if a volume is encrypting files
+ * @sb: superblock
+ */
+static inline bool apfs_vol_is_encrypted(struct super_block *sb)
+{
+	struct apfs_superblock *vsb_raw = APFS_SB(sb)->s_vsb_raw;
+
+	return (vsb_raw->apfs_fs_flags & cpu_to_le64(APFS_FS_UNENCRYPTED)) == 0;
+}
+
+/**
+ * APFS_NXI - Get the shared container info for a volume's superblock
+ * @sb: superblock structure
+ */
+static inline struct apfs_nxsb_info *APFS_NXI(struct super_block *sb)
+{
+	return APFS_SB(sb)->s_nxi;
+}
+
+/**
+ * APFS_SM - Get the shared spaceman struct for a volume's superblock
+ * @sb: superblock structure
+ */
+static inline struct apfs_spaceman *APFS_SM(struct super_block *sb)
+{
+	return APFS_NXI(sb)->nx_spaceman;
+}
+
+static inline bool apfs_is_case_insensitive(struct super_block *sb)
+{
+	return (APFS_SB(sb)->s_vsb_raw->apfs_incompatible_features &
+	       cpu_to_le64(APFS_INCOMPAT_CASE_INSENSITIVE)) != 0;
+}
+
+static inline bool apfs_is_normalization_insensitive(struct super_block *sb)
+{
+	struct apfs_sb_info *sbi = APFS_SB(sb);
+	u64 flags = le64_to_cpu(sbi->s_vsb_raw->apfs_incompatible_features);
+
+	if (apfs_is_case_insensitive(sb))
+		return true;
+	if (flags & APFS_INCOMPAT_NORMALIZATION_INSENSITIVE)
+		return true;
+	return false;
+}
+
+/**
+ * apfs_max_maps_per_block - Find the maximum map count for a mapping block
+ * @sb: superblock structure
+ */
+static inline int apfs_max_maps_per_block(struct super_block *sb)
+{
+	unsigned long maps_size;
+
+	maps_size = (sb->s_blocksize - sizeof(struct apfs_checkpoint_map_phys));
+	return maps_size / sizeof(struct apfs_checkpoint_mapping);
+}
+
+/*
+ * In-memory representation of a key, as relevant for a b-tree query.
+ */
+struct apfs_key {
+	u64		id;
+	u64		number;	/* Extent offset, name hash or transaction id */
+	const char	*name;	/* On-disk name string */
+	u8		type;	/* Record type (0 for the omap) */
+};
+
+/**
+ * apfs_init_free_queue_key - Initialize an in-memory key for a free queue query
+ * @xid:	transaction id
+ * @paddr:	block number
+ * @key:	apfs_key structure to initialize
+ */
+static inline void apfs_init_free_queue_key(u64 xid, u64 paddr,
+					    struct apfs_key *key)
+{
+	key->id = xid;
+	key->type = 0;
+	key->number = paddr;
+	key->name = NULL;
+}
+
+/**
+ * apfs_init_omap_key - Initialize an in-memory key for an omap query
+ * @oid:	object id
+ * @xid:	latest transaction id
+ * @key:	apfs_key structure to initialize
+ */
+static inline void apfs_init_omap_key(u64 oid, u64 xid, struct apfs_key *key)
+{
+	key->id = oid;
+	key->type = 0;
+	key->number = xid;
+	key->name = NULL;
+}
+
+/**
+ * apfs_init_extent_key - Initialize an in-memory key for an extentref query
+ * @bno:	physical block number for the start of the extent
+ * @key:	apfs_key structure to initialize
+ */
+static inline void apfs_init_extent_key(u64 bno, struct apfs_key *key)
+{
+	key->id = bno;
+	key->type = APFS_TYPE_EXTENT;
+	key->number = 0;
+	key->name = NULL;
+}
+
+/**
+ * apfs_init_inode_key - Initialize an in-memory key for an inode query
+ * @ino:	inode number
+ * @key:	apfs_key structure to initialize
+ */
+static inline void apfs_init_inode_key(u64 ino, struct apfs_key *key)
+{
+	key->id = ino;
+	key->type = APFS_TYPE_INODE;
+	key->number = 0;
+	key->name = NULL;
+}
+
+/**
+ * apfs_init_file_extent_key - Initialize an in-memory key for an extent query
+ * @id:		extent id
+ * @offset:	logical address (0 for a multiple query)
+ * @key:	apfs_key structure to initialize
+ */
+static inline void apfs_init_file_extent_key(u64 id, u64 offset,
+					     struct apfs_key *key)
+{
+	key->id = id;
+	key->type = APFS_TYPE_FILE_EXTENT;
+	key->number = offset;
+	key->name = NULL;
+}
+
+static inline void apfs_init_fext_key(u64 id, u64 offset, struct apfs_key *key)
+{
+	key->id = id;
+	key->type = 0;
+	key->number = offset;
+	key->name = NULL;
+}
+
+/**
+ * apfs_init_dstream_id_key - Initialize an in-memory key for a dstream query
+ * @id:		data stream id
+ * @key:	apfs_key structure to initialize
+ */
+static inline void apfs_init_dstream_id_key(u64 id, struct apfs_key *key)
+{
+	key->id = id;
+	key->type = APFS_TYPE_DSTREAM_ID;
+	key->number = 0;
+	key->name = NULL;
+}
+
+/**
+ * apfs_init_crypto_state_key - Initialize an in-memory key for a crypto query
+ * @id:		crypto state id
+ * @key:	apfs_key structure to initialize
+ */
+static inline void apfs_init_crypto_state_key(u64 id, struct apfs_key *key)
+{
+	key->id = id;
+	key->type = APFS_TYPE_CRYPTO_STATE;
+	key->number = 0;
+	key->name = NULL;
+}
+
+/**
+ * apfs_init_sibling_link_key - Initialize an in-memory key for a sibling query
+ * @ino:	inode number
+ * @id:		sibling id
+ * @key:	apfs_key structure to initialize
+ */
+static inline void apfs_init_sibling_link_key(u64 ino, u64 id,
+					      struct apfs_key *key)
+{
+	key->id = ino;
+	key->type = APFS_TYPE_SIBLING_LINK;
+	key->number = id; /* Only guessing (TODO) */
+	key->name = NULL;
+}
+
+/**
+ * apfs_init_sibling_map_key - Initialize in-memory key for a sibling map query
+ * @id:		sibling id
+ * @key:	apfs_key structure to initialize
+ */
+static inline void apfs_init_sibling_map_key(u64 id, struct apfs_key *key)
+{
+	key->id = id;
+	key->type = APFS_TYPE_SIBLING_MAP;
+	key->number = 0;
+	key->name = NULL;
+}
+
+extern void apfs_init_drec_key(struct super_block *sb, u64 ino, const char *name,
+			       unsigned int name_len, struct apfs_key *key);
+
+/**
+ * apfs_init_xattr_key - Initialize an in-memory key for a xattr query
+ * @ino:	inode number of the parent file
+ * @name:	xattr name (NULL for a multiple query)
+ * @key:	apfs_key structure to initialize
+ */
+static inline void apfs_init_xattr_key(u64 ino, const char *name,
+				       struct apfs_key *key)
+{
+	key->id = ino;
+	key->type = APFS_TYPE_XATTR;
+	key->number = 0;
+	key->name = name;
+}
+
+static inline void apfs_init_snap_metadata_key(u64 xid, struct apfs_key *key)
+{
+	key->id = xid;
+	key->type = APFS_TYPE_SNAP_METADATA;
+	key->number = 0;
+	key->name = NULL;
+}
+
+static inline void apfs_init_snap_name_key(const char *name, struct apfs_key *key)
+{
+	key->id = APFS_SNAP_NAME_OBJ_ID;
+	key->type = APFS_TYPE_SNAP_NAME;
+	key->number = 0;
+	key->name = name;
+}
+
+static inline void apfs_init_omap_snap_key(u64 xid, struct apfs_key *key)
+{
+	key->id = xid;
+	key->type = 0;
+	key->number = 0;
+	key->name = NULL;
+}
+
+/**
+ * apfs_key_set_hdr - Set the header for a raw catalog key
+ * @type:	record type
+ * @id:		record id
+ * @key:	the key to initialize
+ */
+static inline void apfs_key_set_hdr(u64 type, u64 id, void *key)
+{
+	struct apfs_key_header *hdr = key;
+
+	hdr->obj_id_and_type = cpu_to_le64(id | type << APFS_OBJ_TYPE_SHIFT);
+}
+
+/**
+ * apfs_cat_type - Read the record type of a catalog key
+ * @key: the raw catalog key
+ */
+static inline int apfs_cat_type(struct apfs_key_header *key)
+{
+	return (le64_to_cpu(key->obj_id_and_type) & APFS_OBJ_TYPE_MASK) >> APFS_OBJ_TYPE_SHIFT;
+}
+
+/**
+ * apfs_cat_cnid - Read the cnid value on a catalog key
+ * @key: the raw catalog key
+ *
+ * TODO: rename this function, since it's not just for the catalog anymore
+ */
+static inline u64 apfs_cat_cnid(struct apfs_key_header *key)
+{
+	return le64_to_cpu(key->obj_id_and_type) & APFS_OBJ_ID_MASK;
+}
+
+/* Flags for the query structure */
+#define APFS_QUERY_TREE_MASK	000177	/* Which b-tree we query */
+#define APFS_QUERY_OMAP		000001	/* This is a b-tree object map query */
+#define APFS_QUERY_CAT		000002	/* This is a catalog tree query */
+#define APFS_QUERY_FREE_QUEUE	000004	/* This is a free queue query */
+#define APFS_QUERY_EXTENTREF	000010	/* This is an extent reference query */
+#define APFS_QUERY_FEXT		000020	/* This is a fext tree query */
+#define APFS_QUERY_SNAP_META	000040	/* This is a snapshot meta query */
+#define APFS_QUERY_OMAP_SNAP	000100	/* This is an omap snapshots query */
+#define APFS_QUERY_NEXT		000200	/* Find next of multiple matches */
+#define APFS_QUERY_EXACT	000400	/* Search for an exact match */
+#define APFS_QUERY_DONE		001000	/* The search at this level is over */
+#define APFS_QUERY_ANY_NAME	002000	/* Multiple search for any name */
+#define APFS_QUERY_ANY_NUMBER	004000	/* Multiple search for any number */
+#define APFS_QUERY_MULTIPLE	(APFS_QUERY_ANY_NAME | APFS_QUERY_ANY_NUMBER)
+#define APFS_QUERY_PREV		010000	/* Find previous record */
+
+/*
+ * Structure used to retrieve data from an APFS B-Tree.
+ */
+struct apfs_query {
+	struct apfs_node *node;		/* Node being searched */
+	struct apfs_key key;		/* What the query is looking for */
+
+	struct apfs_query *parent;	/* Query for parent node */
+	unsigned int flags;
+
+	/* Set by the query on success */
+	int index;			/* Index of the entry in the node */
+	int key_off;			/* Offset of the key in the node */
+	int key_len;			/* Length of the key */
+	int off;			/* Offset of the value in the node */
+	int len;			/* Length of the value */
+
+	int depth;			/* Put a limit on recursion */
+};
+
+/**
+ * apfs_query_storage - Get the storage type for a query's btree
+ * @query: the query structure
+ */
+static inline u32 apfs_query_storage(struct apfs_query *query)
+{
+	if (query->flags & APFS_QUERY_OMAP)
+		return APFS_OBJ_PHYSICAL;
+	if (query->flags & APFS_QUERY_CAT)
+		return APFS_OBJ_VIRTUAL;
+	if (query->flags & APFS_QUERY_FEXT)
+		return APFS_OBJ_PHYSICAL;
+	if (query->flags & APFS_QUERY_FREE_QUEUE)
+		return APFS_OBJ_EPHEMERAL;
+	if (query->flags & APFS_QUERY_EXTENTREF)
+		return APFS_OBJ_PHYSICAL;
+	if (query->flags & APFS_QUERY_SNAP_META)
+		return APFS_OBJ_PHYSICAL;
+	if (query->flags & APFS_QUERY_OMAP_SNAP)
+		return APFS_OBJ_PHYSICAL;
+
+	/* Absurd, but don't panic: let the callers fail and report it */
+	return -1;
+}
+
+/*
+ * Extent record data in memory
+ */
+struct apfs_file_extent {
+	u64 logical_addr;
+	u64 phys_block_num;
+	u64 len;
+	u64 crypto_id;
+};
+
+/*
+ * Physical extent record data in memory
+ */
+struct apfs_phys_extent {
+	u64 bno;
+	u64 blkcount;
+	u64 len;	/* In bytes */
+	u32 refcnt;
+	u8 kind;
+};
+
+/*
+ * Data stream info in memory
+ */
+struct apfs_dstream_info {
+	struct super_block	*ds_sb;		/* Filesystem superblock */
+	struct inode		*ds_inode;	/* NULL for xattr dstreams */
+	u64			ds_id;		/* ID of the extent records */
+	u64			ds_size;	/* Length of the stream */
+	u64			ds_sparse_bytes;/* Hole byte count in stream */
+	struct apfs_file_extent	ds_cached_ext;	/* Latest extent record */
+	bool			ds_ext_dirty;	/* Is ds_cached_ext dirty? */
+	spinlock_t		ds_ext_lock;	/* Protects ds_cached_ext */
+	bool			ds_shared;	/* Has multiple references? */
+};
+
+/**
+ * apfs_alloced_size - Return the alloced size for a data stream
+ * @dstream: data stream info
+ *
+ * TODO: is this always correct? Or could the extents have an unused tail?
+ */
+static inline u64 apfs_alloced_size(struct apfs_dstream_info *dstream)
+{
+	struct super_block *sb = dstream->ds_sb;
+	u64 blks = (dstream->ds_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
+
+	return blks << sb->s_blocksize_bits;
+}
+
+/*
+ * APFS inode data in memory
+ */
+struct apfs_inode_info {
+	u64			i_ino64;	 /* 32-bit-safe inode number */
+	u64			i_parent_id;	 /* ID of primary parent */
+	struct timespec64	i_crtime;	 /* Time of creation */
+	u32			i_nchildren;	 /* Child count for directory */
+	uid_t			i_saved_uid;	 /* User ID on disk */
+	gid_t			i_saved_gid;	 /* Group ID on disk */
+	u32			i_key_class;	 /* Security class for directory */
+	u64			i_int_flags;	 /* Internal flags */
+	u32			i_bsd_flags;	 /* BSD flags */
+	struct list_head	i_list;		 /* List of inodes in transaction */
+
+	bool			 i_has_dstream;	 /* Is there a dstream record? */
+	struct apfs_dstream_info i_dstream;	 /* Dstream data, if any */
+
+	bool			i_cleaned;	 /* Orphan data already deleted */
+
+	struct inode vfs_inode;
+};
+
+static inline struct apfs_inode_info *APFS_I(const struct inode *inode)
+{
+	return container_of(inode, struct apfs_inode_info, vfs_inode);
+}
+
+/**
+ * apfs_ino - Get the 64-bit id of an inode
+ * @inode: the vfs inode
+ *
+ * Returns all 64 bits of @inode's id, even on 32-bit architectures.
+ */
+static inline u64 apfs_ino(const struct inode *inode)
+{
+	return APFS_I(inode)->i_ino64;
+}
+
+/**
+ * apfs_set_ino - Set a 64-bit id on an inode
+ * @inode: the vfs inode
+ * @id:	   id to set
+ *
+ * Sets both the vfs inode number and the actual 32-bit-safe id.
+ */
+static inline void apfs_set_ino(struct inode *inode, u64 id)
+{
+	inode->i_ino = id; /* Higher bits may be lost, but it doesn't matter */
+	APFS_I(inode)->i_ino64 = id;
+}
+
+/* Make the compiler complain if we ever access i_ino directly by mistake */
+#define i_ino	DONT_USE_I_INO
+
+/*
+ * Directory entry record in memory
+ */
+struct apfs_drec {
+	u8 *name;
+	u64 ino;
+	u64 sibling_id; /* The sibling id; 0 if none */
+	int name_len;
+	unsigned int type;
+};
+
+/*
+ * Xattr record data in memory
+ */
+struct apfs_xattr {
+	u8 *name;
+	u8 *xdata;
+	int name_len;
+	int xdata_len;
+	bool has_dstream;
+};
+
+struct apfs_compressed_data {
+	bool has_dstream;
+	u64 size;
+	union {
+		struct apfs_dstream_info *dstream;
+		void *data;
+	};
+};
+
+/*
+ * Report function name and line number for the message types that are likely
+ * to signal a bug, to make things easier for reporters. Don't do this for the
+ * common messages, there is no point and it makes the console look too busy.
+ */
+#define apfs_emerg(sb, fmt, ...) apfs_msg(sb, KERN_EMERG, __func__, __LINE__, fmt, ##__VA_ARGS__)
+#define apfs_alert(sb, fmt, ...) apfs_msg(sb, KERN_ALERT, __func__, __LINE__, fmt, ##__VA_ARGS__)
+#define apfs_crit(sb, fmt, ...) apfs_msg(sb, KERN_CRIT, __func__, __LINE__, fmt, ##__VA_ARGS__)
+#define apfs_err(sb, fmt, ...) apfs_msg(sb, KERN_ERR, __func__, __LINE__, fmt, ##__VA_ARGS__)
+#define apfs_warn(sb, fmt, ...) apfs_msg(sb, KERN_WARNING, NULL, 0, fmt, ##__VA_ARGS__)
+#define apfs_notice(sb, fmt, ...) apfs_msg(sb, KERN_NOTICE, NULL, 0, fmt, ##__VA_ARGS__)
+#define apfs_info(sb, fmt, ...) apfs_msg(sb, KERN_INFO, NULL, 0, fmt, ##__VA_ARGS__)
+
+#ifdef CONFIG_APFS_DEBUG
+#define ASSERT(expr)	WARN_ON(!(expr))
+#define apfs_debug(sb, fmt, ...) apfs_msg(sb, KERN_DEBUG, __func__, __LINE__, fmt, ##__VA_ARGS__)
+#else
+#define ASSERT(expr)	((void)0)
+#define apfs_debug(sb, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
+#endif /* CONFIG_APFS_DEBUG */
+
+/**
+ * apfs_assert_in_transaction - Assert that the object is in current transaction
+ * @sb:		superblock structure
+ * @obj:	on-disk object to check
+ */
+#define apfs_assert_in_transaction(sb, obj)				\
+do {									\
+	(void)sb;							\
+	(void)obj;							\
+	ASSERT(le64_to_cpu((obj)->o_xid) == APFS_NXI(sb)->nx_xid);	\
+} while (0)
+
+/* btree.c */
+extern struct apfs_node *apfs_query_root(const struct apfs_query *query);
+extern struct apfs_query *apfs_alloc_query(struct apfs_node *node,
+					   struct apfs_query *parent);
+extern void apfs_free_query(struct apfs_query *query);
+extern int apfs_btree_query(struct super_block *sb, struct apfs_query **query);
+extern int apfs_omap_lookup_block(struct super_block *sb, struct apfs_omap *omap, u64 id, u64 *block, bool write);
+extern int apfs_omap_lookup_newest_block(struct super_block *sb, struct apfs_omap *omap, u64 id, u64 *block, bool write);
+extern int apfs_create_omap_rec(struct super_block *sb, u64 oid, u64 bno);
+extern int apfs_delete_omap_rec(struct super_block *sb, u64 oid);
+extern int apfs_query_join_transaction(struct apfs_query *query);
+extern int __apfs_btree_insert(struct apfs_query *query, void *key, int key_len, void *val, int val_len);
+extern int apfs_btree_insert(struct apfs_query *query, void *key, int key_len,
+			     void *val, int val_len);
+extern int apfs_btree_remove(struct apfs_query *query);
+extern void apfs_btree_change_node_count(struct apfs_query *query, int change);
+extern int apfs_btree_replace(struct apfs_query *query, void *key, int key_len,
+			      void *val, int val_len);
+extern void apfs_query_direct_forward(struct apfs_query *query);
+
+/* compress.c */
+extern int apfs_compress_get_size(struct inode *inode, loff_t *size);
+
+/* dir.c */
+extern int apfs_inode_by_name(struct inode *dir, const struct qstr *child,
+			      u64 *ino);
+extern int apfs_mkany(struct inode *dir, struct dentry *dentry,
+		      umode_t mode, dev_t rdev, const char *symname);
+
+extern int apfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+		      struct dentry *dentry, umode_t mode, dev_t rdev);
+extern int apfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+		      struct dentry *dentry, umode_t mode);
+extern int apfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+		       struct dentry *old_dentry, struct inode *new_dir,
+		       struct dentry *new_dentry, unsigned int flags);
+extern int apfs_create(struct mnt_idmap *idmap, struct inode *dir,
+		       struct dentry *dentry, umode_t mode, bool excl);
+
+extern int apfs_link(struct dentry *old_dentry, struct inode *dir,
+		     struct dentry *dentry);
+extern int apfs_unlink(struct inode *dir, struct dentry *dentry);
+extern int apfs_rmdir(struct inode *dir, struct dentry *dentry);
+extern int apfs_delete_orphan_link(struct inode *inode);
+extern int APFS_DELETE_ORPHAN_LINK_MAXOPS(void);
+extern u64 apfs_any_orphan_ino(struct super_block *sb, u64 *ino_p);
+
+/* extents.c */
+extern int apfs_extent_from_query(struct apfs_query *query,
+				  struct apfs_file_extent *extent);
+extern int apfs_logic_to_phys_bno(struct apfs_dstream_info *dstream, sector_t dsblock, u64 *bno);
+extern int __apfs_get_block(struct apfs_dstream_info *dstream, sector_t iblock,
+			    struct buffer_head *bh_result, int create);
+extern int apfs_get_block(struct inode *inode, sector_t iblock,
+			  struct buffer_head *bh_result, int create);
+extern int apfs_flush_extent_cache(struct apfs_dstream_info *dstream);
+extern int apfs_dstream_get_new_bno(struct apfs_dstream_info *dstream, u64 dsblock, u64 *bno);
+extern int apfs_get_new_block(struct inode *inode, sector_t iblock,
+			      struct buffer_head *bh_result, int create);
+extern int APFS_GET_NEW_BLOCK_MAXOPS(void);
+extern int apfs_truncate(struct apfs_dstream_info *dstream, loff_t new_size);
+extern int apfs_inode_delete_front(struct inode *inode);
+extern loff_t apfs_remap_file_range(struct file *src_file, loff_t off, struct file *dst_file, loff_t destoff, loff_t len, unsigned int remap_flags);
+extern int apfs_clone_extents(struct apfs_dstream_info *dstream, u64 new_id);
+extern int apfs_nonsparse_dstream_read(struct apfs_dstream_info *dstream, void *buf, size_t count, u64 offset);
+extern void apfs_nonsparse_dstream_preread(struct apfs_dstream_info *dstream);
+
+/* file.c */
+extern int apfs_file_mmap(struct file *file, struct vm_area_struct *vma);
+extern int apfs_fsync(struct file *file, loff_t start, loff_t end, int datasync);
+
+/* inode.c */
+extern struct inode *apfs_iget(struct super_block *sb, u64 cnid);
+extern int apfs_update_inode(struct inode *inode, char *new_name);
+extern int APFS_UPDATE_INODE_MAXOPS(void);
+extern void apfs_orphan_cleanup_work(struct work_struct *work);
+extern void apfs_evict_inode(struct inode *inode);
+extern struct inode *apfs_new_inode(struct inode *dir, umode_t mode,
+				    dev_t rdev);
+extern int apfs_create_inode_rec(struct super_block *sb, struct inode *inode,
+				 struct dentry *dentry);
+extern int apfs_inode_create_exclusive_dstream(struct inode *inode);
+extern int APFS_CREATE_INODE_REC_MAXOPS(void);
+extern int __apfs_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned int len, unsigned int flags, struct page **pagep, void **fsdata);
+extern int __apfs_write_end(struct file *file, struct address_space *mapping, loff_t pos, unsigned int len, unsigned int copied, struct page *page, void *fsdata);
+extern int apfs_dstream_adj_refcnt(struct apfs_dstream_info *dstream, u32 delta);
+extern int apfs_setattr(struct mnt_idmap *idmap,
+			struct dentry *dentry, struct iattr *iattr);
+
+extern int apfs_update_time(struct inode *inode, int flags);
+long apfs_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+long apfs_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+
+extern int apfs_getattr(struct mnt_idmap *idmap,
+		const struct path *path, struct kstat *stat, u32 request_mask,
+		unsigned int query_flags);
+
+extern int apfs_crypto_adj_refcnt(struct super_block *sb, u64 crypto_id, int delta);
+extern int APFS_CRYPTO_ADJ_REFCNT_MAXOPS(void);
+
+extern int apfs_fileattr_get(struct dentry *dentry, struct fileattr *fa);
+extern int apfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry, struct fileattr *fa);
+
+/* key.c */
+extern int apfs_filename_cmp(struct super_block *sb, const char *name1, unsigned int len1, const char *name2, unsigned int len2);
+extern int apfs_keycmp(struct apfs_key *k1, struct apfs_key *k2);
+extern int apfs_read_cat_key(void *raw, int size, struct apfs_key *key, bool hashed);
+extern int apfs_read_fext_key(void *raw, int size, struct apfs_key *key);
+extern int apfs_read_free_queue_key(void *raw, int size, struct apfs_key *key);
+extern int apfs_read_omap_key(void *raw, int size, struct apfs_key *key);
+extern int apfs_read_extentref_key(void *raw, int size, struct apfs_key *key);
+extern int apfs_read_snap_meta_key(void *raw, int size, struct apfs_key *key);
+extern int apfs_read_omap_snap_key(void *raw, int size, struct apfs_key *key);
+
+/* message.c */
+extern __printf(5, 6) void apfs_msg(struct super_block *sb, const char *prefix, const char *func, int line, const char *fmt, ...);
+
+/* node.c */
+extern struct apfs_node *apfs_read_node(struct super_block *sb, u64 oid,
+					u32 storage, bool write);
+extern void apfs_update_node(struct apfs_node *node);
+extern int apfs_delete_node(struct apfs_node *node, int type);
+extern int apfs_node_query(struct super_block *sb, struct apfs_query *query);
+extern void apfs_node_query_first(struct apfs_query *query);
+extern int apfs_omap_map_from_query(struct apfs_query *query, struct apfs_omap_map *map);
+extern int apfs_node_split(struct apfs_query *query);
+extern int apfs_node_locate_key(struct apfs_node *node, int index, int *off);
+extern void apfs_node_free(struct apfs_node *node);
+extern void apfs_node_free_range(struct apfs_node *node, u16 off, u16 len);
+extern bool apfs_node_has_room(struct apfs_node *node, int length, bool replace);
+extern int apfs_node_replace(struct apfs_query *query, void *key, int key_len, void *val, int val_len);
+extern int apfs_node_insert(struct apfs_query *query, void *key, int key_len, void *val, int val_len);
+extern int apfs_create_single_rec_node(struct apfs_query *query, void *key, int key_len, void *val, int val_len);
+extern int apfs_make_empty_btree_root(struct super_block *sb, u32 subtype, u64 *oid);
+
+/* object.c */
+extern int apfs_obj_verify_csum(struct super_block *sb, struct buffer_head *bh);
+extern void apfs_obj_set_csum(struct super_block *sb, struct apfs_obj_phys *obj);
+extern int apfs_multiblock_verify_csum(char *object, u32 size);
+extern void apfs_multiblock_set_csum(char *object, u32 size);
+extern int apfs_create_cpm_block(struct super_block *sb, u64 bno, struct buffer_head **bh_p);
+extern int apfs_create_cpoint_map(struct super_block *sb, struct apfs_checkpoint_map_phys *cpm, struct apfs_obj_phys *obj, u64 bno, u32 size);
+extern struct apfs_ephemeral_object_info *apfs_ephemeral_object_lookup(struct super_block *sb, u64 oid);
+extern struct buffer_head *apfs_read_object_block(struct super_block *sb, u64 bno, bool write, bool preserve);
+extern u32 apfs_index_in_data_area(struct super_block *sb, u64 bno);
+extern u64 apfs_data_index_to_bno(struct super_block *sb, u32 index);
+
+/* snapshot.c */
+extern int apfs_ioc_take_snapshot(struct file *file, void __user *user_arg);
+extern int apfs_switch_to_snapshot(struct super_block *sb);
+
+/* spaceman.c */
+extern int apfs_read_spaceman(struct super_block *sb);
+extern int apfs_free_queue_insert_nocache(struct super_block *sb, u64 bno, u64 count);
+extern int apfs_free_queue_insert(struct super_block *sb, u64 bno, u64 count);
+extern int apfs_spaceman_allocate_block(struct super_block *sb, u64 *bno, bool backwards);
+extern int apfs_write_ip_bitmaps(struct super_block *sb);
+
+/* super.c */
+extern int apfs_map_volume_super_bno(struct super_block *sb, u64 bno, bool check);
+extern int apfs_map_volume_super(struct super_block *sb, bool write);
+extern void apfs_unmap_volume_super(struct super_block *sb);
+extern int apfs_read_omap(struct super_block *sb, bool write);
+extern int apfs_read_catalog(struct super_block *sb, bool write);
+extern int apfs_sync_fs(struct super_block *sb, int wait);
+
+/* transaction.c */
+extern int apfs_cpoint_data_free(struct super_block *sb, u64 bno);
+extern void apfs_transaction_init(struct apfs_nx_transaction *trans);
+extern int apfs_transaction_start(struct super_block *sb, struct apfs_max_ops maxops);
+extern int apfs_transaction_commit(struct super_block *sb);
+extern void apfs_inode_join_transaction(struct super_block *sb, struct inode *inode);
+extern int apfs_transaction_join(struct super_block *sb,
+				 struct buffer_head *bh);
+void apfs_transaction_abort(struct super_block *sb);
+extern int apfs_transaction_flush_all_inodes(struct super_block *sb);
+
+/* xattr.c */
+extern int ____apfs_xattr_get(struct inode *inode, const char *name, void *buffer,
+			      size_t size, bool only_whole);
+extern int __apfs_xattr_get(struct inode *inode, const char *name, void *buffer,
+			    size_t size);
+extern int apfs_delete_all_xattrs(struct inode *inode);
+extern int apfs_xattr_set(struct inode *inode, const char *name, const void *value,
+			  size_t size, int flags);
+extern int APFS_XATTR_SET_MAXOPS(void);
+extern ssize_t apfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
+extern int apfs_xattr_get_compressed_data(struct inode *inode, const char *name, struct apfs_compressed_data *cdata);
+extern void apfs_release_compressed_data(struct apfs_compressed_data *cdata);
+extern int apfs_compressed_data_read(struct apfs_compressed_data *cdata, void *buf, size_t count, u64 offset);
+
+/* xfield.c */
+extern int apfs_find_xfield(u8 *xfields, int len, u8 xtype, char **xval);
+extern int apfs_init_xfields(u8 *buffer, int buflen);
+extern int apfs_insert_xfield(u8 *buffer, int buflen,
+			      const struct apfs_x_field *xkey,
+			      const void *xval);
+
+/*
+ * Inode and file operations
+ */
+
+/* compress.c */
+extern const struct address_space_operations apfs_compress_aops;
+extern const struct file_operations apfs_compress_file_operations;
+
+/* dir.c */
+extern const struct file_operations apfs_dir_operations;
+
+/* file.c */
+extern const struct file_operations apfs_file_operations;
+extern const struct inode_operations apfs_file_inode_operations;
+
+/* namei.c */
+extern const struct inode_operations apfs_dir_inode_operations;
+extern const struct inode_operations apfs_special_inode_operations;
+extern const struct dentry_operations apfs_dentry_operations;
+
+/* symlink.c */
+extern const struct inode_operations apfs_symlink_inode_operations;
+
+/* xattr.c */
+extern const struct xattr_handler *apfs_xattr_handlers[];
+
+/**
+ * apfs_assert_query_is_valid - Assert that all of a query's ancestors are set
+ * @query: the query to check
+ *
+ * A query may lose some of its ancestors during a node split, but nothing
+ * should be done to such a query until it gets refreshed.
+ */
+static inline void apfs_assert_query_is_valid(const struct apfs_query *query)
+{
+	ASSERT(apfs_node_is_root(apfs_query_root(query)));
+}
+
+/*
+ * TODO: the following are modified variants of buffer head functions that will
+ * work with the shared block device for the container. The correct approach
+ * here would be to avoid buffer heads and use bios, but for now this will do.
+ */
+
+static inline void
+apfs_map_bh(struct buffer_head *bh, struct super_block *sb, sector_t block)
+{
+	struct apfs_nxsb_info *nxi = NULL;
+	struct apfs_blkdev_info *info = NULL;
+
+	nxi = APFS_NXI(sb);
+	info = nxi->nx_blkdev_info;
+
+	/*
+	 * Block numbers above s_tier2_bno are for the tier 2 device of a
+	 * fusion drive. Don't bother returning an error code if a regular
+	 * drive gets corrupted and reports a tier 2 block number: just treat
+	 * it the same as any other out-of-range block.
+	 */
+	if (block >= nxi->nx_tier2_bno) {
+		if (nxi->nx_tier2_info) {
+			info = nxi->nx_tier2_info;
+			block -= nxi->nx_tier2_bno;
+		} else {
+			apfs_err(sb, "block number in tier 2 range (0x%llx)", (unsigned long long)block);
+		}
+	}
+
+	set_buffer_mapped(bh);
+	bh->b_bdev = info->blki_bdev;
+	bh->b_blocknr = block;
+	bh->b_size = sb->s_blocksize;
+}
+
+static inline struct buffer_head *
+apfs_sb_bread(struct super_block *sb, sector_t block)
+{
+	struct apfs_nxsb_info *nxi = NULL;
+	struct apfs_blkdev_info *info = NULL;
+
+	nxi = APFS_NXI(sb);
+	info = nxi->nx_blkdev_info;
+
+	if (block >= nxi->nx_tier2_bno) {
+		if (!nxi->nx_tier2_info) {
+			/* Not really a fusion drive, so it's corrupted */
+			apfs_err(sb, "block number in tier 2 range (0x%llx)", (unsigned long long)block);
+			return NULL;
+		}
+		info = nxi->nx_tier2_info;
+		block -= nxi->nx_tier2_bno;
+	}
+
+	return __bread_gfp(info->blki_bdev, block, sb->s_blocksize, __GFP_MOVABLE);
+}
+
+/* Like apfs_getblk(), but doesn't mark the buffer uptodate */
+static inline struct buffer_head *
+__apfs_getblk(struct super_block *sb, sector_t block)
+{
+	struct apfs_nxsb_info *nxi = NULL;
+	struct apfs_blkdev_info *info = NULL;
+
+	nxi = APFS_NXI(sb);
+	info = nxi->nx_blkdev_info;
+
+	if (block >= nxi->nx_tier2_bno) {
+		if (!nxi->nx_tier2_info) {
+			/* Not really a fusion drive, so it's corrupted */
+			apfs_err(sb, "block number in tier 2 range (0x%llx)", (unsigned long long)block);
+			return NULL;
+		}
+		info = nxi->nx_tier2_info;
+		block -= nxi->nx_tier2_bno;
+	}
+
+	return bdev_getblk(info->blki_bdev, block, sb->s_blocksize, __GFP_MOVABLE);
+}
+
+/* Use instead of apfs_sb_bread() for blocks that will just be overwritten */
+static inline struct buffer_head *
+apfs_getblk(struct super_block *sb, sector_t block)
+{
+	struct buffer_head *bh = NULL;
+
+	bh = __apfs_getblk(sb, block);
+	if (bh)
+		set_buffer_uptodate(bh);
+	return bh;
+}
+
+#endif	/* _APFS_H */
drivers/staging/apfs/btree.c new file +1174 -0

1,174 lines not on this page · raw message

drivers/staging/apfs/compress.c new file +441 -0

441 lines not on this page · raw message

drivers/staging/apfs/dir.c new file +1439 -0

193 lines not on this page · raw message

drivers/staging/apfs/extents.c new file +2370 -0

2,370 lines not on this page · raw message

drivers/staging/apfs/file.c new file +163 -0

163 lines not on this page · raw message

drivers/staging/apfs/inode.c new file +2234 -0

2,234 lines not on this page · raw message

drivers/staging/apfs/key.c new file +337 -0

337 lines not on this page · raw message

drivers/staging/apfs/message.c new file +29 -0
new file mode 100644
index 0000000000000000000000000000000000000000..fdd74ccb8e37924df14488d1ff3fca6d76c73b3b

Lines of this file are not shown. View the raw message.

drivers/staging/apfs/namei.c new file +132 -0

132 lines not on this page · raw message

drivers/staging/apfs/node.c new file +2069 -0

2,069 lines not on this page · raw message

drivers/staging/apfs/object.c new file +315 -0

315 lines not on this page · raw message

drivers/staging/apfs/snapshot.c new file +683 -0

683 lines not on this page · raw message

drivers/staging/apfs/spaceman.c new file +1433 -0

1,433 lines not on this page · raw message

drivers/staging/apfs/super.c new file +2098 -0

2,098 lines not on this page · raw message

drivers/staging/apfs/symlink.c new file +77 -0

77 lines not on this page · raw message

drivers/staging/apfs/transaction.c new file +959 -0

959 lines not on this page · raw message

drivers/staging/apfs/xattr.c new file +911 -0

911 lines not on this page · raw message

drivers/staging/apfs/xfield.c new file +171 -0

171 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.48.1

Part of the diff is not shown here. View the raw message.

#7 lore raw

RFC PATCH v2 6/8 staging: apfs: init build support for APFS

In reply to Ethan Carter Edwards

APFS read support is stable and functional for unencrypted, non-fusion drives. Write support for unencrypted drives is somewhat stable and supported. This commit adds the relevant Kconfig and Makefile options to build this APFS driver as a module or kernel builtin.

---
 drivers/staging/Kconfig       |  2 ++
 drivers/staging/apfs/Kconfig  | 13 +++++++++++++
 drivers/staging/apfs/Makefile | 10 ++++++++++
 3 files changed, 25 insertions(+)
drivers/staging/Kconfig +2 -0
index 075e775d3868b3449922a25df1f79dec5a83a42d..2a063a9b759091eba8b0d5486976552d3a5df0a0 100644
@@ -50,4 +50,6 @@ source "drivers/staging/vme_user/Kconfig"
 
 source "drivers/staging/gpib/Kconfig"
 
+source "drivers/staging/apfs/Kconfig"
+
 endif # STAGING
drivers/staging/apfs/Kconfig new file +13 -0
new file mode 100644
index 0000000000000000000000000000000000000000..55de44bba9ef29c79a1647d722caa57ba813d189
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config APFS_FS
+	tristate "Apple File System support"
+	select LIBCRC32C
+	select ZLIB_INFLATE
+	select NLS
+	select BUFFER_HEAD
+	select FS_IOMAP
+	select LEGACY_DIRECT_IO
+	help
+	  If you say Y here, you will be able to mount APFS partitions
+	  with read-only access. Write access is experimental and may
+	  corrupt your container.
drivers/staging/apfs/Makefile new file +10 -0
new file mode 100644
index 0000000000000000000000000000000000000000..2fa127dd126716f0159baa514ba3194688ec1c0f
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Makefile for the Linux APFS module.
+#
+
+obj-$(CONFIG_APFS_FS) += apfs.o
+apfs-y := btree.o compress.o dir.o extents.o file.o inode.o key.o libzbitmap.o \
+	  lzfse/lzfse_decode.o lzfse/lzfse_decode_base.o lzfse/lzfse_fse.o \
+	  lzfse/lzvn_decode_base.o message.o namei.o node.o object.o snapshot.o \
+	  spaceman.o super.o symlink.o transaction.o unicode.o xattr.o xfield.o
Signature · 1 line
2.48.1
#8 lore raw

RFC PATCH v2 7/8 staging: apfs: init TODO and README.rst

In reply to Ethan Carter Edwards

There are various cleanup tasks required before this driver can be moved to fs/ and out of staging/. TODO attempts to start a list of what those tasks may be.

The README delineates a history and provides credit to the module's original authors. I am not the original author, I have just ported it for upstream submission.

---
 drivers/staging/apfs/README.rst | 87 +++++++++++++++++++++++++++++++++++++++++
 drivers/staging/apfs/TODO       |  7 ++++
 2 files changed, 94 insertions(+)
drivers/staging/apfs/README.rst new file +87 -0
new file mode 100644
index 0000000000000000000000000000000000000000..d7cd1eb1068f473160951c6ddb65372026445c0d
@@ -0,0 +1,87 @@
+===========================
+Apple File System for Linux
+===========================
+
+The Apple File System (APFS) is the copy-on-write filesystem currently used on
+all Apple devices. This module provides a degree of experimental support on
+Linux.
+
+To help test write support, a set of userland tools is also under development.
+The git tree can be retrieved from https://github.com/eafer/apfsprogs.git.
+
+Known limitations
+=================
+
+This module is the result of reverse engineering and testing has been limited.
+If you make use of the write support, there is a real risk of data corruption.
+Please report any issues that you find.
+
+Writes to fusion drives are not currently supported.
+Encryption is also not yet implemented even in read-only mode.
+
+Reporting bugs
+==============
+
+If you encounter any problem, the first thing you should do is run (as root)::
+
+	dmesg | grep -i apfs
+
+to see all the error messages. If that doesn't help you, please report the
+issue via email at lore.kernel.org.
+
+Mount
+=====
+
+Like all filesystems, apfs is mounted with::
+
+	mount [-o options] device dir
+
+where ``device`` is the path to your device file or filesystem image, and
+``dir`` is the mount point. The following options are accepted:
+
+============   =================================================================
+vol=n	       Volume number to mount. The default is volume 0.
+
+snap=label     Volume snapshot to mount (in read-only mode).
+
+tier2=path     Path to the tier 2 device. For fusion drives only.
+
+uid=n, gid=n   Override on-disk inode ownership data with given uid/gid.
+
+cknodes	       Verify the checksum on all metadata nodes. Right now this has a
+	       severe performance cost, so it's not recommended.
+
+readwrite      Enable the experimental write support. This may corrupt your
+	       container.
+============   =================================================================
+
+So for instance, if you want to mount volume number 2, and you want the metadata
+to be checked, you should run (as root)::
+
+	mount -o cknodes,vol=2 device dir
+
+To unmount it, run::
+
+	umount dir
+
+Credits
+=======
+
+Originally written by Ernesto A. Fernández <[email protected]>, with
+several contributions from Gabriel Krisman Bertazi <[email protected]>,
+Arnaud Ferraris <[email protected]> and Stan Skowronek
+<[email protected]>. For attribution details see the historical
+git tree at https://github.com/eafer/linux-apfs.git and
+https://github.com/linux-apfs/linux-apfs-rw.
+
+The module was ported by Ethan Carter Edwards <[email protected]> to
+mainline and submitted upstream in 2025.
+
+Work was first based on reverse engineering done by others [1]_ [2]_, and later
+on the (very incomplete) official specification [3]_. Some parts of the code
+imitate the ext2 module, and to a lesser degree xfs, udf, gfs2 and hfsplus.
+
+.. [1] Hansen, K.H., Toolan, F., Decoding the APFS file system, Digital
+   Investigation (2017), https://dx.doi.org/10.1016/j.diin.2017.07.003
+.. [2] https://github.com/sgan81/apfs-fuse
+.. [3] https://developer.apple.com/support/apple-file-system/Apple-File-System-Reference.pdf
drivers/staging/apfs/TODO new file +7 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b73107f4ea976af20d7e9ae19a928c5d6eb85026
@@ -0,0 +1,7 @@
+There are a couple things that should probably happen before this
+module is moved to fs/ and out of staging/. Most notably is the
+proper documentation of how APFS/this module works. Another is the
+conversion from bufferheads/pages to folios.
+
+Another good task for newcomers is patches that make it so this
+module conforms to current kernel coding standards.
Signature · 1 line
2.48.1
#9 lore raw

RFC PATCH v2 8/8 MAINTAINERS: apfs: add entry and relevant information

In reply to Ethan Carter Edwards

Add the APFS driver to staging/ and add myself as the maintainer.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index 12852355bd66b2ca1841432b3e0d8c5856c62b9a..b4040e647e3ec6ae6b4723823fedff18c7a94544 100644
@@ -683,6 +683,12 @@ F:	Documentation/filesystems/afs.rst
 F:	fs/afs/
 F:	include/trace/events/afs.h
 
+APFS FILESYSTEM
+M:	Ethan Carter Edwards <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/staging/apfs
+
 AGPGART DRIVER
 M:	David Airlie <[email protected]>
 L:	[email protected]
Signature · 1 line
2.48.1
#10 lore raw
In reply to Ethan Carter Edwards
Quoted 22 lines · Ethan Carter Edwards

Hello everyone,

In series 2, I have fixed the formatting with clang-format of the lzfse library and fixed the comments to use linux kernel styles. I also removed my Copyright from files where it was not appropriate. Additionally, I removed the encode.c files as they were unused and not compiled into the final module They should be easy enough to add back if needed. I also rebased on Linus's tree, just in case. Nothing broke! ;)

I am holding off on adding Ernesto's Co-developed-by and Signed-off-by tags until I get a better grasp of where this module is headed. I hope to here back from Christian and the LSFMMBPF folks sometime in the next few weeks.

I understand the jury is still out on supporting both reading and writing. As it stands, I have configured the code to support reading/writing on mount, but upstream auto-rw is configurable via a CONFIG option. Some people have expressed that they want the module upstreamed even if only read is supported. I will stay tuned and make changes as needed.

Quoted 5 lines

Additionally, I realize that staging/ may not be the correct location for the driver. However, I am basing my upstream process off of the erofs process. They started in staging. I understand that the correct tree and dir will be discussed as next weeks LSFMMBPF summit, so I will wait on their feedback before making any moves.

I don't know why erofs is related to your case here:

- erofs is not a project based on reserve engineering from the beginning; it was a real productizied project initially designed for Android and got wider adoption for various use cases now;

- It was a story 6 years ago (I've been actively working on this project more than 7 years and it sacrificed my extra free time and some other possibility), more recent fses instead directly land into "fs/" and it seems the preferred way. But, nevertheless, there is also some fs like ntfs3 directly into "fs/" and got some dispute;

- I have no idea if you have enough professional experience to resolve apfs-specific issues properly and in time. I think it's a basic requirement for a kernel subsystem upstream maintainer now that you introduced this;

- And you'd better to keep relatively active during the entire Linux kernel lifetime even that is not related to your ongoing work rather than dump and leave.

Thanks,
Gao Xiang

#12 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

In reply to Ethan Carter Edwards

+cc Slava and Adrian

I'm interested in bringing apfs upstream to the community, and perhaps slava and adrian too.

Thx,
Yangtao

#13 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

Hi Yangtao,

Quoted 2 lines · Yangtao Li

I'm interested in bringing apfs upstream to the community, and perhaps slava and adrian too.

Do you have any particular use case in mind here? I don't mind putting in the work to get the driver upstream, but I don't want to be fighting people to convince them that it's needed. I'm not even sure about it myself.

Ernesto

#14 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

Ernesto A. Fernández 於 2025/5/13 清晨7:40 寫道:

Quoted 8 lines

Hi Yangtao,

Quoted 2 lines · Yangtao Li

I'm interested in bringing apfs upstream to the community, and perhaps slava and adrian too.

Do you have any particular use case in mind here? I don't mind putting in the work to get the driver upstream, but I don't want to be fighting people to convince them that it's needed. I'm not even sure about it myself.

These are the use cases I can think of:

1. When running Linux on Apple Silicon Mac, accessing the xART APFS volume is required for enabling some SEP functionalities.

2. When running Linux on iPhone, iPad, iPod touch, Apple TV (currently there are Apple A7-A11 SoC support in upstream), resizing the main APFS volume is not feasible especially on A11 due to shenanigans with the encrypted data volume. So the safe ish way to store a file system on the disk becomes a using linux-apfs-rw on a (possibly fixed size) volume that only has one file and that file is used as a loopback device.

(do note that the main storage do not currently work upstream and I only have storage working on A11 downstream)

3. Obviously, accessing Mac files from Linux too, not sure how big of a use case that is but apparently it is big enough for hfsplus to continue receive patches here and there.

Quoted 3 lines

Ernesto

Nick Chan

reviewer
#15 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

Quoted 24 lines · Nick Chan

Ernesto A. Fernández 於 2025/5/13 清晨7:40 寫道:

Quoted 8 lines

Hi Yangtao,

Quoted 2 lines · Yangtao Li

I'm interested in bringing apfs upstream to the community, and perhaps slava and adrian too.

Do you have any particular use case in mind here? I don't mind putting in the work to get the driver upstream, but I don't want to be fighting people to convince them that it's needed. I'm not even sure about it myself.

These are the use cases I can think of:

1. When running Linux on Apple Silicon Mac, accessing the xART APFS volume is required for enabling some SEP functionalities.

2. When running Linux on iPhone, iPad, iPod touch, Apple TV (currently there are Apple A7-A11 SoC support in upstream), resizing the main APFS volume is not feasible especially on A11 due to shenanigans with the encrypted data volume. So the safe ish way to store a file system on the disk becomes a using linux-apfs-rw on a (possibly fixed size) volume that only has one file and that file is used as a loopback device.

Quoted 4 lines

(do note that the main storage do not currently work upstream and I only have storage working on A11 downstream)

3. Obviously, accessing Mac files from Linux too, not sure how big of a use case that is but apparently it is big enough for hfsplus to continue receive patches here and there.

I can see that accessing APFS filesystem is useful at times. But the question is: why do we need it in the kernel? Why isn't a FUSE driver enough? Because for relatively niche usecase like this that is a much more acceptable (and easier to maintain) choice.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#16 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

In reply to Nick Chan
Quoted 26 lines · Nick Chan



Quoted 9 lines

Ernesto A. Fernández 於 2025/5/13 清晨7:40 寫道:
Hi Yangtao,

Quoted 3 lines · Yangtao Li

I'm interested in bringing apfs upstream to the community, and perhaps slava and adrian too.

Do you have any particular use case in mind here? I don't mind putting in the work to get the driver upstream, but I don't want to be fighting people to convince them that it's needed. I'm not even sure about it myself.

These are the use cases I can think of:

1. When running Linux on Apple Silicon Mac, accessing the xART APFS volume is required for enabling some SEP functionalities.

2. When running Linux on iPhone, iPad, iPod touch, Apple TV (currently there are Apple A7-A11 SoC support in upstream), resizing the main APFS volume is not feasible especially on A11 due to shenanigans with the encrypted data volume. So the safe ish way to store a file system on the disk becomes a using linux-apfs-rw on a (possibly fixed size) volume that only has one file and that file is used as a loopback device.

Quoted 5 lines

(do note that the main storage do not currently work upstream and I only have storage working on A11 downstream)

3. Obviously, accessing Mac files from Linux too, not sure how big of a use case that is but apparently it is big enough for hfsplus to continue receive patches here and there.

Quoted 1 line

I'll add a number 4

4. Mounting the macOS recovery partition makes getting the wifi firmware much easier for T2 Macs on Linux.

#17 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

In reply to Nick Chan

Hi Nick,

Quoted 4 lines · Nick Chan

2. When running Linux on iPhone, iPad, iPod touch, Apple TV (currently there are Apple A7-A11 SoC support in upstream), resizing the main APFS volume is not feasible especially on A11 due to shenanigans with the encrypted data volume. So the safe ish way to store a file system on the disk becomes a using linux-apfs-rw on a (possibly fixed size) volume that only has one file and that file is used as a loopback device.

That's very interesting. Fragmentation will be brutal after a while though. Unless you are patching away the copy-on-write somehow?

Quoted 2 lines

3. Obviously, accessing Mac files from Linux too, not sure how big of a use case that is but apparently it is big enough for hfsplus to continue receive patches here and there.

True, but the hfsplus driver is already merged and people may be relying on it. Still, there was some push to get rid of it recently. I don't expect much support for picking up a whole new driver.

Ernesto

#18 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

Ernesto A. Fernández 於 2025/5/15 凌晨4:19 寫道:

Quoted 9 lines

Hi Nick,

Quoted 4 lines · Nick Chan

2. When running Linux on iPhone, iPad, iPod touch, Apple TV (currently there are Apple A7-A11 SoC support in upstream), resizing the main APFS volume is not feasible especially on A11 due to shenanigans with the encrypted data volume. So the safe ish way to store a file system on the disk becomes a using linux-apfs-rw on a (possibly fixed size) volume that only has one file and that file is used as a loopback device.

That's very interesting. Fragmentation will be brutal after a while though. Unless you are patching away the copy-on-write somehow?'

On a fixed size (preallocated size == max size) volume with only a single non-sparse file on it, copy-on-write should not happen. I believe the xART volume is also the same case with only one non-sparse file.

[...]

Quoted 1 line

Ernesto

Nick Chan

#19 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

Quoted 8 lines · Nick Chan

Ernesto A. Fernández 於 2025/5/15 凌晨4:19 寫道:

Quoted 7 lines

Hi Nick,

Quoted 4 lines · Nick Chan

2. When running Linux on iPhone, iPad, iPod touch, Apple TV (currently there are Apple A7-A11 SoC support in upstream), resizing the main APFS volume is not feasible especially on A11 due to shenanigans with the encrypted data volume. So the safe ish way to store a file system on the disk becomes a using linux-apfs-rw on a (possibly fixed size) volume that only has one file and that file is used as a loopback device.

Quoted 7 lines
Quoted 2 lines

That's very interesting. Fragmentation will be brutal after a while though. Unless you are patching away the copy-on-write somehow?'

On a fixed size (preallocated size == max size) volume with only a single non-sparse file on it,
copy-on-write should not happen. I believe the xART volume is also the same case with only
one non-sparse file.

Yeah, the gigalocker file on the xART volume (which is the only file we care about for eventual Secure Enclave support on M1+ macs) is stored contiguously without copy-on-write on the disk.

Sven

#20 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

In reply to Ernesto A. Fernández

Hi Ernesto,

Quoted 9 lines · Ernesto A. Fernández

Hi Yangtao,

Quoted 2 lines · Yangtao Li

I'm interested in bringing apfs upstream to the community, and perhaps slava and adrian too.

Do you have any particular use case in mind here? I don't mind putting in the work to get the driver upstream, but I don't want to be fighting people to convince them that it's needed. I'm not even sure about it myself.

Now that some current use cases have already been provided, I'm curious about what the biggest obstacles are at present. APFS in the kernel should have better performance than a FUSE implementation. Are there any TODO items moving forward in this direction, such as IOMAP support and other similar things? I can't guarantee that I have a lot of time to invest heavily in this at the moment, but there should be others who are interested.

Thx,
Yangtao

#21 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

Hi again,

Quoted 1 line · Yangtao Li

Now that some current use cases have already been provided

Some interesting use cases have been mentioned, yes, but I doubt they are common enough to convince upstream to pick up a whole new filesystem. I was also more curious about your own personal interest in the driver, because you are going to get some very hostile feedback if you try to get it merged. You won't get anywhere without strong conviction in the matter.

Quoted 1 line

I'm curious about what the biggest obstacles are at present.

I don't think there are any big technical problems, the driver is fairly usable at this point and it's been a while since xfstests found any corruption bugs. But it's still a reverse engineered filesystem, and there will always be risks. There's also the issue of the buffer heads, but Ted Ts'o has said before that it doesn't matter much.

The real obstacle is that I have no idea how to convince people that this is a good idea, and nobody else is going to do it for me. There were no replies to Jan Kara's obvious and fairly friendly objection; it's going to get much worse than that if you try to push this through.

Personally, I just don't mind maintaining the driver out of tree.

Quoted 2 lines

APFS in the kernel should have better performance than a FUSE implementation.

Sure, but how much better? You could try running benchmarks against the two existing (read-only) fuse implementations. And if the driver is indeed much faster, does that matter to you for any particular reason? Keep in mind that you need to convince Jan Kara, not me.

Anyway, it's nice when people get interested in your projects and I do appreciate that. But I just don't see it happening.

Ernesto

reviewer
#22 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

Hi!

Quoted 8 lines · Ernesto A. Fernández
Quoted 1 line · Yangtao Li

Now that some current use cases have already been provided

Some interesting use cases have been mentioned, yes, but I doubt they are common enough to convince upstream to pick up a whole new filesystem. I was also more curious about your own personal interest in the driver, because you are going to get some very hostile feedback if you try to get it merged. You won't get anywhere without strong conviction in the matter.

Correct, this kind of matches my feelings from this discussion so far. Sure APFS support in the kernel would be more convenient for some users. But so far I didn't hear a reason why FUSE driver wouldn't cover 99% of the usecases (since I know close to nothing about Apple ecosystem, maybe I've missed some so please correct me in that case).

Perhaps to explain the reasons of a pushback a bit: Once the filesystem driver is merged, it's very difficult to get rid of it as users may depend on it. Each filesystem driver adds certain maintenance burden - most notably for changes in VFS and other generic infrastructure that need to take into account what each and every filesystem is doing. We already carry quite a few filesystem drivers used by very few people and since few people are interested it them it's difficult to find people to get these drivers converted to new mount API, iomap infrastructure, new page cache APIs etc. which forces us to keep carring the old interfaces. This gets particularly painful for filesystems where we don't have full specification so usually the mkfs and fsck tooling is not as comprehensive which makes testing changes harder. So the bar (in terms of usecases) to get the new filesystem driver merged is relatively high.

Quoted 7 lines
Quoted 2 lines

APFS in the kernel should have better performance than a FUSE implementation.

Sure, but how much better? You could try running benchmarks against the two existing (read-only) fuse implementations. And if the driver is indeed much faster, does that matter to you for any particular reason? Keep in mind that you need to convince Jan Kara, not me.

Using FUSE to access the filesystem certainly has it's overhead (although there is work in progress to heavily reduce that for data-intensive operations such as streaming IO). But I doubt your the usecase for APFS is to use it as a backend for a file server or a database. We have other filesystems in Linux for that. All the usecases I've heard are about being able to access you Mac files from Linux. And FUSE driver should have acceptable performance for that from my experience.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#23 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

Hi,
just one nitpick:

Quoted 8 lines · Jan Kara

We already carry
quite a few filesystem drivers used by very few people and since few people are interested it them it's difficult to find people to get these drivers converted to new mount API, iomap infrastructure, new page cache APIs etc. which forces us to keep carring the old interfaces. This gets particularly painful for filesystems where we don't have full specification so usually the mkfs and fsck tooling is not as comprehensive which makes testing changes harder.

For the record, my fsck [1] is far more thorough than the official one, I don't take data corruption lightly. It's only for testing though, it doesn't actually fix anything. And of course it could have mistakes since the specification is incomplete and buggy.

[1] https://github.com/linux-apfs/apfsprogs

#24 lore raw

Re: Subject: [RFC PATCH v2 0/8] staging: apfs: init APFS filesystem support

In reply to Yangtao Li

Hi Yangtao,

Quoted 3 lines · Yangtao Li

+cc Slava and Adrian

I'm interested in bringing apfs upstream to the community, and perhaps slava and adrian too.

I don't have much experience with APFS yet other than using it on my Macs and maintaining the apfsprogs package in openSUSE, but adding APFS support to the kernel would certainly be a welcome improvement.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913