This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
There is a java program that executes external programms on various physical disks. What I want to do is to queue tasks (so only 1 task is being done on 1 physical disk). I have a String path to the executable. How to learn to which HDD that executable belongs? (We're talking Ubuntu here).
Thank you very much in advance for any help with this.
ps: I am not looking for any internal hdd serial number, I'm just looking for some simple solution
First, read the mtab file (usually stored in /etc/) to find all the current mount points and their devices. Then create a File object, and get its parent until you've found a match. The resulting device tells you which hard drive it is, but it can also be a virtual device such as proc or udev.
Unfortunately, I don't think you can. The unix filesystem shows up as a single filesystem, starting from the root directory.... and there doesn't seem to be a way to get the mounts from the core libs.
For Windows, you can get all the roots with the listRoots() method call -- in which case, it returns a root file for each drive letter.
Joined: Mar 08, 2012
Thank you for your replies. I already coded the part to get UUID. Now I need to figure out how to synchronize the access... I'll think about it; maybe I will be able to do it alone, without bothering you again for help.
for ppl who use "Search" and find this, the code is this: