components/net-snmp/patches/027.7118090.hr_filesys.patch
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Thu, 30 Jan 2014 13:44:37 -0800
changeset 1679 51291a5fd692
parent 1650 ce501c11d5fa
permissions -rw-r--r--
backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
     1
/*
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
     2
 *  This patch fixes the performance issue observed while retrieving the
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
     3
 *  hrStorage parameters in systems with large number of mountpoints
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
     4
 *  parameters using snmpwalk.
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
     5
 *
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
     6
 *  This issue is happening due to the overhead of large number of
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
     7
 *  ioctl() system calls in getmntent() function called by the
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
     8
 *  Get_Next_HR_FileSys() function.
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
     9
 *
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
    10
 *  We see that in the Get_Next_HR_FileSys() function, inorder to access
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    11
 *  the last mountpoint, the /etc/mnttab is opened and we walk through
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    12
 *  all the mnttab entries for all filesystems till the end. This is the
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    13
 *  reason we find a large number of the MNTIOC_GETMNTENT ioctl() calls.
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    14
 *
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    15
 *  To reduce the overhead of the getmntent() calls, we maintain a cache
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    16
 *  of all the /etc/mnttab entries and walk through the cache instead of
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    17
 *  opening /etc/mnttab and walking all the entries for each mountpoint.
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
    18
 *  This functionality is provided by the load_mnttab_cache_solaris()
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
    19
 *  function called from the Init_HR_FileSys() function.
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    20
 */
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    21
--- net-snmp-5.4.1.orig/agent/mibgroup/host/hr_filesys.c	2007-05-18 11:08:01.000000000 -0700
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    22
+++ net-snmp-5.4.1/agent/mibgroup/host/hr_filesys.c	2013-01-17 03:36:28.181493003 -0800
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    23
@@ -31,6 +31,10 @@
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    24
 #include <sys/mount.h>
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    25
 #endif
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    26
 
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    27
+#ifdef solaris2
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    28
+#include <sys/stat.h>
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    29
+#endif
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    30
+
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    31
 #include <ctype.h>
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    32
 #if HAVE_STRING_H
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    33
 #include <string.h>
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    34
@@ -85,7 +89,11 @@
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    35
 #ifdef solaris2
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    36
 
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    37
 struct mnttab   HRFS_entry_struct;
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    38
-struct mnttab  *HRFS_entry = &HRFS_entry_struct;
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    39
+struct mnttab  *HRFS_entry;
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    40
+struct mnttab	*HRFS_list;
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    41
+static int fscount;
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    42
+static time_t last_access = -1;
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    43
+
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    44
 #define	HRFS_name	mnt_special
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    45
 #define	HRFS_mount	mnt_mountp
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
    46
 #define	HRFS_type	mnt_fstype
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    47
@@ -167,6 +175,9 @@
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    48
 static u_char  *when_dumped(char *filesys, int level, size_t * length);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    49
 int             header_hrfilesys(struct variable *, oid *, size_t *, int,
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    50
                                  size_t *, WriteMethod **);
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
    51
+#ifdef solaris2
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    52
+static int      load_mnttab_cache_solaris(void);
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
    53
+#endif
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    54
 
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    55
         /*********************
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    56
 	 *
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    57
@@ -606,8 +617,14 @@
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
    58
     HRFS_index = 1;
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
    59
     if (fp != NULL)
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
    60
         fclose(fp);
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
    61
+#ifdef solaris2
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    62
+    if(!load_mnttab_cache_solaris())
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    63
+        return;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    64
+#else    
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    65
     fp = fopen(ETC_MNTTAB, "r");
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    66
 #endif
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    67
+
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    68
+#endif
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    69
 }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    70
 
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    71
 const char     *HRFS_ignores[] = {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    72
@@ -663,6 +680,117 @@
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    73
     0
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    74
 };
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    75
 
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    76
+#ifdef solaris2
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    77
+
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    78
+/*
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    79
+ *  This function has been introduced to reduce the overhead
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    80
+ *  of the getmntent() calls used to fetch the details of
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    81
+ *  the /etc/mnttab entries in Init_HR_FileSys().
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    82
+ *
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    83
+ *  We maintain a cache of all the /etc/mnttab entries and
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    84
+ *  walk through the cache instead of opening /etc/mnttab and
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    85
+ *  walking all the entries for each mountpoint.
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    86
+ */
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
    87
