Blame SOURCES/net-snmp-5.7.2-autofs.patch

2908c4
diff -urNp oold/agent/mibgroup/hardware/fsys/fsys_mntctl.c nnew/agent/mibgroup/hardware/fsys/fsys_mntctl.c
2908c4
--- oold/agent/mibgroup/hardware/fsys/fsys_mntctl.c	2012-10-10 00:28:58.000000000 +0200
2908c4
+++ nnew/agent/mibgroup/hardware/fsys/fsys_mntctl.c	2017-10-31 10:21:53.433280099 +0100
2908c4
@@ -43,8 +43,9 @@ _fsys_type( int type)
2908c4
 
2908c4
         case  MNT_NFS:
2908c4
         case  MNT_NFS3:
2908c4
-        case  MNT_AUTOFS:
2908c4
             return NETSNMP_FS_TYPE_NFS;
2908c4
+        case  MNT_AUTOFS:
2908c4
+            return NETSNMP_FS_TYPE_AUTOFS;
2908c4
 
2908c4
     /*
2908c4
      *  The following code covers selected filesystems
2908c4
@@ -153,10 +154,12 @@ netsnmp_fsys_arch_load( void )
2908c4
 
2908c4
         /*
2908c4
          *  Optionally skip retrieving statistics for remote mounts
2908c4
+         *  AUTOFS is skipped by default
2908c4
          */
2908c4
-        if ( (entry->flags & NETSNMP_FS_FLAG_REMOTE) &&
2908c4
+        if ( ((entry->flags & NETSNMP_FS_FLAG_REMOTE) &&
2908c4
             netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
2908c4
-                                   NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES))
2908c4
+                                   NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES)) ||
2908c4
+              entry->type == (NETSNMP_FS_TYPE_AUTOFS))
2908c4
             continue;
2908c4
 
2908c4
         if ( statfs( entry->path, &stat_buf ) < 0 ) {
2908c4
diff -urNp oold/agent/mibgroup/hardware/fsys/fsys_mntent.c nnew/agent/mibgroup/hardware/fsys/fsys_mntent.c
2908c4
--- oold/agent/mibgroup/hardware/fsys/fsys_mntent.c	2017-10-30 14:50:41.784743150 +0100
2908c4
+++ nnew/agent/mibgroup/hardware/fsys/fsys_mntent.c	2017-10-31 08:59:08.953114110 +0100
2908c4
@@ -145,6 +145,13 @@ _fsys_type( char *typename )
2908c4
               !strcmp(typename, MNTTYPE_LOFS))
2908c4
        return NETSNMP_FS_TYPE_OTHER;
2908c4
 
2908c4
+    /* Detection of AUTOFS.
2908c4
+     * This file system will be ignored by default
2908c4
+     */ 
2908c4
+    else if ( !strcmp(typename, MNTTYPE_AUTOFS))
2908c4
+        return NETSNMP_FS_TYPE_AUTOFS;
2908c4
+
2908c4
+
2908c4
     /*    
2908c4
      *  All other types are silently skipped
2908c4
      */
2908c4
@@ -239,6 +246,10 @@ netsnmp_fsys_arch_load( void )
2908c4
                                    NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES))
2908c4
             continue;
2908c4
 
2908c4
+        /* Skip AUTOFS enteries */
2908c4
+        if ( entry->type == (NETSNMP_FS_TYPE_AUTOFS))
2908c4
+            continue;
2908c4
+
2908c4
 #ifdef irix6
2908c4
         if ( NSFS_STATFS( entry->path, &stat_buf, sizeof(struct statfs), 0) < 0 )
2908c4
 #else
2908c4
diff -urNp oold/agent/mibgroup/hardware/fsys/mnttypes.h nnew/agent/mibgroup/hardware/fsys/mnttypes.h
2908c4
--- oold/agent/mibgroup/hardware/fsys/mnttypes.h	2017-10-30 14:50:41.741743139 +0100
2908c4
+++ nnew/agent/mibgroup/hardware/fsys/mnttypes.h	2017-10-31 09:01:40.462427047 +0100
2908c4
@@ -159,6 +159,9 @@
2908c4
 #ifndef MNTTYPE_APP
2908c4
 #define MNTTYPE_APP      "app"
2908c4
 #endif
2908c4
+#ifndef MNTTYPE_AUTOFS
2908c4
+#define MNTTYPE_AUTOFS   "autofs"
2908c4
+#endif
2908c4
 #ifndef MNTTYPE_DEVPTS
2908c4
 #define MNTTYPE_DEVPTS   "devpts"
2908c4
 #endif
