On 2023/4/4 16:02, Jingbo Xu wrote:
Besides the predefined xattr name prefixes, introduces extra xattr name
prefixes, which works similarly as the predefined xattr name prefixees,
except that they are user specified.

Besides the built-in xattr name prefixes, let's introduce user-defined
extra xattr name prefixes, which works similarly as the pre-defined xattr
name prefixees, except that they are user specified.


When matched with a user specified extra xattr name prefix, only the
trailing part of the xattr name except the xattr name prefix will be
stored in erofs_xattr_entry.e_name.  e_name is empty if the xattr name
matches exactly as the extra xattr name prefix.

When a user-specified extra xattr name prefix is matched, only the
trailing part of the xattr name which already eliminates the given
prefix will be stored in `erofs_xattr_entry.e_name`.  `e_name` can be
empty if the xattr full name matches exactly as the name prefix.


All extra xattr name prefixes are stored in the packed file.  For each
extra xattr name prefix, the on-disk format in packed file can be shown
as (u8 prefix_len, prefix string), where the first u8 represents the
length of the prefix string (excluding '\0'), followed by the content of
the prefix string (including '\0').

Why we have to introduce a prefix_len here?


Two fields are introduced to the on-disk superblock, where
ea_prefix_count represents the total number of the extra xattr name
prefixes recorded in the packed file, and ea_prefix_off represents the
start offset of recorded name prefixes in the packed file.

When referring to an extra xattr name prefix, the highest bit (bit 7) of
erofs_xattr_entry.e_name_index is set, while the lower bits (bit 0-6)
as a whole represents the index of the referred name prefix among all
extra xattr name prefixes in the packed file.

When an extra xattr name prefix is referred, the highest bit (bit 7) of
`erofs_xattr_entry.e_name_index` is set, while the lower bits (bit 0-6)
as a whole represents the index of the referred name prefix among all
extra xattr name prefixes in the packed file.


Signed-off-by: Jingbo Xu <[email protected]>
---
  include/erofs_fs.h | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/erofs_fs.h b/include/erofs_fs.h
index 8835a76..3d8eb5f 100644
--- a/include/erofs_fs.h
+++ b/include/erofs_fs.h
@@ -77,7 +77,9 @@ struct erofs_super_block {
        } __packed u1;
        __le16 extra_devices;   /* # of devices besides the primary device */
        __le16 devt_slotoff;    /* startoff = devt_slotoff * devt_slotsize */
-       __u8 reserved[6];
+       __u8 reserved;
+       __u8 ea_prefix_count;   /* # of extra xattr name prefix */
+       __le32 ea_prefix_off;   /* start offset of extra prefixes in packed 
inode */
        __le64 packed_nid;      /* nid of the special packed inode */
        __u8 reserved2[24];
  };
@@ -228,6 +230,9 @@ struct erofs_xattr_ibody_header {
  #define EROFS_XATTR_INDEX_LUSTRE            5
  #define EROFS_XATTR_INDEX_SECURITY          6
+#define EROFS_XATTR_EA_FLAG (1 << 7)
+#define EROFS_XATTR_EA_MASK    (EROFS_XATTR_EINDEX_FLAG - 1)

EROFS_EXTRA_XATTR_FLAG          0x80
EROFS_EXTRA_XATTR_MASK          0x7F

?

Thanks,
Gao Xiang

+
  /* xattr entry (for both inline & shared xattrs) */
  struct erofs_xattr_entry {
        __u8   e_name_len;      /* length of name */

Reply via email to