+
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    88
+static int 
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    89
+load_mnttab_cache_solaris()
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    90
+{
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    91
+    char buf[512] = {NULL};
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    92
+    int i = 0;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    93
+    struct stat file_stat;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    94
+    const char **cpp;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    95
+    char *ch;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    96
+    int token_flag = 0;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    97
+    int skip_flag = 0;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    98
+    int ignore_flag = 0;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
    99
+    int j = 0;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   100
+    int lines = 0;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   101
+    int ret = 0;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   102
+    HRFS_index = 0;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   103
+
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   104
+    stat(ETC_MNTTAB, &file_stat);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   105
+    if (last_access == -1 || last_access != file_stat.st_mtime) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   106
+        fp = fopen(ETC_MNTTAB, "r");
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   107
+        if(fp == NULL)
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   108
+        {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   109
+            DEBUGMSGTL(("host/hr_filesys", "fopen failed for mnttab.\n"));
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   110
+            return -1;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   111
+        }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   112
+        
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   113
+        /* find the number of valid entries in mnttab. */
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   114
+        
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   115
+        while ((fgets((char *) &buf, sizeof(buf), fp)) != NULL) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   116
+            j = 0;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   117
+            skip_flag = 0;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   118
+            token_flag = 0;
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   119
+
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   120
+            /* tokenize the mnttab entries to fetch the fstype
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   121
+             * which determines the valid entries.
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   122
+             */
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   123
+
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   124
+            ch = strtok(buf, " \t");
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   125
+            while (ch != NULL) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   126
+                j++;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   127
+                if(j == 3) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   128
+                    for (cpp = HRFS_ignores; *cpp != NULL; ++cpp) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   129
+                        if(!strncmp(ch, *cpp, strlen(ch))) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   130
+                            skip_flag = 1;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   131
+                            break;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   132
+                        }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   133
+                    }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   134
+                    token_flag = 1;
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   135
+                }
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   136
+                if(token_flag)
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   137
+                    break;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   138
+                ch = strtok(NULL, " \t");
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   139
+             }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   140
+             if(!skip_flag)
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   141
+                 lines++;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   142
+        }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   143
+        fclose(fp);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   144
+
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   145
+        fscount = lines;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   146
+        HRFS_list = (struct mnttab *) malloc (sizeof(struct mnttab) * fscount);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   147
+        if(HRFS_list == NULL) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   148
+            DEBUGMSGTL(("host/hr_filesys", "Memory allocation for mnttab cache failed.\n"));
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   149
+            return -1;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   150
+        }
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   151
+
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   152
+        fp = fopen(ETC_MNTTAB, "r");
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   153
+        if(fp == NULL) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   154
+            DEBUGMSGTL(("host/hr_filesys", "fopen failed for mnttab.\n"));
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   155
+            free(HRFS_list);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   156
+            return -1;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   157
+        }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   158
+
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   159
+        while (i < fscount) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   160
+            if (getmntent(fp, &HRFS_entry_struct) == 0) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   161
+                 for (cpp = HRFS_ignores; *cpp != NULL; ++cpp) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   162
+                     if (!strcmp(HRFS_entry_struct.HRFS_type, *cpp)) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   163
+                         ignore_flag = 1;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   164
+                         break;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   165
+                     }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   166
+                 }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   167
+
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   168
+                 if(!ignore_flag) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   169
+                     HRFS_list[i].mnt_special = strdup(HRFS_entry_struct.mnt_special);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   170
+                     HRFS_list[i].mnt_mountp = strdup(HRFS_entry_struct.mnt_mountp);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   171
+                     HRFS_list[i].mnt_fstype = strdup(HRFS_entry_struct.mnt_fstype);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   172
+                     HRFS_list[i].mnt_mntopts = strdup(HRFS_entry_struct.mnt_mntopts);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   173
+                     i++;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   174
+                 }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   175
+
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   176
+                 ignore_flag = 0;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   177
+            }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   178
+        }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   179
+
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   180
+        HRFS_entry = HRFS_list;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   181
+        last_access = file_stat.st_mtime;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   182
+    }
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   183
+    return ret;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   184
+}
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   185
+#endif
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   186
+
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   187
 int
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   188
 Get_Next_HR_FileSys(void)
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   189
 {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   190
@@ -699,17 +827,18 @@
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   191
 #else
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   192
     const char    **cpp;
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   193
 
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   194
-    if (fp == NULL)
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   195
-        return -1;
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   196
 
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   197
 #ifdef solaris2
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   198
-    if (getmntent(fp, HRFS_entry) != 0)
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   199
+    if (HRFS_index >= fscount)
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   200
         return -1;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   201
+    HRFS_entry = &HRFS_list[HRFS_index];
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   202
+        return ++HRFS_index;
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   203
 #else
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   204
+    if (fp == NULL)
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   205
+        return -1;
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   206
     HRFS_entry = getmntent(fp);
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   207
     if (HRFS_entry == NULL)
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   208
         return -1;
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   209
-#endif                          /* solaris2 */
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   210
 
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   211
     for (cpp = HRFS_ignores; *cpp != NULL; ++cpp)
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   212
         if (!strcmp(HRFS_entry->HRFS_type, *cpp))
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   213
@@ -728,6 +857,8 @@
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   214
     }
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   215
 
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   216
     return HRFS_index++;
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   217
+#endif
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   218
+
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   219
 #endif                          /* HAVE_GETFSSTAT */
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   220
 }
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   221
 
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   222
@@ -791,9 +922,24 @@
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   223
         HRFS_entry = NULL;
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   224
     }
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   225
 #else
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   226
+    int i = 0;
1126
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   227
     if (fp != NULL)
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   228
         fclose(fp);
a7e552aeef46 15818955 SUNBT7201487 snmpd cores multiple times during walk with service ending in maint
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents: 964
diff changeset
   229
     fp = NULL;
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   230
+
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   231
+#ifdef solaris2
1679
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   232
+while (i < fscount) {
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   233
+    free(HRFS_list[i].mnt_special);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   234
+    free(HRFS_list[i].mnt_mountp);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   235
+    free(HRFS_list[i].mnt_fstype);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   236
+    free(HRFS_list[i].mnt_mntopts);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   237
+    i++;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   238
+}
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   239
+    if (HRFS_list != NULL)
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   240
+        free(HRFS_list);
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   241
+    last_access = -1;
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   242
+#endif
51291a5fd692 backout 17949399/16488880/15685782/15997718/15705167/15754602/16066103/16242256 - needs more work
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1650
diff changeset
   243
+
1650
ce501c11d5fa 15685782 SUNBT7005330 NET-SNMP upgrade to latest stable version
Gowtham Thommandra <Gowtham.Thommandra@Oracle.COM>
parents: 1306
diff changeset
   244
 #endif
964
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   245
 }
3193e50c7331 7118090 snmpwalk of hrStorageIndex can take several minutes due to excessive ioctl calls for mnttab by snmpd
Lijo George - Oracle Corporation - Bangalore India <lijo.x.george@oracle.com>
parents:
diff changeset
   246