1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
5 * Author: Phil Schwan <phil@clusterfs.com>
7 * This file is part of Lustre, http://www.lustre.org.
9 * Lustre is free software; you can redistribute it and/or
10 * modify it under the terms of version 2 of the GNU General Public
11 * License as published by the Free Software Foundation.
13 * Lustre is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Lustre; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 # define EXPORT_SYMTAB
27 #include <linux/config.h>
28 #include <linux/module.h>
29 #include <linux/kmod.h>
30 #include <linux/notifier.h>
31 #include <linux/kernel.h>
33 #include <linux/string.h>
34 #include <linux/stat.h>
35 #include <linux/errno.h>
36 #include <linux/smp_lock.h>
37 #include <linux/unistd.h>
38 #include <linux/interrupt.h>
39 #include <asm/system.h>
40 #include <asm/uaccess.h>
41 #include <linux/completion.h>
44 #include <linux/stat.h>
45 #include <asm/uaccess.h>
46 #include <asm/segment.h>
47 #include <linux/miscdevice.h>
48 #include <linux/version.h>
50 # define DEBUG_SUBSYSTEM S_PORTALS
52 #include <libcfs/kp30.h>
53 #include <libcfs/linux/portals_compat25.h>
54 #include <libcfs/libcfs.h>
56 #include "tracefile.h"
58 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
59 #include <linux/kallsyms.h>
62 char portals_upcall[1024] = "/usr/lib/lustre/portals_upcall";
64 void portals_run_upcall(char **argv)
70 "PATH=/sbin:/bin:/usr/sbin:/usr/bin",
74 argv[0] = portals_upcall;
76 while (argv[argc] != NULL)
81 rc = USERMODEHELPER(argv[0], argv, envp);
83 CERROR("Error %d invoking portals upcall %s %s%s%s%s%s%s%s%s; "
84 "check /proc/sys/portals/upcall\n",
86 argc < 3 ? "" : ",", argc < 3 ? "" : argv[2],
87 argc < 4 ? "" : ",", argc < 4 ? "" : argv[3],
88 argc < 5 ? "" : ",", argc < 5 ? "" : argv[4],
89 argc < 6 ? "" : ",...");
91 CERROR("Invoked portals upcall %s %s%s%s%s%s%s%s%s\n",
93 argc < 3 ? "" : ",", argc < 3 ? "" : argv[2],
94 argc < 4 ? "" : ",", argc < 4 ? "" : argv[3],
95 argc < 5 ? "" : ",", argc < 5 ? "" : argv[4],
96 argc < 6 ? "" : ",...");
100 void portals_run_lbug_upcall(char *file, const char *fn, const int line)
106 snprintf (buf, sizeof buf, "%d", line);
110 argv[3] = (char *)fn;
114 portals_run_upcall (argv);
119 void portals_debug_dumpstack(struct task_struct *tsk)
121 #if defined(__arch_um__)
123 CWARN("stack dump for pid %d (%d) requested; wake up gdb.\n",
124 tsk->pid, UML_PID(tsk));
126 #elif defined(HAVE_SHOW_TASK)
127 /* this is exported by lustre kernel version 42 */
128 extern void show_task(struct task_struct *);
132 CWARN("showing stack for process %d\n", tsk->pid);
135 CWARN("can't show stack: kernel doesn't export show_task\n");
139 cfs_task_t *portals_current(void)
141 CWARN("current task struct is %p\n", current);
144 EXPORT_SYMBOL(portals_debug_dumpstack);
145 EXPORT_SYMBOL(portals_current);
147 #endif /* __KERNEL__ */
149 EXPORT_SYMBOL(portals_run_upcall);
150 EXPORT_SYMBOL(portals_run_lbug_upcall);