/* * early liblustre init * called from C startup in catamount apps, before main() * * The following is a skeleton sysio startup sequence, * as implemented in C startup (skipping error handling). * In this framework none of these calls need be made here * or in the apps themselves. The NAMESPACE_STRING specifying * the initial set of fs ops (creates, mounts, etc.) is passed * as an environment variable. * * _sysio_init(); * _sysio_incore_init(); * _sysio_native_init(); * _sysio_lustre_init(); * _sysio_boot(NAMESPACE_STRING); * * the name _sysio_lustre_init() follows the naming convention * established in other fs drivers from libsysio: * _sysio_incore_init(), _sysio_native_init() * * _sysio_lustre_init() must be called before _sysio_boot() * to enable libsysio's processing of namespace init strings containing * lustre filesystem operations */ int _sysio_lustre_init(void) { int err; char *envstr; #ifndef INIT_SYSIO extern void __liblustre_cleanup_(void); #endif liblustre_init_random(); err = lllib_init(); if (err) { perror("init llite driver"); return err; } envstr = getenv("LIBLUSTRE_TIMEOUT"); if (envstr != NULL) { obd_timeout = (unsigned int)strtol(envstr, NULL, 0); printf("LibLustre: obd timeout=%u seconds\n", obd_timeout); } /* debug peer on timeout? */ envstr = getenv("LIBLUSTRE_DEBUG_PEER_ON_TIMEOUT"); if (envstr != NULL) { obd_debug_peer_on_timeout = (unsigned int)strtol(envstr, NULL, 0); printf("LibLustre: debug peer on timeout=%d\n", obd_debug_peer_on_timeout ? 0 : 1); } #ifndef INIT_SYSIO (void)atexit(__liblustre_cleanup_); #endif return err; }
int main(int argc, char **argv) { int c, rc; int xindex = -1; /* index of -x option */ /* loop until all options are consumed or we hit * a -x option */ while ((c = getopt(argc, argv, "s:n:x:")) != -1 && xindex == -1) { switch (c) { case 's': echo_server_nid = optarg; break; case 'n': echo_server_ostname = optarg; break; case 'x': xindex = optind-1; break; default: usage(argv[0]); return 1; } } /* * Only warn with usage() if the -x option isn't specificed * because when using -x this check is not valid. */ if (optind != argc && xindex == -1) usage(argv[0]); if (!echo_server_nid) { usage(argv[0]); return 1; } libcfs_debug = 0; libcfs_subsystem_debug = 0; liblustre_init_random(); if (liblustre_init_current(argv[0]) || init_obdclass() || init_lib_portals() || ptlrpc_init() || lmv_init() || mdc_init() || lov_init() || osc_init() || echo_client_init()) { printf("error\n"); return 1; } rc = connect_echo_client(); if (rc) return rc; set_ioc_handler(liblustre_ioctl); /* * If the -x option is not specified pass no args to lctl * otherwise pass all the options after the "-x" to lctl * * HACK: in the case when the -x option is specified * lctl sees argv[0] == "-x" and not the real argv[0] seen * in this function. If that is a problem, a mapping will * have to be done to fix that. However for normal functioning * it seems to be irrelavant */ if( xindex == -1 ) rc = lctl_main(1, &argv[0]); else rc = lctl_main(argc-xindex+1, &argv[xindex-1]); rc |= disconnect_echo_client(); return rc; }