2908c4
diff -urNp oold/agent/mibgroup/host/hr_filesys.c nnew/agent/mibgroup/host/hr_filesys.c
2908c4
--- oold/agent/mibgroup/host/hr_filesys.c	2012-10-10 00:28:58.000000000 +0200
2908c4
+++ nnew/agent/mibgroup/host/hr_filesys.c	2017-10-31 09:28:46.926093897 +0100
2908c4
@@ -839,6 +839,27 @@ Check_HR_FileSys_NFS (void)
2908c4
     return 0;		/* no NFS file system */
2908c4
 }
2908c4
 
2908c4
+/* This function checks whether current file system is an AutoFs
2908c4
+ * HRFS_entry must be valid prior to calling this function
2908c4
+ * return 1 if AutoFs, 0 otherwise
2908c4
+ */
2908c4
+int
2908c4
+Check_HR_FileSys_AutoFs (void)
2908c4
+{
2908c4
+#if HAVE_GETFSSTAT
2908c4
+    if ( HRFS_entry->HRFS_type != NULL && 
2908c4
+#if defined(MNTTYPE_AUTOFS)
2908c4
+        !strcmp( HRFS_entry->HRFS_type, MNTTYPE_AUTOFS)
2908c4
+#else
2908c4
+        !strcmp( HRFS_entry->HRFS_type, "autofs")
2908c4
+#endif
2908c4
+        )
2908c4
+#endif /* HAVE_GETFSSTAT */
2908c4
+        return 1;  /* AUTOFS */
2908c4
+
2908c4
+    return 0; /* no AUTOFS */
2908c4
+}
2908c4
+
2908c4
 void
2908c4
 End_HR_FileSys(void)
2908c4
 {
2908c4
diff -urNp oold/agent/mibgroup/host/hr_filesys.h nnew/agent/mibgroup/host/hr_filesys.h
2908c4
--- oold/agent/mibgroup/host/hr_filesys.h	2012-10-10 00:28:58.000000000 +0200
2908c4
+++ nnew/agent/mibgroup/host/hr_filesys.h	2017-10-31 09:29:44.541837515 +0100
2908c4
@@ -10,6 +10,7 @@ extern void     Init_HR_FileSys(void);
2908c4
 extern FindVarMethod var_hrfilesys;
2908c4
 extern int      Get_Next_HR_FileSys(void);
2908c4
 extern int      Check_HR_FileSys_NFS(void);
2908c4
+extern int      Check_HR_FileSys_AutoFs(void);
2908c4
 
2908c4
 extern int      Get_FSIndex(char *);
2908c4
 extern long     Get_FSSize(char *);     /* Temporary */
2908c4
diff -urNp oold/agent/mibgroup/host/hrh_filesys.c nnew/agent/mibgroup/host/hrh_filesys.c
2908c4
--- oold/agent/mibgroup/host/hrh_filesys.c	2012-10-10 00:28:58.000000000 +0200
2908c4
+++ nnew/agent/mibgroup/host/hrh_filesys.c	2017-10-31 09:37:36.787634605 +0100
2908c4
@@ -427,3 +427,9 @@ Check_HR_FileSys_NFS (void)
2908c4
 {
2908c4
     return (HRFS_entry->flags & NETSNMP_FS_FLAG_REMOTE) ? 1 : 0;
2908c4
 }
2908c4
+
2908c4
+int
2908c4
+Check_HR_FileSys_AutoFs (void)
2908c4
+{
2908c4
+    return (HRFS_entry->type == (NETSNMP_FS_TYPE_AUTOFS)) ? 1 : 0;
2908c4
+}
2908c4
diff -urNp oold/agent/mibgroup/host/hrh_filesys.h nnew/agent/mibgroup/host/hrh_filesys.h
2908c4
--- oold/agent/mibgroup/host/hrh_filesys.h	2012-10-10 00:28:58.000000000 +0200
2908c4
+++ nnew/agent/mibgroup/host/hrh_filesys.h	2017-10-31 09:38:00.644616572 +0100
2908c4
@@ -10,6 +10,7 @@ extern void     Init_HR_FileSys(void);
2908c4
 extern FindVarMethod var_hrhfilesys;
2908c4
 extern int      Get_Next_HR_FileSys(void);
2908c4
 extern int      Check_HR_FileSys_NFS(void);
2908c4
+extern int	Check_HR_FileSys_AutoFs(void);
2908c4
 
2908c4
 extern int      Get_FSIndex(char *);
2908c4
 extern long     Get_FSSize(char *);     /* Temporary */
2908c4
diff -urNp oold/agent/mibgroup/host/hrh_storage.c nnew/agent/mibgroup/host/hrh_storage.c
2908c4
--- oold/agent/mibgroup/host/hrh_storage.c	2017-10-30 14:50:41.766743146 +0100
2908c4
+++ nnew/agent/mibgroup/host/hrh_storage.c	2017-10-31 10:08:25.482217951 +0100
2908c4
@@ -368,9 +368,10 @@ really_try_next:
2908c4
         store_idx = name[ HRSTORE_ENTRY_NAME_LENGTH ];
2908c4
         if (HRFS_entry &&
2908c4
 	    store_idx > NETSNMP_MEM_TYPE_MAX &&
2908c4
-            netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
2908c4
+            ((netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
2908c4
                                    NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
2908c4
-            Check_HR_FileSys_NFS())
2908c4
+            Check_HR_FileSys_NFS()) ||
2908c4
+            Check_HR_FileSys_AutoFs()))
2908c4
             return NULL;
