PERFORCE change 80480 for review
soc-victor
soc-victor at FreeBSD.org
Mon Jul 18 21:57:00 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=80480
Change 80480 by soc-victor at soc-victor_82.76.158.176 on 2005/07/18 21:56:19
hrFSTable step #2: some optimizations and some improvements.
Affected files ...
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile#7 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c#2 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h#9 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c#6 edit
Differences ...
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile#7 (text+ko) ====
@@ -10,7 +10,7 @@
hostres_storage_tbl.c hostres_fs_tbl.c
WARNS?= 6
#Not having NDEBUG defined will enable assertions and a lot of output on stderr
-#CFLAGS+= -DNDEBUG
+CFLAGS+= -DNDEBUG
XSYM= host hrStorageOther hrStorageRam hrStorageVirtualMemory \
hrStorageFixedDisk hrStorageRemovableDisk hrStorageFloppyDisk \
hrStorageCompactDisc hrStorageRamDisk hrStorageFlashMemory \
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c#2 (text+ko) ====
@@ -75,12 +75,15 @@
return (NULL);
}
map->hrIndex = hrState_g.next_hrFS_index ++;
- strncpy(map->a_name, entry->mountPoint, 255);
+ map->a_name[sizeof(map->a_name)-1]='\0';
+ strncpy(map->a_name, entry->mountPoint, sizeof(map->a_name)-1);
map->entry_p = entry;
STAILQ_INSERT_TAIL(&hrState_g.fs_name_map, map, link);
- HR_DPRINTF((stderr, "%s added into hrFSMap at index=%d\n ",name, map->hrIndex));
+ HR_DPRINTF((stderr, "%s added into hrFSMap at index=%d\n ",
+ name, map->hrIndex));
} else {
- HR_DPRINTF((stderr, "%s exists in hrFSMap index=%d\n ",name, map->hrIndex));
+ HR_DPRINTF((stderr, "%s exists in hrFSMap index=%d\n ",
+ name, map->hrIndex));
}
entry->index = map->hrIndex;
@@ -158,20 +161,20 @@
}
+void
+FS_tbl_pre_refresh_v(void) {
+ struct hrFSTblEntry *entry = NULL;
-void refresh_hrFS_tbl_v(void) {
- struct hrFSTblEntry *entry = NULL, *entry_tmp = NULL;
-
- if ( this_tick <= hrState_g.hr_fs_tick) {
- HR_DPRINTF((stderr, "%s: no refresh needed\n ",__func__));
- return;
- }
-
/*mark each entry as missisng*/
TAILQ_FOREACH(entry, &hrState_g.hr_fs_tbl, link)
entry->flags &= ~HR_FS_FOUND;
- hrStorage_OS_get_fs_v();
+}
+
+
+void
+FS_tbl_post_refresh_v(void) {
+ struct hrFSTblEntry *entry = NULL, *entry_tmp = NULL;
/*
* Purge items items that disappeared
@@ -187,7 +190,17 @@
hrState_g.hr_fs_tick = this_tick;
hrState_g.hrFS_tbl_age = time(NULL);
+}
+
+void refresh_hrFS_tbl_v(void) {
+ if ( this_tick <= hrState_g.hr_fs_tick) {
+ HR_DPRINTF((stderr, "%s: no refresh needed\n ",__func__));
+ return;
+ }
+
+ refresh_hrStorage_tbl_v();
+
HR_DPRINTF((stderr, "%s: refresh DONE\n ",__func__));
}
@@ -292,17 +305,24 @@
entry->access = FS_READ_WRITE;
}
- entry->bootable = SNMP_FALSE; /*FIX ME*/
+ /*FIX ME - bootable fs ?! */
+ if( ( fs_p->f_flags & MNT_ROOTFS ) == MNT_ROOTFS ) {
+ entry->bootable = SNMP_TRUE;
+ } else {
+ entry->bootable = SNMP_FALSE;
+ }
entry->storageIndex = storage_idx;
memset(&entry->lastFullBackupDate[0], 0,
sizeof(entry->lastFullBackupDate)); /*Info not available*/
+
+
memset(&entry->lastPartialBackupDate[0], 0,
sizeof(entry->lastPartialBackupDate)); /*Info not available*/
+
-
return;
}
if ((entry = hrFSTblEntry_create(fs_p->f_mntonname)) != NULL) {
@@ -324,13 +344,21 @@
get_FS_type_v(fs_p, &entry->type);
- if( (fs_p->f_flags & MNT_RDONLY) == MNT_RDONLY ) {
+ if( ( fs_p->f_flags & MNT_RDONLY ) == MNT_RDONLY ) {
entry->access = FS_READ_ONLY;
} else {
entry->access = FS_READ_WRITE;
}
+
+ /*FIX ME - bootable fs ?! */
+ if( ( fs_p->f_flags & MNT_ROOTFS ) == MNT_ROOTFS ) {
+ entry->bootable = SNMP_TRUE;
+ } else {
+ entry->bootable = SNMP_FALSE;
+ }
+
- entry->bootable = SNMP_FALSE; /*FIX ME*/
+
entry->storageIndex = storage_idx;
@@ -339,7 +367,8 @@
memset(&entry->lastPartialBackupDate[0], 0,
sizeof(entry->lastPartialBackupDate)); /*Info not available*/
-
+
+
}
return;
}
@@ -418,10 +447,10 @@
value->v.integer = entry->storageIndex;
break;
case LEAF_hrFSLastFullBackupDate:
- ret = string_get(value, entry->lastFullBackupDate, 11);
+ ret = string_get(value, entry->lastFullBackupDate, 8);
break;
case LEAF_hrFSLastPartialBackupDate:
- ret = string_get(value, entry->lastPartialBackupDate, 11);
+ ret = string_get(value, entry->lastPartialBackupDate, 8);
break;
default:
assert(0);
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h#9 (text+ko) ====
@@ -136,7 +136,7 @@
*/
struct FSNameMapEntry {
int32_t hrIndex; /*used for hrFSTblEntry::index*/
- u_char a_name[255+1]; /*map key*/
+ u_char a_name[128]; /*map key*/
/*
* next may be NULL if the respective hrFSTblEntry
@@ -200,12 +200,6 @@
/*
- * Query the underlaying OS for the mounted file systems
- * anf fill in the respective lists (for hrStorageTable and for hrFSTable)
- */
-void hrStorage_OS_get_fs_v(void);
-
-/*
* Init the things for hrStorageTable.
*/
void init_hrStorage_tbl_v(void);
@@ -216,6 +210,11 @@
*/
void fini_hrStorage_tbl_v(void);
+/*
+ * Next macro represents the number of seconds
+ * between two consecutive queries to the OS for getting the new data
+ * for hrStorageTable
+ */
#define HR_STORAGE_TBL_REFRESH 7
/*
* Refresh routine for hrStorageTable.
@@ -224,12 +223,28 @@
void refresh_hrStorage_tbl_v(void);
+/*
+ * Because hrFSTable depends to hrStorageTable we are
+ * refreshing hrFSTable by refreshing hrStorageTable.
+ * When one entry "of type" fs from hrStorageTable is refreshed
+ * then the corresponding entry from hrFSTable is refreshed
+ * FS_tbl_pre_refresh_v() is called before refeshing fs part of hrStorageTable
+ */
+void
+FS_tbl_pre_refresh_v(void);
void
FS_tbl_process_statfs_entry_v(const struct statfs *fs_p, int32_t storage_idx);
/*
+ * FS_tbl_pre_refresh_v() is called after refeshing fs part of hrStorageTable
+ */
+void
+FS_tbl_post_refresh_v(void);
+
+
+/*
* Init the things for hrFSTable.
*/
void init_hrFS_tbl_v(void);
@@ -240,7 +255,12 @@
*/
void fini_hrFS_tbl_v(void);
-#define HR_FS_TBL_REFRESH 7
+/*
+ * Next macro represents the number of seconds
+ * between two consecutive queries to the OS for getting the new data
+ * for hrFSTable
+ */
+#define HR_FS_TBL_REFRESH HR_STORAGE_TBL_REFRESH
/*
* Refresh routine for hrFSTable.
* Usable for polling the system for any changes.
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c#6 (text+ko) ====
@@ -309,7 +309,11 @@
}
-
+/*
+ * Query the underlaying OS for the mounted file systems
+ * anf fill in the respective lists (for hrStorageTable and for hrFSTable)
+ */
+static
void hrStorage_OS_get_fs_v(void) {
int mounted_fs_count = 0;
int i = 0;
@@ -341,6 +345,9 @@
}
HR_DPRINTF((stderr, "%s: Got %d mounted FS\n ", __func__, mounted_fs_count));
+
+ FS_tbl_pre_refresh_v();
+
for(i = 0; i < mounted_fs_count; i++ ) {
@@ -405,6 +412,7 @@
}/*end for*/
+ FS_tbl_post_refresh_v();
}
More information about the p4-projects
mailing list