?? log.c
字號:
#include <stdio.h>
#include "filesys.h"
int login(uid,passwd)
unsigned short uid;
char * passwd;
{
int i,j;
for(i=0;i<PWDNUM;i++)
{
if((uid==pwd[i].p_uid)&&(!strcmp(passwd,pwd[i].password)))
{
for(j=0;j<USERNUM;j++)
if(user[j].u_uid==0) break;
if(j==USERNUM)
{
printf("\ntoo much user in the system,walted to login\n");
return 0;
}
else
{
user[j].u_uid=uid;
user[j].u_gid=pwd[i].p_gid;
user[j].u_default_mode=DEFAULTMODE;
user_id=j;
}
break;
}
}
if(i==PWDNUM)
{
printf("\nincorrect password\n");
printf("log---->out\n");
return 0;
}
else
{
printf("\nyour uid:%d\n",uid);
printf("your password:%s\n",passwd);
printf("log---->out\n");
return 1;
}
}
int logout(uid) /* logout */
unsigned short uid;
{
int i,j,sys_no;
struct inode *inode;
for(i=0;i<USERNUM;i++)
if(uid==user[i].u_uid) break;
if(i==USERNUM)
{
printf("\nno such a file\n");
return NULL;
}
for(j=0;j<NOFILE;j++)
{
if(user[i].u_ofile[j]!=SYSOPENFILE+1)
{
/* iput the inode free the sys_ofile and clear the user_ofile */
sys_no=user[i].u_ofile[j];
inode=sys_ofile[sys_no].f_inode;
iput(inode);
sys_ofile[sys_no].f_count--;
user[i].u_ofile[j]=SYSOPENFILE+1;
}
}
return 1;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -