2 #include <netinet/in.h>
3 #include <sys/socket.h>
6 #include <portals/api-support.h> /* needed for ptpctl.h */
7 #include <portals/ptlctl.h> /* needed for parse_dump */
10 #include <liblustre.h>
11 #include <linux/obd.h>
12 #include <linux/obd_class.h>
13 #include <portals/procbridge.h>
15 struct ldlm_namespace;
19 extern int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, struct ldlm_res_id *res_id, int flags);
20 extern int ldlm_namespace_cleanup(struct ldlm_namespace *ns, int local_only);
21 extern int ldlm_replay_locks(struct obd_import *imp);
23 void *inter_module_get(char *arg)
25 if (!strcmp(arg, "tcpnal_ni"))
27 else if (!strcmp(arg, "ldlm_cli_cancel_unused"))
28 return ldlm_cli_cancel_unused;
29 else if (!strcmp(arg, "ldlm_namespace_cleanup"))
30 return ldlm_namespace_cleanup;
31 else if (!strcmp(arg, "ldlm_replay_locks"))
32 return ldlm_replay_locks;
37 ptl_handle_ni_t tcpnal_ni;
47 struct task_struct *current;
49 struct obd_class_user_state ocus;
51 /* portals interfaces */
53 kportal_get_ni (int nal)
59 kportal_put_ni (int nal)
64 void init_current(int argc, char **argv)
66 current = malloc(sizeof(*current));
67 strncpy(current->comm, argv[0], sizeof(current->comm));
68 current->pid = getpid();
72 ptl_nid_t tcpnal_mynid;
74 int init_lib_portals(struct pingcli_args *args)
79 tcpnal_mynid = args->mynid;
80 rc = PtlNIInit(procbridge_interface, 0, 0, 0, &tcpnal_ni);
82 CERROR("ksocknal: PtlNIInit failed: error %d\n", rc);
86 PtlNIDebug(tcpnal_ni, ~0);
90 extern int class_handle_ioctl(struct obd_class_user_state *ocus, unsigned int cmd, unsigned long arg);
93 int lib_ioctl(int dev_id, int opc, void * ptr)
96 if (dev_id == OBD_DEV_ID) {
97 struct obd_ioctl_data *ioc = ptr;
98 class_handle_ioctl(&ocus, opc, (unsigned long)ptr);
100 /* you _may_ need to call obd_ioctl_unpack or some
101 other verification function if you want to use ioc
103 printf ("processing ioctl cmd: %x buf len: %d\n",
109 int main(int argc, char **argv)
111 struct pingcli_args *args;
112 args= malloc(sizeof(*args));
114 printf("Malloc error\n");
118 args->mynid = ntohl (inet_addr (argv[1]));
119 INIT_LIST_HEAD(&ocus.ocus_conns);
121 init_current(argc, argv);
123 init_lib_portals(args);
131 parse_dump("/tmp/DUMP_FILE", lib_ioctl);