| 1 | /* |
| 2 | * Copyright (C) 2008 Mathieu Desnoyers |
| 3 | * |
| 4 | * Dual LGPL v2.1/GPL v2 license. |
| 5 | */ |
| 6 | |
| 7 | #include <linux/module.h> |
| 8 | #include <linux/debugfs.h> |
| 9 | #include <linux/fs.h> |
| 10 | #include <linux/mutex.h> |
| 11 | |
| 12 | #include "ltt-tracer.h" |
| 13 | |
| 14 | #define LTT_FILTER_DIR "filter" |
| 15 | |
| 16 | /* |
| 17 | * Protects the ltt_filter_dir allocation. |
| 18 | */ |
| 19 | static DEFINE_MUTEX(ltt_filter_mutex); |
| 20 | |
| 21 | static struct dentry *ltt_filter_dir; |
| 22 | |
| 23 | struct dentry *get_filter_root(void) |
| 24 | { |
| 25 | struct dentry *ltt_root_dentry; |
| 26 | |
| 27 | mutex_lock(<t_filter_mutex); |
| 28 | if (!ltt_filter_dir) { |
| 29 | ltt_root_dentry = get_ltt_root(); |
| 30 | if (!ltt_root_dentry) |
| 31 | goto err_no_root; |
| 32 | |
| 33 | ltt_filter_dir = debugfs_create_dir(LTT_FILTER_DIR, |
| 34 | ltt_root_dentry); |
| 35 | if (!ltt_filter_dir) |
| 36 | printk(KERN_ERR |
| 37 | "ltt_filter_init: failed to create dir %s\n", |
| 38 | LTT_FILTER_DIR); |
| 39 | } |
| 40 | err_no_root: |
| 41 | mutex_unlock(<t_filter_mutex); |
| 42 | return ltt_filter_dir; |
| 43 | } |
| 44 | EXPORT_SYMBOL_GPL(get_filter_root); |
| 45 | |
| 46 | static void __exit ltt_filter_exit(void) |
| 47 | { |
| 48 | debugfs_remove(ltt_filter_dir); |
| 49 | } |
| 50 | |
| 51 | module_exit(ltt_filter_exit); |
| 52 | |
| 53 | MODULE_LICENSE("GPL and additional rights"); |
| 54 | MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>"); |
| 55 | MODULE_DESCRIPTION("Linux Trace Toolkit Filter"); |