|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnachos.kernel.filesys.OpenFileStub
class OpenFileStub
This "stub" class implements file operations for Nachos by simply passing the filesystem operations through to the native filesystem on the host platform. This is provided in case the multiprogramming and virtual memory assignments (which make use of the file system) are done before the file system assignment.
Field Summary | |
---|---|
private static boolean |
BLOCKING_FILESYS
Do file operations cause the calling thread to block waiting for the operation to complete? Blocking is simulated by calling Scheduler.yield; more realistically, the thread would wait for an interrupt to inform it that the operation is complete. |
private long |
currentOffset
The current file position. |
private java.io.RandomAccessFile |
file
The underlying file on the host platform. |
Constructor Summary | |
---|---|
OpenFileStub(java.io.RandomAccessFile f)
Open a file. |
Method Summary | |
---|---|
int |
close()
Close the file, releasing any resources held in kernel memory. |
long |
length()
Determine the number of bytes in the file (this interface is simpler than the UNIX idiom -- lseek to end of file, tell, lseek back). |
int |
read(byte[] into,
int index,
int numBytes)
Read bytes from the file, starting at the implicit position. |
int |
readAt(byte[] into,
int index,
int numBytes,
long position)
Read bytes from the file, bypassing the implicit position. |
void |
seek(long position)
Set the position from which to start reading/writing -- UNIX lseek |
int |
write(byte[] from,
int index,
int numBytes)
Write bytes to the file, starting at the implicit position. |
int |
writeAt(byte[] from,
int index,
int numBytes,
long position)
Write bytes to the file, bypassing the implicit position. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean BLOCKING_FILESYS
private java.io.RandomAccessFile file
private long currentOffset
Constructor Detail |
---|
OpenFileStub(java.io.RandomAccessFile f)
f
- The underlying file on the host filesystem.Method Detail |
---|
public void seek(long position)
seek
in interface OpenFile
position
- The desired position in the file, in bytes from
the start of file.public int readAt(byte[] into, int index, int numBytes, long position)
readAt
in interface OpenFile
into
- Buffer into which to read data.index
- Starting position in the buffer.numBytes
- Number of bytes desired.position
- Starting position in the file.
public int writeAt(byte[] from, int index, int numBytes, long position)
writeAt
in interface OpenFile
from
- Buffer containing the data to be written.index
- Starting position in the buffer.numBytes
- Number of bytes to write.position
- Starting position in the file.
public int read(byte[] into, int index, int numBytes)
read
in interface OpenFile
into
- Buffer into which to read data.index
- Starting position in the buffer.numBytes
- Number of bytes desired.
public int write(byte[] from, int index, int numBytes)
write
in interface OpenFile
from
- Buffer containing the data to be written.index
- Starting position in the buffer.numBytes
- Number of bytes to write.
public long length()
length
in interface OpenFile
public int close()
close
in interface OpenFile
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |