diff options
author | hunt <hunt> | 2007-03-14 16:11:30 +0000 |
---|---|---|
committer | hunt <hunt> | 2007-03-14 16:11:30 +0000 |
commit | a846e9cd2b991b2b6f895b45f0a2af1ce2c994bc (patch) | |
tree | 9a68653421384b8d0fa0da1afb4689f763a70ca8 /runtime/staprun/ctl.c | |
parent | 5ba96b9022078048e9f916431d3b8792a9dc8615 (diff) | |
download | systemtap-steved-a846e9cd2b991b2b6f895b45f0a2af1ce2c994bc.tar.gz systemtap-steved-a846e9cd2b991b2b6f895b45f0a2af1ce2c994bc.tar.xz systemtap-steved-a846e9cd2b991b2b6f895b45f0a2af1ce2c994bc.zip |
2007-03-14 Martin Hunt <hunt@redhat.com>
* staprun.c: Renamed from stpd.c. Removed quiet and print_only
options. Added "-x" option as an alias for "-t". Removed "-m"
option. Updated arg processing to leave 4 slots for modoptions[].
Bump the priority of staprun.
* ctl.c: New. Transport control channel functions.
* relay.c: New. Relayfs control functions for new transport.
* relay_old.c: New. Relayfs control functions for older
versions of relayfs.
* mainloop.c: New. Staprun main loop.
* staprun.h: Renamed from librelay.h. Cleaned up.
* stap_merge.c: Renamed. Updated for modified save format.
Diffstat (limited to 'runtime/staprun/ctl.c')
-rw-r--r-- | runtime/staprun/ctl.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/runtime/staprun/ctl.c b/runtime/staprun/ctl.c new file mode 100644 index 00000000..9336631c --- /dev/null +++ b/runtime/staprun/ctl.c @@ -0,0 +1,40 @@ +/* -*- linux-c -*- + * + * ctl.c - staprun control channel + * + * 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. + * + * Copyright (C) 2007 Red Hat Inc. + */ + +#include "staprun.h" + +int init_ctl_channel(void) +{ + char buf[128]; + struct statfs st; + + if (statfs("/sys/kernel/debug", &st) == 0 && (int) st.f_type == (int) DEBUGFS_MAGIC) + sprintf (buf, "/sys/kernel/debug/systemtap_%d/cmd", getpid()); + else + sprintf (buf, "/proc/systemtap_%d/cmd", getpid()); + + dbug("Opening %s\n", buf); + control_channel = open(buf, O_RDWR); + if (control_channel < 0) { + fprintf(stderr, "ERROR: couldn't open control channel %s: errcode = %s\n", buf, strerror(errno)); + return -1; + } + return 0; +} + +void close_ctl_channel(void) +{ + if (control_channel > 0) { + close(control_channel); + control_channel = 0; + } +} |