#include "copyright.h"#include "utility.h"#include "filesys.h"#include "system.h"#include "thread.h"#include "disk.h"#include "stats.h"Go to the source code of this file.
Defines | |
| #define | TransferSize 10 |
| #define | FileName "TestFile" |
| #define | Contents "1234567890" |
| #define | ContentSize strlen(Contents) |
| #define | FileSize ((int)(ContentSize * 5000)) |
Functions | |
| void | Copy (char *from, char *to) |
| void | Print (char *name) |
| void | FileWrite () |
| void | FileRead () |
| void | PerformanceTest () |
|
|
|
|
|
|
|
|
Definition at line 111 of file fstest.cc. Referenced by FileRead, FileWrite, and PerformanceTest. |
|
|
|
|
|
|
|
||||||||||||
|
Definition at line 32 of file fstest.cc. References ASSERT, DEBUG, NULL, TransferSize, and OpenFile::Write.
00033 {
00034 FILE *fp;
00035 OpenFile* openFile;
00036 int amountRead, fileLength;
00037 char *buffer;
00038
00039 // Open UNIX file
00040 if ((fp = fopen(from, "r")) == NULL) {
00041 printf("Copy: couldn't open input file %s\n", from);
00042 return;
00043 }
00044
00045 // Figure out length of UNIX file
00046 fseek(fp, 0, 2);
00047 fileLength = ftell(fp);
00048 fseek(fp, 0, 0);
00049
00050 // Create a Nachos file of the same length
00051 DEBUG('f', "Copying file %s, size %d, to file %s\n", from, fileLength, to);
00052 if (!fileSystem->Create(to, fileLength)) { // Create Nachos file
00053 printf("Copy: couldn't create output file %s\n", to);
00054 fclose(fp);
00055 return;
00056 }
00057
00058 openFile = fileSystem->Open(to);
00059 ASSERT(openFile != NULL);
00060
00061 // Copy the data in TransferSize chunks
00062 buffer = new char[TransferSize];
00063 while ((amountRead = fread(buffer, sizeof(char), TransferSize, fp)) > 0)
00064 openFile->Write(buffer, amountRead);
00065 delete [] buffer;
00066
00067 // Close the UNIX and the Nachos files
00068 delete openFile;
00069 fclose(fp);
00070 }
|
|
|
Definition at line 145 of file fstest.cc. References Contents, ContentSize, FileName, FileSize, NULL, and OpenFile::Read. Referenced by PerformanceTest.
00146 {
00147 OpenFile *openFile;
00148 char *buffer = new char[ContentSize];
00149 int i, numBytes;
00150
00151 printf("Sequential read of %d byte file, in %d byte chunks\n",
00152 FileSize, (int) ContentSize);
00153
00154 if ((openFile = fileSystem->Open(FileName)) == NULL) {
00155 printf("Perf test: unable to open file %s\n", FileName);
00156 delete [] buffer;
00157 return;
00158 }
00159 for (i = 0; i < FileSize; i += ContentSize) {
00160 numBytes = openFile->Read(buffer, ContentSize);
00161 if ((numBytes < 10) || strncmp(buffer, Contents, ContentSize)) {
00162 printf("Perf test: unable to read %s\n", FileName);
00163 delete openFile;
00164 delete [] buffer;
00165 return;
00166 }
00167 }
00168 delete [] buffer;
00169 delete openFile; // close file
00170 }
|
|
|
Definition at line 117 of file fstest.cc. References Contents, ContentSize, FileName, FileSize, NULL, and OpenFile::Write. Referenced by PerformanceTest.
00118 {
00119 OpenFile *openFile;
00120 int i, numBytes;
00121
00122 printf("Sequential write of %d byte file, in %d byte chunks\n",
00123 FileSize, (int) ContentSize);
00124 if (!fileSystem->Create(FileName, 0)) {
00125 printf("Perf test: can't create %s\n", FileName);
00126 return;
00127 }
00128 openFile = fileSystem->Open(FileName);
00129 if (openFile == NULL) {
00130 printf("Perf test: unable to open %s\n", FileName);
00131 return;
00132 }
00133 for (i = 0; i < FileSize; i += ContentSize) {
00134 numBytes = openFile->Write(Contents, ContentSize);
00135 if (numBytes < 10) {
00136 printf("Perf test: unable to write %s\n", FileName);
00137 delete openFile;
00138 return;
00139 }
00140 }
00141 delete openFile; // close file
00142 }
|
|
|
Definition at line 173 of file fstest.cc. References FileName, FileRead, and FileWrite. Referenced by main.
|
|
|
Definition at line 78 of file fstest.cc. References NULL, OpenFile::Read, and TransferSize.
00079 {
00080 OpenFile *openFile;
00081 int i, amountRead;
00082 char *buffer;
00083
00084 if ((openFile = fileSystem->Open(name)) == NULL) {
00085 printf("Print: unable to open file %s\n", name);
00086 return;
00087 }
00088
00089 buffer = new char[TransferSize];
00090 while ((amountRead = openFile->Read(buffer, TransferSize)) > 0)
00091 for (i = 0; i < amountRead; i++)
00092 printf("%c", buffer[i]);
00093 delete [] buffer;
00094
00095 delete openFile; // close the Nachos file
00096 return;
00097 }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002