Results 1 to 1 of 1
I am having a program which gives details of pci slots like sata slot and usb slots.
But this program is not working for some systems like Redhat 9 having ...
- 09-06-2007 #1Just Joined!
- Join Date
- Nov 2006
- Posts
- 13
Ioctl Fail In Some Systems Like Redhat 9, Kernel 2.4.20-8
I am having a program which gives details of pci slots like sata slot and usb slots.
But this program is not working for some systems like Redhat 9 having kernel 2.4.20-8
I am using ioctl SCSI_IOCTL_GET_PCI , which is not working in this system .
So what should I have to do for getting information of slots in this Redhat 9 pc.
Please give me any help if possible ...
Thanking you in advance ...
The Program is given below :
================================================== =======================
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <scsi/sg.h>
#include <scsi/scsi.h>
#include <string.h>
#define SUCCESS 1
#define FAILURE -1
#define SG_X "/dev/sg%d"
#ifndef SCSI_IOCTL_GET_PCI
#define SCSI_IOCTL_GET_PCI 0x5387
#endif
int scan_sg( int sg )
{
char buffer[20] = { '\0' };
int fd = -1;
snprintf(buffer, sizeof(buffer), SG_X, sg);
fd = open(buffer, O_RDWR | O_NONBLOCK);
if (fd < 0)
{
// printf(" Inside scan_sg fd open failed returning false \n" );
return FAILURE;
}
char slot_name[64] = { '\0' };
memset(slot_name, 0, sizeof(slot_name));
if (ioctl(fd, SCSI_IOCTL_GET_PCI, slot_name) >= 0)
{
printf("SLOT NAME :- %s\n", slot_name);//parent = n.findChildByBusInfo(guessBusInfo(hw::strip(slot_n ame)));
}
printf("\n");
close(fd);
return SUCCESS;
}
int main()
{
int i;
for(i = 0 ; i <=10;i++)
scan_sg(i);
return 0;
}


Reply With Quote