Link to home
Start Free TrialLog in
Avatar of kevinnguyen
kevinnguyen

asked on

Listing current devices on Linux box

I write a Java program that lists all devices available on a Linux box. Such devices are floppy, cdrom, memory stick (usb) etc. I don't have root privileges. Can I do that ? Are there any sample codes out there ? Any suggestions ?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sciuriware
sciuriware

objects, that will give you only    /     on UNIX.

;JOOP!
You can also read a file like /etc/fstab, but to find actual mounts, use mount as I said.

;JOOP!
I believe I gave the only right answers:

"http://javaalmanac.com/egs/java.io/Roots.html"                         is definitively wrong,

"Or you can use the Java communications API, I guess."                is indeed a guess.


;JOOP!
I am not only suggesting solutions based on answers, several times I need to do it based on guesses (i.e. to guess if a comment would lead to a possible solution) if the user does not respond back with feedback. I believe all are valid comments:

objects' is, since in Unix everything is a file and you could find devices from the file system. The user said that (s)he is using Linux so AFAIK it is a valid answer.
mayankeagle's also since you could use the java comm api to find all devices in a linux box.
I insist:
"http://javaalmanac.com/egs/java.io/Roots.html"  finds disk partition root directories.

On MSWindows this could be interesting (A:, C:, D:, E:, G:, K: ...)
On LINUX you get  "/"  and that's all; that's no use!

Even looking at mounted or mountable devices, as I suggested, is an incomplete solution.
If effect, only descending /dev would reveal all devices, but, only if you know the 'local implementation standards'.
I can live with guesses.
I politely suggest: split between mayankeagle and me and assign B level.

;JOOP!