Exemplo n.º 1
0
/* returns id */
int fs_addFile(char* name, int fileSize, int processes, int* processStart, int* processSize, int* data) {
    int i;
    int id;
    int fileStart;

    if (FS_DEBUG) {
        heavyLine();
        printf("fs_addFile(\"%s\", %d, ..., ..., ...)\n", name, fileSize);

        if (FS_VERBOSE) {
            printf("processStart: ");
            for (i = 0; i < MAXPRO; i++)
                printf("%d ", processStart[i]);
            printf("\nprocessSize: ");
            for (i = 0; i < MAXPRO; i++)
                printf("%d ", processSize[i]);
            dumpData(fileSize, data);
        }
        heavyLine();
    }

    if (!fs_dataIsValid(fileSize, data))
        return -1;

    fileStart = fs_addData(fileSize, data);
    id = fs_addINode(name, fileStart, fileSize, processes, processStart, processSize);

    if (FS_VERBOSE)
        fs_dump();

    return id;
}
Exemplo n.º 2
0
int main() {
  int i;
  int j;
  
  int currentProcess;
  
  heavyLine();
  printf("filesystem self test\n");
  heavyLine();
  printf("\n");
  
  // initialize the filesystem and the pagetable
  fs_initialize();
  pt_initialize();
  
  // import programs
  fs_import("./programs.cpu/prog1out.cpu", "prog1");
  fs_nodeList();
  fs_dump();
  
  pt_dump();

  // set current program (global)
  currentProgramId = 1;
  currentProcess = 0;
  
  for (i = 0; i < fs_getProcessSize(currentProgramId, currentProcess); i++) {
    printf("instruction: %d \n", pt_getInstruction(currentProcess, i));
  }
  
  starLine();
  currentProcess = 1;
  for (i = 0; i < fs_getProcessSize(currentProgramId, currentProcess); i++) {
    printf("instruction: %d \n", pt_getInstruction(currentProcess, i));
  }
  
  starLine();
  currentProcess = 2;
  for (i = 0; i < fs_getProcessSize(currentProgramId, currentProcess); i++) {
    printf("instruction: %d \n", pt_getInstruction(currentProcess, i));
  }
  
  pt_dump();
  
  return 0;
}
Exemplo n.º 3
0
void fs_initialize() {
    int i;

    if (FS_DEBUG) {
        heavyLine();
        printf("fs_initialize()\n");
    }

    fs_idCounter = 0;
    iNodes = list_create("iNodes");

    for (i = 0; i < FS_SIZE; i++)
        filesystem[i] = FS_NULL;

    if (FS_VERBOSE)
        fs_dump();

    if (FS_DEBUG)
        heavyLine();


}
Exemplo n.º 4
0
int start_main()
{
	/* Testing system file. */
	// You don't have to know what is the declaration below, memorize it till you learn the concept of 'pointers'.
	FILE * file;
	char c;
	// You are not allowed to use monitor_write function, you have to implement your own.
	monitor_write("[-] Dump: File System Contents\n");
	// This function has been used to dump the file system,  and is available in the debug library.
	fs_dump(TRUE);
	// You are not allowed to use monitor_write function, you have to implement your own.
	monitor_write("[-] Test: fopen function\n");
	// If you have included your own file(s), change the file name below.
	file = fopen("fs_test.txt", "r");
	while((c=fgetc(file)) != EOF)
	{
		putch(c);
	}
	// You are not allowed to use monitor_write function, you have to implement your own.
	monitor_write("[-] If you see any text, then the test has been sucessful.\n");
	while(TRUE);
	return EXIT_SUCCESS;
}