3

I would like to know my HDD's free areas. For example if my hard disk is divided into 100 million parts, can I see which parts of the disk are free, within a given range?

For example, if there are 100 million cells, and I want to know which cells are free between 99th million cell and 100th million cell - can I print the addresses in Java, C++, C etc?

Isaac
  • 16,458
  • 5
  • 57
  • 81
hakki
  • 6,181
  • 6
  • 62
  • 106
  • 1
    The procedure will depend on the file-system I think. – Anirudh Ramanathan Nov 24 '12 at 06:23
  • You won't be able to do it via Java, as it's a higher level language. You can sure do it on C... take a look at this question: http://stackoverflow.com/questions/2702853/direct-access-to-harddrive – Frankie Nov 24 '12 at 06:38
  • 1
    @Frankie, are you sure about that? On Windows there are ways to call the Windows APIs. You could even get some mileage out of opening the underlying device and doing direct reads from the disk. You'd have to decode the filesystem yourself, which depending of the filesystem isn't too bad (FAT), or really awful (most other file systems). – jimhark Nov 24 '12 at 06:52
  • 1
    You may check source code of some well known defrag tool. http://ultradefrag.sourceforge.net/en/index.html – Jayan Nov 24 '12 at 06:58
  • @hakiko, which platforms (Windows, OS X, Linux) and file systems (FAT, NTFS, HPFS+, EXT3, etc.) are you interested in? – jimhark Nov 24 '12 at 07:22
  • If you have enough permissions, you can open `/dev/sda` on Linux or physical disk device on Windows and simply inspect this huge 'virtual' file. However, this will not tell you whether given block is in use or not – mvp Nov 24 '12 at 07:23
  • @mvp ,not directly. You have to decode the file structures. Just how difficult that is depends on which filesystems need to be supported. – jimhark Nov 24 '12 at 08:46
  • You could use Java Runtime to execute commands and parse the output – Shamis Shukoor Nov 24 '12 at 10:16

0 Answers0