2#include "pedigree/kernel/LockGuard.h"
3#include "pedigree/kernel/syscallError.h"
5#include "Ext2Directory.h"
7#include "Ext2Filesystem.h"
8#include "Ext2Symlink.h"
11bool Ext2Node::changeInodeOwnership(
size_t uid,
size_t gid,
bool changeUid,
bool changeGid) {
15 SYSCALL_ERROR(ReadOnlyFilesystem);
18 if (m_State->quotaFile) {
19 SYSCALL_ERROR(NotEnoughPermissions);
23 if ((changeUid && uid > UINT32_MAX) || (changeGid && gid > UINT32_MAX)) {
24 SYSCALL_ERROR(ValueTooLarge);
28 if (!m_pExt2Fs->prepareInodeWrite(m_InodeNumber))
30 auto status = m_pExt2Fs->prepareQuotaInodeLocked(m_InodeNumber);
31 if (status == QuotaStatus::Success)
32 status = m_pExt2Fs->m_Quota.transfer(m_InodeNumber, changeUid ? uid : Ext2Owner::uid(*m_pInode),
33 changeGid ? gid : Ext2Owner::gid(*m_pInode));
34 if (!m_pExt2Fs->quotaSucceeded(status))
37 Ext2Owner::setUid(*m_pInode, uid);
39 Ext2Owner::setGid(*m_pInode, gid);
40 m_pInode->i_ctime = HOST_TO_LITTLE32(Time::getTime());
41 m_pExt2Fs->writeInode(m_InodeNumber);
45bool Ext2File::changeOwnership(
size_t uid,
size_t gid,
bool changeUid,
bool changeGid) {
46 return changeInodeOwnership(uid, gid, changeUid, changeGid);
48bool Ext2Directory::changeOwnership(
size_t uid,
size_t gid,
bool changeUid,
bool changeGid) {
49 return changeInodeOwnership(uid, gid, changeUid, changeGid);
51bool Ext2Symlink::changeOwnership(
size_t uid,
size_t gid,
bool changeUid,
bool changeGid) {
52 return changeInodeOwnership(uid, gid, changeUid, changeGid);
55bool Ext2File::allowResize(
size_t,
size_t) {
56 if (__atomic_load_n(&m_State->quotaFile, __ATOMIC_ACQUIRE)) {
57 SYSCALL_ERROR(NotEnoughPermissions);
63bool Ext2File::allowPhysicalPage()
const {
64 return !__atomic_load_n(&m_State->quotaFile, __ATOMIC_ACQUIRE);