Find the answer to your Linux question:
Results 1 to 5 of 5
Does any body knows how to find hard disk information using c proramg, like Total Size of disk, mounted partitions, unmounted partitions, unused size , serial no etc....
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2006
    Posts
    48

    How to get Hard Disk Info Using C program


    Does any body knows how to find hard disk information using c proramg, like Total Size of disk, mounted partitions, unmounted partitions, unused size , serial no etc.

  2. #2
    Linux User fernape's Avatar
    Join Date
    Dec 2005
    Location
    Holland
    Posts
    301
    procfs is your friend

    Surf /proc and see partitions file and ide directory... and read the procfs documentation that comes with the kernel source.

    Best regards

  3. #3
    Just Joined!
    Join Date
    Aug 2006
    Posts
    48
    without using /proc pshedo file system i want to know the stuff using c proram.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User fernape's Avatar
    Join Date
    Dec 2005
    Location
    Holland
    Posts
    301
    The way you should gather system information is using procfs. It is it's purpose.
    In addition, you have two alternatives:

    • Execute the sysctl command: This is really dirty.
    • Use the sysctl system call: If you carefully read the man page, at the bottom, you can find this:
      The object names vary between kernel versions. THIS MAKES THIS SYSTEM CALL WORTHLESS FOR APPLICATIONS. Use the /proc/sys interface instead.


    Although it's possible to gather the information that you want by means of other system calls / functions, using procfs is what top, ps and other tools do. (and I'm not sure, but free and df probably do too)

    Best Regards

  6. #5
    Just Joined!
    Join Date
    Aug 2006
    Posts
    48

    Thanks for ur reply

    Thanks for ur reply

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •