Get a list of harddisks (with some infos like size, used/free) - Linux

This is a discussion on Get a list of harddisks (with some infos like size, used/free) - Linux ; Hi, I'm developing a plugin for vdr. I want to get a list of harddisk (internals and externals). And I want to have following informations: - numbers of disks - size of the disk - partitions - size of partitions ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Get a list of harddisks (with some infos like size, used/free)

  1. Get a list of harddisks (with some infos like size, used/free)

    Hi,
    I'm developing a plugin for vdr. I want to get a list of harddisk (internals
    and externals). And I want to have following informations:
    - numbers of disks
    - size of the disk
    - partitions
    - size of partitions (and used/free space of this)

    And a information which I could identify a disk, even if there are same
    harddisk-vendor/-type (like Serialnumber or UUID?).

    How could I do that with C/C++?
    Tips about getting informations by using commandline are useful as far it's
    not user interactive (=> e.g. 'fdisk /dev/sda' is no good).

    Thank you!
    cu Floh

  2. Re: Get a list of harddisks (with some infos like size, used/free)

    Josef Moellers wrote:

    > Florian Erfurth wrote:
    >> Hi,
    >> I'm developing a plugin for vdr. I want to get a list of harddisk
    >> (internals and externals). And I want to have following informations:
    >> - numbers of disks
    >> - size of the disk
    >> - partitions
    >> - size of partitions (and used/free space of this)
    >>
    >> And a information which I could identify a disk, even if there are same
    >> harddisk-vendor/-type (like Serialnumber or UUID?).
    >>
    >> How could I do that with C/C++?
    >> Tips about getting informations by using commandline are useful as far
    >> it's not user interactive (=> e.g. 'fdisk /dev/sda' is no good).

    >
    > You could traverse /sys/block.


    8-o never know about that! Thank you very much! This looks very useful! I
    only tried with /proc/...

    cu Floh

  3. Re: Get a list of harddisks (with some infos like size, used/free)

    Rainer Weikusat wrote:

    > Florian Erfurth writes:
    >> I'm developing a plugin for vdr. I want to get a list of harddisk
    >> (internals and externals). And I want to have following informations:
    >> - numbers of disks
    >> - size of the disk
    >> - partitions
    >> - size of partitions (and used/free space of this)
    >>
    >> And a information which I could identify a disk, even if there are same
    >> harddisk-vendor/-type (like Serialnumber or UUID?).
    >>
    >> How could I do that with C/C++?
    >> Tips about getting informations by using commandline are useful as far
    >> it's not user interactive (=> e.g. 'fdisk /dev/sda' is no good).

    >
    > fdisk -l /dev/sda?

    This would be useful: 'fdisk -l /dev/sd*'
    Thank you very much. But I think as Josef told /sys/block/sd* fit better for
    my needing.

    cu Floh

  4. Re: Get a list of harddisks (with some infos like size, used/free)

    Florian Erfurth writes:
    > I'm developing a plugin for vdr. I want to get a list of harddisk (internals
    > and externals). And I want to have following informations:
    > - numbers of disks
    > - size of the disk
    > - partitions
    > - size of partitions (and used/free space of this)
    >
    > And a information which I could identify a disk, even if there are same
    > harddisk-vendor/-type (like Serialnumber or UUID?).
    >
    > How could I do that with C/C++?
    > Tips about getting informations by using commandline are useful as far it's
    > not user interactive (=> e.g. 'fdisk /dev/sda' is no good).


    fdisk -l /dev/sda?



  5. Re: Get a list of harddisks (with some infos like size, used/free)

    Florian Erfurth wrote:
    > Hi,
    > I'm developing a plugin for vdr. I want to get a list of harddisk (internals
    > and externals). And I want to have following informations:
    > - numbers of disks
    > - size of the disk
    > - partitions
    > - size of partitions (and used/free space of this)
    >
    > And a information which I could identify a disk, even if there are same
    > harddisk-vendor/-type (like Serialnumber or UUID?).
    >
    > How could I do that with C/C++?
    > Tips about getting informations by using commandline are useful as far it's
    > not user interactive (=> e.g. 'fdisk /dev/sda' is no good).


    You could traverse /sys/block.

    --
    These are my personal views and not those of Fujitsu Siemens Computers!
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize (T. Pratchett)
    Company Details: http://www.fujitsu-siemens.com/imprint.html

  6. Re: Get a list of harddisks (with some infos like size, used/free)

    Florian Erfurth schrieb:

    > 8-o never know about that! Thank you very much! This looks very useful! I
    > only tried with /proc/...


    Which would also have provided you with a solution if you had looked at
    /proc/partitions.

    Greetings,
    Johannes

    --
    "PS: Ein Realname wäre nett. Ich selbst nutze nur keinen, weil mich die
    meisten hier bereits mit Namen kennen." -- Markus Gronotte aka Makus /
    Kosst Amojan / maqqusz / Mr. G / Ferdinand Simpson / Quartillia
    Rosenberg in dse <45608268$0$5719$9b4e6d93@newsspool3.arcor-online.net>

  7. Re: Get a list of harddisks (with some infos like size, used/free)

    On Mon, 07 Apr 2008 12:27:42 +0200 Florian Erfurth wrote:

    | I'm developing a plugin for vdr. I want to get a list of harddisk (internals
    | and externals). And I want to have following informations:
    | - numbers of disks
    | - size of the disk
    | - partitions
    | - size of partitions (and used/free space of this)
    |
    | And a information which I could identify a disk, even if there are same
    | harddisk-vendor/-type (like Serialnumber or UUID?).
    |
    | How could I do that with C/C++?
    | Tips about getting informations by using commandline are useful as far it's
    | not user interactive (=> e.g. 'fdisk /dev/sda' is no good).

    Open and read /proc/partitions. For each entry, mount the filesystem in
    some way (if not already mounted) and query that filesystem as needed.
    This doesn't have to be kernel mounted in the case of filesystem types
    for which library code is available to access them "in process". But
    you will at least need device level access to read them to see what is
    on them. Is this program of yours expected to be run as root (user root
    or suid root)?

    --
    |---------------------------------------/----------------------------------|
    | Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
    | first name lower case at ipal.net / spamtrap-2008-04-07-0902@ipal.net |
    |------------------------------------/-------------------------------------|

+ Reply to Thread