PDA

View Full Version : Qt4 Access to Linux HD Sectors and Tracks



jkennedy
4th December 2009, 23:48
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

Gravis
7th December 2009, 01:57
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/

jkennedy
7th December 2009, 17:27
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

squidge
7th December 2009, 17:35
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.

Tanuki-no Torigava
8th December 2009, 06:49
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 (http://www.gnu.org/software/parted/index.shtml) and hdparm (http://en.wikipedia.org/wiki/Hdparm)/sdparm (http://sg.danny.cz/sg/sdparm.html).

Good luck