]> sourceware.org Git - systemtap.git/commitdiff
2007-03-14 Martin Hunt <hunt@redhat.com>
authorhunt <hunt>
Wed, 14 Mar 2007 22:07:49 +0000 (22:07 +0000)
committerhunt <hunt>
Wed, 14 Mar 2007 22:07:49 +0000 (22:07 +0000)
* stpd: Remove directory.
* relayfs: Remove directory.

18 files changed:
runtime/ChangeLog
runtime/relayfs/ChangeLog [deleted file]
runtime/relayfs/Makefile [deleted file]
runtime/relayfs/buffers.c [deleted file]
runtime/relayfs/buffers.h [deleted file]
runtime/relayfs/inode.c [deleted file]
runtime/relayfs/linux/relayfs_fs.h [deleted file]
runtime/relayfs/relay.c [deleted file]
runtime/relayfs/relay.h [deleted file]
runtime/relayfs/relayfs.txt [deleted file]
runtime/stpd/ChangeLog [deleted file]
runtime/stpd/Makefile [deleted file]
runtime/stpd/librelay.c [deleted file]
runtime/stpd/librelay.h [deleted file]
runtime/stpd/stp_dump.c [deleted file]
runtime/stpd/stp_merge.c [deleted file]
runtime/stpd/stpd.c [deleted file]
runtime/stpd/symbols.c [deleted file]

index f21384bed28d3a7c3e5debfee529984148c50bec..5278a744a3a71089c3d618e921899cd360e2d679 100644 (file)
@@ -1,5 +1,8 @@
 2007-03-14  Martin Hunt  <hunt@redhat.com>
-
+       * stpd: Remove directory.
+       * relayfs: Remove directory.
+       
+2007-03-14  Martin Hunt  <hunt@redhat.com>     
        * bench2/bench.rb: Updated to work with new transport
        and new itest.c.
        * bench2/Makefile: Updated for new itest.c
