Skip to content

Commit 0705e93

Browse files
committed
who(user_id) - uid, gid, password
1 parent 7214e3c commit 0705e93

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

filesys.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ extern int namei(char *);
172172
extern unsigned short iname(char *);
173173
extern unsigned int access(unsigned int,struct inode *,unsigned short);
174174
extern void _dir();
175+
extern void who(unsigned short);
175176
extern void mkdir(char *);
176177
extern void chdir(char *);
177178
extern short open(int,char*,char);

log.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,17 @@ int logout(unsigned short uid){
5858
return 1;
5959
}
6060

61-
62-
63-
64-
61+
void who(unsigned short user_id)
62+
{
63+
printf("user[%u].u_uid = %u\n", user_id, user[user_id].u_uid);
64+
printf("user[%u].u_gid = %u\n", user_id, user[user_id].u_gid);
65+
for (int i = 0; i < PWDNUM; i++) {
66+
if (user[user_id].u_uid == pwd[i].p_uid) {
67+
printf("pwd[%d].password = %s\n", i, pwd[i].password);
68+
break;
69+
}
70+
}
71+
}
6572

6673

6774

shell.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ char commands[CNUM][CLEN]={
1010
"mkfile",
1111
"del",
1212
"write",
13-
"read"
13+
"read",
14+
"who"
1415
};
1516
int getcid(char *command){
1617
int i;
@@ -129,6 +130,9 @@ int shell(int user_id,char *str){
129130
free(buf);
130131
close(user_id,fd);
131132
break;
133+
case 8:
134+
who(user_id);
135+
break;
132136
case 0:
133137
return 0;
134138
default:

0 commit comments

Comments
 (0)