Results 1 to 2 of 2
- 10-01-2011, 07:51 PM #1
Member
- Join Date
- Oct 2011
- Posts
- 4
- Rep Power
- 0
MappedByteBuffer to access Linux device driver through MMAP
Hello. I'd like to access the mmap method of a file using the FileChannel -> MappedByteBuffer class. The kicker though is that what I want to access isn't really a file, but a character device on Linux. My understanding is that on Linux /dev/zero for example should be appear just like any other file (implements read/write/mmap/ioctl/llseek etc). This doesn't quite work though, the following code will run ...
FileChannel fc = new FileInputStream("/dev/zero").getChannel();
ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
... but the file channel size is zero. If I try to hard code a non zero number it will throw an IO exception (invalid argument). It looks like the FileChannel.map method is actually checking the size of the file before it implements the the low level "mmap" system call. I guess my question is, how is java getting the size of the file? If it's from the file-system then I'm out of luck, but if it's through some kind of normal file operation I could mimic that behavior in my driver (I realize /dev/zero probably does return that it has no size, but a custom char driver could possibly look like it does have >0 bytes).
Perhaps if I really want to use MMAP fromJava for char drivers I need to use JNI (??)
Thanks for reading thisLast edited by amess; 10-01-2011 at 08:39 PM.
- 10-25-2011, 04:26 PM #2
Member
- Join Date
- Oct 2011
- Posts
- 1
- Rep Power
- 0
Similar Threads
-
Architecture Mismatch for MS-ACCESS JDBC ODBC DRIVER (Windows 7 64-bit)
By Gajesh Tripathi in forum JDBCReplies: 1Last Post: 08-03-2011, 03:36 PM -
Bluetooth Device Discovery using Netbeans IDE + Java ME Device Manager
By sawyerized in forum CLDC and MIDPReplies: 0Last Post: 02-25-2011, 11:46 AM -
run in my PC: Type 1 db driver Access / java[SE1.6] Desktop Applications, what I need
By lse123 in forum JDBCReplies: 7Last Post: 11-20-2009, 03:02 AM -
How to access driver in Windows like a file?
By pthoonen in forum New To JavaReplies: 6Last Post: 01-15-2009, 03:28 AM -
Access Linux shared folder from Windows OS
By nitinpjairaj in forum NetworkingReplies: 3Last Post: 08-26-2008, 06:14 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks