public class LinuxFile extends RandomAccessFile
Modifier and Type | Class and Description |
---|---|
static class |
LinuxFile.LinuxFileException |
static class |
LinuxFile.MMAPFlags |
static class |
LinuxFile.MMAPProt |
static class |
LinuxFile.ScratchBufferOverrun |
Modifier and Type | Field and Description |
---|---|
static int |
localBufferSize |
static ThreadLocal<ByteBuffer> |
localDataBuffer |
static ThreadLocal<IntBuffer> |
localOffsetsBuffer |
static int |
wordSize |
Modifier and Type | Method and Description |
---|---|
protected static int |
directIOCTL(int fd,
long command,
int value) |
protected static int |
directIOCTLStructure(int fd,
long command,
ByteBuffer data,
int dataOffset,
IntBuffer offsetMap,
int offsetMapOffset,
int offsetCapacity) |
static int |
errno() |
protected void |
finalize() |
void |
ioctl(long command,
ByteBuffer data,
IntBuffer offsets)
Runs an ioctl on a file descriptor.
|
void |
ioctl(long command,
int value)
Runs an ioctl value command on a file descriptor.
|
protected static long |
mmap(int fd,
int length,
int prot,
int flags,
int offset) |
ByteBuffer |
mmap(int length,
LinuxFile.MMAPProt prot,
LinuxFile.MMAPFlags flags,
int offset)
Direct memory mapping from a file descriptor.
|
static void |
munmap(ByteBuffer mappedBuffer) |
protected static int |
munmapDirect(long address,
long capacity) |
static String |
strerror(int code) |
close, getChannel, getFD, getFilePointer, length, read, read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seek, setLength, skipBytes, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
public static final int wordSize
public static final int localBufferSize
public static final ThreadLocal<ByteBuffer> localDataBuffer
public static final ThreadLocal<IntBuffer> localOffsetsBuffer
public LinuxFile(String name, String mode) throws FileNotFoundException
FileNotFoundException
public void ioctl(long command, int value) throws IOException
command
- ioctl commandvalue
- int ioctl valueIOException
public void ioctl(long command, ByteBuffer data, IntBuffer offsets) throws IOException
wordSize
to determine the size
in bytes needed for a pointer. Also be sure to consider GCC padding and structure alignment.
GCC will try a field to its word size (32b ints align at 4-byte, etc), and will align the
structure size with the native word size (4-byte for 32b, 8-byte for 64b).
Provided IntBuffer offsets must use native byte order (endianness).
<NEED BETTER EXAMPLE HERE>
DANGER: check your buffer length! The possible length varies depending on the ioctl call.
Overruns are very possible. ioctl tries to determine EFAULTs, but sometimes
you might trample JVM data if you are not careful.command
- ioctl commanddata
- values in bytes for all structures, with 4 or 8 byte size holes for pointersoffsets
- byte offsets of pointer at given indexIOException
public ByteBuffer mmap(int length, LinuxFile.MMAPProt prot, LinuxFile.MMAPFlags flags, int offset) throws IOException
length
- length of desired mappingprot
- protocol used for mappingflags
- flags for mappingoffset
- offset in file for mappingIOException
public static void munmap(ByteBuffer mappedBuffer) throws IOException
IOException
public static int errno()
protected static int directIOCTL(int fd, long command, int value)
protected static long mmap(int fd, int length, int prot, int flags, int offset)
protected static int munmapDirect(long address, long capacity)
protected static int directIOCTLStructure(int fd, long command, ByteBuffer data, int dataOffset, IntBuffer offsetMap, int offsetMapOffset, int offsetCapacity)
Copyright © 2012–2019 Pi4J. All rights reserved.