成都信息工程学院操作系统实验报告四文件操作.docVIP

  • 15
  • 0
  • 约6.67千字
  • 约 8页
  • 2019-03-17 发布于广东
  • 举报

成都信息工程学院操作系统实验报告四文件操作.doc

课程名: 计算机操作系统 地点: 姓名: 班级: 学号: 成绩 项目: 文件操作 实验目的 掌握文件系统的工作机理 理解文件系统的主要数据结构 学习较为复杂的 Linux 下的编程 实验内容 设计并实现一个一级(单用户)文件系统程序 1、提供以下操作 文件创建/删除接口命令create/delete 目录创建/删除接口命令midair/rmdir 显示目录内容命令ls 2、创建的文件不要求格式和内容 在以上基础上设计并实现一个二级文件系统 具备提供用户登录 文件、目录要有权限 程序主文件代码: #include stdio.h #include malloc.h #include stdlib.h #include string.h #include structure.h #include creat.h #include access.h #include ballfre.h #include close.h #include delete.h #include dir.h #include format.h #include halt.h #include iallfre.h #include install.h #include log.h #include name.h #include open.h #include rdwt.h #include igetput.h struct hinode hinode[NHINO]; struct dir dir; struct file sys_ofile[SYSOPENFILE]; struct filsys filsys; struct pwd pwd[PWDNUM]; struct user user[USERNUM]; FILE *fd; struct inode *cur_path_inode; int user_id; unsigned short usr_id; char usr_p[12]; char sel; char temp_dir[12]; main() { unsigned short ab_fd1,ab_fd2,ab_fd3,ab_fd4,i,j; char *buf; int done=1; printf(\nDo you want to format the disk(y or n)?\n); if(getchar()==y) { printf(\nFormat will erase all context on the disk \n); printf(Formating...\n); format(); printf(\nNow will install the fillsystem,please wait...\n); install(); printf(\n----Login----\nPlease input your userid:); scanf(%u,usr_id); printf(\nPlease input your password:); scanf(%s,usr_p); if(!login(usr_id,usr_p)) return; /*login(2118,abcd);*/ while(done) { printf(\n Please Select Your Operating\n); printf( -1----ls\n -2----mkdir\n -3----change dir\n -4----create file\n -0----Logout\n); sel=getchar(); sel=getchar(); switch(sel) { case 1: _dir(); break; case 2: printf(please input dir name:); scanf(%s,temp_dir); mkdir(temp_dir); break; case 3: printf(please input dir name:); scanf(%s,temp_dir); chdir(temp_dir); break; case 4: printf(please input file name:); scanf(%s,temp_dir); ab_fd1=creat(2118,temp_dir,01777); buf=(char *)malloc(BLOCKSIZ*6+5); write(ab_fd1,buf,BLOCKSIZ*6+5)

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档