操作系统实验五文件系统

实验五已验收,不建议直接用我的代码(看看就好),不然你的分数可能会不太好

提示

系统验收的时候老师指出了很大的问题,就是这个系统真实情况下是在磁盘上进行操作的,我的系统就是在内存中跑的

命令简要

  • cd dirname 【更改目录,注意dirname只能是ls命令下的那些文件名】
  • ls 【打印出当前目录下的文件】
  • mkdir dirname 【创建目录】
  • rmdir dirname 【删除目录】
  • create filename 【 创建文件】
  • rm filename 【删除文件】
  • open filename 【 打开文件,打开后进入该文件目录,可输入read ,write, close命令】
  • read 【打印文件内容】
  • write 【输入命令后,选择写入模式,0截断写,1覆盖写,2追加写】
  • close 【关闭文件】
  • exit 【退出系统】

执行截图

代码附录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>

#define blockSize 1024 //一个磁盘块大小
#define Size 1024000 //磁盘总大小
#define End 65535 //FAT表中盘块结束标志
#define Free 0 //FAT表中空闲块标志
#define maxOpenfile 10 //用户文件表最大长度

typedef struct FCB{
char fileName[8];
char exName[3]; //扩展名,有"dr"和"fl"两种
unsigned char attribute; //0代表目录,1代表文件
unsigned short time;
unsigned short date;
unsigned short first; //起始盘块号,由于我们只分配一个磁盘块给文件,这个是比较重要的数据
unsigned long length; //文件长度
char free; //是否已分配
}fcb;

typedef struct FAT{
unsigned short id; //有Free和End两种类型
}fat;

typedef struct userOpen{
char fileName[8];
char exName[3];
unsigned char attribute;
unsigned short time;
unsigned short date;
unsigned short first;
unsigned long length;
char dir[80]; // 记录目录
int count; //读写指针,我没有用到
char fcbState; //0未修改,1已修改
char toOpenfile; //0空闲,1占用
}userOpen;

typedef struct Block0{
char information[200]; //描述信息
unsigned short root; //根目录起始盘块号
unsigned char* startBlock; //描述信息
}block0;

unsigned char* myVhard; //磁盘首地址
userOpen openFileList[maxOpenfile]; //用户打开文件表
int curdir; //当前目录fd
char currentDir[80]; //当前目录路径
unsigned char* pstart; //数据区起始地址

time_t now ;
struct tm tm_now ; //获得日期时间

void startSys(); //系统初始化
void myFormat(); //磁盘格式化
void my_cd(char* dirname); //cd命令调用
void my_mkdir(char* dirname); //mkdir命令调用
void my_rmdir(char* dirname); //rmdir命令调用
void my_ls(); //ls命令调用
void my_create(char* filename); //create命令调用
void my_rm(char* filename); //rm命令调用
int my_open(char* filename); //open命令调用
void my_write(int type); //write命令调用
void my_read(); //read命令调用
void my_close(); //close命令调用
void my_exit(); //exit命令调用

int getEmptyBlock(); // 得到一个
int getEmptyList(); //
fcb* find_dir(fcb* dir,char* dirname); //在dir目录中找dirname文件,有返回他的fcb地址,无返回NULL

int main(){
time(&now) ;
localtime_r(&tm_now,&now) ; // 得到时间,不重要

startSys(); //系统初始化
while(1){
printf("%s :",currentDir); //进入命令行
char cmd[256];
scanf("%s",cmd); //输入命令
// 依次比对,调用命令函数
if(strcmp(cmd,"cd")==0){
char dirname[80];
scanf("%s",dirname);
my_cd(dirname);
}
else if(strcmp(cmd,"ls")==0){
my_ls();
}
else if(strcmp(cmd,"mkdir")==0){
char dirname[80];
scanf("%s",dirname);
my_mkdir(dirname);
}
else if(strcmp(cmd,"rmdir")==0){
char dirname[80];
scanf("%s",dirname);
my_rmdir(dirname);
}
else if(strcmp(cmd,"create")==0){
char filename[80];
scanf("%s",filename);
my_create(filename);
}
else if(strcmp(cmd,"rm")==0){
char filename[80];
scanf("%s",filename);
my_rm(filename);
}
else if(strcmp(cmd,"open")==0){
char filename[80];
scanf("%s",filename);
if(my_open(filename)!=-1){ //进入文件打开目录
while(1){
printf("%s :",currentDir);
char cmd[8];
scanf("%s",cmd); //输入文件操作命令依次比对
if(strcmp(cmd,"read")==0)
my_read();
else if(strcmp(cmd,"write")==0){
printf("type:0 jieduan\t 1 fugai\t 2 zuijia \n");
int type;
scanf("%d",&type);
my_write(type);
}
else if(strcmp(cmd,"close")==0){
my_close();
break;
}
else
printf("error: wrong command\n");
}
}
else
printf("error: open failed\n");
}
else if(strcmp(cmd,"exit")==0){
my_exit();
break;
}
else
printf("error: wrong command\n");
}
return 0;
}

