The Pedigree Project 0.1
metadata-abi.h
1/* Copyright (c) 2026, Pedigree Developers. */
2#ifndef POSIX_METADATA_ABI_H
3#define POSIX_METADATA_ABI_H
4#include "pedigree/kernel/processor/types.h"
5namespace PosixMetadata {
6constexpr int64_t TimeNow = 1073741823, TimeOmit = 1073741822;
7struct Timespec {
8 int64_t seconds;
9 int64_t nanoseconds;
10};
12 int64_t seconds;
13 uint32_t nanoseconds, reserved;
14};
15struct Statx {
16 uint32_t mask, blockSize;
17 uint64_t attributes;
18 uint32_t links, uid, gid;
19 uint16_t mode, reserved;
20 uint64_t inode, size, blocks, attributesMask;
21 StatxTimestamp accessed, born, changed, modified;
22 uint32_t deviceMajor, deviceMinor, filesystemMajor, filesystemMinor;
23 uint64_t mountId;
24 uint32_t directMemoryAlignment, directOffsetAlignment;
25 uint64_t subvolume;
26 uint32_t atomicWriteMin, atomicWriteMax, atomicWriteSegments, reserved2;
27 uint64_t reserved3[9];
28};
29static_assert(sizeof(Timespec) == 16);
30static_assert(sizeof(StatxTimestamp) == 16);
31static_assert(sizeof(Statx) == 256);
32static_assert(offsetof(Statx, accessed) == 64);
33static_assert(offsetof(Statx, mountId) == 144);
34constexpr bool validNanoseconds(int64_t value) {
35 return value == TimeNow || value == TimeOmit || (value >= 0 && value < 1000000000);
36}
37constexpr uint32_t deviceMajor(uint64_t value) {
38 return ((value >> 8) & 0xfff) | ((value >> 32) & 0xfffff000);
39}
40constexpr uint32_t deviceMinor(uint64_t value) {
41 return (value & 0xff) | ((value >> 12) & 0xffffff00);
42}
43} // namespace PosixMetadata
44#endif