summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorhunt <hunt>2006-09-13 22:46:09 +0000
committerhunt <hunt>2006-09-13 22:46:09 +0000
commit3f4deba001e76e2af20b9b6f9a1522c309c67fda (patch)
tree4788a64310c5120bb25f5a0816d3d9c36e2cdb22 /runtime
parentae966e5f2df152603e36a1b96a0b5d05e89afdbc (diff)
downloadsystemtap-steved-3f4deba001e76e2af20b9b6f9a1522c309c67fda.tar.gz
systemtap-steved-3f4deba001e76e2af20b9b6f9a1522c309c67fda.tar.xz
systemtap-steved-3f4deba001e76e2af20b9b6f9a1522c309c67fda.zip
2006-09-13 Martin Hunt <hunt@redhat.com>
* librelay.c (init_relayfs): Exec stp_check and find relay_filebase. * librelay.h (stp_main_loop): Fix declaration of init_stp(). * stpd.c (usage): Remove "-r" option. (main): Don't find stpd_filebase and don't send it to init_stp().
Diffstat (limited to 'runtime')
-rw-r--r--runtime/stpd/ChangeLog11
-rw-r--r--runtime/stpd/librelay.c50
-rw-r--r--runtime/stpd/librelay.h2
-rw-r--r--runtime/stpd/stpd.c55
4 files changed, 59 insertions, 59 deletions
diff --git a/runtime/stpd/ChangeLog b/runtime/stpd/ChangeLog
index 7dd75470..370d7671 100644
--- a/runtime/stpd/ChangeLog
+++ b/runtime/stpd/ChangeLog
@@ -1,3 +1,14 @@
+2006-09-13 Martin Hunt <hunt@redhat.com>
+
+ * librelay.c (init_relayfs): Exec stp_check and find
+ relay_filebase.
+
+ * librelay.h (stp_main_loop): Fix declaration of init_stp().
+
+ * stpd.c (usage): Remove "-r" option.
+ (main): Don't find stpd_filebase and don't send it to init_stp().
+
+
2006-08-02 Tom Zanussi <zanussi@us.ibm.com>
* stpd.c (main): Use modname rather than driver_pid in
diff --git a/runtime/stpd/librelay.c b/runtime/stpd/librelay.c
index 6636d1eb..e348928d 100644
--- a/runtime/stpd/librelay.c
+++ b/runtime/stpd/librelay.c
@@ -38,8 +38,17 @@
#include <sys/socket.h>
#include <linux/types.h>
#include <linux/limits.h>
+#include <sys/wait.h>
+#include <sys/statfs.h>
#include "librelay.h"
+/* stp_check script */
+#ifdef PKGLIBDIR
+char *stp_check=PKGLIBDIR "/stp_check";
+#else
+char *stp_check="stp_check";
+#endif
+
/* maximum number of CPUs we can handle - change if more */
#define NR_CPUS 256
@@ -375,6 +384,7 @@ static void read_last_buffers(void)
}
}
+#define RELAYFS_MAGIC 0xF0B4A981
/**
* init_relayfs - create files and threads for relayfs processing
*
@@ -382,9 +392,41 @@ static void read_last_buffers(void)
*/
int init_relayfs(void)
{
- int i, j;
+ int i, j, wstat;
+ pid_t pid;
+ struct statfs st;
+
dbug("initializing relayfs\n");
+ /* first run the _stp_check script */
+ if ((pid = fork()) < 0) {
+ perror ("fork of stp_check failed.");
+ exit(-1);
+ } else if (pid == 0) {
+ if (execlp(stp_check, stp_check, NULL) < 0)
+ _exit (-1);
+ }
+ if (waitpid(pid, &wstat, 0) < 0) {
+ perror("waitpid");
+ exit(-1);
+ }
+ if (WIFEXITED(wstat) && WEXITSTATUS(wstat)) {
+ perror (stp_check);
+ fprintf(stderr, "Could not execute %s\n", stp_check);
+ exit(1);
+ }
+
+ if (statfs("/mnt/relay", &st) == 0 && (int) st.f_type == (int) RELAYFS_MAGIC)
+ sprintf(params.relay_filebase, "/mnt/relay/%d/cpu", getpid());
+ else {
+ char *ptr;
+ sprintf(params.relay_filebase, "/proc/systemtap/%s", modname);
+ ptr = index(params.relay_filebase,'.');
+ if (ptr)
+ *ptr = 0;
+ strcat(params.relay_filebase, "/cpu");
+ }
+
for (i = 0; i < ncpus; i++) {
if (open_relayfs_files(i, params.relay_filebase) < 0) {
fprintf(stderr, "ERROR: couldn't open relayfs files, cpu = %d\n", i);
@@ -468,12 +510,11 @@ static void cleanup_and_exit (int);
/**
* init_stp - initialize the app
- * @relay_filebase: full path of base name of the per-cpu relayfs files
* @print_summary: boolean, print summary or not at end of run
*
* Returns 0 on success, negative otherwise.
*/
-int init_stp(const char *relay_filebase, int print_summary)
+int init_stp(int print_summary)
{
char buf[1024];
struct transport_info ti;
@@ -505,9 +546,6 @@ int init_stp(const char *relay_filebase, int print_summary)
fprintf(stderr, "ERROR, couldn't insmod probe module %s\n", modpath);
return -1;
}
-
- if (relay_filebase)
- strcpy(params.relay_filebase, relay_filebase);
sprintf (proc_filebase, "/proc/systemtap/%s", modname);
char *ptr = index(proc_filebase,'.');
diff --git a/runtime/stpd/librelay.h b/runtime/stpd/librelay.h
index 289952d7..0a6a1920 100644
--- a/runtime/stpd/librelay.h
+++ b/runtime/stpd/librelay.h
@@ -9,6 +9,6 @@
/*
* stp external API functions
*/
-extern int init_stp(const char *relay_filebase, int print_summary);
+extern int init_stp(int print_summary);
extern int stp_main_loop(void);
extern int send_request(int type, void *data, int len);
diff --git a/runtime/stpd/stpd.c b/runtime/stpd/stpd.c
index 3158e5ed..96710b08 100644
--- a/runtime/stpd/stpd.c
+++ b/runtime/stpd/stpd.c
@@ -24,8 +24,6 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <sys/wait.h>
-#include <sys/statfs.h>
#include <pwd.h>
#include "librelay.h"
@@ -37,7 +35,6 @@ int print_only = 0;
int quiet = 0;
int merge = 1;
int verbose = 0;
-int enable_relayfs = 1;
int target_pid = 0;
int driver_pid = 0;
unsigned int buffer_size = 0;
@@ -51,17 +48,6 @@ char *username = NULL;
uid_t cmd_uid;
gid_t cmd_gid;
- /* relayfs base file name */
-static char stpd_filebase[1024];
-#define RELAYFS_MAGIC 0xF0B4A981
-
-/* stp_check script */
-#ifdef PKGLIBDIR
-char *stp_check=PKGLIBDIR "/stp_check";
-#else
-char *stp_check="stp_check";
-#endif
-
static void usage(char *prog)
{
fprintf(stderr, "\n%s [-m] [-p] [-q] [-r] [-c cmd ] [-t pid]\n"
@@ -69,7 +55,6 @@ static void usage(char *prog)
fprintf(stderr, "-m Don't merge per-cpu files.\n");
fprintf(stderr, "-p Print only. Don't log to files.\n");
fprintf(stderr, "-q Quiet. Don't display trace to stdout.\n");
- fprintf(stderr, "-r Disable running stp_check and loading relayfs module.\n");
fprintf(stderr, "-c cmd. Command \'cmd\' will be run and stpd will exit when it does.\n");
fprintf(stderr, " _stp_target will contain the pid for the command.\n");
fprintf(stderr, "-t pid. Sets _stp_target to pid.\n");
@@ -85,9 +70,7 @@ static void usage(char *prog)
int main(int argc, char **argv)
{
- int c, status;
- pid_t pid;
- struct statfs st;
+ int c;
while ((c = getopt(argc, argv, "mpqrb:n:t:d:c:vo:u:")) != EOF)
{
@@ -105,7 +88,7 @@ int main(int argc, char **argv)
verbose = 1;
break;
case 'r':
- enable_relayfs = 0;
+ fprintf(stderr, "Warning: -r option deprecated. Ignoring...\n");
break;
case 'b':
{
@@ -188,39 +171,7 @@ int main(int argc, char **argv)
cmd_gid = getgid();
}
- if (enable_relayfs) {
- /* now run the _stp_check script */
- if ((pid = fork()) < 0) {
- perror ("fork of stp_check failed.");
- exit(-1);
- } else if (pid == 0) {
- if (execlp(stp_check, stp_check, NULL) < 0)
- _exit (-1);
- }
- if (waitpid(pid, &status, 0) < 0) {
- perror("waitpid");
- exit(-1);
- }
- if (WIFEXITED(status) && WEXITSTATUS(status)) {
- perror (stp_check);
- fprintf(stderr, "Could not execute %s\n", stp_check);
- exit(1);
- }
- }
-
- if (statfs("/mnt/relay", &st) == 0
- && (int) st.f_type == (int) RELAYFS_MAGIC)
- sprintf(stpd_filebase, "/mnt/relay/%d/cpu", getpid());
- else {
- char *ptr;
- sprintf(stpd_filebase, "/proc/systemtap/%s", modname);
- ptr = index(stpd_filebase,'.');
- if (ptr)
- *ptr = 0;
- strcat(stpd_filebase, "/cpu");
- }
-
- if (init_stp(stpd_filebase, !quiet)) {
+ if (init_stp(!quiet)) {
//fprintf(stderr, "Couldn't initialize stpd. Exiting.\n");
exit(1);
}