Results 1 to 5 of 5

Thread: Qt4 Access to Linux HD Sectors and Tracks

  1. #1
    Join Date
    Dec 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Qt4 Access to Linux HD Sectors and Tracks

    I'm new to Qt environment, currently going through the documentation and "C++ GUI Programming with Qt4" publication; but can't find any class reference for access to the raw data on a hard drive. (ie: /dev/sda1, boot sector architecture)

    Can anyone confirm if Qt4 can access the sectors and tracks of a hard drive on a linux system?

    Any guidance would be appreciated.

    Much Thanks
    jk

  2. #2
    Join Date
    Aug 2009
    Location
    LOL Land
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt4 Access to Linux HD Sectors and Tracks

    Quote Originally Posted by jkennedy View Post
    but can't find any class reference for access to the raw data on a hard drive. (ie: /dev/sda1, boot sector architecture)
    Qt does not have raw access to hard drive devices. HOWEVER, there is an easy way to fix this. subclass QIODevice with a few functions from stdio.h (fopen, fread, fwrite at minimum) and you will be able to use it like any other QIODevice subclass (QFile and the like).

    fopen can open block devices like they are a normal file.

    info on stdio functions: http://www.cplusplus.com/reference/clibrary/cstdio/

  3. #3
    Join Date
    Dec 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt4 Access to Linux HD Sectors and Tracks

    Thanks Gravis;

    I'll check out the QIODevice calss as you suggested. Somtimes all it takes is a push in the right
    direction.

    Again, much thanks.

    JK

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt4 Access to Linux HD Sectors and Tracks

    Block devices on linux are normal files, so you already have full access to them provided you have appropriate priviledges (eg. root access).

    Secondly, Linux has no notion of sectors or tracks (actually, neither does Windows). It's all logical block addressing now.

  5. #5
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt4 Access to Linux HD Sectors and Tracks

    Block devices on linux are normal files, so you already have full access to them provided you have appropriate priviledges (eg. root access).
    That's true. But you can get more with various kernel level calls (e.g. sysctl)

    Secondly, Linux has no notion of sectors or tracks (actually, neither does Windows). It's all logical block addressing now.
    Partly true because linux provides 2 files for each block device: block device and char device (sequential). But to crack the question:
    Can anyone confirm if Qt4 can access the sectors and tracks of a hard drive on a linux system?
    You should go down to the waterline. And very good candidates here are sources of parted and hdparm/sdparm.

    Good luck

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.