void startSys(){

myVhard=(char*)malloc(Size); //申请分配内存空间
FILE *file=fopen("FATsys.txt","r"); // 打开存放磁盘数据的文件
if(file!=NULL){
char buffer[Size]; //缓冲区
fread(buffer,Size,1,file); //将磁盘数据读入缓冲区中
memcpy(myVhard,buffer,Size); //将缓冲区数据覆盖到申请的内存空间中
}
else{ //如果没有文件,就进行创建
FILE *file=fopen("FATsys.txt","w");
myFormat(); //调用format进行格式化
fwrite(myVhard,Size,1,file); //格式化完成将数据写回文件
fclose(file);
}
// 进入系统设置当前目录为根目录
fcb* root=(fcb*)(myVhard+5*blockSize); //得到根目录fcb地址
memcpy(openFileList,root,sizeof(fcb)); //将根目录fcb拷贝到用户文件打开表的第0项
strcpy(openFileList[0].dir,"/"); //设置当前文件路径
openFileList[0].toOpenfile=1; //置1,表明0项已被占用
curdir=0; //设置为当前目录
strcpy(currentDir,"/"); //设置当前路径
pstart=(char*)root; // 数据区起始地址即根目录起始地址

}

void myFormat(){

block0* block=(block0*)myVhard; //引导快地址
strcpy(block->information,"sixGroupFATsys_1024_1024000"); //系统信息
block->root=5; //根目录盘块号
block->startBlock=myVhard+5*blockSize; //数据区起始地址

fat* fat1=(fat*)(myVhard+1*blockSize); //fat1表起始地址
int i;
for(i=0;i<6;i++)
(fat1+i)->id=End; //前面六个盘块已被占用
for(i=6;i<1000;i++)
(fat1+i)->id=Free; //未占用盘块置零

fat* fat2=(fat*)(myVhard+3*blockSize); //fat2表起始地址
memcpy(fat2,fat1,2*blockSize); // fat2表备份

fcb* root=(fcb*)(myVhard+5*blockSize); //根目录fcb地址
strcpy(root->fileName,"/"); //设置文件名
strcpy(root->exName,"di"); // 设置扩展名
root->attribute=0; //表明是目录
root->first=5; // 起始盘块
root->length=2*sizeof(fcb); // 长度,因为初始时有/和..两个目录,所以长度是两个fcb
root->free=1; //已分配
root->time=tm_now.tm_mday; //设置时间
root->date=tm_now.tm_mon;

fcb* fatherDir=root+1; //设置父目录
memcpy(fatherDir,root,sizeof(fcb)); //由于是根目录,父目录即他自身
strcpy(fatherDir->fileName,".."); //只需更改文件名
}

void my_cd(char* dirname){
//由于cd命令会更改当前目录,所以判断当前目录是否改过,如果改过更新fcb
if(openFileList[curdir].fcbState==1){
fcb* f;
if(curdir==0)
f=(fcb*)pstart; //根目录fcb地址
else{
f=(fcb*)(myVhard+openFileList[curdir-1].first*blockSize);// 父目录的盘块起始地址
for(;strcmp(f->fileName,openFileList[curdir].fileName)!=0;f++);//比对遍历
}
// 对比用户打开表和fcb,其实只有length会发生变化,只需更新length
f->length=openFileList[curdir].length;

}
// 返回上一级目录
if(strcmp(dirname,"..")==0){
if(curdir==0)
return; //根目录直接返回
else{
openFileList[curdir].toOpenfile=0;
curdir--; //当前目录号减1
strcpy(currentDir,openFileList[curdir].dir); //更新当前路径
}
}
else{

if(curdir==0&&strcmp(dirname,"/")==0)
return; // "cd /" 特殊情况直接返回
else{
userOpen* dir=&openFileList[curdir];
fcb* destDir=find_dir((fcb*)dir,dirname);// 在当前目录下查找
if(destDir==NULL)
printf("error: dirname not exist\n");
else if(destDir->attribute==1) //如果是文件
printf("error: the dirname is file\n");
else if(destDir->attribute==0){
int num=getEmptyList(); //得到一个空白用户文件打开表号
if(num==-1)
printf("error: no empty openList\n");
else{
// 更新当前目录
openFileList[num].toOpenfile=1;
memcpy(openFileList+num,destDir,sizeof(fcb));
strcpy(openFileList[num].dir,openFileList[curdir].dir);
strcat(openFileList[num].dir,openFileList[num].fileName);
strcat(openFileList[num].dir,"/");
openFileList[num].fcbState=0;
curdir=num;
strcpy(currentDir,openFileList[curdir].dir);
}
}
}
}
}

