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