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) {
13 if (!m_pExt2Fs->tryAcquireOperation(operation)) {
19 SYSCALL_ERROR(ReadOnlyFilesystem);
22 if (m_State->quotaFile) {
23 SYSCALL_ERROR(NotEnoughPermissions);
27 if ((changeUid && uid > UINT32_MAX) || (changeGid && gid > UINT32_MAX)) {
28 SYSCALL_ERROR(ValueTooLarge);
32 if (!m_pExt2Fs->prepareInodeWrite(m_InodeNumber))
34 auto status = m_pExt2Fs->prepareQuotaInodeLocked(m_InodeNumber);
35 if (status == QuotaStatus::Success)
36 status = m_pExt2Fs->m_Quota.transfer(m_InodeNumber, changeUid ? uid : Ext2Owner::uid(*m_pInode),
37 changeGid ? gid : Ext2Owner::gid(*m_pInode));
38 if (!m_pExt2Fs->quotaSucceeded(status))
41 Ext2Owner::setUid(*m_pInode, uid);
43 Ext2Owner::setGid(*m_pInode, gid);
44 m_pInode->i_ctime = HOST_TO_LITTLE32(Time::getTime());
45 m_pExt2Fs->writeInode(m_InodeNumber);
49bool Ext2File::changeOwnership(
size_t uid,
size_t gid,
bool changeUid,
bool changeGid) {
50 return changeInodeOwnership(uid, gid, changeUid, changeGid);
52bool Ext2Directory::changeOwnership(
size_t uid,
size_t gid,
bool changeUid,
bool changeGid) {
53 return changeInodeOwnership(uid, gid, changeUid, changeGid);
55bool Ext2Symlink::changeOwnership(
size_t uid,
size_t gid,
bool changeUid,
bool changeGid) {
56 return changeInodeOwnership(uid, gid, changeUid, changeGid);
59bool Ext2File::allowResize(
size_t,
size_t) {
60 if (__atomic_load_n(&m_State->quotaFile, __ATOMIC_ACQUIRE)) {
61 SYSCALL_ERROR(NotEnoughPermissions);
67bool Ext2File::allowPhysicalPage()
const {
68 return !__atomic_load_n(&m_State->quotaFile, __ATOMIC_ACQUIRE);