-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinode.cpp
More file actions
33 lines (33 loc) · 965 Bytes
/
inode.cpp
File metadata and controls
33 lines (33 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "inode_helper.h"
#include "inode.h"
#include "user_context.h"
INode::INode(const ID_T & inode_id) {
this->inode = INodeHelper::GetINode(inode_id);
}
void INode::save() {
INodeLoader::SaveINode(*this->inode);
}
BOOL_T INode::HasPermissionRead() const {
return CheckPermissionBit(UserContext::user_id, ReadBit);
}
BOOL_T INode::HasPermissionWrite() const {
return CheckPermissionBit(UserContext::user_id, WriteBit);
}
BOOL_T INode::HasPermissionExec() const {
return CheckPermissionBit(UserContext::user_id, ExecBit);
}
BOOL_T INode::CheckPermissionBit(ID_T login_user_id, int bit) const {
if (login_user_id == kROOT_ID) {
return true;
}
if (((inode->global_permission >> bit) & 1) == 1)
return true;
if (inode->owner_id == login_user_id) {
if (((inode->owner_permission >> bit) & 1) == 1)
return true;
}
return false;
}
BOOL_T INode::IsOwner()const {
return UserContext::user_id == inode->owner_id || UserContext::user_id == kROOT_ID;
}