The Pedigree Project 0.1
Ext2Xattr.h
1/* Copyright (c) 2026, Pedigree Developers. */
2#ifndef EXT2_XATTR_H
3#define EXT2_XATTR_H
4
5#include "pedigree/kernel/processor/types.h"
6#include "pedigree/kernel/utilities/StringView.h"
7
8#include "modules/system/vfs/ExtendedAttributes.h"
9
10namespace Ext2Ea {
11constexpr uint32_t Magic = 0xea020000;
12constexpr unsigned User = 1;
13struct Header {
14 uint32_t magic, references, blocks, hash, reserved[4];
15};
16struct Entry {
17 uint8_t nameLength, nameIndex;
18 uint16_t valueOffset;
19 uint32_t valueBlock, valueLength, hash;
20} __attribute__((packed));
21static_assert(sizeof(Header) == 32, "Ext2 EA header");
22static_assert(sizeof(Entry) == 16, "Ext2 EA entry");
23
24XattrStatus validate(const void* block, size_t size);
25XattrStatus get(const void* block, size_t size, const StringView& name, void* output,
26 size_t capacity, size_t& required);
27XattrStatus list(const void* block, size_t size, void* output, size_t capacity, size_t& required);
28XattrStatus rebuild(const void* oldBlock, size_t size, const StringView& name, const void* value,
29 size_t length, unsigned flags, bool remove, void* replacement, bool& empty);
30} // namespace Ext2Ea
31#endif
Definition User.h:32