-
Notifications
You must be signed in to change notification settings - Fork 46
/
chown_chmod.c
39 lines (30 loc) · 932 Bytes
/
chown_chmod.c
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
34
35
36
37
38
//
// Created by bruce on 27/04/20.
//
#include <fs/fs.h>
int sys_chown(struct proc* who, const char* pathname, uid_t owner, gid_t group){
return -EINVAL;
}
int do_chown(struct proc* who, struct message* msg){
char* path = (char *) get_physical_addr(msg->m1_p1, who);
if(!is_vaddr_accessible(msg->m1_p1, who))
return -EFAULT;
return sys_chown(who, path, msg->m1_i1, msg->m1_i2);
}
int sys_chmod(struct proc* who, const char* pathname, mode_t mode){
int ret;
inode_t *inode = NULL;
if((ret = get_inode_by_path(who, pathname, &inode)))
return ret;
if(!inode)
return -ENOENT;
inode->i_mode = mode;
put_inode(inode, true);
return 0;
}
int do_chmod(struct proc* who, struct message* msg){
char* path = (char *) get_physical_addr(msg->m1_p1, who);
if(!is_vaddr_accessible(msg->m1_p1, who))
return -EFAULT;
return sys_chmod(who, path, msg->m1_i1);
}