2908c4
         if (store_idx <= NETSNMP_MEM_TYPE_MAX ) {
2908c4
 	    mem = (netsnmp_memory_info*)ptr;
2908c4
@@ -509,7 +510,8 @@ Get_Next_HR_Store(void)
2908c4
 		if (HRS_index >= 0) {
2908c4
 			if (!(netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, 
2908c4
 							NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) && 
2908c4
-						Check_HR_FileSys_NFS())) {
2908c4
+						Check_HR_FileSys_NFS()) &&
2908c4
+                         !Check_HR_FileSys_AutoFs()) {
2908c4
 				return HRS_index + NETSNMP_MEM_TYPE_MAX;	
2908c4
 			}
2908c4
 		} else {
2908c4
diff -urNp oold/agent/mibgroup/host/hr_storage.c nnew/agent/mibgroup/host/hr_storage.c
2908c4
--- oold/agent/mibgroup/host/hr_storage.c	2012-10-10 00:28:58.000000000 +0200
2908c4
+++ nnew/agent/mibgroup/host/hr_storage.c	2017-10-31 10:11:41.161064352 +0100
2908c4
@@ -545,9 +545,10 @@ really_try_next:
2908c4
 
2908c4
         store_idx = name[ HRSTORE_ENTRY_NAME_LENGTH ];
2908c4
         if (store_idx > NETSNMP_MEM_TYPE_MAX ) {
2908c4
-            if ( netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
2908c4
+            if ( (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
2908c4
                                         NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
2908c4
-                 Check_HR_FileSys_NFS())
2908c4
+                 Check_HR_FileSys_NFS()) ||
2908c4
+                 Check_HR_FileSys_AutoFs())
2908c4
                 return NULL;  /* or goto try_next; */
2908c4
 	    if (HRFS_statfs(HRFS_entry->HRFS_mount, &stat_buf) < 0) {
2908c4
 		snmp_log_perror(HRFS_entry->HRFS_mount);
2908c4
@@ -688,7 +689,8 @@ Get_Next_HR_Store(void)
2908c4
 		if (HRS_index >= 0) {
2908c4
 			if (!(netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, 
2908c4
 							NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) && 
2908c4
-						Check_HR_FileSys_NFS())) {
2908c4
+						Check_HR_FileSys_NFS()) &&
2908c4
+                            !Check_HR_FileSys_AutoFs()) {
2908c4
 				return HRS_index + NETSNMP_MEM_TYPE_MAX;	
2908c4
 			}
2908c4
 		} else {
2908c4
diff -urNp oold/include/net-snmp/agent/hardware/fsys.h nnew/include/net-snmp/agent/hardware/fsys.h
2908c4
--- oold/include/net-snmp/agent/hardware/fsys.h	2012-10-10 00:28:58.000000000 +0200
2908c4
+++ nnew/include/net-snmp/agent/hardware/fsys.h	2017-10-31 10:14:59.560581680 +0100
2908c4
@@ -41,6 +41,7 @@ typedef struct netsnmp_fsys_info_s netsn
2908c4
 #define NETSNMP_FS_TYPE_SYSFS	   4 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT
2908c4
 #define NETSNMP_FS_TYPE_TMPFS	   5 | _NETSNMP_FS_TYPE_LOCAL
2908c4
 #define NETSNMP_FS_TYPE_USBFS	   6 | _NETSNMP_FS_TYPE_LOCAL
2908c4
+#define NETSNMP_FS_TYPE_AUTOFS     7 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT
2908c4
 
2908c4
 #define NETSNMP_FS_FLAG_ACTIVE   0x01
2908c4
 #define NETSNMP_FS_FLAG_REMOTE   0x02