svn commit: r313450 - in stable/11: lib/libc/gen lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys
Slawa Olhovchenkov
slw at zxy.spb.ru
Wed Mar 22 12:40:58 UTC 2017
On Tue, Mar 21, 2017 at 08:05:31PM -0700, John Baldwin wrote:
> On Wednesday, March 15, 2017 05:30:53 PM Slawa Olhovchenkov wrote:
> > On Wed, Feb 08, 2017 at 06:32:35PM +0000, John Baldwin wrote:
> >
> > > Author: jhb
> > > Date: Wed Feb 8 18:32:35 2017
> > > New Revision: 313450
> > > URL: https://svnweb.freebsd.org/changeset/base/313450
> > >
> > > Log:
> > > MFC 310638:
> > > Rename the 'flags' argument to getfsstat() to 'mode' and validate it.
> > >
> > > This argument is not a bitmask of flags, but only accepts a single value.
> > > Fail with EINVAL if an invalid value is passed to 'flag'. Rename the
> > > 'flags' argument to getmntinfo(3) to 'mode' as well to match.
> > >
> > > This is a followup to r308088.
> >
> > > kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
> > > - size_t *countp, enum uio_seg bufseg, int flags)
> > > + size_t *countp, enum uio_seg bufseg, int mode)
> > > {
> > > struct mount *mp, *nmp;
> > > struct statfs *sfsp, *sp, *sptmp, *tofree;
> > > size_t count, maxcount;
> > > int error;
> > >
> > > + switch (mode) {
> > > + case MNT_WAIT:
> > > + case MNT_NOWAIT:
> > > + break;
> > > + default:
> > > + return (EINVAL);
> > > + }
> > > restart:
> >
> > This is break net-snmp UCD-SNMP-MIB::dskTable oid:
> >
> > 82434 snmpd CALL getfsstat(0,0,<invalid=0>)
> > 82434 snmpd RET getfsstat -1 errno 22 Invalid argument
> > 82434 snmpd CALL getfsstat(0,0xfffffffffffffe28,MNT_NOWAIT)
> > 82434 snmpd RET getfsstat -1 errno 22 Invalid argument
> > 82434 snmpd CALL write(0x9,0x800f162ea,0x1)
>
> This doesn't seem to match the code in the port:
>
> void
> Init_HR_FileSys(void)
> {
> #if HAVE_GETFSSTAT
> #if defined(HAVE_STATVFS) && defined(__NetBSD__)
> fscount = getvfsstat(NULL, 0, ST_NOWAIT);
> #else
> fscount = getfsstat(NULL, 0, MNT_NOWAIT);
> #endif
> if (fsstats)
> free((char *) fsstats);
> fsstats = NULL;
> fsstats = malloc(fscount * sizeof(*fsstats));
> #if defined(HAVE_STATVFS) && defined(__NetBSD__)
> getvfsstat(fsstats, fscount * sizeof(*fsstats), ST_NOWAIT);
> #else
> getfsstat(fsstats, fscount * sizeof(*fsstats), MNT_NOWAIT);
> #endif
> HRFS_index = 0;
>
> (Here it always calls with MNT_NOWAIT) This is for net-snmp 5.7.3,
> but it seems like that code hasn't changed in quite a while.
I see, strange. I am also use net-snmp 5.7.3 (net-snmp-5.7.3_12).
# dtrace -n 'syscall:freebsd:getfsstat:entry { printf("%s %p %d %d\n", execname, args[0], args[1], args[2]); stack(); ustack();}'
dtrace: description 'syscall:freebsd:getfsstat:entry ' matched 1 probe
CPU ID FUNCTION:NAME
22 43059 getfsstat:entry snmpd 0 0 0
kernel`amd64_syscall+0x36b
kernel`0xffffffff8071c84b
libc.so.7`getfsstat+0xa
libnetsnmpmibs.so.30.0.3`netsnmp_fsys_load+0x9
libnetsnmpagent.so.30.0.3`0x80083dfbf
libnetsnmpmibs.so.30.0.3`var_extensible_disk+0x38
libnetsnmpagent.so.30.0.3`netsnmp_old_api_helper+0x18f
libnetsnmpagent.so.30.0.3`netsnmp_call_handler+0x134
libnetsnmpagent.so.30.0.3`netsnmp_bulk_to_next_helper+0x1a1
libnetsnmpagent.so.30.0.3`netsnmp_call_handler+0x134
libnetsnmpagent.so.30.0.3`handle_var_requests+0x67
libnetsnmpagent.so.30.0.3`handle_getnext_loop+0x244
libnetsnmpagent.so.30.0.3`netsnmp_handle_request+0x186
libnetsnmpagent.so.30.0.3`handle_snmp_packet+0x140
libnetsnmp.so.30.0.3`0x800ece6c6
libnetsnmp.so.30.0.3`_sess_read+0x5b9
libnetsnmp.so.30.0.3`snmp_read2+0x3b
snmpd`0x404cab
snmpd`0x40317f
ld-elf.so.1`0x800629000
Ok, what is it:
/*
* Wrapper routine for re-loading filesystem statistics on demand
*/
int
netsnmp_fsys_load( netsnmp_cache *cache, void *data )
{
/* XXX - check cache timeliness */
return _fsys_load();
}
/*
* Architecture-independent processing of loading filesystem
statistics
*/
static int
_fsys_load( void )
{
netsnmp_fsys_arch_load();
/* XXX - update cache timestamp */
return 0;
}
agent/mibgroup/hardware/fsys/fsys_getfsstats.c:
void
netsnmp_fsys_arch_load( void )
{
int n, i;
struct NSFS_STATFS *stats;
netsnmp_fsys_info *entry;
/*
* Retrieve information about the currently mounted filesystems...
*/
n = NSFS_GETFSSTAT( NULL, 0, 0 );
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
More information about the svn-src-stable
mailing list