cad怎么把毫米变成米:求教以下一段代码的意思(1)

来源:百度文库 编辑:高校问答 时间:2024/04/27 23:03:29
#include "stdio.h"
#include "filesys.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;
int iHave_formated;
int iCur_free_block_index;

main( )
{ unsigned short ab_fd1,ab_fd2,ab_fd3,ab_fd4,ab_fd5;
char *buf;
char file_content_buf[BLOCKSIZ];

char c;

printf("begin:\n");
printf("\nDo you want to format the disk?\n");
if(getchar( )=='y')
printf("\nFormat will erase context on the disk \n Are you sure?\n");
getchar();
if((c=getchar( ))=='y')
{
printf("format starts\n");
format( );
iHave_formated = 1;
printf("format ended\n");
}
else
printf("received char :%c from stdin\n",c);

printf("step 1 ended\n");
install( );
printf("step 2 ended\n");
_dir( );
printf("step 3 ended\n");
login(2118,"abcd");
user_id=0;
printf("step 4 ended\n");

mkdir("a2118");
_dir();
printf("step 5-1 ended\n");

chdir("a2118");
_dir();
printf("step 5-2 ended\n");

ab_fd1=creat(2118,"ab_file0.c",01777);
_dir();
printf("step 6 ended\n");

buf=(char *)malloc(BLOCKSIZ*6+5);
printf("step 7 ended\n");
write(2118,ab_fd1,buf,BLOCKSIZ*6+5);
printf("step 8 ended\n");
close(2118,ab_fd1);
printf("step 9 ended\n");
free(buf);
write(2118,ab_fd4,buf,BLOCKSIZ*8+300);
printf("step 18 ended\n");
close(2118,ab_fd4);
free(buf);
printf("step 19 ended\n");

ab_fd3=open(2118,"ab_file2.c",FAPPEND);
printf("step 20 ended\n");
buf=(char *)malloc(BLOCKSIZ*3+100);
write(2118,ab_fd3,buf,BLOCKSIZ*3+100);