#include <blockio.h>
Inheritance diagram for FileBlockIO:


Public Member Functions | |
| FileBlockIO (int blocksize=4096) | |
| virtual OpenStatus | open (const char *filename="enf.enf") |
| ??? | |
| virtual bool const | is_open () |
| virtual void | close () |
| ??? | |
| virtual bool | get (void *buf, int buflen, BlockNum blockno) |
| ??? | |
| virtual bool | put (void *buf, int buflen, BlockNum blockno) |
| ??? | |
Public Attributes | |
| int | blockfd |
???
Definition at line 97 of file blockio.h.
|
|
Definition at line 104 of file blockio.h. References blockfd, and BlockIO::blocksize.
|
|
|
??? (to be defined) Implements BlockIO. Definition at line 93 of file blockio.cxx. References assert, and blockfd.
|
|
||||||||||||||||
|
??? (to be defined) Implements BlockIO. Definition at line 109 of file blockio.cxx. References assert, blockfd, BlockNum, BlockIO::stats::blocks_read, BlockIO::blocksize, goodblock(), L, NULL, and BlockIO::stats.
00113 {
00114 L("FileBlockIO::get(buf=0x%08lX, buflen=%d, blockno=%d) blocksize=%d\n", buf, buflen, blockno, blocksize);
00115 assert(buf != NULL);
00116 assert(blockno != 0);
00117 assert( goodblock(blockno) );
00118 // assert(buflen <= blocksize);
00119
00120 //OBSOLETE if (!enffileread) {
00121 //OBSOLETE if (close(enffiledes) != 0)
00122 //OBSOLETE perror("close failed in readloaf");
00123 //OBSOLETE
00124 //OBSOLETE if ((enffiledes = open("enf.enf", O_RDWR, 0)) == -1) {
00125 //OBSOLETE perror("open");
00126 //OBSOLETE assert(0); // open
00127 //OBSOLETE }
00128 //OBSOLETE enffileread = true;
00129 //OBSOLETE }
00130
00131 if (lseek(blockfd, (long) blockno * blocksize, 0) < 0) {
00132 perror("FileBlockIO::get");
00133 return false;
00134 }
00135
00136 int nbytes = read(blockfd, buf, buflen);
00137 assert(nbytes > 0); // Incorrect Usage of Assertion
00138
00139 stats.blocks_read++;
00140 return true;
00141 }
|
|
|
Implements BlockIO. Definition at line 109 of file blockio.h. References blockfd.
00109 { return blockfd >= 0; }
|
|
|
??? (to be defined) Implements BlockIO. Definition at line 65 of file blockio.cxx. References blockfd, errno, BlockIO::OS_CREATED, BlockIO::OS_FAILED, and BlockIO::OS_OPENED.
00067 {
00068 // Try to Open an Existing File
00069 blockfd = ::open(filename, O_RDWR, 0);
00070 if (blockfd >= 0)
00071 return OS_OPENED; // Existing Media was Found and Opened
00072
00073 errno = 0;
00074
00075 // Else Try to Create a New File
00076 blockfd = creat(filename, 0660);
00077 if (blockfd >= 0)
00078 return OS_CREATED; // No Media Found so a New One was Created
00079
00080 // Error: Unable to Open or Create the File
00081 perror("FileBlockIO::open");
00082 return OS_FAILED;
00083 }
|
|
||||||||||||||||
|
??? (to be defined) Implements BlockIO. Definition at line 151 of file blockio.cxx. References assert, blockfd, BlockNum, BlockIO::stats::blocks_written, BlockIO::blocksize, goodblock(), L, NULL, and BlockIO::stats.
00155 {
00156 L("FileBlockIO::put(buf=0x%08lX, buflen=%d, blockno=%d) blocksize=%d\n", buf, buflen, blockno, blocksize);
00157 assert(buf != NULL);
00158 assert(blockno != 0);
00159 assert( goodblock(blockno) );
00160 assert(buflen <= blocksize);
00161
00162 if (lseek(blockfd, (long) blockno * blocksize, 0) < 0) {
00163 perror("FileBlockIO::put");
00164 return false;
00165 }
00166
00167 int nbytes = write(blockfd, buf, buflen);
00168 assert(nbytes >= 0); // Incorrect Usage of Assert
00169
00170 stats.blocks_written++;
00171 return true;
00172 }
|
|
|
Definition at line 102 of file blockio.h. Referenced by close(), FileBlockIO(), get(), is_open(), open(), and put(). |
1.3.4