|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface MFileOps
This interface defines kernel "file-operations". Besides its obvious use for "real" file-handling, it is used to interface any stream in general, including pipes, character devices and block devices. Character devices treat read/write in the way that would be expected, lseek() is probably meaningless though. Block devices treat read/write/lseek a bit differently: read() must be called with the correct sized block of data (ie, the device block-size) write() must be used in similar manner lseek() offsets are block offsets, not byte-offsets. BEG/CUR/END are still valid, however How a block-device handles its own internal management of the "offset" is up to it.. i'd suggest all operations sharing a common offset, that is the block offset, which read() and write() increment.
| Field Summary | |
|---|---|
static int |
F_GETFL
get file-descriptor flags |
static int |
F_OK
file exists |
static int |
F_SETFL
set file-descriptor flags |
static int |
LSEEK_BEG
seek from beginning of file |
static int |
LSEEK_CUR
seek from current offset |
static int |
LSEEK_END
seek from end of file |
static int |
O_CLOEXEC
close on exec flag |
static int |
O_NONBLOCK
non-blocking flag |
static int |
OPEN_CREAT
create file if it doesn't exist |
static int |
OPEN_READ
open file for reading |
static int |
OPEN_TRUNC
truncate the file (empty it) if it exists |
static int |
OPEN_WRITE
open file for writing |
static int |
R_OK
file is readable |
static int |
W_OK
file is writable |
static int |
X_OK
file is executable |
| Method Summary | |
|---|---|
int |
close(MFile handle)
used to close the file. |
int |
fcntl(MFile handle,
int op,
int arg)
file-handle control |
int |
lseek(MFile handle,
int offset,
int whence)
seek to a specific offset |
int |
open(MFile handle,
int flags)
used to open the file. |
int |
read(MFile handle,
byte[] buffer,
int count)
read bytes from file |
int |
write(MFile handle,
byte[] buffer,
int count)
write bytes to file |
| Field Detail |
|---|
static final int F_GETFL
static final int F_SETFL
static final int O_NONBLOCK
static final int O_CLOEXEC
static final int OPEN_READ
static final int OPEN_WRITE
static final int OPEN_CREAT
static final int OPEN_TRUNC
static final int LSEEK_BEG
static final int LSEEK_CUR
static final int LSEEK_END
static final int F_OK
static final int R_OK
static final int W_OK
static final int X_OK
| Method Detail |
|---|
int open(MFile handle,
int flags)
handle - file-handle of file being openedflags - open flags (for devices, minor number is (flags >> 16))
int close(MFile handle)
handle - file-handle of file being closed
int lseek(MFile handle,
int offset,
int whence)
handle - file-handleoffset - byte-offset relative to "whence" (block offset for block devices)whence - constant indicating position seek should occur from
int read(MFile handle,
byte[] buffer,
int count)
handle - file-handlebuffer - buffer where data will be storedcount - maximum number of bytes to read
int write(MFile handle,
byte[] buffer,
int count)
handle - file-handlebuffer - data to writecount - maximum number of bytes to write
int fcntl(MFile handle,
int op,
int arg)
handle - file-handleop - operation to performarg - argument to operation (if applicable)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||