View topic - how can i get the size of a QNX partition(programmaticaly)

how can i get the size of a QNX partition(programmaticaly)

General Help about QNX

how can i get the size of a QNX partition(programmaticaly)

Postby stepwolfalbatros » Wed Dec 16, 2009 3:31 pm

i just want to learn the size of any given partition in my program.
do you have any idea?
thanks for your advices..
stepwolfalbatros
New Member
 
Posts: 8
Joined: Tue Dec 15, 2009 10:32 am

RE: how can i get the size of a QNX partition(programmatical

Postby mario » Wed Dec 16, 2009 3:49 pm

struct stat64 statBuf;

stats64( "/dev/hd0t77", &statBuf );

statBuff.st_size should contain the size of the partition.

Or you could use fstatvfs64 to gather more specific information if you need to.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Re: RE: how can i get the size of a QNX partition(programmat

Postby stepwolfalbatros » Thu Dec 17, 2009 7:46 am

mario wrote:struct stat64 statBuf;

stats64( "/dev/hd0t77", &statBuf );

statBuff.st_size should contain the size of the partition.

Or you could use fstatvfs64 to gather more specific information if you need to.


if ( stat64( "../../home", &statBuf ) == -1) {
perror ("stat" );
return EXIT_FAILURE;
} else {
printf ("Free memory: %d bytes\n", statBuf.st_size);
return EXIT_SUCCESS;
}
when i execute this code , i get always this output : 4096 bytes
what is wrong?
stepwolfalbatros
New Member
 
Posts: 8
Joined: Tue Dec 15, 2009 10:32 am

RE: Re: RE: how can i get the size of a QNX partition(progra

Postby mario » Thu Dec 17, 2009 3:34 pm

because you didn't the read the documentation. st_size is a 64 bit value, you need to use %lld.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am


Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests