#include "../lutil.h"
+
+#ifdef CRAY_XT3
+int _sysio_lustre_init(void)
+{
+ /*
+ * This is an aweful HACK. Basically the problem is on
+ * Catamount, the build system links in liblustre.a to
+ * all the test executables, and at this point its not
+ * clear how to modify the build system to prevent this
+ * from happening. So providing our own call to
+ * _sysio_lustre_init() that does nothing, prevents
+ * liblustre.a from initializing.
+ *
+ * Why is liblustre.a initializing a problem anyway. Well
+ * this main() in this module calls init_obdclass(), as
+ * well as the llite_lib.c's _sysio_lustre_init(). Two
+ * calls to init_obdclass() cause an assertion. Secondly
+ * it doesn't even logically make sense, this is module
+ * does not need lustre file system functionality, it's
+ * just the echo_tester.
+ *
+ */
+ /*lprintf("--> THIS OVERRIDES liblustre.a INITIALIZATION <--\n");*/
+ return 0;
+}
+#endif
+
+
+
extern int class_handle_ioctl(unsigned int cmd, unsigned long arg);
static int liblustre_ioctl(int dev_id, unsigned int opc, void *ptr)
static void usage(const char *s)
{
- printf("Usage: %s -s ost_host_name [-n ost_name]\n", s);
+ printf("Usage: %s -s ost_host_name [-n ost_name] [-x lctl_options ...]\n", s);
printf(" ost_host_name: the host name of echo server\n");
printf(" ost_name: ost name, default is \"obd1\"\n");
+ printf(" lctl_options: options to pass to lctl.\n");
+ printf(" (e.g. -x --device 1 test_getattr 10000 -5)\n");
}
extern int time_ptlwait1;
int main(int argc, char **argv)
{
int c, rc;
+ int xindex = -1; /* index of -x option */
- while ((c = getopt(argc, argv, "s:n:")) != -1) {
+ /* 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;
case 'n':
echo_server_ostname = optarg;
break;
+ case 'x':
+ xindex = optind-1;
+ break;
default:
usage(argv[0]);
return 1;
}
}
- if (optind != argc)
+ /*
+ * 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) {
liblustre_init_random();
- if (liblustre_init_current(argv[0]) ||
+ if (liblustre_init_current(argv[0]) ||
init_obdclass() || init_lib_portals() ||
ptlrpc_init() ||
mdc_init() ||
set_ioc_handler(liblustre_ioctl);
- rc = lctl_main(1, &argv[0]);
+
+ /*
+ * 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();