File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -172,6 +172,7 @@ extern int namei(char *);
172172extern unsigned short iname (char * );
173173extern unsigned int access (unsigned int ,struct inode * ,unsigned short );
174174extern void _dir ();
175+ extern void who (unsigned short );
175176extern void mkdir (char * );
176177extern void chdir (char * );
177178extern short open (int ,char * ,char );
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ char commands[CNUM][CLEN]={
1010" mkfile" ,
1111" del" ,
1212" write" ,
13- " read"
13+ " read" ,
14+ " who"
1415};
1516int 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 :
You can’t perform that action at this time.
0 commit comments