~ubuntu-branches/ubuntu/vivid/ecryptfs-utils/vivid

« back to all changes in this revision

Viewing changes to src/jprobes/jprobe-release.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2007-11-16 12:10:00 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20071116121000-8ob8mqnq4btrafhx
Tags: 30-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * jprobe module for debugging eCryptfs mount operations
3
 
 */
4
 
 
5
 
#include <linux/module.h>
6
 
#include <linux/init.h>
7
 
#include <linux/kprobes.h>
8
 
#include <linux/kallsyms.h>
9
 
#include <linux/fs.h>
10
 
#include <linux/mount.h>
11
 
 
12
 
struct jprobe_mapping_elem {
13
 
        struct jprobe *jp;
14
 
        char *symbol;
15
 
        void *fp;
16
 
};
17
 
 
18
 
struct ecryptfs_crypt_stat {
19
 
        int v;
20
 
};
21
 
 
22
 
/* file private data. */
23
 
struct ecryptfs_file_info {
24
 
        struct file *wfi_file;
25
 
        struct ecryptfs_crypt_stat *crypt_stat;
26
 
};
27
 
 
28
 
static inline struct ecryptfs_file_info *
29
 
ecryptfs_file_to_private(struct file *file)
30
 
{
31
 
        return (struct ecryptfs_file_info *)file->private_data;
32
 
}
33
 
 
34
 
static inline struct file *ecryptfs_file_to_lower(struct file *file)
35
 
{
36
 
        return ((struct ecryptfs_file_info *)file->private_data)->wfi_file;
37
 
}
38
 
 
39
 
/* inode private data. */
40
 
struct ecryptfs_inode_info {
41
 
        struct inode *wii_inode;
42
 
        struct inode vfs_inode;
43
 
        struct ecryptfs_crypt_stat crypt_stat;
44
 
};
45
 
 
46
 
static inline struct inode *ecryptfs_inode_to_lower(struct inode *inode)
47
 
{
48
 
        return ((struct ecryptfs_inode_info *)inode->i_private)->wii_inode;
49
 
}
50
 
 
51
 
int jp_ecryptfs_release(struct inode *inode, struct file *file)
52
 
{
53
 
        struct file *lower_file = ecryptfs_file_to_lower(file);
54
 
        struct ecryptfs_file_info *file_info = ecryptfs_file_to_private(file);
55
 
        struct inode *lower_inode = ecryptfs_inode_to_lower(inode);
56
 
        int fcnt;
57
 
 
58
 
/*      fput(lower_file);
59
 
        inode->i_blocks = lower_inode->i_blocks;
60
 
        kmem_cache_free(ecryptfs_file_info_cache, file_info); */
61
 
        printk(KERN_INFO "%s: inode = [0x%p]; file = [0x%p]; lower_file = "
62
 
               "[0x%p]; file_info = [0x%p]; lower_inode = [0x%p]\n",
63
 
               __FUNCTION__, inode, file, lower_file, file_info, lower_inode);
64
 
        fcnt = atomic_read(&lower_file->f_count);
65
 
        printk(KERN_INFO "%s: lower_file->f_count = [%d]\n", __FUNCTION__,
66
 
               fcnt);
67
 
        jprobe_return();
68
 
        return 0;
69
 
}
70
 
 
71
 
struct jprobe_mapping_elem jprobe_mapping[] = {
72
 
        {NULL, "ecryptfs_release", jp_ecryptfs_release},
73
 
};
74
 
 
75
 
static int __init jprobe_mount_init(void)
76
 
{
77
 
        int i;
78
 
 
79
 
        for (i = 0; i < ARRAY_SIZE(jprobe_mapping); i++) {
80
 
                jprobe_mapping[i].jp = kmalloc(sizeof(struct jprobe),
81
 
                                               GFP_KERNEL);
82
 
                jprobe_mapping[i].jp->entry = jprobe_mapping[i].fp;
83
 
                jprobe_mapping[i].jp->kp.addr = (kprobe_opcode_t *)
84
 
                        kallsyms_lookup_name(jprobe_mapping[i].symbol);
85
 
                if (jprobe_mapping[i].jp->kp.addr == NULL) {
86
 
                        int j;
87
 
 
88
 
                        printk(KERN_NOTICE "Unable to find symbol [%s]\n",
89
 
                               jprobe_mapping[i].symbol);
90
 
                        for (j = 0; j < i; j++) {
91
 
                                unregister_jprobe(jprobe_mapping[j].jp);
92
 
                                kfree(jprobe_mapping[j].jp);
93
 
                        }
94
 
                        return -EINVAL;
95
 
                }
96
 
                register_jprobe(jprobe_mapping[i].jp);
97
 
        }
98
 
        return 0;
99
 
}
100
 
 
101
 
static void __exit jprobe_mount_exit(void)
102
 
{
103
 
        int i;
104
 
 
105
 
        for (i = 0; i < ARRAY_SIZE(jprobe_mapping); i++) {
106
 
                unregister_jprobe(jprobe_mapping[i].jp);
107
 
                kfree(jprobe_mapping[i].jp);
108
 
        }
109
 
}
110
 
 
111
 
module_init(jprobe_mount_init);
112
 
module_exit(jprobe_mount_exit);
113
 
MODULE_LICENSE("GPL");