(SIGAR-131) use pstat_getfile2 in sigar_proc_fd_get on HP/UX 11iv2+
Signed-off-by: Doug MacEachern <dougm@hyperic.com>
This commit is contained in:
		
							parent
							
								
									f0ef330989
								
							
						
					
					
						commit
						2d86ebadfb
					
				@ -16,6 +16,10 @@
 | 
			
		||||
 * USA.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_CONFIG_H
 | 
			
		||||
#include "config.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "sigar.h"
 | 
			
		||||
#include "sigar_private.h"
 | 
			
		||||
#include "sigar_util.h"
 | 
			
		||||
@ -416,7 +420,11 @@ int sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid,
 | 
			
		||||
{
 | 
			
		||||
    struct pst_status status;
 | 
			
		||||
    int idx, i, n;
 | 
			
		||||
#ifdef HAVE_STRUCT_PST_FILEINFO2
 | 
			
		||||
    struct pst_fileinfo2 psf[16];
 | 
			
		||||
#else
 | 
			
		||||
    struct pst_fileinfo psf[16];
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    procfd->total = 0;
 | 
			
		||||
 | 
			
		||||
@ -424,6 +432,18 @@ int sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid,
 | 
			
		||||
        return errno;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* HPUX 11.31 removed the deprecated pstat_getfile call */
 | 
			
		||||
#ifdef HAVE_STRUCT_PST_FILEINFO2
 | 
			
		||||
    idx = status.pst_idx;
 | 
			
		||||
 | 
			
		||||
    while ((n = pstat_getfile2(psf, sizeof(psf[0]),
 | 
			
		||||
                               sizeof(psf)/sizeof(psf[0]),
 | 
			
		||||
                               idx, pid)) > 0)
 | 
			
		||||
    {
 | 
			
		||||
        procfd->total += n;
 | 
			
		||||
        idx = psf[n-1].psf_fd;
 | 
			
		||||
    }
 | 
			
		||||
#else
 | 
			
		||||
    /* man pstat_getfile for index splaination */
 | 
			
		||||
    idx = (status.pst_idx << 16) | (0 & 0xffff);
 | 
			
		||||
 | 
			
		||||
@ -434,6 +454,7 @@ int sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid,
 | 
			
		||||
        procfd->total += n;
 | 
			
		||||
        idx = psf[n-1].psf_idx + 1;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    if (n == -1) {
 | 
			
		||||
        return errno;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user