void my_ls(){
userOpen* dir=&openFileList[curdir];
if(dir->attribute==1){ //如果是文件
printf("error: file cannot use this command\n");
}
else if(dir->attribute==0){
int i;
fcb* f=(fcb*)(myVhard+dir->first*blockSize);//当前目录盘块起始地址
for(i=0;i<dir->length/sizeof(fcb);i++) //遍历打印
printf("%s (%s) \t",(f+i)->fileName,(f+i)->exName);
printf("\n");
}
}

void my_mkdir(char* dirname){
userOpen* dir=&openFileList[curdir];
if(find_dir((fcb*)dir,dirname)!=NULL) //遍历查找是否重名
printf("error: dirname is existed\n");
else if(blockSize<(dir->length+sizeof(fcb))) //目录盘块是否有空余空间
printf("error: curdir is full\n");
else if(getEmptyBlock()==-1) //创建目录要分配盘块,看看是否有空闲盘块
printf("error: the disk is full\n");
else{
int blocknum=getEmptyBlock();
fat* fat1=(fat*)(myVhard+1*blockSize);
fat1[blocknum].id=End; // 分配一个空闲盘块
//在父目录中写入fcb
fcb* mkdir=(fcb*)(myVhard+dir->first*blockSize+dir->length); //写入起始地址
strcpy(mkdir->fileName,dirname);
strcpy(mkdir->exName,"di");
mkdir->attribute=0;
mkdir->first=blocknum;
mkdir->length=sizeof(fcb);
mkdir->free=1;
mkdir->time=tm_now.tm_mday;
mkdir->date=tm_now.tm_mon;

dir->length+=sizeof(fcb); //父目录长度加一个fcb
dir->fcbState=1; //修改位置1
// 设置..目录
fcb* fatherDir=(fcb*)(myVhard+blocknum*blockSize);
memcpy(fatherDir,dir,sizeof(fcb));
strcpy(fatherDir->fileName,"..");
fatherDir->free=1;
}
}

void my_rmdir(char* dirname){
userOpen* dir=&openFileList[curdir];
fcb* destDir=find_dir((fcb*)dir,dirname);//父目录查找
if(destDir==NULL)
printf("error: the dir not exist\n");
else if(destDir->attribute==1)
printf("error: the file cannot use command\n");
else{
int num=destDir->length/sizeof(fcb);
if(num>1) //如果是非空目录
printf("error: the dir not empty\n");
else{
fat* fat1=(fat*)(myVhard+1*blockSize);
fat1[destDir->first].id=0; //回收目录盘块
openFileList[curdir].length-=sizeof(fcb); //父目录长度减一个fcb
openFileList[curdir].fcbState=1;
}

}
}

void my_create(char* filename){
userOpen* dir=&openFileList[curdir];
if(find_dir((fcb*)dir,filename)!=NULL) // 判断是否重名
printf("error: filename is existed\n");
else if(blockSize<(dir->length+sizeof(fcb))) //当前目录盘块是否有空余
printf("error: curdir is full\n");
else{
// 下面参考mkdir,不同的是create不进行盘块分配,写入该文件时进行分配
fcb* fl=(fcb*)(myVhard+dir->first*blockSize+dir->length);
strcpy(fl->fileName,filename);
strcpy(fl->exName,"fl");
fl->attribute=1;
fl->first=End;
fl->length=0;
fl->time=tm_now.tm_mday;
fl->date=tm_now.tm_mon;
dir->length+=sizeof(fcb);
dir->fcbState=1;
}
}

void my_rm(char* filename){
userOpen* dir=&openFileList[curdir];
fcb* fl=find_dir((fcb*)dir,filename);
if(fl==NULL)
printf("error: filename not exist\n");
else if(fl->attribute==0)
printf("error: the file is dir\n");
else{
fat* fat1=(fat*)(myVhard+1*blockSize);
int bnum=fl->first;
// 回收盘块
while(bnum!=End){
int a=bnum;
bnum=fat1[bnum].id;
fat1[a].id=0;
}
dir->length-=sizeof(fcb);
dir->fcbState=1;
}
}

int my_open(char* filename){
int ret=-1;
userOpen* dir=&openFileList[curdir];
fcb* destFile=find_dir((fcb*)dir,filename);
if(destFile==NULL)
printf("error: filename not exist\n");
else if(destFile->attribute==0)
printf("error: the filename is dir\n");
else if(destFile->attribute==1){
int num=getEmptyList();
if(num==-1)
printf("error: no empty openList\n");
else{
// 加载到用户打开文件表 ,参考cd
openFileList[num].toOpenfile=1;
memcpy(openFileList+num,destFile,sizeof(fcb));
strcpy(openFileList[num].dir,openFileList[curdir].dir);
strcat(openFileList[num].dir,openFileList[num].fileName);
strcat(openFileList[num].dir,"/");
openFileList[num].fcbState=0;
curdir=num;
strcpy(currentDir,openFileList[curdir].dir);
ret=curdir;
}
}
return ret;
}
void my_write(int type){
fat* fat1=(fat*)(myVhard+1*blockSize);
// 判断是否分配了盘块
if(openFileList[curdir].first==End){
int blocknum=getEmptyBlock(); //分配盘块
fat1[blocknum].id=End;
openFileList[curdir].first=blocknum;
openFileList[curdir].fcbState=1;
}
char* pwrite=myVhard+openFileList[curdir].first*blockSize;
if(type==0){
char buffer[10240]; // 设置写缓冲区
printf("please write(type0):\n");
scanf("%s",buffer);
int writesize=strlen(buffer)*sizeof(char); //计算待写入大小

int bnum=openFileList[curdir].first; // 起始盘块号
do{
char* pblock=myVhard+bnum*blockSize;
memset(pblock,0,blockSize);
bnum=fat1[bnum].id;
}while(bnum!=End); //截断写,先进行清空
openFileList[curdir].length=0;
bnum=openFileList[curdir].first; // 起始写入盘块号
int i=0; //计算写入次数,以便得到缓冲区偏移量
int preblock; // 记录前一个盘块号
do{
// 如果需要盘块,进行分配
if(bnum==End){
bnum=getEmptyBlock();
if(bnum==-1){
printf("error: no empty block\n");
break;
}
fat1[preblock].id=bnum;
fat1[bnum].id=End;
}
char* pwrite=myVhard+bnum*blockSize; //每次写入的起始指针

// 如果待写入大小大于一个盘块大小,本一次写入一个盘块大小
if(writesize>blockSize){
memcpy(pwrite,buffer+i*blockSize,blockSize);
openFileList[curdir].length+=blockSize;
i++;
}
else{ // 如果小于,写入待写入大小
memcpy(pwrite,buffer+i*blockSize,writesize);
openFileList[curdir].length+=writesize;
}
writesize-=blockSize; //按盘块写入的,每次减一个盘块大小
preblock=bnum; // 记录前一个盘块,以便更新fat表
bnum=fat1[bnum].id; //下一个盘块
}while(writesize>0);
openFileList[curdir].fcbState=1;
}
else if(type==1){ //与截断写类似,不过不需要清空,并且需要比较覆盖长度和原长度的大小
char buffer[10240];
printf("please write(type1):\n");
scanf("%s",buffer);
int writesize=strlen(buffer)*sizeof(char);
int bnum=openFileList[curdir].first;
bnum=openFileList[curdir].first;
int i=0;
int preblock;
int newlength=0;
do{
if(bnum==End){
bnum=getEmptyBlock();
if(bnum==-1){
printf("error: no empty block\n");
break;
}
fat1[preblock].id=bnum;
fat1[bnum].id=End;
}
char* pwrite=myVhard+bnum*blockSize;
if(writesize>blockSize){
memcpy(pwrite,buffer+i*blockSize,blockSize);
newlength+=blockSize;
i++;
}
else{
memcpy(pwrite,buffer+i*blockSize,writesize);
newlength+=writesize;
}
writesize-=blockSize;
preblock=bnum;
bnum=fat1[bnum].id;
}while(writesize>0);
openFileList[curdir].fcbState=1;
if(newlength>openFileList[curdir].length)
openFileList[curdir].length=newlength;
}
else if(type==2){ // 追加写要复杂一些
char buffer[10240];
printf("please write(type2):\n");
scanf("%s",buffer);
int writesize=strlen(buffer)*sizeof(char);
int lastblock=openFileList[curdir].first;
for(;fat1[lastblock].id!=End;lastblock=fat1[lastblock].id); // 得到最后一个盘块号
//判断文件盘块是否写满
if(openFileList[curdir].length%blockSize==0){//满了需要申请空闲盘块
int preblock=lastblock;
int bnum=End;
int i=0;
do{
bnum=getEmptyBlock(); // 申请盘块
if(bnum==-1){
printf("error: no empty block\n");
break;
}
fat1[preblock].id=bnum;
fat1[bnum].id=End;
char* pwrite=myVhard+bnum*blockSize; //写指针

if(writesize>blockSize){
memcpy(pwrite,buffer+i*blockSize,blockSize);
openFileList[curdir].length+=blockSize;
i++;
}
else{
memcpy(pwrite,buffer+i*blockSize,writesize);
openFileList[curdir].length+=writesize;
}
writesize-=blockSize;
preblock=bnum;
bnum=fat1[bnum].id;
}while(writesize>0);
}
else{//未满说明盘块还有剩余空间
int bnum=lastblock;
int i=0;
int preblock;
int freeSize=blockSize-openFileList[curdir].length%blockSize;//计算剩余空间
do{
if(bnum==End){
bnum=getEmptyBlock();
if(bnum==-1){
printf("error: no empty block\n");
break;
}
fat1[preblock].id=bnum;
fat1[bnum].id=End;
}
char* pwrite;
if(freeSize<blockSize) // 计算写指针位置
pwrite=myVhard+bnum*blockSize+openFileList[curdir].length%blockSize;
else
pwrite=myVhard+bnum*blockSize;

if(writesize>freeSize){
memcpy(pwrite,buffer+i*freeSize,freeSize);
openFileList[curdir].length+=freeSize;
i++;
}
else{
memcpy(pwrite,buffer+i*freeSize,writesize);
openFileList[curdir].length+=writesize;
}
writesize-=freeSize;
preblock=bnum;
bnum=fat1[bnum].id;
freeSize=blockSize;
}while(writesize>0);
}

openFileList[curdir].fcbState=1;
}
}
void my_read(){
if(openFileList[curdir].first==End)
printf("error: file is empty\n");
else{
char buffer[1024]={0};
int bnum=openFileList[curdir].first;
int i=0;
fat* fat1=(fat*)(myVhard+1*blockSize);
while(bnum!=End){
char* pread=myVhard+bnum*blockSize;
memcpy(buffer,pread,blockSize);//每次读一个盘块
printf("read::\n");
printf("%s\n",buffer);
bnum=fat1[bnum].id;
}
}
}
void my_close(){
//关闭文件时,判断文件是否被修改,如果被修改,需要写回fcb中
if(openFileList[curdir].fcbState==1){
fcb* f;
if(curdir==0)
f=(fcb*)pstart;
else{
f=(fcb*)(myVhard+openFileList[curdir-1].first*blockSize);
for(;strcmp(f->fileName,openFileList[curdir].fileName)!=0;f++);
}
f->first=openFileList[curdir].first;
f->length=openFileList[curdir].length;
}
openFileList[curdir].toOpenfile=0;
curdir--;
strcpy(currentDir,openFileList[curdir].dir);
}

