The Pedigree Project 0.1
PosixMemoryLockAccount.h
1/*
2 * Copyright (c) 2026, Pedigree Developers
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted.
6 */
7
8#ifndef PEDIGREE_POSIX_MEMORY_LOCK_ACCOUNT_H
9#define PEDIGREE_POSIX_MEMORY_LOCK_ACCOUNT_H
10
11#include "pedigree/kernel/processor/UserMemoryPolicy.h"
12
13#include "linux-resource-abi.h"
14
15class EXPORTED_PUBLIC PosixMemoryLockAccount final : public MemoryLockAccount {
16 public:
17 enum class LimitStatus { Success, Invalid, PermissionDenied };
18
19 PosixMemoryLockAccount() = default;
21
22 bool permitsTotalPages(size_t total, bool privileged) const override;
23 bool permitsLocking(bool privileged) const override {
24 return privileged || m_Limit.current != 0;
25 }
26
27 // Limit mutation and mapping admission share the manager operation gate.
28 LinuxRlimit64 limit() const {
29 return m_Limit;
30 }
31 LimitStatus setLimit(const LinuxRlimit64& limit, bool privileged);
32
33 private:
34 PosixMemoryLockAccount& operator=(const PosixMemoryLockAccount&) = delete;
35 LinuxRlimit64 m_Limit{1ULL << 24, 1ULL << 24};
36};
37
38#endif