summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2009-02-24 11:54:16 -0600
committerDavid Smith <dsmith@redhat.com>2009-02-24 11:54:16 -0600
commit23c1c6557af76d506a28bcb3e864d3500e6dc565 (patch)
tree582ccd45b08f0d897daf8cea0e9e140227fc6470
parentcfba34fccd99924a47622c5082706867f0a34b12 (diff)
downloadsystemtap-steved-23c1c6557af76d506a28bcb3e864d3500e6dc565.tar.gz
systemtap-steved-23c1c6557af76d506a28bcb3e864d3500e6dc565.tar.xz
systemtap-steved-23c1c6557af76d506a28bcb3e864d3500e6dc565.zip
Major hacking to minimal config.
2009-02-24 David Smith <dsmith@redhat.com> * print.h: New file. * print.c: Includes new print.h file. * print_new.c (stp_print_flush): Commented out some code that needs replacing. * sym.c: Includes sym.h. * transport/debugfs.c: Includes transport.h. * transport/relayfs.c: Updated _stp_get_root_dir() call. * transport/transport.c: Ifdef'ed out most setup. * transport/transport.h: Ifdef'ed out all but basics. * transport/utt.c (utt_create_tree): Updated _stp_get_root_dir() call. * transport/utt.h: Commented out 'rchan' in struct utt_trace. (utt_reserve): Ifdef'ed out guts.
-rw-r--r--runtime/print.c1
-rw-r--r--runtime/print.h16
-rw-r--r--runtime/print_new.c5
-rw-r--r--runtime/sym.c1
-rw-r--r--runtime/transport/debugfs.c1
-rw-r--r--runtime/transport/relayfs.c2
-rw-r--r--runtime/transport/transport.c140
-rw-r--r--runtime/transport/transport.h36
-rw-r--r--runtime/transport/utt.c4
-rw-r--r--runtime/transport/utt.h9
10 files changed, 175 insertions, 40 deletions
diff --git a/runtime/print.c b/runtime/print.c
index 2c84d3c9..fa517cb5 100644
--- a/runtime/print.c
+++ b/runtime/print.c
@@ -14,6 +14,7 @@
#include "string.h"
#include "vsprintf.c"
+#include "print.h"
#include "transport/transport.c"
/** @file print.c
diff --git a/runtime/print.h b/runtime/print.h
new file mode 100644
index 00000000..d5c588a3
--- /dev/null
+++ b/runtime/print.h
@@ -0,0 +1,16 @@
+/* -*- linux-c -*-
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * This file is part of systemtap, and is free software. You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ */
+
+#ifndef _STP_PRINT_H_
+#define _STP_PRINT_H_
+
+static int _stp_print_init(void);
+static void _stp_print_cleanup(void);
+
+#endif /* _STP_PRINT_H_ */
diff --git a/runtime/print_new.c b/runtime/print_new.c
index fa7b4727..43e37822 100644
--- a/runtime/print_new.c
+++ b/runtime/print_new.c
@@ -28,8 +28,9 @@ void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb)
pb->len = 0;
- if (unlikely(!_stp_utt || _stp_utt->trace_state != Utt_trace_running))
- return;
+//DRS FIXME: this digs down too deep in internals
+// if (unlikely(!_stp_utt || _stp_utt->trace_state != Utt_trace_running))
+// return;
#ifdef STP_BULKMODE
{
diff --git a/runtime/sym.c b/runtime/sym.c
index 1d88a862..31700326 100644
--- a/runtime/sym.c
+++ b/runtime/sym.c
@@ -12,6 +12,7 @@
#ifndef _STP_SYM_C_
#define _STP_SYM_C_
+#include "sym.h"
#include "string.c"
/** @file sym.c
diff --git a/runtime/transport/debugfs.c b/runtime/transport/debugfs.c
index 85ee604d..7de57335 100644
--- a/runtime/transport/debugfs.c
+++ b/runtime/transport/debugfs.c
@@ -10,6 +10,7 @@
*/
#include <linux/debugfs.h>
+#include "transport.h"
#define STP_DEFAULT_BUFFERS 50
diff --git a/runtime/transport/relayfs.c b/runtime/transport/relayfs.c
index 6eefda8d..42be4283 100644
--- a/runtime/transport/relayfs.c
+++ b/runtime/transport/relayfs.c
@@ -86,7 +86,7 @@ static struct utt_trace *utt_trace_setup(struct utt_trace_setup *utts)
if (!utt)
return NULL;
- utt->utt_tree_root = _stp_get_root_dir(utts->root);
+ utt->utt_tree_root = _stp_get_root_dir();
if (!utt->utt_tree_root)
goto err;
diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c
index 7fcebd42..2d82270a 100644
--- a/runtime/transport/transport.c
+++ b/runtime/transport/transport.c
@@ -14,10 +14,21 @@
#ifndef _TRANSPORT_TRANSPORT_C_
#define _TRANSPORT_TRANSPORT_C_
-#include <linux/delay.h>
-#include <linux/namei.h>
#include "transport.h"
-#include "time.c"
+struct utt_trace {
+ int dummy;
+};
+static struct utt_trace *_stp_utt = NULL;
+static int _stp_ctl_write(int type, void *data, unsigned len) {
+ return 0;
+}
+
+static int _stp_exit_flag = 0;
+
+#include <linux/debugfs.h>
+#include <linux/namei.h>
+#if 0
+#include <linux/delay.h>
#include "../mempool.c"
#include "symbols.c"
@@ -37,10 +48,15 @@ static int _stp_exit_flag = 0;
#endif
#include "control.c"
+#endif /* if 0 */
+static unsigned _stp_nsubbufs = 8;
+static unsigned _stp_subbuf_size = 65536*4;
+
/* module parameters */
static int _stp_bufsize;
module_param(_stp_bufsize, int, 0);
MODULE_PARM_DESC(_stp_bufsize, "buffer size");
+#if 0
/* forward declarations */
static void probe_exit(void);
@@ -173,6 +189,7 @@ static void _stp_work_queue(void *data)
if (likely(_stp_attached))
queue_delayed_work(_stp_wq, &_stp_work, STP_WORK_TIMER);
}
+#endif /* #if 0 */
/**
* _stp_transport_close - close ctl and relayfs channels
@@ -180,9 +197,11 @@ static void _stp_work_queue(void *data)
* This is called automatically when the module is unloaded.
*
*/
-static void _stp_transport_close()
+static void _stp_transport_close(void)
{
- dbug_trans(1, "%d: ************** transport_close *************\n", current->pid);
+ dbug_trans(1, "%d: ************** transport_close *************\n",
+ current->pid);
+#if 0
_stp_cleanup_and_exit(0);
destroy_workqueue(_stp_wq);
_stp_unregister_ctl_channel();
@@ -190,9 +209,13 @@ static void _stp_transport_close()
utt_trace_remove(_stp_utt);
_stp_print_cleanup(); /* free print buffers */
_stp_mem_debug_done();
+#endif
+ _stp_transport_fs_close();
+
dbug_trans(1, "---- CLOSED ----\n");
}
+#if 0
static struct utt_trace *_stp_utt_open(void)
{
struct utt_trace_setup utts;
@@ -209,6 +232,7 @@ static struct utt_trace *_stp_utt_open(void)
return utt_trace_setup(&utts);
}
+#endif /* #if 0 */
/**
* _stp_transport_init() is called from the module initialization.
@@ -217,7 +241,6 @@ static struct utt_trace *_stp_utt_open(void)
static int _stp_transport_init(void)
{
dbug_trans(1, "transport_init\n");
- _stp_init_pid = current->pid;
#ifdef STAPCONF_TASK_UID
_stp_uid = current->uid;
_stp_gid = current->gid;
@@ -226,6 +249,8 @@ static int _stp_transport_init(void)
_stp_gid = current_gid();
#endif
+// DRS: is RELAY_GUEST/RELAY_HOST documented? does it work? are there
+// test cases?
#ifdef RELAY_GUEST
/* Guest scripts use relay only for reporting warnings and errors */
_stp_subbuf_size = 65536;
@@ -243,6 +268,10 @@ static int _stp_transport_init(void)
dbug_trans(1, "Using %d subbufs of size %d\n", _stp_nsubbufs, _stp_subbuf_size);
}
+ if (_stp_transport_fs_init(THIS_MODULE->name))
+ return -1;
+
+#if 0
#if !defined (STP_OLD_TRANSPORT) || defined (STP_BULKMODE)
/* open utt (relayfs) channel to send data to userspace */
_stp_utt = _stp_utt_open();
@@ -253,11 +282,13 @@ static int _stp_transport_init(void)
/* create control channel */
if (_stp_register_ctl_channel() < 0)
goto err1;
+#endif /* #if 0 */
/* create print buffers */
if (_stp_print_init() < 0)
goto err2;
+#if 0
/* start transport */
utt_trace_startstop(_stp_utt, 1, &utt_seq);
@@ -270,16 +301,19 @@ static int _stp_transport_init(void)
/* Signal stapio to send us STP_START back (XXX: ?!?!?!). */
_stp_ctl_send(STP_TRANSPORT, NULL, 0);
+#endif /* #if 0 */
return 0;
err3:
_stp_print_cleanup();
err2:
+#if 0
_stp_unregister_ctl_channel();
err1:
if (_stp_utt)
utt_trace_remove(_stp_utt);
+#endif /* #if 0 */
err0:
return -1;
}
@@ -331,51 +365,109 @@ static void _stp_unlock_transport_dir(void)
}
}
-/* _stp_get_root_dir(name) - creates root directory 'name' or */
-/* returns a pointer to it if it already exists. Used in */
-/* utt.c and relayfs.c. Will not be necessary if utt is included */
-/* in the kernel. */
+static struct dentry *__stp_root_dir = NULL;
-static struct dentry *_stp_get_root_dir(const char *name)
+/* _stp_get_root_dir() - creates root directory or returns
+ * a pointer to it if it already exists. */
+
+static struct dentry *_stp_get_root_dir(void)
{
struct file_system_type *fs;
- struct dentry *root;
struct super_block *sb;
+ const char *name = "systemtap";
+
+ if (__stp_root_dir != NULL) {
+ return __stp_root_dir;
+ }
#ifdef STP_OLD_TRANSPORT
fs = get_fs_type("relayfs");
+ if (!fs) {
+ errk("Couldn't find relayfs filesystem.\n");
+ return NULL;
+ }
#else
fs = get_fs_type("debugfs");
-#endif
if (!fs) {
- errk("Couldn't find debugfs or relayfs filesystem.\n");
+ errk("Couldn't find debugfs filesystem.\n");
return NULL;
}
+#endif
if (!_stp_lock_transport_dir()) {
errk("Couldn't lock transport directory.\n");
return NULL;
}
#ifdef STP_OLD_TRANSPORT
- root = relayfs_create_dir(name, NULL);
+ __stp_root_dir = relayfs_create_dir(name, NULL);
#else
- root = debugfs_create_dir(name, NULL);
+ __stp_root_dir = debugfs_create_dir(name, NULL);
#endif
- if (!root) {
- /* couldn't create it because it is already there, so find it. */
- sb = list_entry(fs->fs_supers.next, struct super_block, s_instances);
+ if (!__stp_root_dir) {
+ /* Couldn't create it because it is already there, so
+ * find it. */
+ sb = list_entry(fs->fs_supers.next, struct super_block,
+ s_instances);
_stp_lock_inode(sb->s_root->d_inode);
- root = lookup_one_len(name, sb->s_root, strlen(name));
+ __stp_root_dir = lookup_one_len(name, sb->s_root,
+ strlen(name));
_stp_unlock_inode(sb->s_root->d_inode);
- if (!IS_ERR(root))
- dput(root);
+ if (!IS_ERR(__stp_root_dir))
+ dput(__stp_root_dir);
else {
- root = NULL;
+ __stp_root_dir = NULL;
errk("Could not create or find transport directory.\n");
}
}
_stp_unlock_transport_dir();
- return root;
+ return __stp_root_dir;
+}
+
+static void _stp_remove_root_dir(void)
+{
+ if (__stp_root_dir) {
+ if (!_stp_lock_transport_dir()) {
+ errk("Unable to lock transport directory.\n");
+ return;
+ }
+ if (simple_empty(__stp_root_dir))
+ debugfs_remove(__stp_root_dir);
+ _stp_unlock_transport_dir();
+ __stp_root_dir = NULL;
+ }
}
+static struct dentry *__stp_module_dir = NULL;
+
+static int _stp_transport_fs_init(const char *module_name)
+{
+ struct dentry *root_dir;
+
+ if (module_name == NULL)
+ return -1;
+
+ root_dir = _stp_get_root_dir();
+ if (root_dir == NULL)
+ return -1;
+
+ __stp_module_dir = debugfs_create_dir(module_name, root_dir);
+ if (!__stp_module_dir) {
+ _stp_remove_root_dir();
+ return -1;
+ }
+ return 0;
+}
+
+static void _stp_transport_fs_close(void)
+{
+ dbug_trans(1, "stp_transport_fs_close\n");
+ if (__stp_module_dir) {
+ debugfs_remove(__stp_module_dir);
+ __stp_module_dir = NULL;
+ }
+
+ _stp_remove_root_dir();
+}
+
+
#endif /* _TRANSPORT_C_ */
diff --git a/runtime/transport/transport.h b/runtime/transport/transport.h
index 7d249c45..c6d850ef 100644
--- a/runtime/transport/transport.h
+++ b/runtime/transport/transport.h
@@ -11,6 +11,20 @@
/* amount of data a print can send. */
#define STP_BUFFER_SIZE 8192
+struct utt_trace;
+
+static int _stp_ctl_write(int type, void *data, unsigned len);
+
+static int _stp_transport_init(void);
+static void _stp_transport_close(void);
+
+static inline void *utt_reserve(struct utt_trace *utt, size_t length)
+{
+ return NULL;
+}
+
+
+#if 0
/* STP_CTL_BUFFER_SIZE is the maximum size of a message */
/* exchanged on the control channel. */
#ifdef STP_OLD_TRANSPORT
@@ -23,27 +37,33 @@
/* how often the work queue wakes up and checks buffers */
#define STP_WORK_TIMER (HZ/100)
-static unsigned _stp_nsubbufs = 8;
-static unsigned _stp_subbuf_size = 65536*4;
+#endif /* #if 0 */
+static unsigned _stp_nsubbufs;
+static unsigned _stp_subbuf_size;
static int _stp_transport_init(void);
static void _stp_transport_close(void);
-static void _stp_warn (const char *fmt, ...);
-static int _stp_print_init(void);
-static void _stp_print_cleanup(void);
-static struct dentry *_stp_get_root_dir(const char *name);
-
static int _stp_lock_transport_dir(void);
static void _stp_unlock_transport_dir(void);
+static struct dentry *_stp_get_root_dir(void);
+
+static int _stp_transport_fs_init(const char *module_name);
+static void _stp_transport_fs_close(void);
+
+#if 0
+static void _stp_warn (const char *fmt, ...);
+
static void _stp_attach(void);
static void _stp_detach(void);
static void _stp_handle_start(struct _stp_msg_start *st);
static int _stp_pid = 0;
+#endif
static uid_t _stp_uid = 0;
static gid_t _stp_gid = 0;
-static pid_t _stp_init_pid = 0;
+#if 0
static int _stp_attached = 0;
+#endif
#endif /* _TRANSPORT_TRANSPORT_H_ */
diff --git a/runtime/transport/utt.c b/runtime/transport/utt.c
index 915662b2..2dd303a5 100644
--- a/runtime/transport/utt.c
+++ b/runtime/transport/utt.c
@@ -26,7 +26,6 @@
#include <linux/percpu.h>
#include <linux/init.h>
#include <linux/debugfs.h>
-#include <linux/relay.h>
#include <linux/mm.h>
#include "utt.h"
@@ -157,7 +156,7 @@ static struct dentry *utt_create_tree(struct utt_trace *utt, const char *root, c
return NULL;
if (!utt->utt_tree_root) {
- utt->utt_tree_root = _stp_get_root_dir(root);
+ utt->utt_tree_root = _stp_get_root_dir();
if (!utt->utt_tree_root)
goto err;
}
@@ -169,7 +168,6 @@ err:
return dir;
}
-
static void utt_trace_cleanup(struct utt_trace *utt)
{
if (utt == NULL)
diff --git a/runtime/transport/utt.h b/runtime/transport/utt.h
index 40e54919..0a0944c0 100644
--- a/runtime/transport/utt.h
+++ b/runtime/transport/utt.h
@@ -9,11 +9,11 @@ enum {
struct utt_trace {
int trace_state;
- struct rchan *rchan;
+// struct rchan *rchan;
struct dentry *dir; /* systemtap/module_name */
struct dentry *dropped_file;
atomic_t dropped;
- struct dentry *utt_tree_root; /* systemtap */
+ struct dentry *utt_tree_root; /* systemtap */
void *private_data;
atomic_t wakeup;
struct timer_list timer;
@@ -41,6 +41,7 @@ struct utt_trace_setup {
static struct utt_trace *utt_trace_setup(struct utt_trace_setup *utts);
+
static int utt_trace_startstop(struct utt_trace *utt, int start,
unsigned int *trace_seq);
static void utt_trace_cleanup(struct utt_trace *utt);
@@ -60,6 +61,7 @@ static size_t utt_switch_subbuf(struct utt_trace *utt, struct rchan_buf *buf,
*/
static inline void *utt_reserve(struct utt_trace *utt, size_t length)
{
+#if 0
void *reserved;
struct rchan_buf *buf = utt->rchan->buf[smp_processor_id()];
@@ -72,6 +74,9 @@ static inline void *utt_reserve(struct utt_trace *utt, size_t length)
buf->offset += length;
return reserved;
+#else
+ return NULL;
+#endif
}
#endif