diff --git a/runtime/relayfs/ChangeLog b/runtime/relayfs/ChangeLog
deleted file mode 100644 (file)
index 09f237a..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-2005-10-19  Tom Zanussi  <zanussi@us.ibm.com>
-
-       * inode.c (relayfs_remove): Applied patch
-       [PATCH 2.6.13-rc6-mm2] relayfs: relayfs_remove fix
-
-2005-10-14  Tom Zanussi  <zanussi@us.ibm.com>
-
-       * buffers.c (relay_alloc_buf): Applied patch
-       [PATCH 2.6.14-rc4] relayfs: fix bogus param value in call to vmap
-
-2005-05-17  Martin Hunt  <hunt@redhat.com>
-
-       * relay.c (relay_switch_subbuf): Applied patch
-       [PATCH 2.6.12-rc1-mm2] relayfs: properly handle oversized events
-
-2005-04-11  Martin Hunt  <hunt@redhat.com>
-
-       * inode.c: Latest kernels have modified backing_dev_info. Detect
-       newer version and set appropriately.
-       
-
diff --git a/runtime/relayfs/Makefile b/runtime/relayfs/Makefile
deleted file mode 100644 (file)
index b9f2fac..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# relayfs Makefile
-#
-
-PWD     := $(shell pwd)
-KDIR   := /lib/modules/$(shell uname -r)/build
-
-relayfs-y := relay.o inode.o buffers.o
-
-obj-m += relayfs.o
-
-default:
-       $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
-
-clean:
-       /bin/rm -rf *.o *.ko *~ *.mod.c .*.cmd .tmp_versions
-
diff --git a/runtime/relayfs/buffers.c b/runtime/relayfs/buffers.c
deleted file mode 100644 (file)
index 0fa7cea..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * RelayFS buffer management code.
- *
- * Copyright (C) 2002-2005 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
- * Copyright (C) 1999-2005 - Karim Yaghmour (karim@opersys.com)
- *
- * This file is released under the GPL.
- */
-
-#include <linux/module.h>
-#include <linux/vmalloc.h>
-#include <linux/mm.h>
-#include "linux/relayfs_fs.h"
-#include "relay.h"
-#include "buffers.h"
-
-/*
- * close() vm_op implementation for relayfs file mapping.
- */
-static void relay_file_mmap_close(struct vm_area_struct *vma)
-{
-       struct rchan_buf *buf = vma->vm_private_data;
-       buf->chan->cb->buf_unmapped(buf, vma->vm_file);
-}
-
-/*
- * nopage() vm_op implementation for relayfs file mapping.
- */
-static struct page *relay_buf_nopage(struct vm_area_struct *vma,
-                                    unsigned long address,
-                                    int *type)
-{
-       struct page *page;
-       struct rchan_buf *buf = vma->vm_private_data;
-       unsigned long offset = address - vma->vm_start;
-
-       if (address > vma->vm_end)
-               return NOPAGE_SIGBUS; /* Disallow mremap */
-       if (!buf)
-               return NOPAGE_OOM;
-
-       page = vmalloc_to_page(buf->start + offset);
-       if (!page)
-               return NOPAGE_OOM;
-       get_page(page);
-
-       if (type)
-               *type = VM_FAULT_MINOR;
-
-       return page;
-}
-
-/*
- * vm_ops for relay file mappings.
- */
-static struct vm_operations_struct relay_file_mmap_ops = {
-       .nopage = relay_buf_nopage,
-       .close = relay_file_mmap_close,
-};
-
-/**
- *     relay_mmap_buf: - mmap channel buffer to process address space
- *     @buf: relay channel buffer
- *     @vma: vm_area_struct describing memory to be mapped
- *
- *     Returns 0 if ok, negative on error
- *
- *     Caller should already have grabbed mmap_sem.
- */
-int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma)
-{
-       unsigned long length = vma->vm_end - vma->vm_start;
-       struct file *filp = vma->vm_file;
-
-       if (!buf)
-               return -EBADF;
-
-       if (length != (unsigned long)buf->chan->alloc_size)
-               return -EINVAL;
-
-       vma->vm_ops = &relay_file_mmap_ops;
-       vma->vm_private_data = buf;
-       buf->chan->cb->buf_mapped(buf, filp);
-
-       return 0;
-}
-
-/**
- *     relay_alloc_buf - allocate a channel buffer
- *     @buf: the buffer struct
- *     @size: total size of the buffer
- *
- *     Returns a pointer to the resulting buffer, NULL if unsuccessful
- */
-static void *relay_alloc_buf(struct rchan_buf *buf, unsigned long size)
-{
-       void *mem;
-       int i, j, n_pages;
-
-       size = PAGE_ALIGN(size);
-       n_pages = size >> PAGE_SHIFT;
-
-       buf->page_array = kcalloc(n_pages, sizeof(struct page *), GFP_KERNEL);
-       if (!buf->page_array)
-               return NULL;
-
-       for (i = 0; i < n_pages; i++) {
-               buf->page_array[i] = alloc_page(GFP_KERNEL);
-               if (unlikely(!buf->page_array[i]))
-                       goto depopulate;
-       }
-       mem = vmap(buf->page_array, n_pages, VM_MAP, PAGE_KERNEL);
-       if (!mem)
-               goto depopulate;
-
-       memset(mem, 0, size);
-       buf->page_count = n_pages;
-       return mem;
-
-depopulate:
-       for (j = 0; j < i; j++)
-               __free_page(buf->page_array[j]);
-       kfree(buf->page_array);
-       return NULL;
-}
-
-/**
- *     relay_create_buf - allocate and initialize a channel buffer
- *     @alloc_size: size of the buffer to allocate
- *     @n_subbufs: number of sub-buffers in the channel
- *
- *     Returns channel buffer if successful, NULL otherwise
- */
-struct rchan_buf *relay_create_buf(struct rchan *chan)
-{
-       struct rchan_buf *buf = kcalloc(1, sizeof(struct rchan_buf), GFP_KERNEL);
-       if (!buf)
-               return NULL;
-
-       buf->padding = kmalloc(chan->n_subbufs * sizeof(unsigned *), GFP_KERNEL);
-       if (!buf->padding)
-               goto free_buf;
-
-       buf->commit = kmalloc(chan->n_subbufs * sizeof(unsigned *), GFP_KERNEL);
-       if (!buf->commit)
-               goto free_buf;
-
-       buf->start = relay_alloc_buf(buf, chan->alloc_size);
-       if (!buf->start)
-               goto free_buf;
-
-       buf->chan = chan;
-       kref_get(&buf->chan->kref);
-       return buf;
-
-free_buf:
-       kfree(buf->commit);
-       kfree(buf->padding);
-       kfree(buf);
-       return NULL;
-}
-
-/**
- *     relay_destroy_buf - destroy an rchan_buf struct and associated buffer
- *     @buf: the buffer struct
- */
-void relay_destroy_buf(struct rchan_buf *buf)
-{
-       struct rchan *chan = buf->chan;
-       int i;
-
-       if (likely(buf->start)) {
-               vunmap(buf->start);
-               for (i = 0; i < buf->page_count; i++)
-                       __free_page(buf->page_array[i]);
-               kfree(buf->page_array);
-       }
-       kfree(buf->padding);
-       kfree(buf->commit);
-       kfree(buf);
-       kref_put(&chan->kref, relay_destroy_channel);
-}
-
-/**
- *     relay_remove_buf - remove a channel buffer
- *
- *     Removes the file from the relayfs fileystem, which also frees the
- *     rchan_buf_struct and the channel buffer.  Should only be called from
- *     kref_put().
- */
-void relay_remove_buf(struct kref *kref)
-{
-       struct rchan_buf *buf = container_of(kref, struct rchan_buf, kref);
-       relayfs_remove(buf->dentry);
-}
diff --git a/runtime/relayfs/buffers.h b/runtime/relayfs/buffers.h
deleted file mode 100644 (file)
index 37a1249..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _BUFFERS_H
-#define _BUFFERS_H
-
-/* This inspired by rtai/shmem */
-#define FIX_SIZE(x) (((x) - 1) & PAGE_MASK) + PAGE_SIZE
-
-extern int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma);
-extern struct rchan_buf *relay_create_buf(struct rchan *chan);
-extern void relay_destroy_buf(struct rchan_buf *buf);
-extern void relay_remove_buf(struct kref *kref);
-
-#endif/* _BUFFERS_H */
diff --git a/runtime/relayfs/inode.c b/runtime/relayfs/inode.c
deleted file mode 100644 (file)
index 26faf9f..0000000
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * VFS-related code for RelayFS, a high-speed data relay filesystem.
- *
- * Copyright (C) 2003-2005 - Tom Zanussi <zanussi@us.ibm.com>, IBM Corp
- * Copyright (C) 2003-2005 - Karim Yaghmour <karim@opersys.com>
- *
- * Based on ramfs, Copyright (C) 2002 - Linus Torvalds
- *
- * This file is released under the GPL.
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/mount.h>
-#include <linux/pagemap.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/backing-dev.h>
-#include <linux/namei.h>
-#include <linux/poll.h>
-#include "linux/relayfs_fs.h"
-#include "relay.h"
-#include "buffers.h"
-
-#define RELAYFS_MAGIC                  0xF0B4A981
-
-static struct vfsmount *               relayfs_mount;
-static int                             relayfs_mount_count;
-static kmem_cache_t *                  relayfs_inode_cachep;
-
-static struct backing_dev_info         relayfs_backing_dev_info = {
-       .ra_pages       = 0,    /* No readahead */
-#ifdef BDI_CAP_NO_ACCT_DIRTY
-       .capabilities   = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK,
-#else
-       .memory_backed  = 1,    /* Does not contribute to dirty memory */
-#endif
-};
-
-static struct inode *relayfs_get_inode(struct super_block *sb, int mode,
-                                      struct rchan *chan)
-{
-       struct rchan_buf *buf = NULL;
-       struct inode *inode;
-
-       if (S_ISREG(mode)) {
-               BUG_ON(!chan);
-               buf = relay_create_buf(chan);
-               if (!buf)
-                       return NULL;
-       }
-
-       inode = new_inode(sb);
-       if (!inode) {
-               relay_destroy_buf(buf);
-               return NULL;
-       }
-
-       inode->i_mode = mode;
-       inode->i_uid = 0;
-       inode->i_gid = 0;
-       inode->i_blksize = PAGE_CACHE_SIZE;
-       inode->i_blocks = 0;
-       inode->i_mapping->backing_dev_info = &relayfs_backing_dev_info;
-       inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
-       switch (mode & S_IFMT) {
-       case S_IFREG:
-               inode->i_fop = &relayfs_file_operations;
-               RELAYFS_I(inode)->buf = buf;
-               break;
-       case S_IFDIR:
-               inode->i_op = &simple_dir_inode_operations;
-               inode->i_fop = &simple_dir_operations;
-
-               /* directory inodes start off with i_nlink == 2 (for "." entry) */
-               inode->i_nlink++;
-               break;
-       default:
-               break;
-       }
-
-       return inode;
-}
-
-/**
- *     relayfs_create_entry - create a relayfs directory or file
- *     @name: the name of the file to create
- *     @parent: parent directory
- *     @mode: mode
- *     @chan: relay channel associated with the file
- *
- *     Returns the new dentry, NULL on failure
- *
- *     Creates a file or directory with the specifed permissions.
- */
-static struct dentry *relayfs_create_entry(const char *name,
-                                          struct dentry *parent,
-                                          int mode,
-                                          struct rchan *chan)
-{
-       struct qstr qname;
-       struct dentry *d;
-       struct inode *inode;
-       int error = 0;
-
-       BUG_ON(!name || !(S_ISREG(mode) || S_ISDIR(mode)));
-
-       error = simple_pin_fs("relayfs", &relayfs_mount, &relayfs_mount_count);
-       if (error) {
-               printk(KERN_ERR "Couldn't mount relayfs: errcode %d\n", error);
-               return NULL;
-       }
-
-       qname.name = name;
-       qname.len = strlen(name);
-       qname.hash = full_name_hash(name, qname.len);
-
-       if (!parent && relayfs_mount && relayfs_mount->mnt_sb)
-               parent = relayfs_mount->mnt_sb->s_root;
-
-       if (!parent) {
-               simple_release_fs(&relayfs_mount, &relayfs_mount_count);
-               return NULL;
-       }
-
-       parent = dget(parent);
-       down(&parent->d_inode->i_sem);
-       d = lookup_hash(&qname, parent);
-       if (IS_ERR(d)) {
-               d = NULL;
-               goto release_mount;
-       }
-
-       if (d->d_inode) {
-               d = NULL;
-               goto release_mount;
-       }
-
-       inode = relayfs_get_inode(parent->d_inode->i_sb, mode, chan);
-       if (!inode) {
-               d = NULL;
-               goto release_mount;
-       }
-
-       d_instantiate(d, inode);
-       dget(d);        /* Extra count - pin the dentry in core */
-
-       if (S_ISDIR(mode))
-               parent->d_inode->i_nlink++;
-
-       goto exit;
-
-release_mount:
-       simple_release_fs(&relayfs_mount, &relayfs_mount_count);
-
-exit:
-       up(&parent->d_inode->i_sem);
-       dput(parent);
-       return d;
-}
-
-/**
- *     relayfs_create_file - create a file in the relay filesystem
- *     @name: the name of the file to create
- *     @parent: parent directory
- *     @mode: mode, if not specied the default perms are used
- *     @chan: channel associated with the file
- *
- *     Returns file dentry if successful, NULL otherwise.
- *
- *     The file will be created user r on behalf of current user.
- */
-struct dentry *relayfs_create_file(const char *name, struct dentry *parent,
-                                  int mode, struct rchan *chan)
-{
-       if (!mode)
-               mode = S_IRUSR;
-       mode = (mode & S_IALLUGO) | S_IFREG;
-
-       return relayfs_create_entry(name, parent, mode, chan);
-}
-
-/**
- *     relayfs_create_dir - create a directory in the relay filesystem
- *     @name: the name of the directory to create
- *     @parent: parent directory, NULL if parent should be fs root
- *
- *     Returns directory dentry if successful, NULL otherwise.
- *
- *     The directory will be created world rwx on behalf of current user.
- */
-struct dentry *relayfs_create_dir(const char *name, struct dentry *parent)
-{
-       int mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
-       return relayfs_create_entry(name, parent, mode, NULL);
-}
-
-/**
- *     relayfs_remove - remove a file or directory in the relay filesystem
- *     @dentry: file or directory dentry
- *
- *     Returns 0 if successful, negative otherwise.
- */
-int relayfs_remove(struct dentry *dentry)
-{
-       struct dentry *parent;
-       int error = 0;
-
-       if (!dentry)
-               return -EINVAL;
-       parent = dentry->d_parent;
-       if (!parent)
-               return -EINVAL;
-
-       parent = dget(parent);
-       down(&parent->d_inode->i_sem);
-       if (dentry->d_inode) {
-               if (S_ISDIR(dentry->d_inode->i_mode))
-                       error = simple_rmdir(parent->d_inode, dentry);
-               else
-                       error = simple_unlink(parent->d_inode, dentry);
-               if (!error)
-                       d_delete(dentry);
-       }
-       if (!error)
-               dput(dentry);
-       up(&parent->d_inode->i_sem);
-       dput(parent);
-
-       if (!error)
-               simple_release_fs(&relayfs_mount, &relayfs_mount_count);
-
-       return error;
-}
-
-/**
- *     relayfs_remove_dir - remove a directory in the relay filesystem
- *     @dentry: directory dentry
- *
- *     Returns 0 if successful, negative otherwise.
- */
-int relayfs_remove_dir(struct dentry *dentry)
-{
-       return relayfs_remove(dentry);
-}
-
-/**
- *     relayfs_open - open file op for relayfs files
- *     @inode: the inode
- *     @filp: the file
- *
- *     Increments the channel buffer refcount.
- */
-int relayfs_open(struct inode *inode, struct file *filp)
-{
-       struct rchan_buf *buf = RELAYFS_I(inode)->buf;
-       kref_get(&buf->kref);
-
-       return 0;
-}
-
-/**
- *     relayfs_mmap - mmap file op for relayfs files
- *     @filp: the file
- *     @vma: the vma describing what to map
- *
- *     Calls upon relay_mmap_buf to map the file into user space.
- */
-int relayfs_mmap(struct file *filp, struct vm_area_struct *vma)
-{
-       struct inode *inode = filp->f_dentry->d_inode;
-       return relay_mmap_buf(RELAYFS_I(inode)->buf, vma);
-}
-
-/**
- *     relayfs_poll - poll file op for relayfs files
- *     @filp: the file
- *     @wait: poll table
- *
- *     Poll implemention.
- */
-unsigned int relayfs_poll(struct file *filp, poll_table *wait)
-{
-       unsigned int mask = 0;
-       struct inode *inode = filp->f_dentry->d_inode;
-       struct rchan_buf *buf = RELAYFS_I(inode)->buf;
-
-       if (buf->finalized)
-               return POLLERR;
-
-       if (filp->f_mode & FMODE_READ) {
-               poll_wait(filp, &buf->read_wait, wait);
-               if (!relay_buf_empty(buf))
-                       mask |= POLLIN | POLLRDNORM;
-       }
-
-       return mask;
-}
-
-/**
- *     relayfs_release - release file op for relayfs files
- *     @inode: the inode
- *     @filp: the file
- *
- *     Decrements the channel refcount, as the filesystem is
- *     no longer using it.
- */
-int relayfs_release(struct inode *inode, struct file *filp)
-{
-       struct rchan_buf *buf = RELAYFS_I(inode)->buf;
-       kref_put(&buf->kref, relay_remove_buf);
-
-       return 0;
-}
-
-/**
- *     relayfs alloc_inode() implementation
- */
-static struct inode *relayfs_alloc_inode(struct super_block *sb)
-{
-       struct relayfs_inode_info *p = kmem_cache_alloc(relayfs_inode_cachep, SLAB_KERNEL);
-       if (!p)
-               return NULL;
-       p->buf = NULL;
-
-       return &p->vfs_inode;
-}
-
-/**
- *     relayfs destroy_inode() implementation
- */
-static void relayfs_destroy_inode(struct inode *inode)
-{
-       if (RELAYFS_I(inode)->buf)
-               relay_destroy_buf(RELAYFS_I(inode)->buf);
-
-       kmem_cache_free(relayfs_inode_cachep, RELAYFS_I(inode));
-}
-
-static void init_once(void *p, kmem_cache_t *cachep, unsigned long flags)
-{
-       struct relayfs_inode_info *i = p;
-       if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) == SLAB_CTOR_CONSTRUCTOR)
-               inode_init_once(&i->vfs_inode);
-}
-
-struct file_operations relayfs_file_operations = {
-       .open           = relayfs_open,
-       .poll           = relayfs_poll,
-       .mmap           = relayfs_mmap,
-       .release        = relayfs_release,
-};
-
-static struct super_operations relayfs_ops = {
-       .statfs         = simple_statfs,
-       .drop_inode     = generic_delete_inode,
-       .alloc_inode    = relayfs_alloc_inode,
-       .destroy_inode  = relayfs_destroy_inode,
-};
-
-static int relayfs_fill_super(struct super_block * sb, void * data, int silent)
-{
-       struct inode *inode;
-       struct dentry *root;
-       int mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
-
-       sb->s_blocksize = PAGE_CACHE_SIZE;
-       sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
-       sb->s_magic = RELAYFS_MAGIC;
-       sb->s_op = &relayfs_ops;
-       inode = relayfs_get_inode(sb, mode, NULL);
-
-       if (!inode)
-               return -ENOMEM;
-
-       root = d_alloc_root(inode);
-       if (!root) {
-               iput(inode);
-               return -ENOMEM;
-       }
-       sb->s_root = root;
-
-       return 0;
-}
-
-static struct super_block * relayfs_get_sb(struct file_system_type *fs_type,
-                                          int flags, const char *dev_name,
-                                          void *data)
-{
-       return get_sb_single(fs_type, flags, data, relayfs_fill_super);
-}
-
-static struct file_system_type relayfs_fs_type = {
-       .owner          = THIS_MODULE,
-       .name           = "relayfs",
-       .get_sb         = relayfs_get_sb,
-       .kill_sb        = kill_litter_super,
-};
-
-static int __init init_relayfs_fs(void)
-{
-       int err;
-
-       relayfs_inode_cachep = kmem_cache_create("relayfs_inode_cache",
-                               sizeof(struct relayfs_inode_info), 0,
-                               0, init_once, NULL);
-       if (!relayfs_inode_cachep)
-               return -ENOMEM;
-
-       err = register_filesystem(&relayfs_fs_type);
-       if (err)
-               kmem_cache_destroy(relayfs_inode_cachep);
-
-       return err;
-}
-
-static void __exit exit_relayfs_fs(void)
-{
-       unregister_filesystem(&relayfs_fs_type);
-       kmem_cache_destroy(relayfs_inode_cachep);
-}
-
-module_init(init_relayfs_fs)
-module_exit(exit_relayfs_fs)
-
-EXPORT_SYMBOL_GPL(relayfs_open);
-EXPORT_SYMBOL_GPL(relayfs_poll);
-EXPORT_SYMBOL_GPL(relayfs_mmap);
-EXPORT_SYMBOL_GPL(relayfs_release);
-EXPORT_SYMBOL_GPL(relayfs_file_operations);
-EXPORT_SYMBOL_GPL(relayfs_create_dir);
-EXPORT_SYMBOL_GPL(relayfs_remove_dir);
-
-MODULE_AUTHOR("Tom Zanussi <zanussi@us.ibm.com> and Karim Yaghmour <karim@opersys.com>");
-MODULE_DESCRIPTION("Relay Filesystem");
-MODULE_LICENSE("GPL");
-
diff --git a/runtime/relayfs/linux/relayfs_fs.h b/runtime/relayfs/linux/relayfs_fs.h
deleted file mode 100644 (file)
index 2d270a3..0000000
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * linux/include/linux/relayfs_fs.h
- *
- * Copyright (C) 2002, 2003 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
- * Copyright (C) 1999, 2000, 2001, 2002 - Karim Yaghmour (karim@opersys.com)
- *
- * RelayFS definitions and declarations
- */
-
-#ifndef _LINUX_RELAYFS_FS_H
-#define _LINUX_RELAYFS_FS_H
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/list.h>
-#include <linux/fs.h>
-#include <linux/poll.h>
-#include <linux/kref.h>
-
-/*
- * Tracks changes to rchan_buf struct
- */
-#define RELAYFS_CHANNEL_VERSION                3
-
-/*
- * Per-cpu relay channel buffer
- */
-struct rchan_buf
-{
-       void *start;                    /* start of channel buffer */
-       void *data;                     /* start of current sub-buffer */
-       unsigned offset;                /* current offset into sub-buffer */
-       atomic_t subbufs_produced;      /* count of sub-buffers produced */
-       atomic_t subbufs_consumed;      /* count of sub-buffers consumed */
-       atomic_t unfull;                /* state has gone from full to not */
-       struct rchan *chan;             /* associated channel */
-       wait_queue_head_t read_wait;    /* reader wait queue */
-       struct work_struct wake_readers; /* reader wake-up work struct */
-       struct dentry *dentry;          /* channel file dentry */
-       struct kref kref;               /* channel buffer refcount */
-       struct page **page_array;       /* array of current buffer pages */
-       int page_count;                 /* number of current buffer pages */
-       unsigned *padding;              /* padding counts per sub-buffer */
-       unsigned *commit;               /* commit counts per sub-buffer */
-       int finalized;                  /* buffer has been finalized */
-} ____cacheline_aligned;
-
-/*
- * Relay channel data structure
- */
-struct rchan
-{
-       u32 version;                    /* the version of this struct */
-       unsigned subbuf_size;           /* sub-buffer size */
-       unsigned n_subbufs;             /* number of sub-buffers per buffer */
-       unsigned alloc_size;            /* total buffer size allocated */
-       int overwrite;                  /* overwrite buffer when full? */
-       struct rchan_callbacks *cb;     /* client callbacks */
-       struct kref kref;               /* channel refcount */
-       void *private_data;             /* for user-defined data */
-       struct rchan_buf *buf[NR_CPUS]; /* per-cpu channel buffers */
-};
-
-/*
- * Relayfs inode
- */
-struct relayfs_inode_info
-{
-       struct inode vfs_inode;
-       struct rchan_buf *buf;
-};
-
-static inline struct relayfs_inode_info *RELAYFS_I(struct inode *inode)
-{
-       return container_of(inode, struct relayfs_inode_info, vfs_inode);
-}
-
-/*
- * Relay channel client callbacks
- */
-struct rchan_callbacks
-{
-       /*
-        * subbuf_start - called on buffer-switch to a new sub-buffer
-        * @buf: the channel buffer containing the new sub-buffer
-        * @subbuf: the start of the new sub-buffer
-        * @prev_subbuf_idx: the previous sub-buffer's index
-        * @prev_subbuf: the start of the previous sub-buffer
-        *
-        * The client should return the number of bytes it reserves at
-        * the beginning of the sub-buffer, 0 if none.
-        *
-        * NOTE: subbuf_start will also be invoked when the buffer is
-        *       created, so that the first sub-buffer can be initialized
-        *       if necessary.  In this case, prev_subbuf will be NULL.
-        */
-       int (*subbuf_start) (struct rchan_buf *buf,
-                            void *subbuf,
-                            unsigned prev_subbuf_idx,
-                            void *prev_subbuf);
-
-       /*
-        * deliver - deliver a guaranteed full sub-buffer to client
-        * @buf: the channel buffer containing the sub-buffer
-        * @subbuf_idx: the sub-buffer's index
-        * @subbuf: the start of the new sub-buffer
-        *
-        * Only works if relay_commit is also used
-        */
-       void (*deliver) (struct rchan_buf *buf,
-                        unsigned subbuf_idx,
-                        void *subbuf);
-
-       /*
-        * buf_mapped - relayfs buffer mmap notification
-        * @buf: the channel buffer
-        * @filp: relayfs file pointer
-        *
-        * Called when a relayfs file is successfully mmapped
-        */
-        void (*buf_mapped)(struct rchan_buf *buf,
-                          struct file *filp);
-
-       /*
-        * buf_unmapped - relayfs buffer unmap notification
-        * @buf: the channel buffer
-        * @filp: relayfs file pointer
-        *
-        * Called when a relayfs file is successfully unmapped
-        */
-        void (*buf_unmapped)(struct rchan_buf *buf,
-                            struct file *filp);
-
-       /*
-        * buf_full - relayfs buffer full notification
-        * @buf: the channel channel buffer
-        * @subbuf_idx: the current sub-buffer's index
-        * @subbuf: the start of the current sub-buffer
-        *
-        * Called when a relayfs buffer becomes full
-        */
-        void (*buf_full)(struct rchan_buf *buf,
-                        unsigned subbuf_idx,
-                        void *subbuf);
-};
-
-/*
- * relayfs kernel API, fs/relayfs/relay.c
- */
-
-struct rchan *relay_open(const char *base_filename,
-                        struct dentry *parent,
-                        unsigned subbuf_size,
-                        unsigned n_subbufs,
-                        int overwrite,
-                        struct rchan_callbacks *cb);
-extern void relay_close(struct rchan *chan);
-extern void relay_flush(struct rchan *chan);
-extern void relay_subbufs_consumed(struct rchan *chan,
-                                  int cpu,
-                                  int subbufs_consumed);
-extern void relay_reset(struct rchan *chan);
-extern unsigned relay_switch_subbuf(struct rchan_buf *buf,
-                                   unsigned length);
-extern void relay_commit(struct rchan_buf *buf,
-                        void *reserved,
-                        unsigned count);
-extern struct dentry *relayfs_create_dir(const char *name,
-                                        struct dentry *parent);
-extern int relayfs_remove_dir(struct dentry *dentry);
-
-/**
- *     relay_write - write data into the channel
- *     @chan: relay channel
- *     @data: data to be written
- *     @length: number of bytes to write
- *
- *     Writes data into the current cpu's channel buffer.
- *
- *     Protects the buffer by disabling interrupts.  Use this
- *     if you might be logging from interrupt context.  Try
- *     __relay_write() if you know you won't be logging from
- *     interrupt context.
- */
-static inline void relay_write(struct rchan *chan,
-                              const void *data,
-                              unsigned length)
-{
-       unsigned long flags;
-       struct rchan_buf *buf;
-
-       local_irq_save(flags);
-       buf = chan->buf[smp_processor_id()];
-       if (unlikely(buf->offset + length > chan->subbuf_size))
-               length = relay_switch_subbuf(buf, length);
-       memcpy(buf->data + buf->offset, data, length);
-       buf->offset += length;
-       local_irq_restore(flags);
-}
-
-/**
- *     __relay_write - write data into the channel
- *     @chan: relay channel
- *     @data: data to be written
- *     @length: number of bytes to write
- *
- *     Writes data into the current cpu's channel buffer.
- *
- *     Protects the buffer by disabling preemption.  Use
- *     relay_write() if you might be logging from interrupt
- *     context.
- */
-static inline void __relay_write(struct rchan *chan,
-                                const void *data,
-                                unsigned length)
-{
-       struct rchan_buf *buf;
-
-       buf = chan->buf[get_cpu()];
-       if (unlikely(buf->offset + length > buf->chan->subbuf_size))
-               length = relay_switch_subbuf(buf, length);
-       memcpy(buf->data + buf->offset, data, length);
-       buf->offset += length;
-       put_cpu();
-}
-
-/**
- *     relay_reserve - reserve slot in channel buffer
- *     @chan: relay channel
- *     @length: number of bytes to reserve
- *
- *     Returns pointer to reserved slot, NULL if full.
- *
- *     Reserves a slot in the current cpu's channel buffer.
- *     Does not protect the buffer at all - caller must provide
- *     appropriate synchronization.
- */
-static inline void *relay_reserve(struct rchan *chan, unsigned length)
-{
-       void *reserved;
-       struct rchan_buf *buf = chan->buf[smp_processor_id()];
-
-       if (unlikely(buf->offset + length > buf->chan->subbuf_size)) {
-               length = relay_switch_subbuf(buf, length);
-               if (!length)
-                       return NULL;
-       }
-       reserved = buf->data + buf->offset;
-       buf->offset += length;
-
-       return reserved;
-}
-
-/*
- * exported relayfs file operations, fs/relayfs/inode.c
- */
-
-extern struct file_operations relayfs_file_operations;
-extern int relayfs_open(struct inode *inode, struct file *filp);
-extern unsigned int relayfs_poll(struct file *filp, poll_table *wait);
-extern int relayfs_mmap(struct file *filp, struct vm_area_struct *vma);
-extern int relayfs_release(struct inode *inode, struct file *filp);
-
-#endif /* _LINUX_RELAYFS_FS_H */
-
diff --git a/runtime/relayfs/relay.c b/runtime/relayfs/relay.c
deleted file mode 100644 (file)
index e35429f..0000000
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * Public API and common code for RelayFS.
- *
- * See Documentation/filesystems/relayfs.txt for an overview of relayfs.
- *
- * Copyright (C) 2002-2005 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
- * Copyright (C) 1999-2005 - Karim Yaghmour (karim@opersys.com)
- *
- * This file is released under the GPL.
- */
-
-#include <linux/errno.h>
-#include <linux/stddef.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include "linux/relayfs_fs.h"
-#include "relay.h"
-#include "buffers.h"
-
-/**
- *     relay_buf_empty - boolean, is the channel buffer empty?
- *     @buf: channel buffer
- *
- *     Returns 1 if the buffer is empty, 0 otherwise.
- */
-int relay_buf_empty(struct rchan_buf *buf)
-{
-       int produced = atomic_read(&buf->subbufs_produced);
-       int consumed = atomic_read(&buf->subbufs_consumed);
-
-       return (produced - consumed) ? 0 : 1;
-}
-
-/**
- *     relay_buf_full - boolean, is the channel buffer full?
- *     @buf: channel buffer
- *
- *     Returns 1 if the buffer is full, 0 otherwise.
- */
-static inline int relay_buf_full(struct rchan_buf *buf)
-{
-       int produced, consumed;
-
-       if (buf->chan->overwrite)
-               return 0;
-
-       produced = atomic_read(&buf->subbufs_produced);
-       consumed = atomic_read(&buf->subbufs_consumed);
-
-       return (produced - consumed > buf->chan->n_subbufs - 1) ? 1 : 0;
-}
-
-/*
- * High-level relayfs kernel API and associated functions.
- */
-
-/*
- * rchan_callback implementations defining default channel behavior.  Used
- * in place of corresponding NULL values in client callback struct.
- */
-
-/*
- * subbuf_start() default callback.  Does nothing.
- */
-static int subbuf_start_default_callback (struct rchan_buf *buf,
-                                         void *subbuf,
-                                         unsigned prev_subbuf_idx,
-                                         void *prev_subbuf)
-{
-       return 0;
-}
-
-/*
- * deliver() default callback.  Does nothing.
- */
-static void deliver_default_callback (struct rchan_buf *buf,
-                                     unsigned subbuf_idx,
-                                     void *subbuf)
-{
-}
-
-/*
- * buf_mapped() default callback.  Does nothing.
- */
-static void buf_mapped_default_callback(struct rchan_buf *buf,
-                                       struct file *filp)
-{
-}
-
-/*
- * buf_unmapped() default callback.  Does nothing.
- */
-static void buf_unmapped_default_callback(struct rchan_buf *buf,
-                                         struct file *filp)
-{
-}
-
-/*
- * buf_full() default callback.  Does nothing.
- */
-static void buf_full_default_callback(struct rchan_buf *buf,
-                                     unsigned subbuf_idx,
-                                     void *subbuf)
-{
-}
-
-/* relay channel default callbacks */
-static struct rchan_callbacks default_channel_callbacks = {
-       .subbuf_start = subbuf_start_default_callback,
-       .deliver = deliver_default_callback,
-       .buf_mapped = buf_mapped_default_callback,
-       .buf_unmapped = buf_unmapped_default_callback,
-       .buf_full = buf_full_default_callback,
-};
-
-/**
- *     wakeup_readers - wake up readers waiting on a channel
- *     @private: the channel buffer
- *
- *     This is the work function used to defer reader waking.  The
- *     reason waking is deferred is that calling directly from write
- *     causes problems if you're writing from say the scheduler.
- */
-static void wakeup_readers(void *private)
-{
-       struct rchan_buf *buf = private;
-       wake_up_interruptible(&buf->read_wait);
-}
-
-/**
- *     get_next_subbuf - return next sub-buffer within channel buffer
- *     @buf: channel buffer
- */
-static inline void *get_next_subbuf(struct rchan_buf *buf)
-{
-       void *next = buf->data + buf->chan->subbuf_size;
-       if (next >= buf->start + buf->chan->subbuf_size * buf->chan->n_subbufs)
-               next = buf->start;
-
-       return next;
-}
-
-/**
- *     __relay_reset - reset a channel buffer
- *     @buf: the channel buffer
- *     @init: 1 if this is a first-time initialization
- *
- *     See relay_reset for description of effect.
- */
-static inline void __relay_reset(struct rchan_buf *buf, int init)
-{
-       int i;
-
-       if (init) {
-               init_waitqueue_head(&buf->read_wait);
-               kref_init(&buf->kref);
-               INIT_WORK(&buf->wake_readers, NULL, NULL);
-       } else {
-               cancel_delayed_work(&buf->wake_readers);
-               flush_scheduled_work();
-       }
-
-       atomic_set(&buf->subbufs_produced, 0);
-       atomic_set(&buf->subbufs_consumed, 0);
-       atomic_set(&buf->unfull, 0);
-       buf->finalized = 0;
-       buf->data = buf->start;
-       buf->offset = 0;
-
-       for (i = 0; i < buf->chan->n_subbufs; i++) {
-               buf->padding[i] = 0;
-               buf->commit[i] = 0;
-       }
-
-       buf->offset = buf->chan->cb->subbuf_start(buf, buf->data, 0, NULL);
-       buf->commit[0] = buf->offset;
-}
-
-/**
- *     relay_reset - reset the channel
- *     @chan: the channel
- *
- *     Returns 0 if successful, negative if not.
- *
- *     This has the effect of erasing all data from all channel buffers
- *     and restarting the channel in its initial state.  The buffers
- *     are not freed, so any mappings are still in effect.
- *
- *     NOTE: Care should be taken that the channel isn't actually
- *     being used by anything when this call is made.
- */
-void relay_reset(struct rchan *chan)
-{
-       int i;
-
-       if (!chan)
-               return;
-
-       for (i = 0; i < NR_CPUS; i++) {
-               if (!chan->buf[i])
-                       continue;
-               __relay_reset(chan->buf[i], 0);
-       }
-}
-
-/**
- *     relay_open_buf - create a new channel buffer in relayfs
- *
- *     Internal - used by relay_open().
- */
-static struct rchan_buf *relay_open_buf(struct rchan *chan,
-                                       const char *filename,
-                                       struct dentry *parent)
-{
-       struct rchan_buf *buf;
-       struct dentry *dentry;
-
-       /* Create file in fs */
-       dentry = relayfs_create_file(filename, parent, S_IRUSR, chan);
-       if (!dentry)
-               return NULL;
-
-       buf = RELAYFS_I(dentry->d_inode)->buf;
-       buf->dentry = dentry;
-       __relay_reset(buf, 1);
-
-       return buf;
-}
-
-/**
- *     relay_close_buf - close a channel buffer
- *     @buf: channel buffer
- *
- *     Marks the buffer finalized and restores the default callbacks.
- *     The channel buffer and channel buffer data structure are then freed
- *     automatically when the last reference is given up.
- */
-static inline void relay_close_buf(struct rchan_buf *buf)
-{
-       buf->finalized = 1;
-       buf->chan->cb = &default_channel_callbacks;
-       cancel_delayed_work(&buf->wake_readers);
-       flush_scheduled_work();
-       kref_put(&buf->kref, relay_remove_buf);
-}
-
-static inline void setup_callbacks(struct rchan *chan,
-                                  struct rchan_callbacks *cb)
-{
-       if (!cb) {
-               chan->cb = &default_channel_callbacks;
-               return;
-       }
-
-       if (!cb->subbuf_start)
-               cb->subbuf_start = subbuf_start_default_callback;
-       if (!cb->deliver)
-               cb->deliver = deliver_default_callback;
-       if (!cb->buf_mapped)
-               cb->buf_mapped = buf_mapped_default_callback;
-       if (!cb->buf_unmapped)
-               cb->buf_unmapped = buf_unmapped_default_callback;
-       if (!cb->buf_full)
-               cb->buf_full = buf_full_default_callback;
-       chan->cb = cb;
-}
-
-/**
- *     relay_open - create a new relayfs channel
- *     @base_filename: base name of files to create
- *     @parent: dentry of parent directory, NULL for root directory
- *     @subbuf_size: size of sub-buffers
- *     @n_subbufs: number of sub-buffers
- *     @overwrite: overwrite buffer when full?
- *     @cb: client callback functions
- *
- *     Returns channel pointer if successful, NULL otherwise.
- *
- *     Creates a channel buffer for each cpu using the sizes and
- *     attributes specified.  The created channel buffer files
- *     will be named base_filename0...base_filenameN-1.  File
- *     permissions will be S_IRUSR.
- */
-struct rchan *relay_open(const char *base_filename,
-                        struct dentry *parent,
-                        unsigned subbuf_size,
-                        unsigned n_subbufs,
-                        int overwrite,
-                        struct rchan_callbacks *cb)
-{
-       int i;
-       struct rchan *chan;
-       char *tmpname;
-
-       if (!base_filename)
-               return NULL;
-
-       if (!(subbuf_size && n_subbufs))
-               return NULL;
-
-       chan = kcalloc(1, sizeof(struct rchan), GFP_KERNEL);
-       if (!chan)
-               return NULL;
-
-       chan->version = RELAYFS_CHANNEL_VERSION;
-       chan->overwrite = overwrite;
-       chan->n_subbufs = n_subbufs;
-       chan->subbuf_size = subbuf_size;
-       chan->alloc_size = FIX_SIZE(subbuf_size * n_subbufs);
-       setup_callbacks(chan, cb);
-       kref_init(&chan->kref);
-
-       tmpname = kmalloc(NAME_MAX + 1, GFP_KERNEL);
-       if (!tmpname)
-               goto free_chan;
-
-       for_each_online_cpu(i) {
-               sprintf(tmpname, "%s%d", base_filename, i);
-               chan->buf[i] = relay_open_buf(chan, tmpname, parent);
-               if (!chan->buf[i])
-                       goto free_bufs;
-       }
-
-       kfree(tmpname);
-       return chan;
-
-free_bufs:
-       for (i = 0; i < NR_CPUS; i++) {
-               if (!chan->buf[i])
-                       break;
-               relay_close_buf(chan->buf[i]);
-       }
-       kfree(tmpname);
-
-free_chan:
-       kref_put(&chan->kref, relay_destroy_channel);
-       return NULL;
-}
-
-/**
- *     deliver_check - deliver a guaranteed full sub-buffer if applicable
- */
-static inline void deliver_check(struct rchan_buf *buf,
-                                unsigned subbuf_idx)
-{
-       void *subbuf;
-       unsigned full = buf->chan->subbuf_size - buf->padding[subbuf_idx];
-
-       if (buf->commit[subbuf_idx] == full) {
-               subbuf = buf->start + subbuf_idx * buf->chan->subbuf_size;
-               buf->chan->cb->deliver(buf, subbuf_idx, subbuf);
-       }
-}
-
-/**
- *     do_switch - change subbuf pointer and do related bookkeeping
- */
-static inline void do_switch(struct rchan_buf *buf, unsigned new, unsigned old)
-{
-       unsigned start = 0;
-       void *old_data = buf->start + old * buf->chan->subbuf_size;
-
-       buf->data = get_next_subbuf(buf);
-       buf->padding[new] = 0;
-       start = buf->chan->cb->subbuf_start(buf, buf->data, old, old_data);
-       buf->offset = buf->commit[new] = start;
-}
-
-/**
- *     relay_switch_subbuf - switch to a new sub-buffer
- *     @buf: channel buffer
- *     @length: size of current event
- *
- *     Returns either the length passed in or 0 if full.
-
- *     Performs sub-buffer-switch tasks such as invoking callbacks,
- *     updating padding counts, waking up readers, etc.
- */
-unsigned relay_switch_subbuf(struct rchan_buf *buf, unsigned length)
-{
-       int new, old, produced = atomic_read(&buf->subbufs_produced);
-       unsigned padding;
-
-       if (unlikely(length > buf->chan->subbuf_size))
-         goto toobig;
-       
-       if (unlikely(atomic_read(&buf->unfull))) {
-               atomic_set(&buf->unfull, 0);
-               new = produced % buf->chan->n_subbufs;
-               old = (produced - 1) % buf->chan->n_subbufs;
-               do_switch(buf, new, old);
-               return 0;
-       }
-
-       if (unlikely(relay_buf_full(buf)))
-               return 0;
-
-       old = produced % buf->chan->n_subbufs;
-       padding = buf->chan->subbuf_size - buf->offset;
-       buf->padding[old] = padding;
-       deliver_check(buf, old);
-       buf->offset = buf->chan->subbuf_size;
-       atomic_inc(&buf->subbufs_produced);
-
-       if (waitqueue_active(&buf->read_wait)) {
-               PREPARE_WORK(&buf->wake_readers, wakeup_readers, buf);
-               schedule_delayed_work(&buf->wake_readers, 1);
-       }
-
-       if (unlikely(relay_buf_full(buf))) {
-               void *old_data = buf->start + old * buf->chan->subbuf_size;
-               buf->chan->cb->buf_full(buf, old, old_data);
-               return 0;
-       }
-
-       new = (produced + 1) % buf->chan->n_subbufs;
-       do_switch(buf, new, old);
-
-       if (unlikely(length + buf->offset > buf->chan->subbuf_size))
-         goto toobig;
-
-       return length;
-       
- toobig:
-       printk(KERN_WARNING "relayfs: event too large (%u)\n", length);
-       WARN_ON(1);
-       return 0;
-}
-
-/**
- *     relay_commit - add count bytes to a sub-buffer's commit count
- *     @buf: channel buffer
- *     @reserved: reserved address associated with commit
- *     @count: number of bytes committed
- *
- *     Invokes deliver() callback if sub-buffer is completely written.
- */
-void relay_commit(struct rchan_buf *buf,
-                 void *reserved,
-                 unsigned count)
-{
-       unsigned offset, subbuf_idx;
-
-       offset = reserved - buf->start;
-       subbuf_idx = offset / buf->chan->subbuf_size;
-       buf->commit[subbuf_idx] += count;
-       deliver_check(buf, subbuf_idx);
-}
-
-/**
- *     relay_subbufs_consumed - update the buffer's sub-buffers-consumed count
- *     @chan: the channel
- *     @cpu: the cpu associated with the channel buffer to update
- *     @subbufs_consumed: number of sub-buffers to add to current buf's count
- *
- *     Adds to the channel buffer's consumed sub-buffer count.
- *     subbufs_consumed should be the number of sub-buffers newly consumed,
- *     not the total consumed.
- *
- *     NOTE: kernel clients don't need to call this function if the channel
- *     mode is 'overwrite'.
- */
-void relay_subbufs_consumed(struct rchan *chan, int cpu, int subbufs_consumed)
-{
-       int produced, consumed;
-       struct rchan_buf *buf;
-
-       if (!chan)
-               return;
-
-       if (cpu >= NR_CPUS || !chan->buf[cpu])
-               return;
-
-       buf = chan->buf[cpu];
-       if (relay_buf_full(buf))
-               atomic_set(&buf->unfull, 1);
-
-       atomic_add(subbufs_consumed, &buf->subbufs_consumed);
-       produced = atomic_read(&buf->subbufs_produced);
-       consumed = atomic_read(&buf->subbufs_consumed);
-       if (consumed > produced)
-               atomic_set(&buf->subbufs_consumed, produced);
-}
-
-/**
- *     relay_destroy_channel - free the channel struct
- *
- *     Should only be called from kref_put().
- */
-void relay_destroy_channel(struct kref *kref)
-{
-       struct rchan *chan = container_of(kref, struct rchan, kref);
-       kfree(chan);
-}
-
-/**
- *     relay_close - close the channel
- *     @chan: the channel
- *
- *     Closes all channel buffers and frees the channel.
- */
-void relay_close(struct rchan *chan)
-{
-       int i;
-
-       if (!chan)
-               return;
-
-       for (i = 0; i < NR_CPUS; i++) {
-               if (!chan->buf[i])
-                       continue;
-               relay_close_buf(chan->buf[i]);
-       }
-
-       kref_put(&chan->kref, relay_destroy_channel);
-}
-
-/**
- *     relay_flush - close the channel
- *     @chan: the channel
- *
- *     Flushes all channel buffers i.e. forces buffer switch.
- */
-void relay_flush(struct rchan *chan)
-{
-       int i;
-
-       if (!chan)
-               return;
-
-       for (i = 0; i < NR_CPUS; i++) {
-               if (!chan->buf[i])
-                       continue;
-               relay_switch_subbuf(chan->buf[i], 0);
-       }
-}
-
-EXPORT_SYMBOL_GPL(relay_open);
-EXPORT_SYMBOL_GPL(relay_close);
-EXPORT_SYMBOL_GPL(relay_flush);
-EXPORT_SYMBOL_GPL(relay_reset);
-EXPORT_SYMBOL_GPL(relay_subbufs_consumed);
-EXPORT_SYMBOL_GPL(relay_commit);
-EXPORT_SYMBOL_GPL(relay_switch_subbuf);
diff --git a/runtime/relayfs/relay.h b/runtime/relayfs/relay.h
deleted file mode 100644 (file)
index 703503f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _RELAY_H
-#define _RELAY_H
-
-struct dentry *relayfs_create_file(const char *name,
-                                  struct dentry *parent,
-                                  int mode,
-                                  struct rchan *chan);
-extern int relayfs_remove(struct dentry *dentry);
-extern int relay_buf_empty(struct rchan_buf *buf);
-extern void relay_destroy_channel(struct kref *kref);
-
-#endif /* _RELAY_H */
diff --git a/runtime/relayfs/relayfs.txt b/runtime/relayfs/relayfs.txt
deleted file mode 100644 (file)
index 6d97306..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-
-relayfs - a high-speed data relay filesystem
-============================================
-
-relayfs is a filesystem designed to provide an efficient mechanism for
-tools and facilities to relay large and potentially sustained streams
-of data from kernel space to user space.
-
-The main abstraction of relayfs is the 'channel'.  A channel consists
-of a set of per-cpu kernel buffers each represented by a file in the
-relayfs filesystem.  Kernel clients write into a channel using
-efficient write functions which automatically log to the current cpu's
-channel buffer.  User space applications mmap() the per-cpu files and
-retrieve the data as it becomes available.
-
-The format of the data logged into the channel buffers is completely
-up to the relayfs client; relayfs does however provide hooks which
-allow clients to impose some stucture on the buffer data.  Nor does
-relayfs implement any form of data filtering - this also is left to
-the client.  The purpose is to keep relayfs as simple as possible.
-
-This document provides an overview of the relayfs API.  The details of
-the function parameters are documented along with the functions in the
-filesystem code - please see that for details.
-
-
-The relayfs user space API
-==========================
-
-relayfs implements basic file operations for user space access to
-relayfs channel buffer data.  Here are the file operations that are
-available and some comments regarding their behavior:
-
-open()  enables user to open an _existing_ buffer.
-
-mmap()  results in channel buffer being mapped into the caller's
-        memory space.
-
-poll()  POLLIN/POLLRDNORM/POLLERR supported.  User applications are
-        notified when sub-buffer boundaries are crossed.
-
-close() decrements the channel buffer's refcount.  When the refcount
-       reaches 0 i.e. when no process or kernel client has the buffer
-       open, the channel buffer is freed.
-
-
-In order for a user application to make use of relayfs files, the
-relayfs filesystem must be mounted.  For example,
-
-       mount -t relayfs relayfs /mnt/relay
-
-NOTE:  relayfs doesn't need to be mounted for kernel clients to create
-       or use channels - it only needs to be mounted when user space
-       applications need access to the buffer data.
-
-
-The relayfs kernel API
-======================
-
-Here's a summary of the API relayfs provides to in-kernel clients:
-
-
-  channel management functions:
-
-    relay_open(base_filename, parent, subbuf_size, n_subbufs,
-               overwrite, callbacks)
-    relay_close(chan)
-    relay_flush(chan)
-    relay_reset(chan)
-    relayfs_create_dir(name, parent)
-    relayfs_remove_dir(dentry)
-    relay_commit(buf, reserved, count)
-    relay_subbufs_consumed(chan, cpu, subbufs_consumed)
-
-  write functions:
-
-    relay_write(chan, data, length)
-    __relay_write(chan, data, length)
-    relay_reserve(chan, length)
-
-  callbacks:
-
-    subbuf_start(buf, subbuf, prev_subbuf_idx, prev_subbuf)
-    deliver(buf, subbuf_idx, subbuf)
-    buf_mapped(buf, filp)
-    buf_unmapped(buf, filp)
-    buf_full(buf, subbuf_idx)
-
-
-A relayfs channel is made of up one or more per-cpu channel buffers,
-each implemented as a circular buffer subdivided into one or more
-sub-buffers.
-
-relay_open() is used to create a channel, along with its per-cpu
-channel buffers.  Each channel buffer will have an associated file
-created for it in the relayfs filesystem, which can be opened and
-mmapped from user space if desired.  The files are named
-basename0...basenameN-1 where N is the number of online cpus, and by
-default will be created in the root of the filesystem.  If you want a
-directory structure to contain your relayfs files, you can create it
-with relayfs_create_dir() and pass the parent directory to
-relay_open().  Clients are responsible for cleaning up any directory
-structure they create when the channel is closed - use
-relayfs_remove_dir() for that.
-
-The total size of each per-cpu buffer is calculated by multiplying the
-number of sub-buffers by the sub-buffer size passed into relay_open().
-The idea behind sub-buffers is that they're basically an extension of
-double-buffering to N buffers, and they also allow applications to
-easily implement random-access-on-buffer-boundary schemes, which can
-be important for some high-volume applications.  The number and size
-of sub-buffers is completely dependent on the application and even for
-the same application, different conditions will warrant different
-values for these parameters at different times.  Typically, the right
-values to use are best decided after some experimentation; in general,
-though, it's safe to assume that having only 1 sub-buffer is a bad
-idea - you're guaranteed to either overwrite data or lose events
-depending on the channel mode being used.
-
-relayfs channels can be opened in either of two modes - 'overwrite' or
-'no-overwrite'.  In overwrite mode, writes continuously cycle around
-the buffer and will never fail, but will unconditionally overwrite old
-data regardless of whether it's actually been consumed.  In
-no-overwrite mode, writes will fail i.e. data will be lost, if the
-number of unconsumed sub-buffers equals the total number of
-sub-buffers in the channel.  In this mode, the client is reponsible
-for notifying relayfs when sub-buffers have been consumed via
-relay_subbufs_consumed().  A full buffer will become 'unfull' and
-logging will continue once the client calls relay_subbufs_consumed()
-again.  When a buffer becomes full, the buf_full() callback is invoked
-to notify the client.  In both modes, the subbuf_start() callback will
-notify the client whenever a sub-buffer boundary is crossed.  This can
-be used to write header information into the new sub-buffer or fill in
-header information reserved in the previous sub-buffer.  One piece of
-information that's useful to save in a reserved header slot is the
-number of bytes of 'padding' for a sub-buffer, which is the amount of
-unused space at the end of a sub-buffer.  The padding count for each
-sub-buffer is contained in an array in the rchan_buf struct passed
-into the subbuf_start() callback: rchan_buf->padding[prev_subbuf_idx]
-can be used to to get the padding for the just-finished sub-buffer.
-subbuf_start() is also called for the first sub-buffer in each channel
-buffer when the channel is created.  The mode is specified to
-relay_open() using the overwrite parameter.
-
-kernel clients write data into the current cpu's channel buffer using
-relay_write() or __relay_write().  relay_write() is the main logging
-function - it uses local_irqsave() to protect the buffer and should be
-used if you might be logging from interrupt context.  If you know
-you'll never be logging from interrupt context, you can use
-__relay_write(), which only disables preemption.  These functions
-don't return a value, so you can't determine whether or not they
-failed - the assumption is that you wouldn't want to check a return
-value in the fast logging path anyway, and that they'll always succeed
-unless the buffer is full and in no-overwrite mode, in which case
-you'll be notified via the buf_full() callback.
-
-relay_reserve() is used to reserve a slot in a channel buffer which
-can be written to later.  This would typically be used in applications
-that need to write directly into a channel buffer without having to
-stage data in a temporary buffer beforehand.  Because the actual write
-may not happen immediately after the slot is reserved, applications
-using relay_reserve() can call relay_commit() to notify relayfs when
-the slot has actually been written.  When all the reserved slots have
-been committed, the deliver() callback is invoked to notify the client
-that a guaranteed full sub-buffer has been produced.  Because the
-write is under control of the client and is separated from the
-reserve, relay_reserve() doesn't protect the buffer at all - it's up
-to the client to provide the appropriate synchronization when using
-relay_reserve().
-
-The client calls relay_close() when it's finished using the channel.
-The channel and its associated buffers are destroyed when there are no
-longer any references to any of the channel buffers.  relay_flush()
-forces a sub-buffer switch on all the channel buffers, and can be used
-to finalize and process the last sub-buffers before the channel is
-closed.
-
-Some applications may want to keep a channel around and re-use it
-rather than open and close a new channel for each use.  relay_reset()
-can be used for this purpose - it resets a channel to its initial
-state without reallocating channel buffer memory or destroying
-existing mappings.  It should however only be called when it's safe to
-do so i.e. when the channel isn't currently being written to.
-
-Finally, there are a couple of utility callbacks that can be used for
-different purposes.  buf_mapped() is called whenever a channel buffer
-is mmapped from user space and buf_unmapped() is called when it's
-unmapped.  The client can use this notification to trigger actions
-within the kernel application, such as enabling/disabling logging to
-the channel.
-
-
-Resources
-=========
-
-For news, example code, mailing list, etc. see the relayfs homepage:
-
-    http://relayfs.sourceforge.net
-
-
-Credits
-=======
-
-The ideas and specs for relayfs came about as a result of discussions
-on tracing involving the following:
-
-Michel Dagenais                <michel.dagenais@polymtl.ca>
-Richard Moore          <richardj_moore@uk.ibm.com>
-Bob Wisniewski         <bob@watson.ibm.com>
-Karim Yaghmour         <karim@opersys.com>
-Tom Zanussi            <zanussi@us.ibm.com>
-
-Also thanks to Hubertus Franke for a lot of useful suggestions and bug
-reports.
diff --git a/runtime/stpd/ChangeLog b/runtime/stpd/ChangeLog
deleted file mode 100644 (file)
index 7b60957..0000000
+++ /dev/null
@@ -1,401 +0,0 @@
-2007-03-12  Frank Ch. Eigler  <fche@elastic.org>
-
-       * librelay.c (init_stp): Use /proc/MODULE rather than
-       /proc/systemtap/MODULE.
-
-2006-12-11  Martin Hunt  <hunt@redhat.com>
-
-       * symbols.c (get_sections): Set buffer sizes to large enough
-       sizes to hold all possible values, but also include checks in case
-       we are wrong.
-
-2006-11-15  Martin Hunt  <hunt@redhat.com>
-
-       * symbols.c (do_kernel_symbols): Add sizeof(long) to sym_base
-       to preserve 64-bit alignment.
-
-2006-11-09  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c: Change all references to transport messages
-       to use the new names with "_stp" prefix.
-       (stp_main_loop): For STP_SYMBOLS, check pointer size and 
-       endianess to confirm staprun is compatible with the kernel.
-
-       * librelay.h: Move a bunch of common includes here.
-       * stpd.c: Cleanup includes.
-       * symbols.c: Ditto.
-       
-2006-11-02  Martin Hunt  <hunt@redhat.com>
-
-       * symbols.c: New file. Sends symbol and module information to
-       the systemtap module.
-       
-       * librelay.c (stp_main_loop): Add STP_MODULE and STP_SYMBOLS
-       message handling.
-
-       * librelay.h: Add some new function prototypes.
-
-       * Makefile (CFLAGS): Set to be the same as for building modules.
-       Added symbols.c to sources.
-
-2006-10-10  Tom Zanussi  <zanussi@us.ibm.com>
-       
-       * librelay.c (merge_output): Add check for min when writing
-       output, otherwise last write happens twice.
-
-2006-09-26  David Smith  <dsmith@redhat.com>
-
-       * Makefile: Changed 'stpd' references to 'staprun'.
-       * librelay.c: Ditto.
-       * stpd.c: Ditto.
-       
-2006-09-25  Tom Zanussi  <zanussi@us.ibm.com>
-       
-       * librelay.c (kill_percpu_threads): Remove printf.
-       (wait_for_percpu_threads): New.
-       (process_subbufs): Remove processing, processing_mutex, exit
-       thread if exiting flag set.
-       (read_last_buffers): Removed.
-       (cleanup_and_exit): Remove call to read_last_buffers, wait for
-       threads to read flushed buffers instead.
-       (stp_main_loop): Remove mutex init.     
-
-2006-09-22  Tom Zanussi  <zanussi@us.ibm.com>
-       
-       * librelay.c (init_relayfs): Cleanup if stp_check fails.
-
-2006-09-19  Tom Zanussi  <zanussi@us.ibm.com>
-       
-       * librelay.c (init_relayfs): Add debugfs path to relay files and
-       add new systemtap directory to path.
-       (init_stp): rmmod module on failure.
-       (merge_output): Remove debugging printfs left in code.
-       (close_relay_files): Clear relay_file descriptor after close.
-       (cleanup_and_exit): Allow cleanup and exit even if there was an
-       error opening relay files.
-       (stp_main_loop): Call cleanup_and_exit() if init_relayfs() fails.
-
-2006-09-18  Martin Hunt  <hunt@redhat.com>
-
-       * stpd.c (usage): Remove "-m" option.
-       (main): Print warning if "-m" is used.
-       * librelay.c (merge_output): Rewrite to handle
-       new format that support binary.
-       (stp_main_loop): Read merge option from the
-       transport info message.
-
-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
-       stpd_filebase.
-
-2006-07-20  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (stp_main_loop): If module doesn't start, kill any
-       target command.
-
-2006-06-23  Tom Zanussi  <zanussi@us.ibm.com>
-
-       * librelay.c (cleanup_and_exit): Close relay files even if
-       not merging.
-
-2006-06-13  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (start_cmd): Rewrite using sigwait() to eliminate
-       a race.
-
-2006-05-18  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (stp_main_loop): Set output to always be line
-       buffered.
-
-2006-04-08  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (stp_main_loop): Write with fwrite() instead 
-       of fputs() so we can write binary data.
-
-2006-04-05  Martin Hunt  <hunt@redhat.com>
-       * librelay.c (merge_output): Remove ANSI codes and write
-       warning to stderr.
-
-2006-04-05  Martin Hunt  <hunt@redhat.com>     
-       * librelay.c (merge_output): Set the output filename if necessary.
-       (merge_output): 
-
-       * stpd.c (main): Don't reset output_filename just because 
-       relayfs is possible. Move that code to librelay.c.
-
-2006-04-04  Roland McGrath  <roland@redhat.com>
-
-       * stpd.c (main): Cast f_type when comparing; type differs by machine.
-
-2006-04-04  Tom Zanussi  <zanussi@us.ibm.com>
-
-       * stpd.c (main): Check that /mnt/relay is actually relayfs.
-
-2006-03-15  Tom Zanussi  <zanussi@us.ibm.com>
-
-       * stpd.c (main): Add runtime check for relayfs vs relay-on-proc.
-
-2006-03-06  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (start_cmd): Set proper uid/gid before execing
-       command.
-       (system_cmd): New function.
-       (cleanup_and_exit): Wait for any child processes to complete.
-       (stp_main_loop): Recognize STP_SYSTEM message.
-
-       * stpd.c (main): Add support for "-u username".
-
-2006-02-25  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (init_stp): Better error handling and cleanup.
-
-2006-02-23  Frank Ch. Eigler  <fche@elastic.org>
-
-       PR 1304
-       * stpd.c (mdooptions): New array.
-       (main): Populate it with leftover arguments.
-       * librelay.c (init_stp): Pass it to execve().
-
-2005-12-08  Frank Ch. Eigler  <fche@elastic.org>
-
-       PR 1937
-       * stpd.c (main): Support new "-d" option.
-       (usage): Document it.
-       * librelay.c (driver_poll): New function to react to death of
-       driver process.
-       (stp_main_loop): Call it if "-d PID" given.  Treat SIGHUP like others.
-
-2005-10-19  Tom Zanussi  <zanussi@us.ibm.com>
-
-       * librelay.c: Move output_file var to stpd.c.
-       (stp_main_loop): If the output_file option was specified,
-       and streaming mode is being used, send output to the file
-       instead of stdout.  If !streaming, send output to the file
-       instead of probe.out.
-       * stpd.c (usage): Add comment for -o option.
-       (main): Add -o option.
-
-2005-10-19  Tom Zanussi  <zanussi@us.ibm.com>
-
-       * librelay.c (merge_output): Switch to binary TIMESTAMP.
-       * stp_dump.c (main): Switch to binary TIMESTAMP.
-       * stp_merge.c (main): Switch to binary TIMESTAMP.
-
-2005-10-14  Tom Zanussi  <zanussi@us.ibm.com>
-
-       PR 1476
-       * librelay.c: Add flag for buffer processing.
-       (reader_thread): Disable/enable cancel state around buffer
-       processing, and update flag to show we're busy processing.
-       (cleanup_and_exit): Wait for any threads busy processing.
-       (stp_main_loop): Initialize processing mutex.
-
-2005-09-06  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c: Remove all USE_PROCFS ifdefs.
-       (sig_usr): Signal handler for SIGUSR1.
-       (start_cmd): New function to handle "-c" option, forks()
-       off a new process then waits for SIGUSR1 to exec it.
-       (init_stp): Call start_cmd().
-       (stp_main_loop): Set a signal handler for SIGCHLD.
-
-       * stpd.c (main): Add "-t" and "-c" options.
-       (usage): Update with new options.
-
-2005-08-29  Martin Hunt  <hunt@redhat.com>
-
-       * stpd.c main): Add enable_relayfs flag.
-       Turn it off with "-r".
-
-2005-08-24  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (sigproc): Removed the "Exiting..."
-       message for now.
-
-2005-08-24  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (sigproc): Reestablish signal handler so
-       impatient people don't hit ^C twice and terminate the
-       program before it saves the data and removes the module.
-       Also print a message to stderr that it is exiting.
-       (stp_main_loop): Write OOB data (warnings, errors, etc)
-       to stderr instead of stdout.
-       * librelay.h: Write debug info to stderr.
-       * Makefile: add librelay.h to dependencies.
-
-2005-08-23  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (merge_output): Don't add an extra \n.
-
-2005-08-23  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (read_last_buffers): New function. Directly grab the
-       last buffers.
-       (info_pending): Deleted.
-       (request_last_buffers): Deleted.
-
-2005-08-22  Martin Hunt  <hunt@redhat.com>
-
-       * Makefile (debug): Add debug target.
-       * librelay.h (dbug): Define.
-       * librelay.c: Enable some dbug lines.
-
-2005-08-19  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (reader_thread): Check the return value for write().
-
-2005-08-19  Frank Ch. Eigler  <fche@elastic.org>
-
-       * librelay.c (modpath): New global.  Use it for insmod only.
-       * stpd.c (main): Set both modpath and modname, to support
-       modules specified by full path name.
-
-2005-08-19  Martin Hunt  <hunt@redhat.com>
-
-       * stpd.c (main): Simplify buffer size code.
-       * librelay.c: Major changes to support procfs instead of netlink.
-
-2005-08-03  Tom Zanussi  <trz@us.ibm.com>
-
-       * librelay.c: Track subbuf info requests/replies
-       so we know unequivocally when it's ok to do final
-       processing.
-       (reader_thread): Remove buffer-full warning.
-
-2005-08-03  Martin Hunt  <hunt@redhat.com>
-       * librelay.c (init_stp): Change variable name to eliminate shadow warning.
-
-2005-08-03  Martin Hunt  <hunt@redhat.com>
-       * librelay.c (open_control_channel): Set the receive buffer
-       to 512K, or the max allowed.
-
-       * stpd.c: Remove "-n" subbug option and change "-b" option
-       so you can specify buffering in different ways. Add a verbose option.
-       Exec the "stp_check" script.
-
-2005-08-01  Frank Ch. Eigler  <fche@redhat.com>
-
-       * librelay.c: Correct fwrite api usage.
-       * all: Correct copyright holder name.
-
-2005-08-01  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.h: Get structs and enums from
-       ../transport/transport_msgs.h  to eliminate duplication.
-
-       * librelay.c (send_request): Retry if send fails.
-       (open_relayfs_files): Use fopen() instead of open() for the
-       percpu tmpfiles.
-       (request_last_buffers): Just send cpu number for STP_BUF_INFO request.
-       (reader_thread): Ditto.
-       (process_subbufs): Use fwrite_unlocked() instead of write().
-       (sigchld): Removed.
-       (init_stp): Go back to using system() instead of fork and exec
-       to load module. When done, send a TRANSPORT_INFO request.
-       (cleanup_and_exit): Change parameter to simple flag to
-       indicate if the module needs removing.
-       (sigproc): Remove complicated logic and just send STP_EXIT.
-       (stp_main_loop): When receiving STP_TRANSPORT_INFO, set
-       the local params and reply with a STP_START.  When
-       receiving STP_START, there was an error, so cleanup and exit.
-
-       * stpd.c (main): Added new options to set number of
-       buffers and their size.
-
-2005-07-29  Roland McGrath  <roland@redhat.com>
-
-       * librelay.c (process_subbufs): Use unsigned for I.
-       (sigproc): Add  __attribute__((unused)) on parameter.
-       (sigchld): Likewise.  Avoid shadowing global variable name.
-       (stp_main_loop): Add a cast.
-
-2005-07-18  Martin Hunt  <hunt@redhat.com>
-
-       * stp_merge.c (main): Fix dropped count calculation.
-
-2005-07-14  Tom Zanussi  <zanussi@us.ibm.com>
-
-       * librelay.c (reader_thread): Add missing pthread_mutex_lock
-
-2005-07-14  Frank Ch. Eigler  <fche@redhat.com>
-
-       * stpd.c (main): Pass !quiet mode to init_stp().
-       * librelay.c (init_relayfs): Be quiet if !print_totals.
-
-2005-07-13  Martin Hunt  <hunt@redhat.com>
-
-       * stpd.c (usage): Fix usage string.
-
-       * librelay.c (init_stp): Change last arg to NULL, not 0.
-
-2005-07-08  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (sigchld): Signal handler to detect
-       completion of module loading.
-       (init_stp): Use fork/exec instead of system() so
-       we can get async signal of module load success/failure.
-       (cleanup_and_exit): New function.
-       (sigproc): If module is not loaded, don't send message to it.
-       (stp_main_loop): Call cleanup_and_exit() when STP_EXIT
-       is received. Don't send a request for the transport
-       mode. The module will send notification to the daemon
-       when it is ready.
-
-       * stpd.c (main): Don't print message until module
-       is loaded.
-
-2005-07-01  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c: Removed the color coding of cpu output.
-
-2005-06-28  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (merge_output): Use unlocked stdio
-       to improve speed.
-
-       * stp_merge.c: New file.
-
-       * Makefile: Add stp_merge.
-
-2005-06-27  Martin Hunt  <hunt@redhat.com>
-
-       * stpd.c (main): Add new command line arg, "-m"
-       to disable the per-cpu merging.
-
-       * librelay.c (merge_output): Replacement for sort_output().
-       Efficiently merges per-cpu streams.
-
-
-2005-06-20  Tom Zanussi  <zanussi@us.ibm.com>
-
-       * librelay.c: Large refactoring, important changes are
-       added transport_mode command, for relayfs transport
-       display results only when probe completes and/or write
-       output file, merge, sort and delete the per-cpu files
-       in postprocessing, refactor so that relayfs files aren't
-       created until transport command received, removed sigalrm,
-       read the final subbuffers on exit
-
-       * stpd.c: Remove all command-line args except for -p
-       and -q as well as all code related to buffer sizes.
-
-       * librelay.h: Add transport mode command and struct.
-
-2005-05-16  Martin Hunt  <hunt@redhat.com>
-
-       * librelay.c (sigproc): If STP_EXIT send fails, keep retrying
-       every 10ms.
-       (init_stp): Don't set n_subbufs and subbuf_size params.
diff --git a/runtime/stpd/Makefile b/runtime/stpd/Makefile
deleted file mode 100644 (file)
index 48613a0..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-CFLAGS = -Wall -std=gnu99 -D_GNU_SOURCE -fexceptions -Wall -Werror -Wshadow -Wunused
-
-all: staprun stp_merge stp_dump
-
-staprun: stpd.c librelay.c symbols.c ../transport/transport_msgs.h librelay.h
-       gcc -O3 $(CFLAGS) -o staprun stpd.c librelay.c symbols.c -lpthread
-
-stp_merge: stp_merge.c
-       gcc -O3 $(CFLAGS) -o stp_merge stp_merge.c
-
-stp_dump: stp_dump.c
-       gcc -O3 $(CFLAGS) -o stp_dump stp_dump.c
-
-debug: stpd.c librelay.c symbols.c ../transport/transport_msgs.h librelay.h
-       gcc -g -D DEBUG $(CFLAGS) -o staprun stpd.c librelay.c symbols.c -lpthread      
-
-clean:
-       /bin/rm -f staprun stp_merge *.o *~
diff --git a/runtime/stpd/librelay.c b/runtime/stpd/librelay.c
deleted file mode 100644 (file)
index 6acbe7f..0000000
+++ /dev/null
@@ -1,861 +0,0 @@
-/*
- * libstp - staprun 'library'
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright (C) IBM Corporation, 2005
- * Copyright (C) Red Hat Inc, 2005, 2006
- *
- */
-#include "librelay.h"
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-#include <linux/fd.h>
-#include <sys/mman.h>
-#include <sys/poll.h>
-#include <pthread.h>
-#include <sys/socket.h>
-#include <linux/types.h>
-#include <linux/limits.h>
-#include <sys/wait.h>
-#include <sys/statfs.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
-
-/* relayfs parameters */
-static struct params
-{
-       unsigned subbuf_size;
-       unsigned n_subbufs;
-       int merge;
-       char relay_filebase[256];
-} params;
-
-/* temporary per-cpu output written here for relayfs, filebase0...N */
-static char *percpu_tmpfilebase = "stpd_cpu";
-
-/* procfs files */
-static char proc_filebase[128];
-static int proc_file[NR_CPUS];
-
-/* probe output written here, if non-NULL */
-/* if no output file name is specified, use this */
-#define DEFAULT_RELAYFS_OUTFILE_NAME "probe.out"
-extern char *outfile_name;
-
-/* internal variables */
-static int transport_mode;
-static int ncpus;
-static int print_totals;
-static int exiting;
-
-/* per-cpu data */
-static int relay_file[NR_CPUS];
-static FILE *percpu_tmpfile[NR_CPUS];
-static char *relay_buffer[NR_CPUS];
-static pthread_t reader[NR_CPUS];
-
-/* control channel */
-int control_channel;
-
-/* flags */
-extern int print_only, quiet, verbose;
-extern unsigned int buffer_size;
-extern char *modname;
-extern char *modpath;
-extern char *modoptions[];
-extern int target_pid;
-extern int driver_pid;
-extern char *target_cmd;
-
-/* uid/gid to use when execing external programs */
-extern uid_t cmd_uid;
-extern gid_t cmd_gid;
-
-/* per-cpu buffer info */
-static struct buf_status
-{
-       struct _stp_buf_info info;
-       unsigned max_backlog; /* max # sub-buffers ready at one time */
-} status[NR_CPUS];
-
-
-
-/**
- *     streaming - is the current transport mode streaming or not?
- *
- *     Returns 1 if in streaming mode, 0 otherwise.
- */
-static int streaming(void)
-{
-       if (transport_mode == STP_TRANSPORT_PROC)
-               return 1;
-
-       return 0;
-}
-
-/**
- *     send_request - send request to kernel over control channel
- *     @type: the relay-app command id
- *     @data: pointer to the data to be sent
- *     @len: length of the data to be sent
- *
- *     Returns 0 on success, negative otherwise.
- */
-int send_request(int type, void *data, int len)
-{
-       char buf[1024];
-       memcpy(buf, &type, 4);
-       memcpy(&buf[4],data,len);
-       return write(control_channel, buf, len+4);
-}
-
-
-/**
- *     summarize - print a summary if applicable
- */
-static void summarize(void)
-{
-       int i;
-
-       if (transport_mode != STP_TRANSPORT_RELAYFS)
-               return;
-
-       printf("summary:\n");
-       for (i = 0; i < ncpus; i++) {
-               printf("cpu %u:\n", i);
-               printf("    %u sub-buffers processed\n",
-                      status[i].info.consumed);
-               printf("    %u max backlog\n", status[i].max_backlog);
-       }
-}
-
-static void close_proc_files()
-{
-       int i;
-       for (i = 0; i < ncpus; i++)
-         close(proc_file[i]);
-}
-
-/**
- *     close_relayfs_files - close and munmap buffer and open output file
- */
-static void close_relayfs_files(int cpu)
-{
-       size_t total_bufsize = params.subbuf_size * params.n_subbufs;
-       
-       munmap(relay_buffer[cpu], total_bufsize);
-       close(relay_file[cpu]);
-       relay_file[cpu] = 0;
-       fclose(percpu_tmpfile[cpu]);
-}
-
-/**
- *     close_all_relayfs_files - close and munmap buffers and output files
- */
-static void close_all_relayfs_files(void)
-{
-       int i;
-
-       if (!streaming()) {
-               for (i = 0; i < ncpus; i++)
-                       close_relayfs_files(i);
-       }
-}
-
-/**
- *     open_relayfs_files - open and mmap buffer and open output file
- */
-static int open_relayfs_files(int cpu, const char *relay_filebase)
-{
-       size_t total_bufsize;
-       char tmp[PATH_MAX];
-
-       memset(&status[cpu], 0, sizeof(struct buf_status));
-       status[cpu].info.cpu = cpu;
-
-       sprintf(tmp, "%s%d", relay_filebase, cpu);
-       relay_file[cpu] = open(tmp, O_RDONLY | O_NONBLOCK);
-       if (relay_file[cpu] < 0) {
-               fprintf(stderr, "ERROR: couldn't open relayfs file %s: errcode = %s\n", tmp, strerror(errno));
-               return -1;
-       }
-
-       sprintf(tmp, "%s/%d", proc_filebase, cpu);
-       dbug("Opening %s.\n", tmp); 
-       proc_file[cpu] = open(tmp, O_RDWR | O_NONBLOCK);
-       if (proc_file[cpu] < 0) {
-               fprintf(stderr, "ERROR: couldn't open proc file %s: errcode = %s\n", tmp, strerror(errno));
-               return -1;
-       }
-
-       sprintf(tmp, "%s%d", percpu_tmpfilebase, cpu);  
-       if((percpu_tmpfile[cpu] = fopen(tmp, "w+")) == NULL) {
-               fprintf(stderr, "ERROR: Couldn't open output file %s: errcode = %s\n", tmp, strerror(errno));
-               close(relay_file[cpu]);
-               return -1;
-       }
-
-       total_bufsize = params.subbuf_size * params.n_subbufs;
-       relay_buffer[cpu] = mmap(NULL, total_bufsize, PROT_READ,
-                                MAP_PRIVATE | MAP_POPULATE, relay_file[cpu],
-                                0);
-       if(relay_buffer[cpu] == MAP_FAILED)
-       {
-               fprintf(stderr, "ERROR: couldn't mmap relay file, total_bufsize (%d) = subbuf_size (%d) * n_subbufs(%d), error = %s \n", (int)total_bufsize, (int)params.subbuf_size, (int)params.n_subbufs, strerror(errno));
-               close(relay_file[cpu]);
-               fclose(percpu_tmpfile[cpu]);
-               return -1;
-       }
-
-       return 0;
-}
-
-/**
- *     delete_percpu_files - delete temporary per-cpu output files
- *
- *     Returns 0 if successful, -1 otherwise.
- */
-static int delete_percpu_files(void)
-{
-       int i;
-       char tmp[PATH_MAX];
-
-       for (i = 0; i < ncpus; i++) {
-               sprintf(tmp, "%s%d", percpu_tmpfilebase, i);
-               if (unlink(tmp) < 0) {
-                       fprintf(stderr, "ERROR: couldn't unlink percpu file %s: errcode = %s\n", tmp, strerror(errno));
-                       return -1;
-               }
-       }
-       return 0;
-}
-
-/**
- *     kill_percpu_threads - kill per-cpu threads 0->n-1
- *     @n: number of threads to kill
- *
- *     Returns number of threads killed.
- */
-static int kill_percpu_threads(int n)
-{
-       int i, killed = 0;
-
-       for (i = 0; i < n; i++) {
-               if (pthread_cancel(reader[i]) == 0)
-                       killed++;
-       }
-
-       return killed;
-}
-
-/**
- *     wait_for_percpu_threads - wait for all threads to exit
- *     @n: number of threads to wait for
- */
-static void wait_for_percpu_threads(int n)
-{
-       int i;
-
-       for (i = 0; i < n; i++)
-               pthread_join(reader[i], NULL);
-}
-
-/**
- *     process_subbufs - write ready subbufs to disk
- */
-static int process_subbufs(struct _stp_buf_info *info)
-{
-       unsigned subbufs_ready, start_subbuf, end_subbuf, subbuf_idx, i;
-       int len, cpu = info->cpu;
-       char *subbuf_ptr;
-       int subbufs_consumed = 0;
-       unsigned padding;
-
-       subbufs_ready = info->produced - info->consumed;
-       start_subbuf = info->consumed % params.n_subbufs;
-       end_subbuf = start_subbuf + subbufs_ready;
-
-       for (i = start_subbuf; i < end_subbuf; i++) {
-               subbuf_idx = i % params.n_subbufs;
-               subbuf_ptr = relay_buffer[cpu] + subbuf_idx * params.subbuf_size;
-               padding = *((unsigned *)subbuf_ptr);
-               subbuf_ptr += sizeof(padding);
-               len = (params.subbuf_size - sizeof(padding)) - padding;
-               if (len) {
-                       if (fwrite_unlocked (subbuf_ptr, len, 1, percpu_tmpfile[cpu]) != 1) {
-                               fprintf(stderr, "ERROR: couldn't write to output file for cpu %d, exiting: errcode = %d: %s\n", cpu, errno, strerror(errno));
-                               exit(1);
-                       }
-               }
-               subbufs_consumed++;
-       }
-
-       return subbufs_consumed;
-}
-
-/**
- *     reader_thread - per-cpu channel buffer reader
- */
-static void *reader_thread(void *data)
-{
-       int rc;
-       int cpu = (long)data;
-       struct pollfd pollfd;
-       struct _stp_consumed_info consumed_info;
-       unsigned subbufs_consumed;
-
-       pollfd.fd = relay_file[cpu];
-       pollfd.events = POLLIN;
-
-       do {
-               rc = poll(&pollfd, 1, -1);
-               if (rc < 0) {
-                       if (errno != EINTR) {
-                               fprintf(stderr, "ERROR: poll error: %s\n",
-                                       strerror(errno));
-                               exit(1);
-                       }
-                       fprintf(stderr, "WARNING: poll warning: %s\n",
-                               strerror(errno));
-                       rc = 0;
-               }
-
-               rc = read(proc_file[cpu], &status[cpu].info,
-                         sizeof(struct _stp_buf_info));
-               subbufs_consumed = process_subbufs(&status[cpu].info);
-               if (subbufs_consumed) {
-                       if (subbufs_consumed > status[cpu].max_backlog)
-                               status[cpu].max_backlog = subbufs_consumed;
-                       status[cpu].info.consumed += subbufs_consumed;
-                       consumed_info.cpu = cpu;
-                       consumed_info.consumed = subbufs_consumed;
-                       if (write (proc_file[cpu], &consumed_info, sizeof(struct _stp_consumed_info)) < 0)
-                               fprintf(stderr,"WARNING: writing consumed info failed.\n");
-               }
-               if (status[cpu].info.flushing)
-                       pthread_exit(NULL);
-       } while (1);
-}
-
-#define RELAYFS_MAGIC                  0xF0B4A981
-#define DEBUGFS_MAGIC                  0x64626720
-/**
- *     init_relayfs - create files and threads for relayfs processing
- *
- *     Returns 0 if successful, negative otherwise
- */
-int init_relayfs(void)
-{
-       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);
-               return -1;
-       }
-
-       if (statfs("/mnt/relay", &st) == 0 && (int) st.f_type == (int) RELAYFS_MAGIC)
-               sprintf(params.relay_filebase, "/mnt/relay/systemtap/%d/cpu", getpid());
-       else if (statfs("/sys/kernel/debug", &st) == 0 && (int) st.f_type == (int) DEBUGFS_MAGIC)
-               sprintf(params.relay_filebase, "/sys/kernel/debug/systemtap/%d/cpu", getpid());
-       else
-               sprintf(params.relay_filebase, "/debug/systemtap/%d/cpu", getpid());
-       
-       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);
-                       goto err;
-               }
-               /* create a thread for each per-cpu buffer */
-               if (pthread_create(&reader[i], NULL, reader_thread, (void *)(long)i) < 0) {
-                       close_relayfs_files(i);
-                       fprintf(stderr, "ERROR: Couldn't create reader thread, cpu = %d\n", i);
-                       goto err;
-               }
-       }
-
-        if (print_totals && verbose)
-          printf("Using channel with %u sub-buffers of size %u.\n",
-                 params.n_subbufs, params.subbuf_size);
-
-       return 0;
-err:
-       for (j = 0; j < i; j++)
-               close_relayfs_files(j);
-       kill_percpu_threads(i);
-
-       return -1;
-}
-
-void start_cmd(void)
-{
-       pid_t pid;
-       sigset_t usrset;
-               
-       sigemptyset(&usrset);
-       sigaddset(&usrset, SIGUSR1);
-       sigprocmask(SIG_BLOCK, &usrset, NULL);
-
-       dbug ("execing target_cmd %s\n", target_cmd);
-       if ((pid = fork()) < 0) {
-               perror ("fork");
-               exit(-1);
-       } else if (pid == 0) {
-               int signum;
-
-               if (setregid(cmd_gid, cmd_gid) < 0) {
-                       perror("setregid");
-               }
-               if (setreuid(cmd_uid, cmd_uid) < 0) {
-                       perror("setreuid");
-               }
-               /* wait here until signaled */
-               sigwait(&usrset, &signum);
-
-               if (execl("/bin/sh", "sh", "-c", target_cmd, NULL) < 0)
-                       perror(target_cmd);
-               _exit(-1);
-       }
-       target_pid = pid;
-}
-
-void system_cmd(char *cmd)
-{
-       pid_t pid;
-
-       dbug ("system %s\n", cmd);
-       if ((pid = fork()) < 0) {
-               perror ("fork");
-       } else if (pid == 0) {
-               if (setregid(cmd_gid, cmd_gid) < 0) {
-                       perror("setregid");
-               }
-               if (setreuid(cmd_uid, cmd_uid) < 0) {
-                       perror("setreuid");
-               }
-               if (execl("/bin/sh", "sh", "-c", cmd, NULL) < 0)
-                       perror(cmd);
-               _exit(-1);
-       }
-}
-
-/**
- *     init_stp - initialize the app
- *     @print_summary: boolean, print summary or not at end of run
- *
- *     Returns 0 on success, negative otherwise.
- */
-int init_stp(int print_summary)
-{
-       char buf[1024];
-       struct _stp_transport_info ti;
-       pid_t pid;
-       int rstatus;
-
-       ncpus = sysconf(_SC_NPROCESSORS_ONLN);
-       print_totals = print_summary;
-
-       /* insert module */
-       sprintf(buf, "_stp_pid=%d", (int)getpid());
-        modoptions[0] = "insmod";
-        modoptions[1] = modpath;
-        modoptions[2] = buf;
-        /* modoptions[3...N] set by command line parser. */
-
-       if ((pid = fork()) < 0) {
-               perror ("fork");
-               exit(-1);
-       } else if (pid == 0) {
-               if (execvp("/sbin/insmod",  modoptions) < 0)
-                       _exit(-1);
-       }
-       if (waitpid(pid, &rstatus, 0) < 0) {
-               perror("waitpid");
-               exit(-1);
-       }
-       if (WIFEXITED(rstatus) && WEXITSTATUS(rstatus)) {
-               fprintf(stderr, "ERROR, couldn't insmod probe module %s\n", modpath);
-               return -1;
-       }
-
-        /* We no longer use /proc/systemtap/, just /proc.  */
-       sprintf (proc_filebase, "/proc/%s", modname);
-       char *ptr = index(proc_filebase,'.');
-       if (ptr)
-               *ptr = 0;
-
-       sprintf(buf, "%s/cmd", proc_filebase);
-       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));
-               goto do_rmmod;
-       }
-
-       /* start target_cmd if necessary */
-       if (target_cmd)
-               start_cmd();
-
-       /* now send TRANSPORT_INFO */
-       ti.buf_size = buffer_size;
-       ti.subbuf_size = 0;
-       ti.n_subbufs = 0;
-       ti.target = target_pid;
-       if (send_request(STP_TRANSPORT_INFO, &ti, sizeof(ti)) < 0) {
-               fprintf(stderr, "staprun failed because TRANSPORT_INFO returned an error.\n");
-               if (target_cmd)
-                       kill (target_pid, SIGKILL);
-               close(control_channel);
-               goto do_rmmod;
-       }
-       return 0;
-
- do_rmmod:
-       snprintf(buf, sizeof(buf), "/sbin/rmmod -w %s", modname);
-       if (system(buf))
-               fprintf(stderr, "ERROR: couldn't rmmod probe module %s.\n", modname);
-       return -1;
-}
-
-
-/* length of timestamp in output field 0 */
-#define TIMESTAMP_SIZE (sizeof(uint32_t))
-
-/**
- *     merge_output - merge per-cpu output
- *
- */
-#define MERGE_BUF_SIZE 16*1024
-static int merge_output(void)
-{
-       char *buf[ncpus], tmp[PATH_MAX];
-       int i, j, dropped=0;
-       uint32_t count=0, min, num[ncpus];
-       FILE *ofp, *fp[ncpus];
-       uint32_t length[ncpus];
-
-       for (i = 0; i < ncpus; i++) {
-               sprintf (tmp, "%s%d", percpu_tmpfilebase, i);
-               fp[i] = fopen (tmp, "r");
-               if (!fp[i]) {
-                       fprintf (stderr, "error opening file %s.\n", tmp);
-                       return -1;
-               }
-               num[i] = 0;
-               buf[i] = malloc(MERGE_BUF_SIZE);
-               if (!buf[i]) {
-                       fprintf(stderr,"Out of memory in merge_output(). Aborting merge.\n");
-                       printf("Out of memory in merge_output(). Aborting merge.\n");
-                       return -1;
-               }
-
-               if (fread_unlocked (&length[i], sizeof(uint32_t), 1, fp[i])) {
-                       if (fread_unlocked (buf[i], length[i]+TIMESTAMP_SIZE, 1, fp[i]))
-                               num[i] = *((uint32_t *)buf[i]);
-               }
-       }
-
-       if (!outfile_name)
-               outfile_name = DEFAULT_RELAYFS_OUTFILE_NAME;
-
-       ofp = fopen (outfile_name, "w");
-       if (!ofp) {
-               fprintf (stderr, "ERROR: couldn't open output file %s: errcode = %s\n",
-                        outfile_name, strerror(errno));
-               return -1;
-       }
-
-       do {
-               min = num[0];
-               j = 0;
-               for (i = 1; i < ncpus; i++) {
-                       if (min == 0 || (num[i] && num[i] < min)) {
-                               min = num[i];
-                               j = i;
-                       }
-               }
-
-               if (min && !quiet)
-                       fwrite_unlocked (buf[j]+TIMESTAMP_SIZE, length[j], 1, stdout);
-               if (min && !print_only)
-                       fwrite_unlocked (buf[j]+TIMESTAMP_SIZE, length[j], 1, ofp);
-               
-               if (min && ++count != min) {
-                       count = min;
-                       dropped++ ;
-               }
-
-               num[j] = 0;
-               if (fread_unlocked (&length[j], sizeof(uint32_t), 1, fp[j])) {
-                       if (fread_unlocked (buf[j], length[j]+TIMESTAMP_SIZE, 1, fp[j]))
-                               num[j] = *((uint32_t *)buf[j]);
-               }
-       } while (min);
-
-       if (!print_only)
-               fwrite_unlocked ("\n", 1, 1, ofp);
-
-       for (i = 0; i < ncpus; i++)
-               fclose (fp[i]);
-       fclose (ofp);
-
-       if (dropped)
-               fprintf (stderr, "Sequence had %d drops.\n", dropped);
-
-       return 0;
-}
-
-void cleanup_and_exit (int closed)
-{
-       char tmpbuf[128];
-       pid_t err;
-
-       if (exiting)
-               return;
-       exiting = 1;
-
-       dbug("CLEANUP AND EXIT  closed=%d mode=%d\n", closed, transport_mode);
-
-       /* what about child processes? we will wait for them here. */
-       err = waitpid(-1, NULL, WNOHANG);
-       if (err >= 0)
-               fprintf(stderr,"\nWaititing for processes to exit\n");
-       while(wait(NULL) > 0);
-
-       if (transport_mode == STP_TRANSPORT_RELAYFS && relay_file[0] > 0)
-               wait_for_percpu_threads(ncpus);
-
-       close_proc_files();
-
-       if (print_totals && verbose)
-               summarize();
-
-       if (transport_mode == STP_TRANSPORT_RELAYFS && relay_file[0] > 0) {
-               close_all_relayfs_files();
-               if (params.merge) {
-                       merge_output();
-                       delete_percpu_files();
-               }
-       }
-
-       dbug("closing control channel\n");
-       close(control_channel);
-
-       if (!closed) {
-               snprintf(tmpbuf, sizeof(tmpbuf), "/sbin/rmmod -w %s", modname);
-               if (system(tmpbuf)) {
-                       fprintf(stderr, "ERROR: couldn't rmmod probe module %s.  No output will be written.\n",
-                               modname);
-                       exit(1);
-               }
-       }
-       exit(0);
-}
-
-static void sigproc(int signum)
-{
-       if (signum == SIGCHLD) {
-               pid_t pid = waitpid(-1, NULL, WNOHANG);
-               if (pid != target_pid)
-                       return;
-       }
-       send_request(STP_EXIT, NULL, 0);
-}
-
-static void driver_poll (int signum __attribute__((unused)))
-{
-       /* See if the driver process is still alive.  If not, time to exit.  */
-       if (kill (driver_pid, 0) < 0) {
-               send_request(STP_EXIT, NULL, 0);
-               return;
-       } else  {
-               /* Check again later. Use any reasonable poll interval */
-               signal (SIGALRM, driver_poll);
-               alarm (10); 
-       }
-}
-
-
-/**
- *     stp_main_loop - loop forever reading data
- */
-static char recvbuf[8192];
-
-int stp_main_loop(void)
-{
-       int nb, rc;
-       void *data;
-       int type;
-       FILE *ofp = stdout;
-
-       setvbuf(ofp, (char *)NULL, _IOLBF, 0);
-
-       signal(SIGINT, sigproc);
-       signal(SIGTERM, sigproc);
-       signal(SIGCHLD, sigproc);
-       signal(SIGHUP, sigproc);
-
-        if (driver_pid)
-          driver_poll(0); // And by the way, I'm also the signal handler.
-
-       dbug("in main loop\n");
-
-       while (1) { /* handle messages from control channel */
-               nb = read(control_channel, recvbuf, sizeof(recvbuf));
-               if (nb <= 0) {
-                       perror("recv");
-                       fprintf(stderr, "WARNING: unexpected EOF. nb=%d\n", nb);
-                       continue;
-               }
-
-               type = *(int *)recvbuf;
-               data = (void *)(recvbuf + sizeof(int));
-
-               if (!transport_mode && type != STP_TRANSPORT_INFO && type != STP_EXIT) {
-                       fprintf(stderr, "WARNING: invalid stp command: no transport\n");
-                       continue;
-               }
-
-               switch (type) {
-               case STP_REALTIME_DATA:
-                       fwrite_unlocked(data, nb - sizeof(int), 1, ofp);
-                       break;
-               case STP_OOB_DATA:
-                       fputs ((char *)data, stderr);
-                       break;
-               case STP_EXIT: 
-               {
-                       /* module asks us to unload it and exit */
-                       int *closed = (int *)data;
-                       cleanup_and_exit(*closed);
-                       break;
-               }
-               case STP_START: 
-               {
-                       struct _stp_transport_start *t = (struct _stp_transport_start *)data;
-                       dbug("probe_start() returned %d\n", t->pid);
-                       if (t->pid < 0) {
-                               if (target_cmd)
-                                       kill (target_pid, SIGKILL);
-                               cleanup_and_exit(0);
-                       } else if (target_cmd)
-                               kill (target_pid, SIGUSR1);
-                       break;
-               }
-               case STP_SYSTEM:
-               {
-                       struct _stp_cmd_info *c = (struct _stp_cmd_info *)data;
-                       system_cmd(c->cmd);
-                       break;
-               }
-               case STP_TRANSPORT_INFO:
-               {
-                       struct _stp_transport_info *info = (struct _stp_transport_info *)data;
-                       struct _stp_transport_start ts;
-                       transport_mode = info->transport_mode;
-                       params.subbuf_size = info->subbuf_size;
-                       params.n_subbufs = info->n_subbufs;
-                       params.merge = info->merge;
-#ifdef DEBUG
-                       if (transport_mode == STP_TRANSPORT_RELAYFS) {
-                               fprintf(stderr,"TRANSPORT_INFO recvd: RELAYFS %d bufs of %d bytes.\n", 
-                                       params.n_subbufs, 
-                                       params.subbuf_size);
-                               if (params.merge)
-                                       fprintf(stderr,"Merge output\n");
-                       } else
-                               fprintf(stderr,"TRANSPORT_INFO recvd: PROC with %d Mbyte buffers.\n", 
-                                        info->buf_size); 
-#endif
-                       if (!streaming()) {
-                               rc = init_relayfs();
-                               if (rc < 0) {
-                                       fprintf(stderr, "ERROR: couldn't init relayfs, exiting\n");
-                                       cleanup_and_exit(0);
-                               }
-                       } else if (outfile_name) {
-                               ofp = fopen (outfile_name, "w");
-                               if (!ofp) {
-                                       fprintf (stderr, "ERROR: couldn't open output file %s: errcode = %s\n",
-                                                outfile_name, strerror(errno));
-                                       cleanup_and_exit(0);
-                               }
-                       }
-                       ts.pid = getpid();
-                       send_request(STP_START, &ts, sizeof(ts));
-                       break;
-               }
-               case STP_MODULE:
-               {
-                       struct _stp_transport_start ts;
-                       if (do_module(data)) {
-                         ts.pid = getpid();
-                         send_request(STP_START, &ts, sizeof(ts));
-                       }
-                       break;
-               }               
-               case STP_SYMBOLS:
-               {
-                       struct _stp_symbol_req *req = (struct _stp_symbol_req *)data;
-                       struct _stp_transport_start ts;
-                       dbug("STP_SYMBOLS request received\n");
-                       if (req->endian != 0x1234) {
-                         fprintf(stderr,"ERROR: staprun is compiled with different endianess than the kernel!\n");
-                         cleanup_and_exit(0);
-                       }
-                       if (req->ptr_size != sizeof(char *)) {
-                         fprintf(stderr,"ERROR: staprun is compiled with %d-bit pointers and the kernel uses %d-bit.\n",
-                                 8*sizeof(char *), 8*req->ptr_size);
-                         cleanup_and_exit(0);
-                       }
-                       do_kernel_symbols();
-                       ts.pid = getpid();
-                       send_request(STP_START, &ts, sizeof(ts));
-                       break;
-               }
-               default:
-                       fprintf(stderr, "WARNING: ignored message of type %d\n", (type));
-               }
-       }
-       fclose(ofp);
-       return 0;
-}
diff --git a/runtime/stpd/librelay.h b/runtime/stpd/librelay.h
deleted file mode 100644 (file)
index 15ef6c4..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdint.h>
-
-#include "../transport/transport_msgs.h"
-
-#ifdef DEBUG
-#define dbug(args...) {fprintf(stderr,"%s:%d ",__FUNCTION__, __LINE__); fprintf(stderr,args); }
-#else
-#define dbug(args...) ;
-#endif /* DEBUG */
-
-/*
- * functions
- */
-int init_stp(int print_summary);
-int stp_main_loop(void);
-int send_request(int type, void *data, int len);
-void cleanup_and_exit (int);
-int do_module(void *);
-void do_kernel_symbols(void);
-
-/*
- * variables 
- */
-extern int control_channel;
diff --git a/runtime/stpd/stp_dump.c b/runtime/stpd/stp_dump.c
deleted file mode 100644 (file)
index 5923a2e..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * stp_dump.c - stp data dump program
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright (C) Red Hat Inc, 2005
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-static void usage (char *prog)
-{
-       fprintf(stderr, "%s input_file \n", prog);
-       exit(1);
-}
-
-#define TIMESTAMP_SIZE (sizeof(int))
-
-int main (int argc, char *argv[])
-{
-       char buf[32];
-       int c, seq, lastseq = 0;
-       FILE *fp;
-
-       if (argc != 2)
-         usage(argv[0]);
-
-       fp = fopen(argv[1], "r");
-       if (!fp) {
-         fprintf(stderr, "ERROR: couldn't open input file %s: errcode = %s\n",
-                 argv[1], strerror(errno));
-         return -1;
-       }
-       
-       while (1) {
-         int numbytes = 0;
-
-         if (fread (buf, TIMESTAMP_SIZE, 1, fp))
-           seq = *((int *)buf);
-         else
-           break;
-
-         if (seq < lastseq)
-           fprintf(stderr, "WARNING: seq %d followed by %d\n", lastseq, seq);
-         lastseq = seq;
-
-         while (1) {
-           c = fgetc_unlocked(fp);
-           if (c == 0 || c == EOF)
-             break;
-           numbytes++;
-         }
-         printf ("<%d><%d BYTES>", seq, numbytes);
-         if (c == 0)
-           printf ("<0>\n");
-         else {
-           printf ("<EOF>\n");
-           break;
-         }
-       }
-
-       printf ("DONE\n");
-       fclose (fp);
-       return 0;
-}
diff --git a/runtime/stpd/stp_merge.c b/runtime/stpd/stp_merge.c
deleted file mode 100644 (file)
index 14cb785..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * stp_merge.c - stp merge program
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright (C) Red Hat Inc, 2005
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-static void usage (char *prog)
-{
-       fprintf(stderr, "%s [-o output_filename] input_files ...\n", prog);
-       exit(1);
-}
-
-#define TIMESTAMP_SIZE (sizeof(int))
-#define NR_CPUS 256
-
-int main (int argc, char *argv[])
-{
-       char *outfile_name = NULL;
-       char buf[32];
-       int c, i, j, dropped=0;
-       long count=0, min, num[NR_CPUS];
-       FILE *ofp, *fp[NR_CPUS];
-       int ncpus;
-
-       while ((c = getopt (argc, argv, "o:")) != EOF)  {
-               switch (c) {
-               case 'o':
-                       outfile_name = optarg;
-                       break;
-               default:
-                       usage(argv[0]);
-               }
-       }
-       
-       if (optind == argc)
-               usage (argv[0]);
-
-       i = 0;
-       while (optind < argc) {
-               fp[i] = fopen(argv[optind++], "r");
-               if (!fp[i]) {
-                       fprintf(stderr, "error opening file %s.\n", argv[optind - 1]);
-                       return -1;
-               }
-               if (fread (buf, TIMESTAMP_SIZE, 1, fp[i]))
-                       num[i] = *((int *)buf);
-               else
-                       num[i] = 0;
-               i++;
-       }
-       ncpus = i;
-
-       if (!outfile_name)
-               ofp = stdout;
-       else {
-               ofp = fopen(outfile_name, "w"); 
-               if (!ofp) {
-                       fprintf(stderr, "ERROR: couldn't open output file %s: errcode = %s\n", 
-                               outfile_name, strerror(errno));
-                       return -1;
-               }
-       }
-       
-       do {
-               min = num[0];
-               j = 0;
-               for (i = 1; i < ncpus; i++) {
-                       if (min == 0 || (num[i] && num[i] < min)) {
-                               min = num[i];
-                               j = i;
-                       }
-               }
-
-               while (1) {
-                       c = fgetc_unlocked(fp[j]);
-                       if (c == 0 || c == EOF)
-                               break;
-                       fputc_unlocked (c, ofp);
-               }
-
-               if (min && ++count != min) {
-                       fprintf(stderr, "got %ld. expected %ld\n", min, count);
-                       dropped += min - count ;
-                       count = min;
-               }
-
-               if (fread (buf, TIMESTAMP_SIZE, 1, fp[j]))
-                       num[j] = *((int *)buf);
-               else
-                       num[j] = 0;
-       } while (min);
-
-       fputs ("\n", ofp);
-
-       for (i = 0; i < ncpus; i++)
-               fclose (fp[i]);
-       fclose (ofp);
-       printf ("sequence had %d drops\n", dropped);
-       return 0;
-}
diff --git a/runtime/stpd/stpd.c b/runtime/stpd/stpd.c
deleted file mode 100644 (file)
index f5c2ea1..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * stp.c - stp 'daemon'
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright (C) 2005 IBM Corporation
- * Copyright (C) 2005-2006 Red Hat, Inc.
- *
- */
-
-#include "librelay.h"
-#include <pwd.h>
-
-extern char *optarg;
-extern int optopt;
-extern int optind;
-
-int print_only = 0;
-int quiet = 0;
-int verbose = 0;
-int target_pid = 0;
-int driver_pid = 0;
-unsigned int buffer_size = 0;
-char *modname = NULL;
-char *modpath = NULL;
-#define MAXMODOPTIONS 64
-char *modoptions[MAXMODOPTIONS];
-char *target_cmd = NULL;
-char *outfile_name = NULL;
-char *username = NULL;
-uid_t cmd_uid;
-gid_t cmd_gid;
-
-static void usage(char *prog)
-{
-       fprintf(stderr, "\n%s [-m] [-p] [-q] [-r] [-c cmd ] [-t pid]\n"
-                "\t[-b bufsize] [-o FILE] kmod-name [kmod-options]\n", prog);
-       fprintf(stderr, "-p  Print only.  Don't log to files.\n");
-       fprintf(stderr, "-q  Quiet. Don't display trace to stdout.\n");
-       fprintf(stderr, "-c cmd.  Command \'cmd\' will be run and staprun 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");
-       fprintf(stderr, "-d pid.  Pass the systemtap driver's pid.\n");
-       fprintf(stderr, "-o FILE. Send output to FILE.\n");
-       fprintf(stderr, "-u username. Run commands as username.\n");
-       fprintf(stderr, "-b buffer size. The systemtap module will specify a buffer size.\n");
-       fprintf(stderr, "   Setting one here will override that value. The value should be\n");
-       fprintf(stderr, "   an integer between 1 and 64 which be assumed to be the\n");
-       fprintf(stderr, "   buffer size in MB. That value will be per-cpu if relayfs is used.\n");
-       exit(1);
-}
-
-int main(int argc, char **argv)
-{
-       int c;
-       
-       while ((c = getopt(argc, argv, "mpqrb:n:t:d:c:vo:u:")) != EOF)
-       {
-               switch (c) {
-               case 'm':
-                       fprintf(stderr, "Warning: -m option deprecated. Ignoring...\n");
-                       break;
-               case 'p':
-                       print_only = 1;
-                       break;
-               case 'q':
-                       quiet = 1;
-                       break;
-               case 'v':
-                       verbose = 1;
-                       break;
-               case 'r':
-                       fprintf(stderr, "Warning: -r option deprecated. Ignoring...\n");
-                       break;
-               case 'b':
-               {
-                       int size = (unsigned)atoi(optarg);
-                       if (!size)
-                               usage(argv[0]);
-                       if (size > 64) {
-                         fprintf(stderr, "Maximum buffer size is 64 (MB)\n");
-                         exit(1);
-                       }
-                       buffer_size = size;
-                       break;
-               }
-               case 't':
-                       target_pid = atoi(optarg);
-                       break;
-               case 'd':
-                       driver_pid = atoi(optarg);
-                       break;
-               case 'c':
-                       target_cmd = optarg;
-                       break;
-               case 'o':
-                       outfile_name = optarg;
-                       break;
-               case 'u':
-                       username = optarg;
-                       break;
-               default:
-                       usage(argv[0]);
-               }
-       }
-
-       if (verbose) {
-               if (buffer_size)
-                       printf ("Using a buffer of %u bytes.\n", buffer_size);
-       }
-
-       if (optind < argc)
-          {
-            /* Collect both full path and just the trailing module name.  */
-            modpath = argv[optind++];
-            modname = rindex (modpath, '/');
-            if (modname == NULL)
-              modname = modpath;
-            else
-              modname++; /* skip over / */
-          }
-
-        if (optind < argc)
-          {
-            unsigned start_idx = 3; /* reserve three slots in modoptions[] */
-            while (optind < argc && start_idx+1 < MAXMODOPTIONS)
-              modoptions[start_idx++] = argv[optind++];
-            /* Redundantly ensure that there is a NULL pointer at the end
-               of modoptions[]. */
-            modoptions[start_idx] = NULL;
-          }
-
-       if (!modname) {
-               fprintf (stderr, "Cannot invoke daemon without probe module\n");
-               usage(argv[0]);
-       }
-
-       if (print_only && quiet) {
-               fprintf (stderr, "Cannot do \"-p\" and \"-q\" both.\n");
-               usage(argv[0]);
-       }
-
-       if (username) {
-               struct passwd *pw = getpwnam(username);
-               if (!pw) {
-                       fprintf(stderr, "Cannot find user \"%s\".\n", username);
-                       exit(1);
-               }
-               cmd_uid = pw->pw_uid;
-               cmd_gid = pw->pw_gid;
-       } else {
-               cmd_uid = getuid();
-               cmd_gid = getgid();
-       }
-
-       if (init_stp(!quiet)) {
-               //fprintf(stderr, "Couldn't initialize staprun. Exiting.\n");
-               exit(1);
-       }
-
-       if (stp_main_loop()) {
-               fprintf(stderr,"Couldn't enter main loop. Exiting.\n");
-               exit(1);
-       }
-
-       return 0;
-}
diff --git a/runtime/stpd/symbols.c b/runtime/stpd/symbols.c
deleted file mode 100644 (file)
index 26c9bb1..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-/* -*- linux-c -*-
- * Symbols and modules functions for staprun.
- *
- * Copyright (C) 2006 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.
- */
-
-#include "librelay.h"
-#include "../sym.h"
-
-static int send_data(void *data, int len)
-{
-       return write(control_channel, data, len);
-}
-
-/* Get the sections for a module. Put them in the supplied buffer */
-/* in the following order: */
-/* [struct _stp_module][struct _stp_symbol sections ...][string data] */
-/* Return the total length of all the data. */
-
-#define SECDIR "/sys/module/%s/sections"
-static int get_sections(char *name, char *data_start, int datalen)
-{
-       char dir[STP_MODULE_NAME_LEN + sizeof(SECDIR)];
-       char filename[STP_MODULE_NAME_LEN + 256]; 
-       char buf[32], strdata_start[4096];
-       char *strdata=strdata_start, *data=data_start;
-       int fd, len, res;
-       struct _stp_module *mod = (struct _stp_module *)data_start;
-       struct dirent *d;
-       DIR *secdir;
-       struct _stp_symbol *sec;
-
-       /* start of data is a struct _stp_module */
-       data += sizeof(struct _stp_module);
-
-       res = snprintf(dir, sizeof(dir), SECDIR, name);
-       if (res >= sizeof(dir)) {
-               fprintf(stderr, "ERROR: couldn't fit module \"%s\" into dir buffer.\n", name);
-               fprintf(stderr, "This should never happen. Please file a bug report.\n");
-               cleanup_and_exit(0);
-       }
-
-       if ((secdir = opendir(dir)) == NULL)
-               return 0;
-
-       memset(mod, 0, sizeof(struct _stp_module));
-       strncpy(mod->name, name, STP_MODULE_NAME_LEN);
-
-       while ((d = readdir(secdir))) {
-               char *secname = d->d_name;
-               res = snprintf(filename, sizeof(filename), "/sys/module/%s/sections/%s", name, secname);
-               if (res >= sizeof(filename)) {
-                       fprintf(stderr, "ERROR: couldn't fit secname \"%s\" into filename buffer.\n", secname);
-                       fprintf(stderr, "This should never happen. Please file a bug report.\n");
-                       closedir(secdir);
-                       cleanup_and_exit(0);
-               }
-               if ((fd = open(filename,O_RDONLY)) >= 0) {
-                       if (read(fd, buf, 32) > 0) {
-                               /* filter out some non-useful stuff */
-                               if (!strncmp(secname,"__",2) 
-                                   || !strcmp(secname,".module_sig") 
-                                   || !strcmp(secname,".modinfo") 
-                                   || !strcmp(secname,".strtab") 
-                                   || !strcmp(secname,".symtab") ) {
-                                       close(fd);
-                                       continue;
-                               }
-                               /* create next section */
-                               sec = (struct _stp_symbol *)data;
-                               data += sizeof(struct _stp_symbol);
-                               sec->addr = strtoul(buf,NULL,16);
-                               sec->symbol = (char *)(strdata - strdata_start);
-                               mod->num_sections++;
-
-                               /* now create string data for the section */
-                               strcpy(strdata, secname);
-                               strdata += strlen(secname) + 1;
-
-                               /* These sections are used a lot so keep the values handy */
-                               if (!strcmp(secname, ".data"))
-                                       mod->data = sec->addr;
-                               if (!strcmp(secname, ".text"))
-                                       mod->text = sec->addr;
-                               if (!strcmp(secname, ".gnu.linkonce.this_module"))
-                                       mod->module = sec->addr;
-                       }
-                       close(fd);
-               }
-       }
-       closedir(secdir);
-
-       /* consolidate buffers */
-       len = strdata - strdata_start;
-       if ((len + data - data_start) > datalen) {
-               fprintf(stderr, "ERROR: overflowed buffers in get_sections. Size needed = %d\n",
-                       (int)(len + data - data_start));
-               cleanup_and_exit(0);
-       }
-       strdata = strdata_start;
-       while (len--)
-               *data++ = *strdata++;
-       
-       return data - data_start;
-}
-#undef SECDIR
-
-void send_module (char *modname)
-{
-       char data[8192];
-       int len = get_sections(modname, data, sizeof(data));
-       if (len)
-               send_request(STP_MODULE, data, len);
-}
-
-int do_module (void *data)
-{
-       struct _stp_module *mod = (struct _stp_module *)data;
-
-       if (mod->name[0] == 0) {
-               struct dirent *d;
-               DIR *moddir = opendir("/sys/module");
-               if (moddir) {
-                       while ((d = readdir(moddir)))
-                               send_module(d->d_name);
-                       closedir(moddir);
-               }
-               return 1;
-       }
-
-       send_module(mod->name);
-       return 0;
-}
-
-static int compar(const void *p1, const void *p2)
-{
-       struct _stp_symbol *s1 = (struct _stp_symbol *)p1;
-       struct _stp_symbol *s2 = (struct _stp_symbol *)p2;
-       if (s1->addr == s2->addr) return 0;
-       if (s1->addr < s2->addr) return -1;
-       return 1;
-}
-
-#define MAX_SYMBOLS 32768
-
-void do_kernel_symbols(void)
-{
-       FILE *kallsyms;
-       char *sym_base, *data_base;
-       char buf[128], *ptr, *name, *data, *dataptr, *datamax, type;
-       unsigned long addr;
-       struct _stp_symbol *syms;
-       int num_syms, i = 0;
-
-       sym_base = malloc(MAX_SYMBOLS*sizeof(struct _stp_symbol)+sizeof(long));
-       data_base = malloc(MAX_SYMBOLS*32);
-       if (data_base == NULL || sym_base == NULL) {
-               fprintf(stderr,"Failed to allocate memory for symbols\n");
-               cleanup_and_exit(0);
-       }
-       *(int *)data_base = STP_SYMBOLS;
-       dataptr = data = data_base + sizeof(long);
-       datamax = dataptr + MAX_SYMBOLS*32 - sizeof(long);
-
-       *(int *)sym_base = STP_SYMBOLS;
-       syms = (struct _stp_symbol *)(sym_base + sizeof(long));
-
-       kallsyms = fopen ("/proc/kallsyms", "r");
-       if (!kallsyms) {
-               perror("Fatal error: Unable to open /proc/kallsyms:");
-               cleanup_and_exit(0);
-       }
-
-       /* put empty string in data */
-       *dataptr++ = 0;
-
-       while (fgets_unlocked(buf, 128, kallsyms) && dataptr < datamax) {
-               addr = strtoul(buf, &ptr, 16);
-               while (isspace(*ptr)) ptr++;
-               type = *ptr++;
-               if (type == 't' || type == 'T' || type == 'A') {
-                       while (isspace(*ptr)) ptr++;
-                       name = ptr++;
-                       while (!isspace(*ptr)) ptr++;
-                       *ptr++ = 0;
-                       while (*ptr && *ptr != '[') ptr++;
-                       if (*ptr)
-                               continue; /* it was a module */
-                       syms[i].addr = addr;
-                       syms[i].symbol = (char *)(dataptr - data);
-                       while (*name) *dataptr++ = *name++;
-                       *dataptr++ = 0;
-                       i++;
-                       if (dataptr > datamax - 1000)
-                         break;
-               }
-       }
-       num_syms = i;
-       qsort(syms, num_syms, sizeof(struct _stp_symbol), compar);
-
-#if 0
-       for (i=0;i<num_syms;i++) {
-               fprintf(stderr,"%p , \"%s\"\n", (char *)(syms[i].addr),
-                       (char *)((long)(syms[i].symbol) + data));
-       }
-#endif
-
-       /* send header */
-       *(int *)buf = STP_SYMBOLS;
-       *(int *)(buf+sizeof(long)) = num_syms;
-       *(int *)(buf+sizeof(long)+sizeof(int)) = (unsigned)(dataptr - data);
-       send_data(buf, 2*sizeof(int)+sizeof(long));
-
-       /* send syms */
-       send_data(sym_base, num_syms*sizeof(struct _stp_symbol)+sizeof(long));
-       
-       /* send data */
-       send_data(data_base, dataptr-data+sizeof(long));
-
-       free(data_base);
-       free(sym_base);
-       fclose(kallsyms);
-
-       if (dataptr >= datamax) {
-               fprintf(stderr,"Error: overflowed symbol data area.\n");
-               cleanup_and_exit(0);
-       }
-}
This page took 0.13378 seconds and 5 git commands to generate.