操作系统实验报告文件管理内容摘要:
***读写系统超级块信息***********************************/ void Read_Boot() //读取磁盘超级块数据 信息 { rewind(fsPtr)。 fread(amp。 FsSupBlk,sizeof(struct Super_Block),1,fsPtr)。 return。 } void FileBoot() //超级块数据信息存盘 { rewind(fsPtr)。 fwrite(amp。 FsSupBlk,sizeof(struct Super_Block),1,fsPtr)。 return。 15 } /***********************FAT 操作 ***********************************/ void LoadFat() //装载全部 FAT 到内存 { fseek(fsPtr,*512,SEEK_SET)。 fread(fat_buffer,sizeof(long int), ,fsPtr)。 return。 } void SaveFat() //FAT 到文件 FAT 区 { fseek(fsPtr,*512,SEEK_SET)。 fwrite(fat_buffer,sizeof(long int),fsPtr)。 return。 } /***********************显示超级块信息 ***********************************/ void boot_dis() { printf(=%ld\n,)。 printf(=%d\n,)。 printf(=%d\n,)。 printf(=%d\n,)。 16 printf(=%d\n,)。 printf(=%d\n,)。 printf(=%d\n,)。 printf(=%ld\n,)。 printf(=%ld\n,)。 } /***********************系统初始化 ***********************************/ void Sys_Init() //初始化 { fsPtr=fopen(DiskName,rb+)。 if(fsPtr == NULL) Create_Disk()。 Read_Boot()。 //boot_dis()。 LoadFat()。 return。 } /***********************显示操作 ***********************************/ void dir() //显示目录下的文件 { int i,countFile=0。 char str[16]。 long int n,pos_dir,pos_fat。 17 coutendl。 pos_dir=*512。 pos_fat=*512。 fseek(fsPtr,pos_dir,SEEK_SET)。 while(ftell(fsPtr)pos_fat) { fread(amp。 filefcb[0],sizeof(struct FCB_Block),16 ,fsPtr)。 for(i=0。 i16。 i++) if(filefcb[i].flag == 1) //文件占有 { countFile++。 n = filefcb[i].file_length。 printf( %15s%s%15d bytes\n, filefcb[i].file_name,file,n)。 } } coutendl。 printf( 总共有 %d 个文件 \n,countFile)。 printf( 系统总共有 %ld 个物理块可用 \n\n,)。 } /*************************查找文件 *******************************/ //查找文件 ,文件存在 返回当前 FCB 数组下标,否则返回 1 18 int Find_File(char *filename) { int i。 long int pos_dir,pos_fat。 pos_dir=*512。 pos_fat=*512。 find_fcb=0。 fseek(fsPtr,pos_dir,SEEK_SET)。 while(ftell(fsPtr)pos_fat) { find_fcb++。 fread(amp。 filefcb[0],sizeof(struct FCB_Block),16 ,fsPtr)。 for(i=0。 i16。 i++) if(filefcb[i].flag!=1) { if(strcmp(filename,filefcb[i].file_name) == 0) return i。 } //文件存在 } return 1。 } /*************************创建文件 *******************************/ void create(char *fname,long int num) //在当前目录下创建一个名字为 str 的文件,长度为 num { int i,j。 //true 表示没有与该名字重名的文件 int tempnode。 19 long int pos_dir,getnum=0。 unsigned long int blkcount。 blkcount= num/512+1。 //计算需要的物 理块 if( blkcount) //磁盘没有足够空间 { printf(\n 磁盘没有足够空间,不能建立。 \n\n)。 return。 } tempnode=Find_File(fname)。 if (tempnode!=1) //表示文件存在 { printf(\n 文件已经存在,不需要建立。 \n\n)。 return。 } // 建立文件的处理 pos_dir=*。 fseek(fsPtr,pos_dir,SEEK_SET)。 //定位到目录区 for(i=0。 i。 i++) { //Read_Block(i+,(char *)filefcb)。 fread(amp。 filefcb[0],sizeof(struct FCB_Block),16 ,fsPtr)。 for(j=0。 j16。 j++) 20 if(filefcb[j].flag == 1) //找到空目录项 { // 分配空间 , 标记 FCB 数据项,并将 FCB 写磁盘 getnum=Get_Block(blkcount)。 if(getnum==1){ printf(不能分配存储空间 \n)。 return。 } filefcb[j].file_start=getnum。 filefcb[j].flag = 1。 filefcb[j].file_length=num。 strcpy(filefcb[j].file_name,fname)。 //filefcb[].file_time= //filefcb[].file_date= // 改变磁盘 FCB 值 pos_dir=pos_dir+sizeof(struct FCB_Block)*(i*16+j)。 fseek(fsPtr,pos_dir,SEEK_SET)。 //定位到目录区的 FCB 项 fwrite(amp。 filefcb[j],sizeof(struct FCB_Block),1 ,fsPtr)。 //Write_Block(i+,(char *)filefcb)。 printf( 文件占用了 %d 个物理块 \n,blkcount)。 printf( 系统还。操作系统实验报告文件管理
相关推荐
时屏幕出现的现象,并分析原因。 如果在程序中使用调用 lockf()来给每一个子进程加锁,可以实现进程之间的互斥,观察并分析出现的现象。 〈程序 代码 〉 include main() { int p1,p2,i。 if(p1=fork()) { for(i=0。 i500。 i++) printf(parent%d\n,i)。 wait(0)。 /* 保证在子进程终止前,父进程不会终止 */
int att。 // 文件属性 0 为只读 1 为只写 //用于指向文件内容模块 }fa[8],fg[8]。 int x,k=0。 //全局钥匙 void check() //密码认证 { int check,a=1。 char pin1[]=a。 //此处设定用户口令 21 char pin[20]。 while(a) { printf(* * * * * * * * * * * * * *
人民币 20,(大写:贰万元整) 2020年 月 至 2020年 月, 每月 租金:人民币 6, (大写: 陆仟 元整 ) 2020年 月至 2020年 月, 每 年 租金:人民币 80,000元 (大写:陆仟元整 ) 三、管理方式 乙方委托甲方统一管理租 赁 物,产权属乙方。 四、甲方责任 (一)提供车辆所需燃油; (二)提供操作该设备操作员,负责操作人员工资; (三)视同甲方设备、严格管理
p。 (ns != NULL)) { //前后两个分区都与之合并 if (nslast == NULL) { //若 ns 为头结点,则 fl 链表直接指向其下一个结点 fl = nsnext。 } else if (nsnext == NULL) { //若 ns 为尾结点,则直接将该结点删除 nslastnext = NULL。 } else { nslastnext = nsnext。
)在 △ ABC中,内角 A、 B、 C的对边分别 是 a, b, c,若 a2b2= bc, sin C=2 sin B,则 A=________. 3 33 3分析:由 sin C=2 sin B和正弦定理可求得 c=2 由此运用余弦定理可求得 cos A的值,进而求出 A. b, 2 2 2 2 2 2 322b c a b c b b cb c b c 223