91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 1.59MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2024-02-02
  • 語言: 其他
  • 標簽:

資源簡介

實驗目的: 通過一個簡單多用戶文件系統的設計,加深理解文件系統的內部功能及內部實現。 實驗要求: 為linux系統設計一個簡單的二級文件系統。要求做到以下幾點: (1)可以實現下列幾條命令(至少4條); login 用戶登陸 dir 列文件目錄 create 創建文件 delete 刪除文件 open 打開文件 close 關閉文件 read 讀文件 write 寫文件

資源截圖

代碼片段和文件信息

#include
#include
#include
#include
#include
#include?
#include?
#include?
#define?MaxUser?1028????//用戶最多數目
#define?commandAmount?12?????//對文件操作的指令數
//用戶管理
int?userID?=?-1;?//用戶登錄的ID號,值為-1時表示沒有用戶登錄
char?Name[15];?????//正在登錄用戶名
char?firstName[5];?//正在被操作的文件
long?used?=?0;????//全局變量,用戶數
long?used1?=?0;????//全局變量,用戶創建文件數
char?q2[20]?=?“file/node/“;
typedef?struct?master_file_directory
{
char?userName[15];
char?password[15];
}?MFD;
MFD?userTable[MaxUser];

typedef?struct?node?{
char?fileName[15];
char?number[5];
//UFD?*user;
}?MFD1;
MFD1?fileTable[1024];

void?userCreate();???//創建用戶
int?login();???//用戶登錄
int?createDirectory(const?char*filename);//創建目錄
void?fileAttribute(char*fileName);//文件屬性
void?readDir1();//讀用戶
void?create(char*name);?//創建文件
void?deletefile(const?char*filename);//刪除文件
int?openfile(char*name);//打開文件
void?writefile(char?name[]?char*buf);//寫文件
void?readfile(char?name[]);//查看文件內容
void?closefile(int?fd);
void?userCreate();//創建用戶
int?login();//用戶登錄
void?createfile(char?name[]?char?kind[]);//創建文件
void?reFileName(char*old?char*new);//文件重命名
void?chmodfile(char?name[]?char?kind[]);//修改文件權限
int?main()?{

char?order[commandAmount][10];
strcpy(order[0]?“create“);
strcpy(order[1]?“delete“);
strcpy(order[2]?“read“);
strcpy(order[3]?“write“);
strcpy(order[4]?“arr“);
strcpy(order[5]?“chmod“);
strcpy(order[6]?“ren“);
strcpy(order[7]?“dir“);
strcpy(order[8]?“return“);
strcpy(order[9]?“exit“);
strcpy(order[10]?“diru“);
strcpy(order[11]?“delu“);
char?command[1028]?command_str1[10]?command_str2[10]?command_str3[1028];
int?i?k?j;
int?length;
createDirectory(“file“);
createDirectory(“file/node“);
create(“file/user.txt“);
long?used;
struct?stat?d;
stat(“file/user.txt“?&d);
d.st_size;
used?=?(d.st_size)?/?30l;

FILE?*fp;

if?((fp?=?fopen(“file/user.txt“?“r“))?==?NULL)

{
printf(“cannot?open?this?file\n“);

exit(0);

}
fread(userTable?sizeof(struct?master_file_directory)?used?fp);

fclose(fp);
????if(used==0)
????{
???? strcpy(userTable[0].userName“root“);
??????? ????strcpy(userTable[0].password“root“);

???? char?q[20]?=?“file/“;
???? char?q2[20]?=?“file/node/“;
???? strcat(q?userTable[0].userName);
???? strcat(q2?userTable[0].userName);
???? createDirectory(q);
???? create(q2);
???? used++;
???? FILE?*fp;
???? if?((fp?=?fopen(“file/user.txt“?“w“))?==?NULL)

???? {
???? printf(“cannot?open?this?file\n“);

???? exit(0);

???? }
???? fwrite(userTable?sizeof(struct?master_file_directory)?used?fp);
???? fclose(fp);

????}


int?g?=?0;
while?(g?==?0)?{
printf(“********************************************\n“);
printf(“??????????????????1、login\n“);
printf(“??????????????????2、register\n“);
????printf(“??????????????????3、exit\n“);
printf(“********************************************\n“);
printf(“Please?chooce?the?function?key:>“);
int?choice;
scanf(“%d“?&choice);

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????1775104??2012-03-15?20:32??《操作系統》課程實驗報告.doc

?????文件??????17437??2012-02-19?20:01??file.c

-----------?---------??----------?-----??----

??????????????1792541????????????????????2


評論

共有 條評論