The program below deosn’t give me the partion information on my disk. I’m
getting all zero’s.
What did I do wrong. This is in QNX 6.1 and the disk are standard IDE drive.
Rejean Senecal
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <time.h>
#include <semaphore.h>
#include <sys/stat.h>
#include <pthread.h>
#include <fcntl.h>
#include <assert.h>
#include <errno.h>
#include <devctl.h>
#include <sys/disk.h>
#include <sys/dcmd_blk.h>
#include “test.hpp”
int main(int argc, char *argv)
{
int iFd, iErr;
partition_entry entry;
iFd=open("/dev/hd0",O_RDONLY);
if (iFd == -1) {
perror(“Error opening /dev/hd0”);
exit(0);
}
iErr = devctl(iFd, DCMD_BLK_PARTENTRY, &entry, sizeof(entry), NULL);
if (iErr) {
perror(“Error getting partion entry”);
exit(0);
}
printf("\nboot_ind %d,\n beg_head %d,\n beg_sector %d,\n beg_cylinder %d,\n
os_type %d,\n end_head %d,\n end_sector %d, end_cylinder %d \n
part_offset %ld,\npart_size %ld;\n",
entry.boot_ind,entry.beg_head,entry.beg_sector,entry.beg_cylinder,entry.os_t
ype,entry.end_head,entry.end_sector,entry.end_cylinder,
entry.part_offset,entry.part_size);
return 0;
}