Geting partition information of a device.....

Hi Qnx Gurus,

 I am new to Qnx development environment. I have run the command "io-usb -d ohci" and "devb-umass cam pnp". And after doing "df" command, i could able to see the partition of the device "/dev/hd1" as "/dev/hd1t11".

 can you please tell me, is there any method or command which directly retrives me the PARTION NUMBER of the device.

Advance thank you…



The command to get partition information is ‘fdisk’

‘fdisk /dev/hd1’

will allow you to see/modify/ partition information for a device as well ass change the boot sequence.


No Tim, i think you didn’t get me.

I want to get the information before mounting the device. Let me clarify you.

I am running the stack and driver of USB2.0, using …
"io-usb -d ohci -d ehci "
then to detect the USB, i am doing
“devb-umass cam pnp”

Now if i command 

“fdisk /dev/hd1”
it wont work. since the device is not mounted.

Now in order to mount the device i have to get the device partition. How can i get that? Since my device is not mounted yet. And since i don’t know the partionon information/number how can i mount.

please don’t say command “df” gives the partition information. because it gives the partition info. but there is no way i can get the information so that i can PROGRAMATICALLY mount the device.

Thank you in advance.


Now I understand what you want to do.

I don’t think there is a simple way to do it from a program. I see only three choices:

  1. Hope someone else has done it and posts their code. I suspect it involves using statvfs/statvfs64 calls after looking at the documentation on df.

  2. Obtain the source code for df and take the pieces you need.

  3. Run the ‘df’ command from your program and then parse it’s output to obtain the info you need.

For #3, in your program you’d something like the following:

system(“df > outputFile”); // Place df output in a file
while (!EOF)
//search the line for the new device’s partition info and if you find it you
// have what you need for doing the mount command.

It’s clumsy, but it can be made to work without understanding a lot of low level information on the filesystem.

Hopefully someone else will chime in with an solution using statvfs.


You said “Now if i command “fdisk /dev/hd1” it wont work. since the device is not mounted”

If /dev/hd1 isn’t present it’s because devb-umass didn’t recognize the device. To have the partitions show up try mount -e. Then you can use opendir() to read the content of /dev/ and detect the partitions.

No its not working mario. i have tried a lot. i have written a code like this.

DIR* dirp;
struct dirent* direntp;

syatem(“io-usb -d ohci -d ehci”);
System(“devb-umass cam pnp”);

system(“mount -e”);

dirp = opendir("/dev/hd1");
if (dirp != NULL)
direntp = readdir( dirp );

I am not able to get the mounting point of USB. Please tell me how to get the mounting point of USB.

Thank you.

Since you first post indicate you can see /dev/hd1 after you run those commands in a terminal.

  1. make sure your usb is pluged in.
  2. put a sleep(5) between each “system()” commands.

You can’t opendir("/dev/hd1") , /dev/hd1 is NOT a directory. Instead opendir("/dev") then you must go through every entry in /dev and detect the one that match the patter /dev/hd1* and then deal with them.

Thank you mario…

This really healped me. Thank you once again…