From owner-p4-projects@FreeBSD.ORG Mon Jul 18 21:57:00 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E474A16A420; Mon, 18 Jul 2005 21:56:59 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A673016A41C for ; Mon, 18 Jul 2005 21:56:59 +0000 (GMT) (envelope-from soc-victor@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5DAE243D48 for ; Mon, 18 Jul 2005 21:56:59 +0000 (GMT) (envelope-from soc-victor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j6ILux0S090170 for ; Mon, 18 Jul 2005 21:56:59 GMT (envelope-from soc-victor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j6ILuwGx090167 for perforce@freebsd.org; Mon, 18 Jul 2005 21:56:59 GMT (envelope-from soc-victor@freebsd.org) Date: Mon, 18 Jul 2005 21:56:59 GMT Message-Id: <200507182156.j6ILuwGx090167@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to soc-victor@freebsd.org using -f From: soc-victor To: Perforce Change Reviews Cc: Subject: PERFORCE change 80480 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2005 21:57:00 -0000 http://perforce.freebsd.org/chv.cgi?CH=80480 Change 80480 by soc-victor@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(); }