/** * export_create - create an in-core nfs_export record from an export entry * @xep: export entry to lookup * @canonical: if set, e_hostname is known to be canonical DNS name * * Returns a freshly instantiated export record, or NULL if * a problem occurred. */ nfs_export * export_create(struct exportent *xep, int canonical) { nfs_client *clp; nfs_export *exp; if (!(clp = client_lookup(xep->e_hostname, canonical))) { /* bad export entry; complaint already logged */ return NULL; } exp = (nfs_export *) xmalloc(sizeof(*exp)); export_init(exp, clp, xep); export_add(exp); return exp; }
/* name : prog_init * parameters : none, global parameters * description: some program initialisation * returns : 0 if ok, -1 on error * remarks : */ int prog_init ( void ) { /* daemon */ if ( (g_par.flags&PROBE_DAEMON) && (daemon ( 0, 0 ) < 0) ) { errorf ( "[%s] failed to run as daemon!\n\n", g_par.progname ); return -1; } #if 0 if ( chdir ( "/tmp" ) <0 ) mlogf( 0, "[%s] ERROR cannot change working dir: %s\n", g_par.progname, strerror(errno) ); #endif /* open logfile */ mlog_set_vlevel( g_par.vlevel ); if ( g_par.logfile ) (void) mlog_open( g_par.logfile, NULL ); mlogf( 1, "\nIPFIX probe (%s)\n\n", __DATE__ ); /* signal handler */ signal( SIGKILL, exit_func ); signal( SIGTERM, exit_func ); signal( SIGINT, exit_func ); /* init exporter */ if ( export_init( &g_probe ) <0 ) { return -1; } /* init pcap sniffing */ if ( input_init( &g_probe, g_par.flags ) <0 ) { return -1; } return 0; }