Cannot find module

Alexander Bubnov <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hello, all!

Can you please help me to find workaround?

First of all description. As far as I know net-snmp uses mibs/.index file to
remember MIB modules.

I deleted that index file and net-snmp could not load any mibs with errors:

Cannot find module (IP-MIB): At line 0 in (none)
parse-mibs:
Cannot find module (IF-MIB): At line 0 in (none)
parse-mibs:
Cannot find module (TCP-MIB): At line 0 in (none)
parse-mibs:
Cannot find module (UDP-MIB): At line 0 in (none)

...

I tried to find out a root cause in code of 5.4.2.1. It is in next lines:

function: add_mibdir():

...

  if ((dir = opendir(dirname))) {
  snprintf(tmpstr, sizeof(tmpstr), "%s/.index", dirname);
  tmpstr[ sizeof(tmpstr)-1 ] = 0;
  ip = fopen(tmpstr, "w");
  while ((file = readdir(dir))) {
  /*
  * Only parse file names that don't begin with a '.'
  * Also skip files ending in '~', or starting/ending
  * with '#' which are typically editor backup files.
  */
  if (file->d_name != NULL) {
  fname_len = strlen( file->d_name );
  if (fname_len > 0 && file->d_name[0] != '.'
  && file->d_name[0] != '#'
  && file->d_name[fname_len-1] != '#'
  && file->d_name[fname_len-1] != '~') {
  snprintf(tmpstr, sizeof(tmpstr), "%s/%s", dirname, file->d_name);
  tmpstr[ sizeof(tmpstr)-1 ] = 0;
  if ((dir2 = opendir(tmpstr))) {
  /*
  * file is a directory, don't read it
  */
  closedir(dir2);
  } else {
  if ( !add_mibfile( tmpstr, file->d_name, ip ))
  count++;
  }
  }

...

closer:

  if ((dir2 = opendir(tmpstr))) { <--- OPENDIR CAN OPEN A FILE EVEN IT IS
NOT A DIRECTORY
  /*
  * file is a directory, don't read it
  */
  closedir(dir2);


test.c:

#include<stdio.h>
#include <dirent.h>

int main(int argc,char**argv)
{
  DIR*d;
  if((d=opendir(argv[1])))
  {
  printf("OPEN: %s\n",argv[1]);
  if(readdir(d))
  {
  puts("readdir: NOT NULL");
  }
  else
  {
  perror("readdir NULL");
  }
  }
  else
  {
  perror("opendir");
  }
  return 0;

}

result under Debian:

bubnov /home/alek> uname -a
Linux bubnov 2.6.18-6-686 #1 SMP Mon Oct 13 16:13:09 UTC 2008 i686 GNU/Linux
bubnov /home/alek> :> 1
bubnov /home/alek> ./a.out 1
opendir: Not a directory

result under Suse (10.3 and 11 too):

linux-h110 /root# uname -a
Linux linux-h110 2.6.22.5-31-default #1 SMP 2007/09/21 22:29:00 UTC i686
i686 i386 GNU/Linux
linux-h110 /root# :> 1
linux-h110 /root# ./a.out 1
OPEN: 1
readdir NULL: Not a directory

Note: both of that OSes uses EXT3

Below the root cause of why I cannot add a new MIB module.

My question is: How to load a new module? What is workaround for that case?

One of possible solution is to edit .index file. Is it another?

And I have another question why net-snmp could create .index file at first
run?

-- 
/BR, Alexander

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.