- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: pstat_getdisk Does Not Return All Disk
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2004 02:32 AM
02-23-2004 02:32 AM
##########START CODE foo.cc##########
#include
#include
int main(void){
struct pst_diskinfo pst[100];
int i, count;
count = pstat_getdisk(pst, sizeof(struct pst_diskinfo),
sizeof(pst) / sizeof(struct pst_diskinfo), 0);
if (count < 0) {
perror("pstat_getdisk()");
return ( EXIT_FAILURE );
}
for (i = 0; i < count; i++) {
printf("\n Disk hardware path = %s",
pst[i].psd_hw_path.psh_name);
}
return( EXIT_SUCCESS );
}
##########STOP CODE foo.cc##########
Compile Options:
aCC -o foo foo.cc
On the server that I am dealing with, the following ioscan command shows 68 disks.
# ioscan -FC disk | wc -l
# 68
While the output from foo, which uses function call pstat_getdisk() only shows 27 installed disks.
If I take and run the same code and command on a 8700, ioscan shows 87 disks while the pstat_getdisk() only displays 48.
I have checked to see if the pstat_getdisk() function call displays information from alternate links and it does. Can someone please tell me about the behavior that I am seeing from the pstat_getdisk() command.
Thanks in advance to all that respond.
Phil
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2004 02:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2004 03:01 AM
02-23-2004 03:01 AM
Re: pstat_getdisk Does Not Return All Disk
Define what you mean by open. Do you mean that I need to open( ptrDiskName, O_RDONLY|O_NDELAY ) for all the disks installed on the system or do you mean that the disk must belong to a Volume Group. Because I do see, in some cases, disks that are not part of a VG and sometimes even the CDROM drives.
Phil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2004 03:03 AM
02-23-2004 03:03 AM
Re: pstat_getdisk Does Not Return All Disk
ioscan -FC disk doesn't just show you disks. It shows everything in the class disks. This includes funky stuff like array information from XP's or other storage devices. I would check exactly how many disks are really attached to the system
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2004 03:07 AM
02-23-2004 03:07 AM
Re: pstat_getdisk Does Not Return All Disk
Phil.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2004 07:05 AM
02-23-2004 07:05 AM
Re: pstat_getdisk Does Not Return All Disk
Using the open ( ptrDeviceName, O_RDONLY|O_NDELAY ) and holding the file descriptors until the pstat_getdisk() operations are complete is what it takes. I would hazard to guess that it is true that the kernel does not know anything about these devices, other than they exist, and pstat is unable to obtain access to the information until an open file descriptor to the device(s) in question exists.
Thanks for the speedy replies.
Phil.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2005 11:01 PM
12-01-2005 11:01 PM
Re: pstat_getdisk Does Not Return All Disk
I am also facing the same problem. The pstat_getdisk is not listing all the disk configured in the HP-UX system.
Even i tried opening the devices using open(devicename,O_RDONLY|O_NDELAY) but it didn't help. can some one please tell me why it is not listin all the disks.
Thanks in advance..
Ramesh Babu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2005 08:40 AM
12-02-2005 08:40 AM
Re: pstat_getdisk Does Not Return All Disk
It has been nearly a year since I worked on this issue; however, in my last response the original issue, I indicated that I solved the problem.
It appears that your source code example, "open(devicename,O_RDONLY|O_NDELAY)" is passing the device name and not a pointer to the device. This may not be true, but your code does not indicate otherwise.
Please read my original response:
"Using the open ( ptrDeviceName, O_RDONLY|O_NDELAY ) and holding the file descriptors until the pstat_getdisk() operations are complete is what it takes. I would hazard to guess that it is true that the kernel does not know anything about these devices, other than they exist, and pstat is unable to obtain access to the information until an open file descriptor to the device(s) in question exists."
1). Obtain a Pointer to the directory, such as, /dev.
ptrD = opendir( FULLPATH )
2). Read the directory in something like a while loop.
ptrDir = readdir( ptrD )
3). Perform what ever action you are wanting to accompish, such as, lstat.
4). Cleanup any pointers and data structures.
Here is a couple of chunks of code you can read through to get an idea of what you need to do.
/////////////////////////////////////////////////////////////////////////////////////
// PROTOTYPES //
/////////////////////////////////////////////////////////////////////////////////////
typedef int get_pt ( const char *, const struct stat *, int );
static get_pt get_path_type;
static int get_path ( const char *, get_pt * );
static int parse_path ( get_pt * );
static int parse_path ( get_pt *gpt ) {
////////////////////////////////////////////////////////////////////////////////////
// Descend through the hierarchy, starting at "fullpath". If "fullpath" is //
// anything other than a directory, then lstat() it, call get_path_type [gpt], and//
// return. For a directory, we call ourself ( parse_path ) recursively for each //
// name in the directory. //
////////////////////////////////////////////////////////////////////////////////////
struct stat statbuf;
struct dirent *ptrDir;
DIR *ptrD;
int ret;
char *ptr;
(void)memset( &statbuf, 0, sizeof( struct stat ) );
if ( lstat( FULLPATH, &statbuf ) < 0 ) {
return( gpt( FULLPATH, &statbuf, FTW_NS ) ); /* lstat error */
}
if ( S_ISDIR( statbuf.st_mode ) == 0 ) {
return( gpt( FULLPATH, &statbuf, FTW_F ) ); /* not a directory */
}
/*************************************************************************
** It is a directory. First call get_path_type [gpt] for the directory **
** then process each file name in the directory. **
*************************************************************************/
if ( ( ret = gpt( FULLPATH, &statbuf, FTW_D ) ) != 0 ) {
return( ret );
}
ptr = FULLPATH + strlen( FULLPATH ); /* point to the end of FULLPATH */
*ptr++ = '/';
*ptr = 0;
if ( ( ptrD = opendir( FULLPATH ) ) == NULL ) {
return ( gpt( FULLPATH, &statbuf, FTW_DNR ) ); /* Cannot read directory */
}
while ( ( ptrDir = readdir( ptrD ) ) != NULL ) {
if ( strcmp( ptrDir->d_name, "." ) == 0 |
strcmp( ptrDir->d_name, ".." ) == 0 |
strcmp( ptrDir->d_name, "group" ) == 0 ) {
continue; /* ignore dot ".", dot dot ".." and group */
}
strcpy( ptr, ptrDir->d_name ); /* append name after slash */
if ( ( ret = parse_path( gpt ) ) != 0 ) { break; } /* recursive */
}
ptr[-1] = 0; /* erase everything from slash onward */
if ( closedir( ptrD ) < 0 ) {
printf ( "ERROR: Cannot close directory %s", FULLPATH );
}
////////////////////////////////////////////////////////////////////////////////////
// Cleanup //
////////////////////////////////////////////////////////////////////////////////////
if ( ptrDir ) { delete [] ptrDir; }
return ( ret );
}
static int get_path_type( const char *ptrPathname, const struct stat *ptrStat, int type ) {
////////////////////////////////////////////////////////////////////////////////////
// Determine the path type, is it a directory or a file, can we stat it... //
////////////////////////////////////////////////////////////////////////////////////
string s;
auto unsigned int i =0;
switch (type) {
case FTW_F:
switch( ptrStat->st_mode & S_IFMT ) {
case S_IFREG:
////////////////////////////////////////////////////////////////////////////////
// Regular File. //
////////////////////////////////////////////////////////////////////////////////
break;
case S_IFBLK:
////////////////////////////////////////////////////////////////////////////////
// Block Device File. //
// dev_t st_rdev Device ID; this entry defined only for char or blk spec //
// files. //
////////////////////////////////////////////////////////////////////////////////
for ( i =0; i < strlen( ptrPathname ); i++ ) { s += ptrPathname[i]; }
vdevice.push_back( s );
vmajor.push_back( (int)major(ptrStat->st_rdev) );
vminor.push_back( (int)minor(ptrStat->st_rdev) );
break;
case S_IFCHR:
////////////////////////////////////////////////////////////////////////////////
// Character Device File. //
// dev_t st_rdev Device ID; this entry defined only for char or blk spec //
// files. //
////////////////////////////////////////////////////////////////////////////////
for ( i =0; i < strlen( ptrPathname ); i++ ) { s += ptrPathname[i]; }
vdevice.push_back( s );
vmajor.push_back( (int)major(ptrStat->st_rdev) );
vminor.push_back( (int)minor(ptrStat->st_rdev) );
break;
case S_IFIFO:
//printf ( "%s = IFO\n", ptrPathname );
break;
case S_IFLNK:
////////////////////////////////////////////////////////////////////////////////
// Link File. //
////////////////////////////////////////////////////////////////////////////////
break;
case S_IFSOCK:
////////////////////////////////////////////////////////////////////////////////
// Socket File. //
////////////////////////////////////////////////////////////////////////////////
break;
case S_IFDIR:
////////////////////////////////////////////////////////////////////////////////
// Directory (We should not get here). //
////////////////////////////////////////////////////////////////////////////////
break;
}
break;
case FTW_D:
////////////////////////////////////////////////////////////////////////////////
// Directory. //
////////////////////////////////////////////////////////////////////////////////
break;
case FTW_DNR:
printf ( "ERROR: Cannot read directory %s\n", ptrPathname );
break;
case FTW_NS:
printf ( "ERROR: Cannot stat %s\n", ptrPathname );
break;
default:
printf ( "ERROR: unknown type %d for path %s\n", type, ptrPathname );
break;
}
return ( 0 );
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2005 07:48 PM
12-04-2005 07:48 PM
Re: pstat_getdisk Does Not Return All Disk
I have five devices in my HP-UX host, all are in the /dev/rdsk directory. The pstat_getdisk lists only two devices. Below is the sample program. Program is particularly written for the device "c12t0d0" which is not listed by the pstat_getdisk. Even i have passed pointer to device name in the open call but still pstat is not listing this device. I can open the device successfully and even the lstat worked perfectly. called pstat after opening the device and closed after later.
int main()
{
struct pst_diskinfo sDiskData;
int nReturnCode;
int j;
int nfd;
DIR *ptrD;
struct dirent *ptrDir;
struct stat statbuf;
char DeviceName[50];
char *ptr;
bzero(DeviceName,strlen(DeviceName));
ptrD = opendir("/dev/rdsk");
while( (ptrDir = readdir(ptrD)) != NULL)
{
if(strcmp(ptrDir->d_name,"c12t0d0") != 0)
continue;
sprintf(DeviceName,"/dev/rdsk/%s",ptrDir->d_name);
if(lstat(DeviceName,&statbuf) < 0)
perror("lstat failed");
ptr = DeviceName;
nfd = open(ptr,O_RDONLY|O_NDELAY);
if(nfd == -1)
perror("open failed ");
else
printf("file descriptor is %d \n",nfd);
for(j = 0; j<999; j++)
{
nReturnCode = pstat_getdisk(&sDiskData,sizeof(sDiskData),1,j);
if(nReturnCode == -1)
perror("pstat_getdisk failed : ");
else
printf("%d Name = %s%d \n",j,sDiskData.psd_drv_name.psd_name,sDiskData.psd_instance);
}
}
close(nfd);
return 0;
}
please let me know is there any problem in the sample program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2005 08:19 PM
12-04-2005 08:19 PM
Re: pstat_getdisk Does Not Return All Disk
e.g.
int idx = 0;
struct pst_diskinfo psd;
int rc = 1;
while (rc == 1)
{
rc = pstat_getdisk(&psd, sizeof(psd), 1, idx);
if (rc != 1) break;
// do your stuff ...
idx = psd.psd_idx + 1; /* Next disk */
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2005 08:39 PM
12-04-2005 08:39 PM
Re: pstat_getdisk Does Not Return All Disk
Thx,
Ramesh