Skip to content

Commit

Permalink
chmod
Browse files Browse the repository at this point in the history
  • Loading branch information
w-mj committed Jun 27, 2019
1 parent 0cfb3ab commit 95c1abc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fs/test_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ struct OP {
};
// 2 r 1 w 0 x
bool check(VFS::Inode *i, int pre) {
if (uid == 0)
return true;
if (i->uid == uid) {
return i->mode & (0100 << pre);
}
Expand Down Expand Up @@ -332,6 +334,16 @@ VFS::DEntry *echo(VFS::DEntry *cwd, const std::vector<std::string>& cmdd) {
VFS::DEntry *chmod(VFS::DEntry *cwd, const std::vector<std::string>& cmdd) {
VFS::NameI *fi = VFS::NameI::from_str(cmdd[cmdd.size() - 1]);
VFS::DEntry *file = cwd->get_child(fi);
file->inflate();
pre(chk_w, file->inode);
int m = 0;
for (char x: cmdd[1]) {
m <<= 3;
m += x - '0';
}
file->inode->mode &= ~(0777);
file->inode->mode |= m;
file->inode->dirty();
return cwd;
}

Expand Down Expand Up @@ -363,6 +375,7 @@ OP ops[] = {
{"umount", umount},
{"echo", echo},
{"chown", chown},
{"chmod", chmod},
{"unknown", nullptr}
};

Expand Down

0 comments on commit 95c1abc

Please sign in to comment.