コード例 #1
0
ファイル: test2.c プロジェクト: vinaygangadhar/cs537_projects
int main(int argc, char** argv)
{

    int ret = MFS_Init("procyon.cs.wisc.edu", 1345);
    if(ret != 0)
        printf("MFS_Init error\n");

//long name test
    ret = MFS_Creat(1, 1, "veryveryveryveryveryveryveryveryveryverylengthyfilename1111111111111111111.txt");
    if(ret < 0)
        printf("MFS_Creat Error\n");

//Already existing file
    ret = MFS_Creat(0, 1, "hello.txt");
    if(ret < 0)
        printf("MFS_Creat Error\n");

//Actual create test (creating a file)
    ret = MFS_Creat(0, 1, "test.txt");
    if(ret < 0)
        printf("MFS_Creat Error\n");

//Do a look up on that created file
    ret = MFS_Lookup(0, "test.txt");
    if(ret != 0)
        printf("MFS_Lookup Error\n");

    ret = MFS_Shutdown();
    if(ret < 0)
        printf("MFS_Shutdown Error\n");

    return 0;
}
コード例 #2
0
ファイル: test39.c プロジェクト: HarveyHWChen/cs537projects
int main(int argc, char* argv[]) {
  MFS_Init(argv[2], atoi(argv[1]));

  // /dir1
  int rc;
  rc = MFS_Creat(0, MFS_DIRECTORY, "dir");
  if (rc == -1) return -1;


  int pinum = MFS_Lookup(0, "dir");
  if (pinum <=0) return -1;

  int inum[100]; // inum of file 0-99

  // creating a bunch of file
  int i,j;
  char base[] = "file";
  char filename[10];
  char buf[MFS_BLOCK_SIZE];
  int numfile = 20;
  int numblock = 10;
  memset(buf, 99, MFS_BLOCK_SIZE);
  for (i = 0; i < numfile; i++) {
    sprintf(filename, "%s%d", base, i);
    //printf("filename = .%s.\n", filename);
    rc  = MFS_Creat(pinum, MFS_REGULAR_FILE, filename);
    if (rc == -1) return -1;
    inum[i] = MFS_Lookup(pinum, filename);
    if (inum[i] <= 0) return -1;
    
    for (j = 0; j < numblock; j++) {
      rc = MFS_Write(inum[i], buf, j);
      if (rc == -1) return -1;
    }

  }

  // now double check dir and file99
  MFS_Stat_t m;
  rc = MFS_Stat(pinum, &m);
  printf ("size = %d\n", m.size);
  printf ("block = %d\n", m.blocks);
  if (m.type != MFS_DIRECTORY ||
      m.size != (numfile +2) * sizeof(MFS_DirEnt_t))// ||
      //      m.blocks != (int) (102 * sizeof(MFS_DirEnt_t)) >> 12)
    return -1;  // do we need to check for the blocks

  
  
  return 0;
}
コード例 #3
0
ファイル: test14.c プロジェクト: HarveyHWChen/cs537projects
int main(int argc, char* argv[]) {
  MFS_Init(argv[2], atoi(argv[1]));
  MFS_Stat_t stat;

  if (MFS_Creat(0, MFS_REGULAR_FILE, "file.txt") == -1)
	  return -1;

  int inode = MFS_Lookup(0, "file.txt");
  if (inode == -1 || inode == 0)
	  return -1;

  char buf[MFS_BLOCK_SIZE];
  memset(buf, 99, MFS_BLOCK_SIZE);
  if (MFS_Write(inode, buf, 0) == -1)
	  return -1;

  if (MFS_Stat(inode, &stat) != 0)
	  return -1;
  if (stat.type != MFS_REGULAR_FILE)
	  return -1;
  if (stat.size !=  MFS_BLOCK_SIZE)
	  return -1;
  if (stat.blocks != 1)
	  return -1;

  return 0;

}
コード例 #4
0
ファイル: test35.c プロジェクト: HarveyHWChen/cs537projects
int main(int argc, char* argv[]) {
  MFS_Init(argv[2], atoi(argv[1]));

  // /dir1
  int rc;
  rc = MFS_Creat(0, MFS_DIRECTORY, "dir1");
  if (rc == -1) return -1;

  int inum = MFS_Lookup(0, "dir1");
  if (inum <=0) return -1;

  rc = MFS_Creat(inum, MFS_REGULAR_FILE, "file1");
  if (rc == -1) return -1;

  rc = MFS_Unlink(0, "dir1");
  if (rc == 0) return -1;

  return 0;
}
コード例 #5
0
void
repCreat(){
    printf("CLIENT: initialized server\n");
    int rc=MFS_Init("mumble-38.cs.wisc.edu", 10000);
    printf("CLIENT:: return value from lib init call (%d)\n", rc);    

    printf("=============== rep creat test 1 create root file ============\n");
    rc=MFS_Creat(0,0,"rep_dir_2");
    printf("CLIENT:: return value from lib big dir call (%d)\n", rc);

    printf("=============== rep creat test2 look up test ============\n");
    int testInum=MFS_Lookup(0,"rep_dir_2");
    printf("CLIENT:: return value from lib big dir look up call (%d)\n", testInum);

    char name[60]="aa";
    int i;
    for (i=0;i<5;i++){
      printf("=============== rep creat test 1 create file. name (%s) ============\n", name);
      rc=MFS_Creat(testInum,1,name);
      printf("CLIENT:: return value from lib big dir call (%d)\n", rc);
    }

    for (i=0;i<5;i++){
      printf("=============== rep creat test 1 lookup file. name (%s) ============\n", name);
      rc=MFS_Lookup(testInum,name);
      printf("CLIENT:: return value from lib big dir call (%d)\n", rc);
    }

    for (i=0;i<5;i++){
      printf("=============== rep creat test 1 create file. name (%s) ============\n", name);
      rc=MFS_Creat(testInum,1,name);
      printf("CLIENT:: return value from lib big dir call (%d)\n", rc);
    }

    for (i=0;i<5;i++){
      printf("=============== rep creat test 1 lookup file. name (%s) ============\n", name);
      rc=MFS_Lookup(testInum,name);
      printf("CLIENT:: return value from lib big dir call (%d)\n", rc);
    }
    
}
コード例 #6
0
int main(int argc, char* argv[]) {
  MFS_Init(argv[2], atoi(argv[1]));

  int rc = MFS_Creat(0, MFS_DIRECTORY, "dir0");
  if (rc == -1) return -1;

  rc = MFS_Creat(0, MFS_REGULAR_FILE, "file0");
  if (rc == -1) return -1;
  
  int inum = MFS_Lookup(0, "file0");
  if (inum <= 0) return -1;

  char buf[MFS_BLOCK_SIZE];
  memset(buf, 'A', MFS_BLOCK_SIZE);
  
  rc = MFS_Write(inum, buf, 0);
  if (rc == -1) return -1;
  memset(buf, 'B', MFS_BLOCK_SIZE);
  rc = MFS_Write(inum, buf, 1);
  if (rc == -1) return -1;
  return 0;    
}
コード例 #7
0
ファイル: client.c プロジェクト: nsubramaniam/p6
int main(int argc, char *argv[])
{
  MFS_Init(argv[2], atoi(argv[1]));

  if (MFS_Lookup(0, "file.txt") != -1)
    return -1;
  if (MFS_Creat(0,  MFS_REGULAR_FILE, "file.txt") == -1)
    return -1;
  if (MFS_Lookup(0, "file1.txt") != -1)
    return -1;
printf("here\n");

  return 0;
}
コード例 #8
0
ファイル: main.c プロジェクト: tmfahey/cs537
int
main(int argc, char *argv[])
{
printf("in main\n");    


printf("sizes: check_t %d, imap %d, inode %d, MFS_DirEnt_t %d \n", (int)sizeof(check_t), (int)sizeof(inode_map), (int)sizeof(MFS_inode_t), (int)sizeof(MFS_DirEnt_t));

     MFS_Init("mumble-34.cs.wisc.edu",10000);


     int y= MFS_Creat(0,0,"testdir");
     printf("y=%d\n",y);


     int z =  MFS_Lookup(1,".");
     printf("z %d \n", z);



/*int unlnk =  MFS_Unlink(0, "test");
// printf("unlink is %d\n", unlnk);
// for testing write



    char * buffer1 = (char*)malloc(65*sizeof(char));
     char buffer[4096];
     buffer[0] = 's';
     
     buffer[4095] = 'e';
     int i;
for (i=1;i <4095;i++){
buffer[i] = '\0';
}

     int wr =MFS_Write(1, buffer, 0);
     printf("successful write %d\n", wr);

     printf("%p buf1\n",buffer1);
     int r = MFS_Read(1, buffer1, 0);
  printf("%s",buffer1);
     printf("successful read %d\n", r);*/

 MFS_Shutdown();
    return 0;
}
コード例 #9
0
ファイル: test17.c プロジェクト: HarveyHWChen/cs537projects
int main(int argc, char* argv[]) {
  MFS_Init(argv[2], atoi(argv[1]));

  if (MFS_Creat(0, MFS_DIRECTORY, "usr") == -1)
	  return -1;

  int inode = MFS_Lookup(0, "usr");
  if (inode == -1)
	  return -1;

  char buf[MFS_BLOCK_SIZE];
  memset(buf, 99, MFS_BLOCK_SIZE);
  if (MFS_Write(inode, buf, 0) == 0)
	  return -1;

  return 0;

}
コード例 #10
0
ファイル: client.c プロジェクト: markcoatsworth/CS537
int main(int argc, char *argv[])
{
    // Open the server on the specified port
    int init = MFS_Init("127.0.0.1", 1666);
    printf("[client] MFS_Init returned %d\n", init);
   
   	// Create a new file
   	int NewFileCreate = MFS_Creat(0, MFS_REGULAR_FILE, "file666.txt");
   	printf("[client] MFS_Creat returned %d\n", NewFileCreate);
   	
   	int NewFileInum = MFS_Lookup(0, "file666.txt");
   	printf("[client] MFS_Lookup returned for file666.txt %d\n", NewFileInum);
   	
   	// Now write a block to this file
   	int NewBlockWrite = MFS_Write(NewFileInum, "test file contents!", 0);
   	printf("[client] MFS_Write returned %d\n", NewBlockWrite);
   	
   	//MFS_Debug();

   	// Now write a newblock to this file
   	NewBlockWrite = MFS_Write(NewFileInum, "a second block!", 1);
   	printf("[client] MFS_Write returned %d\n", NewBlockWrite);
   	   	
   	//MFS_Debug();	
   
    // Overwrite a block
    int OverwriteBlock = MFS_Write(NewFileInum, "overwriting the 0th block of the file", 0);
    printf("[client] MFS_Write returned %d for overwrite\n", OverwriteBlock);
    
    //MFS_Debug();
  	
  	// Do a valid read (of the data we just wrote)
	char *ValidReadBuffer;
	ValidReadBuffer = (char*)malloc(MFS_BLOCK_SIZE * sizeof(char));
	int ValidRead = MFS_Read(NewFileInum, ValidReadBuffer, 0);
	printf("[client] MFS_Read returned %d for the valid read, ReadBuffer=%s\n", ValidRead, ValidReadBuffer);
  	
    // Shutdown
    MFS_Shutdown();
    printf("[client] Sent shutdown, now exiting...\n");
    
    exit(0);
}
コード例 #11
0
void
bigDirTest(){
  char buffer[4096];
    int i = 0;
    for (i = 0; i < 10; i++)
    	buffer[i] = 'i';
    for (i = 10; i <2045; i++)
    	buffer[i] = 'a';
    for(i = 2045; i < 4090; i++)
    	buffer[i] = 'v';
    for (i = 4090;i<4095;i++)
    	buffer[i] = 'b';
    buffer[4095]=0;

    printf("CLIENT: initialized server\n");
    int rc=MFS_Init("mumble-38.cs.wisc.edu", 10000);
    printf("CLIENT:: return value from lib init call (%d)\n", rc);    

    printf("=============== big dir test 1 create root file ============\n");
    rc=MFS_Creat(0,0,"big_dir_3");
    printf("CLIENT:: return value from lib big dir call (%d)\n", rc);

    printf("=============== big dir test2 look up test ============\n");
    int testInum=MFS_Lookup(0,"big_dir_3");
    printf("CLIENT:: return value from lib big dir look up call (%d)\n", testInum);

    /* char name[60]; */
    /* for (i=0;i<100;i++){ */
    /*   printf("=============== big dir test 1 create file. name (%d) ============\n", i); */
    /*   sprintf(name,"%d",i); */
    /*   printf("file name %s\n",name); */
    /*   rc=MFS_Creat(testInum,1,name); */
    /*   printf("CLIENT:: return value from lib big dir call (%d)\n", rc); */
    /* } */

    /* for (i=0;i<100;i++){ */
    /*   printf("=============== big dir test 1 lookup file. name (%d) ============\n", i); */
    /*   sprintf(name,"%d",i); */
    /*   printf("file name %s\n",name); */
    /*   rc=MFS_Lookup(testInum,name); */
    /*   printf("CLIENT:: return value from lib big dir call (%d)\n", rc); */
    /* } */
}
コード例 #12
0
ファイル: test.c プロジェクト: vinaygangadhar/cs537_projects
int main(int argc, char** argv)
{
 char buf[MFS_BLOCK_SIZE];
 int inum;

 int ret = MFS_Init("procyon.cs.wisc.edu", 1345);
 if(ret != 0)
		printf("MFS_Init error\n");

 ret = MFS_Lookup(1, "hello.txt");
 if(ret != 0)
		printf("MFS_Lookup error\n");

 MFS_Stat_t mfs_s;
 ret = MFS_Stat(1, &mfs_s);
 if(ret != 0)
	 printf("MFS_Stat error\n");

 strcpy(buf, "A random text to be written to write_buffer");
 ret = MFS_Write(1, buf, 4);
 if(ret != 0)
	 printf("MFS_Write error\n");

 ret = MFS_Read(1, buf, 4);
 if(ret != 0)
	 printf("MFS_Read error\n");


 inum = MFS_Creat(0, MFS_REGULAR_FILE, "sample.txt");
 if(inum != 0)
	 printf("MFS_Creat error\n");

 ret = MFS_Unlink(0, "hello.txt");
 if(ret != 0)
	 printf("MFS_Unlink error\n");

 ret = MFS_Shutdown();
 if(ret != 0)
	 printf("MFS_Shutdown error\n");
 
 return 0;
}
コード例 #13
0
ファイル: test45.c プロジェクト: HarveyHWChen/cs537projects
int main(int argc, char* argv[]) {
  MFS_Init(argv[2], atoi(argv[1]));
  
  if (MFS_Creat(0, MFS_DIRECTORY, "dir") == -1) goto fail;
  MFS_Stat_t m;
  char buf[MFS_BLOCK_SIZE];
  if (MFS_Read(0, buf, 0) == -1) goto fail;

  int rc = MFS_Stat(0, &m);
  if (rc == -1) goto fail;

  int loop = m.size / sizeof(MFS_DirEnt_t);
  printf("loop = %d", loop);
  if (loop != 3) goto fail;
  
  int cur = 0;
  int par = 0;
  int dir = 0;
  int i;
  MFS_DirEnt_t* e;
  for (i = 0; i < loop; i++) {
    e = buf + i * sizeof(MFS_DirEnt_t);
    printf("e->inum = %d\n", e->inum);
    printf("e->name = %s\n", e->name);
    if (e->inum == 0 && strcmp(".", e->name) == 0) cur = 1;
    if (e->inum == 0 && strcmp("..", e->name) == 0) par = 1;
    if (e->inum != 0 && strcmp("dir", e->name) == 0) dir = 1;
  }

  printf("cur = %d\n", cur);
  printf("par = %d\n", par);
  printf("dir = %d\n", dir);
  if (!cur || !par || !dir) goto fail;
  
  printf("PASSED");
  return 0;
  
 fail:
  printf("FAILED");
  return -1;
}
コード例 #14
0
ファイル: test11.c プロジェクト: HarveyHWChen/cs537projects
int main(int argc, char* argv[]) {
  MFS_Init(argv[2], atoi(argv[1]));
  MFS_Stat_t stat;

  if (MFS_Creat(0, MFS_DIRECTORY, "usr") == -1)  
	  return -1;

  int inode = MFS_Lookup(0, "usr");
  if (inode == -1)
	  return -1;
  if (MFS_Stat(inode, &stat) != 0)
	  return -1;
  if (stat.type != MFS_DIRECTORY)
	  return -1;
  if (stat.size !=  2 * sizeof(MFS_DirEnt_t))
	  return -1;
  if (stat.blocks != 1)
	  return -1;
  return 0;

}
コード例 #15
0
void
statTest(){
  char buffer[4096];
    int i = 0;
    for (i = 0; i < 10; i++)
    	buffer[i] = 'i';
    for (i = 10; i <2045; i++)
    	buffer[i] = 'a';
    for(i = 2045; i < 4090; i++)
    	buffer[i] = 'v';
    for (i = 4090;i<4095;i++)
    	buffer[i] = 'b';
    buffer[4095]=0;

    printf("CLIENT: initialized server\n");
    int rc=MFS_Init("mumble-38.cs.wisc.edu", 10000);
    printf("CLIENT:: return value from lib init call (%d)\n", rc);    

    printf("=============== stat test 1 create root file ============\n");
    rc=MFS_Creat(0,1,"test_new_2");
    printf("CLIENT:: return value from lib stat call (%d)\n", rc);

    printf("=============== stat test2 look up test ============\n");
    int testInum=MFS_Lookup(0,"test_new_2");
    printf("CLIENT:: return value from lib stat look up call (%d)\n", testInum);
    
    printf("=============== stat test2 stat root ============\n");
    MFS_Stat_t mStat;
    int inum=0;
    rc=MFS_Stat(inum,&mStat);
    printf("CLIENT:: return value from lib stat call (%d)\n", rc);
    printf("CLIENT:: inum: %d, type: %d, size: %d \n", inum, mStat.type,mStat.size);
    
    printf("=============== stat test 1 read test file stat ============\n");
    inum=testInum;
    rc=MFS_Stat(inum,&mStat);
    printf("CLIENT:: return value from lib stat call (%d)\n", rc);
    printf("CLIENT:: inum: %d, type: %d, size: %d \n", inum, mStat.type,mStat.size);    
}
コード例 #16
0
void
unlinkTest(){
    printf("CLIENT: initialized server\n");
    int rc=MFS_Init("mumble-38.cs.wisc.edu", 10000);
    printf("CLIENT:: return value from lib init call (%d)\n", rc);    

    printf("=============== unlink test 1 create root file ============\n");
    rc=MFS_Creat(0,1,"unlinkTest");
    printf("CLIENT:: return value from lib big dir call (%d)\n", rc);

    printf("=============== unlink test2 look up test ============\n");
    int testInum=MFS_Lookup(0,"unlinkTest");
    printf("CLIENT:: return value from lib big dir look up call (%d)\n", testInum);

    /* printf("=============== unlink test2 unlink test ============\n"); */
    /* testInum=MFS_Unlink(0,"unlinkTest"); */
    /* printf("CLIENT:: return value from lib big dir look up call (%d)\n", testInum); */

    /* printf("=============== unlink test2 look up test ============\n"); */
    /* testInum=MFS_Lookup(0,"unlinkTest"); */
    /* printf("CLIENT:: return value from lib big dir look up call (%d)\n", testInum); */
    
    /* char name[60]; */
    /* for (i=0;i<100;i++){ */
    /*   printf("=============== big dir test 1 create file. name (%d) ============\n", i); */
    /*   sprintf(name,"%d",i); */
    /*   printf("file name %s\n",name); */
    /*   rc=MFS_Creat(testInum,1,name); */
    /*   printf("CLIENT:: return value from lib big dir call (%d)\n", rc); */
    /* } */

    /* for (i=0;i<100;i++){ */
    /*   printf("=============== big dir test 1 lookup file. name (%d) ============\n", i); */
    /*   sprintf(name,"%d",i); */
    /*   printf("file name %s\n",name); */
    /*   rc=MFS_Lookup(testInum,name); */
    /*   printf("CLIENT:: return value from lib big dir call (%d)\n", rc); */
    /* } */
}
コード例 #17
0
ファイル: client.c プロジェクト: MaritalWheat/systems
int
main(int argc, char *argv[])
{
    int ret;
	MFS_Stat_t stat;

	ret = MFS_Init("mumble-28.cs.wisc.edu", 5011);
    print_val(ret);
	ret = MFS_Lookup(0, "test");
    print_val(ret);
	ret = MFS_Stat(0, &stat);
    print_val(ret);
	ret = MFS_Write(0, (char*) &buffer, 1);
    print_val(ret);
	ret = MFS_Read(0, (char*) &buffer, 14);
    print_val(ret);
	ret = MFS_Creat(0, MFS_DIRECTORY, "test_filename");
    print_val(ret);
	ret = MFS_Unlink(0, "test_filename");
    print_val(ret);
	ret = MFS_Shutdown();
    print_val(ret);
    return 0;
}
コード例 #18
0
ファイル: test1.c プロジェクト: vinaygangadhar/cs537_projects
int main(int argc, char** argv)
{

 char buf[MFS_BLOCK_SIZE];
 //char write_buf[MFS_BLOCK_SIZE];
 
 int ret = MFS_Init("mumble-38.cs.wisc.edu", 1345);
 if(ret != 0)
		printf("MFS_Init error\n");

 MFS_Stat_t mfs_s;
 ret = MFS_Stat(1, &mfs_s);
 if(ret != 0)
	 printf("MFS_Stat Error\n");

 ret = MFS_Lookup(2, "helloworld.c");	
 if(ret < 0)
	 printf("MFS_Lookup Error\n");

 //File write test
 //strcpy(write_buf, "A random textaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa adj;p asd;kad'\0\0\0text"); 
 
 char* write_bu;
 write_bu = "Abc\0\0\0text";
 ret = MFS_Write(4, write_bu, 0);	
 if(ret < 0)
	 printf("MFS_Write Error\n");

 //File read test 
 ret = MFS_Read(4, buf, 0);	
 if(ret < 0)
	 printf("MFS_Read Error\n");
 
 /*
 //Dir read test
 ret = MFS_Read(0, buf, 0);	
 if(ret < 0)
	 printf("MFS_Read Error\n");
*/

 //Already existing file
 ret = MFS_Creat(0, 1, "hello.txt");
 if(ret < 0)
	 printf("MFS_Creat Error\n");

 ret = MFS_Unlink(0, "hello.txt");
 if(ret < 0)
	 printf("MFS_Unlink Error\n");

 ret = MFS_Shutdown();	
 if(ret < 0)
	 printf("MFS_Shutdown Error\n");

 /*	
 //Dir read test
 ret = MFS_Read(0, buf, 0);	
 if(ret < 0)
	 printf("MFS_Read Error\n");
 
 //File read test 
 ret = MFS_Read(4, buf, 0);	
 if(ret < 0)
	 printf("MFS_Read Error\n");

 //long name test
 ret = MFS_Creat(1, 1, "veryveryveryveryveryveryveryveryveryverylengthyfilename1111111111111111111.txt");
 if(ret < 0)
	 printf("MFS_Creat Error\n");

 //Already existing file
 ret = MFS_Creat(0, 1, "hello.txt");
 if(ret < 0)
	 printf("MFS_Creat Error\n");

 ret = MFS_Creat(0, 1, "test.txt");
 if(ret < 0)
	 printf("MFS_Creat Error\n");
*/

 return 0;
}
コード例 #19
0
ファイル: test2.c プロジェクト: vinaygangadhar/cs537_projects
int main(int argc, char** argv)
{

 int ret = MFS_Init("procyon.cs.wisc.edu", 1345);
 if(ret != 0)
		printf("MFS_Init error\n");

 //long name test
 ret = MFS_Creat(1, 1, "veryveryveryveryveryveryveryveryveryverylengthyfilename1111111111111111111.txt");
 if(ret < 0)
	 printf("MFS_Creat Error\n");

 //Already existing file
 ret = MFS_Creat(0, 1, "hello.txt");
 if(ret < 0)
	 printf("MFS_Creat Error\n");

 //Actual create test (creating a file)
 ret = MFS_Creat(0, 1, "test.txt");
 if(ret < 0)
	 printf("MFS_Creat Error\n");

 //Actual create test (creating 1 more file )
 ret = MFS_Creat(0, 1, "new_inode_test.txt");
 if(ret < 0)
	 printf("MFS_Creat Error\n");

 //Actual create Dir test
 ret = MFS_Creat(0, 0, "new_dir");
 if(ret < 0)
	 printf("MFS_Creat Error\n");

 //Do a look up on that created file
 ret = MFS_Lookup(0, "test.txt");
 if(ret < 0)
	 printf("MFS_Lookup Error\n");
 else
	 printf("MFS_Lookup inum: %d\n", ret);

 //Do a look up on that 2nd file
 ret = MFS_Lookup(0, "new_inode_test.txt");
 if(ret < 0)
	 printf("MFS_Lookup Error\n");
 else
	 printf("MFS_Lookup inum: %d\n", ret);

 //Do a look up on that new dir
 ret = MFS_Lookup(0, "new_dir");
 if(ret < 0)
	 printf("MFS_Lookup Error\n");
 else
	 printf("MFS_Lookup inum: %d\n", ret);

 MFS_Stat_t mfs_s;
 ret = MFS_Stat(14, &mfs_s);
 if(ret <  0)
	 printf("MFS_Stat Error\n");
 else
	 printf("MFS Stat of inum %d- type: %d, size: %d\n", 14, mfs_s.type, mfs_s.size);

 ret = MFS_Stat(15, &mfs_s);
 if(ret <  0)
	 printf("MFS_Stat Error\n");
 else
	 printf("MFS Stat of inum %d- type: %d, size: %d\n", 15, mfs_s.type, mfs_s.size);

 ret = MFS_Shutdown();	
 if(ret < 0)
	 printf("MFS_Shutdown Error\n");

 return 0;
}
コード例 #20
0
void
statTest2(){
  char buffer[4096];
    int i = 0;
    for (i = 0; i < 10; i++)
    	buffer[i] = 'i';
    for (i = 10; i <2045; i++)
    	buffer[i] = 'a';
    for(i = 2045; i < 4090; i++)
    	buffer[i] = 'v';
    for (i = 4090;i<4095;i++)
    	buffer[i] = 'b';
    buffer[4095]=0;

    printf("CLIENT: initialized server\n");
    int rc=MFS_Init("mumble-38.cs.wisc.edu", 10000);
    printf("CLIENT:: return value from lib init call (%d)\n", rc);    

    printf("=============== stat test 1 create root file ============\n");
    rc=MFS_Creat(0,1,"statTest2");
    printf("CLIENT:: return value from lib stat call (%d)\n", rc);

    printf("=============== stat test2 look up test ============\n");
    int testInum=MFS_Lookup(0,"statTest2");
    printf("CLIENT:: return value from lib stat look up call (%d)\n", testInum);

    
    MFS_Stat_t mStat;    
    printf("=============== stat test 1 read test file stat ============\n");
    int inum=testInum;
    rc=MFS_Stat(inum,&mStat);
    printf("CLIENT:: return value from lib stat call (%d)\n", rc);
    printf("CLIENT:: inum: %d, type: %d, size: %d \n", inum, mStat.type,mStat.size);

    printf("=============== stat test 2 write 0 block ============\n");
    printf("CLIENT:: about to call lib write  send message (%s)\n", buffer);    
    rc=MFS_Write(testInum,&buffer[0],0);
    printf("CLIENT:: return value from lib write call (%d)\n", rc);

    printf("=============== stat test 1 read test file stat ============\n");
    inum=testInum;
    rc=MFS_Stat(inum,&mStat);
    printf("CLIENT:: return value from lib stat call (%d)\n", rc);
    printf("CLIENT:: inum: %d, type: %d, size: %d \n", inum, mStat.type,mStat.size);

    printf("=============== stat test 2 write 0 block ============\n");
    printf("CLIENT:: about to call lib write  send message (%s)\n", buffer);    
    rc=MFS_Write(testInum,&buffer[0],0);
    printf("CLIENT:: return value from lib write call (%d)\n", rc);

    printf("=============== stat test 1 read test file stat ============\n");
    inum=testInum;
    rc=MFS_Stat(inum,&mStat);
    printf("CLIENT:: return value from lib stat call (%d)\n", rc);
    printf("CLIENT:: inum: %d, type: %d, size: %d \n", inum, mStat.type,mStat.size);

    

    printf("=============== stat test 2 write 0 block ============\n");
    printf("CLIENT:: about to call lib write  send message (%s)\n", buffer);    
    rc=MFS_Write(testInum,&buffer[0],13);
    printf("CLIENT:: return value from lib write call (%d)\n", rc);

    printf("=============== stat test 1 read test file stat ============\n");
    inum=testInum;
    rc=MFS_Stat(inum,&mStat);
    printf("CLIENT:: return value from lib stat call (%d)\n", rc);
    printf("CLIENT:: inum: %d, type: %d, size: %d \n", inum, mStat.type,mStat.size);

    printf("=============== stat test 2 write 0 block ============\n");
    printf("CLIENT:: about to call lib write  send message (%s)\n", buffer);    
    rc=MFS_Write(testInum,&buffer[0],13);
    printf("CLIENT:: return value from lib write call (%d)\n", rc);

    printf("=============== stat test 1 read test file stat ============\n");
    inum=testInum;
    rc=MFS_Stat(inum,&mStat);
    printf("CLIENT:: return value from lib stat call (%d)\n", rc);
    printf("CLIENT:: inum: %d, type: %d, size: %d \n", inum, mStat.type,mStat.size);
    
}
コード例 #21
0
ファイル: test26.c プロジェクト: HarveyHWChen/cs537projects
int main(int argc, char* argv[]) {
  MFS_Init(argv[2], atoi(argv[1]));
	char* dirs[] = {"dir0", "dir1", "dir2", "dir3", "dir4", "dir5", "dir6",
		"dir7", "dir8", "dir9", "dir10", "dir11", "dir12", "dir13", ".", ".."};
	int inodes[16];	
	int i;
	for (i = 0; i < 14; i++) {
  	if (MFS_Creat(0, MFS_DIRECTORY, dirs[i]) == -1)	
	  	return -1;
		inodes[i] = MFS_Lookup(0, dirs[i]);
		if (inodes[i] <= 0) return -1;
	}
	inodes[14] = MFS_Lookup(0, ".");
	if (inodes[14] < 0) return -1;
	inodes[15] = MFS_Lookup(0, "..");
	if (inodes[15] < 0) return -1;

	// double check if any inode num is reused
	int j;
	for (i = 0; i < 13; i++)
		for (j = i+1; j < 14; j++)
		if (inodes[i] == inodes[j]) return -1;

	// reread the dir block	
	
  char buf[MFS_BLOCK_SIZE];
  memset(buf, 0, MFS_BLOCK_SIZE);
  if (MFS_Read(0, buf, 1) == 0)
	  return -1;
  if (MFS_Read(0, buf, 0) == -1)
	  return -1;
	
	// sanity check
	int b[16];
	char* dirs2[16];
	int inodes2[16];
	memset(b, 0, 16);
	MFS_DirEnt_t* e;
	for (i = 0; i < 16; i ++) {
		e = buf + i * sizeof(MFS_DirEnt_t);
		inodes2[i] = e->inum;
		dirs2[i] = strdup(e->name);
	}
 	for (i = 0; i < 16; i ++) {
		int fi = 0;
		int fn = 0;
		for (j = 0; j < 16; j++) 
			if (inodes[i] == inodes2[j]) {
				fi = 1;
				break;
			}
		for (j = 0; j < 16; j ++)
			if (strcmp(dirs[i], dirs2[j]) == 0) {
				fn = 1;
				break;
			}
			if (!fi || !fn) return -1;
	}
	
  return 0;

}