Re: Accessing raw devices (hard drives) with Java ?
S??bastien de Mapias wrote:
Hi,
Let's I have (under Solaris for example) a device /dev/[r]dsk/c0t2d0s0
that's not mounted (so I can't performe any 'ls' etc.), and I'd like
to
traverse its bytes: is there a way to access this data from Java ?
Has anyone already tried to write such a program ?
Have /you/ tried to write such a program?
In UNIX a device special file is pretty much like any other file. That's one of
the simplicities of UNIX. The device driver for that device should provide the
basic open/close/read/write functions to the kernel, so that higher level
languages can perform those operations. I presume Java only makes uses of those
native methods to access a file.
Try writing a program to read from it just like you would any binary file. Of
course, you most likely need root permission to open a block special file even
for read because you are bypassing all the filesystem level permissions on
contents of that device. And you need to be able to make sense of what you
read...
--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555