void my_exit(){
// 退出系统,备份fat2,更新根目录fcb,写入系统文件,以便再次打开时可以读取以前的文件
fat* fat1=(fat*)(myVhard+1*blockSize);
fat* fat2=(fat*)(myVhard+3*blockSize);
memcpy(fat2,fat1,2*blockSize);
if(openFileList[0].fcbState==1){
fcb* f=(fcb*)pstart;
f->length=openFileList[0].length;
}
FILE *file=fopen("FATsys.txt","w");
fwrite(myVhard,Size,1,file);
fclose(file);
}
int getEmptyBlock(){
fat* fat1=(fat*)(myVhard+1*blockSize);
int i;
for(i=0;i<1000;i++)
if(fat1[i].id==0)
return i;
return -1;
}
fcb* find_dir(fcb* dir,char* dirname){
if(dir->attribute==0){
int i;
fcb* f=(fcb*)(myVhard+dir->first*blockSize);
for(i=0;i<dir->length/sizeof(fcb);i++)
if(strcmp(f[i].fileName,dirname)==0)
return f+i;
}
return NULL;
}

int getEmptyList(){
int i;
for(i=0;i<10;i++)
if(openFileList[i].toOpenfile==0)
return i;
return -1;
}

author: YaoGuangMing 2022-HDU

转载请标明出处!