~ubuntu-branches/ubuntu/vivid/aufs/vivid

« back to all changes in this revision

Viewing changes to fs/aufs25/sysrq.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080506183550-0b6c974kkgc46oeh
Tags: 0+20080506-1
* New upstream release, supports Kernel 2.6.25 (Closes: #479717)
* Fix building with older Kernels (Closes: #475042)
* Update the patches 01, 04 and 07 to also patch fs/aufs25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2008 Junjiro Okajima
 
3
 *
 
4
 * This program, aufs is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
17
 */
 
18
 
 
19
/*
 
20
 * magic sysrq hanlder
 
21
 *
 
22
 * $Id: sysrq.c,v 1.4 2008/05/04 23:53:27 sfjro Exp $
 
23
 */
 
24
 
 
25
#include <linux/fs.h>
 
26
#include <linux/module.h>
 
27
#include <linux/moduleparam.h>
 
28
#include <linux/sysrq.h>
 
29
#include "aufs.h"
 
30
 
 
31
static void sysrq_sb(struct super_block *sb)
 
32
{
 
33
        char *plevel;
 
34
        struct inode *i;
 
35
 
 
36
        plevel = au_plevel;
 
37
        au_plevel = KERN_WARNING;
 
38
        au_debug_on();
 
39
 
 
40
        pr_warning(AUFS_NAME ": superblock\n");
 
41
        au_dpri_sb(sb);
 
42
        pr_warning(AUFS_NAME ": root dentry\n");
 
43
        au_dpri_dentry(sb->s_root);
 
44
#if 0
 
45
        pr_warning(AUFS_NAME ": root inode\n");
 
46
        au_dpri_inode(sb->s_root->d_inode);
 
47
#endif
 
48
#if 1
 
49
        pr_warning(AUFS_NAME ": isolated inode\n");
 
50
        list_for_each_entry(i, &sb->s_inodes, i_sb_list)
 
51
                if (list_empty(&i->i_dentry))
 
52
                        au_dpri_inode(i);
 
53
#endif
 
54
 
 
55
        au_plevel = plevel;
 
56
        au_debug_off();
 
57
}
 
58
 
 
59
/* ---------------------------------------------------------------------- */
 
60
 
 
61
/* module parameter */
 
62
static char *aufs_sysrq_key = "a";
 
63
module_param_named(sysrq, aufs_sysrq_key, charp, S_IRUGO);
 
64
MODULE_PARM_DESC(sysrq, "MagicSysRq key for " AUFS_NAME);
 
65
 
 
66
static void au_sysrq(int key, struct tty_struct *tty)
 
67
{
 
68
        struct au_sbinfo *sbinfo;
 
69
 
 
70
#if 0
 
71
        if (au_debug_test())
 
72
                au_debug_off();
 
73
        else
 
74
                au_debug_on();
 
75
#endif
 
76
 
 
77
        //mutex_lock(&au_sbilist_mtx);
 
78
        list_for_each_entry(sbinfo, &au_sbilist, si_list)
 
79
                sysrq_sb(sbinfo->si_sb);
 
80
        //mutex_unlock(&au_sbilist_mtx);
 
81
}
 
82
 
 
83
static struct sysrq_key_op au_sysrq_op = {
 
84
        .handler        = au_sysrq,
 
85
        .help_msg       = "Aufs",
 
86
        .action_msg     = "Aufs",
 
87
        .enable_mask    = SYSRQ_ENABLE_DUMP //??
 
88
};
 
89
 
 
90
/* ---------------------------------------------------------------------- */
 
91
 
 
92
int __init au_sysrq_init(void)
 
93
{
 
94
        int err;
 
95
        char key;
 
96
 
 
97
        err = -1;
 
98
        key = *aufs_sysrq_key;
 
99
        if ('a' <= key && key <= 'z')
 
100
                err = register_sysrq_key(key, &au_sysrq_op);
 
101
        if (unlikely(err))
 
102
                AuErr("err %d, sysrq=%c\n", err, key);
 
103
        return err;
 
104
}
 
105
 
 
106
void au_sysrq_fin(void)
 
107
{
 
108
        int err;
 
109
        err = unregister_sysrq_key(*aufs_sysrq_key, &au_sysrq_op);
 
110
        if (unlikely(err))
 
111
                AuErr("err %d (ignored)\n", err);
 
112
}