⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log.c

📁 基于UNIX6的文件系统模拟程序
💻 C
字号:
#include <stdio.h>
#include <string.h>#include "filesys.h"int login(uid,passwd)unsigned short uid;char *passwd;{	int i,j;

	//printf("\nin login pwd[2].uid:%d ,pwd:%s\n",pwd[2].p_uid,pwd[2].password);	for(i=0;i<PWDNUM;i++)	{		if((uid == pwd[i].p_uid)&&!(strcmp(passwd,pwd[i].password)))		{			for(j=0;j<USERNUM;j++)//I change i++ to j++				if(user[j].u_uid == 0)  break;			if(j==USERNUM)			{				printf("\ntoo many user in the system,waited 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;			}			break;		}	}	if(i==PWDNUM)	{		printf("\nincorrect password\n");		return 0;	}	else		return 1;}int logout(uid)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 + -