1 /* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
4 * Copyright (C) 2004, 2005 Oracle. All rights reserved.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 021110-1307, USA.
22 #include <linux/module.h>
23 #include <linux/kernel.h>
24 #include <linux/proc_fs.h>
25 #include <linux/seq_file.h>
26 #include <linux/string.h>
27 #include <asm/uaccess.h>
31 struct mlog_bits mlog_and_bits
= MLOG_BITS_RHS(MLOG_INITIAL_AND_MASK
);
32 EXPORT_SYMBOL_GPL(mlog_and_bits
);
33 struct mlog_bits mlog_not_bits
= MLOG_BITS_RHS(MLOG_INITIAL_NOT_MASK
);
34 EXPORT_SYMBOL_GPL(mlog_not_bits
);
36 static ssize_t
mlog_mask_show(u64 mask
, char *buf
)
40 if (__mlog_test_u64(mask
, mlog_and_bits
))
42 else if (__mlog_test_u64(mask
, mlog_not_bits
))
47 return snprintf(buf
, PAGE_SIZE
, "%s\n", state
);
50 static ssize_t
mlog_mask_store(u64 mask
, const char *buf
, size_t count
)
52 if (!strnicmp(buf
, "allow", 5)) {
53 __mlog_set_u64(mask
, mlog_and_bits
);
54 __mlog_clear_u64(mask
, mlog_not_bits
);
55 } else if (!strnicmp(buf
, "deny", 4)) {
56 __mlog_set_u64(mask
, mlog_not_bits
);
57 __mlog_clear_u64(mask
, mlog_and_bits
);
58 } else if (!strnicmp(buf
, "off", 3)) {
59 __mlog_clear_u64(mask
, mlog_not_bits
);
60 __mlog_clear_u64(mask
, mlog_and_bits
);
67 struct mlog_attribute
{
68 struct attribute attr
;
72 #define to_mlog_attr(_attr) container_of(_attr, struct mlog_attribute, attr)
74 #define define_mask(_name) { \
77 .mode = S_IRUGO | S_IWUSR, \
82 static struct mlog_attribute mlog_attrs
[MLOG_MAX_BITS
] = {
88 define_mask(HEARTBEAT
),
92 define_mask(DLM_DOMAIN
),
93 define_mask(DLM_THREAD
),
94 define_mask(DLM_MASTER
),
95 define_mask(DLM_RECOVERY
),
98 define_mask(DISK_ALLOC
),
100 define_mask(FILE_IO
),
101 define_mask(EXTENT_MAP
),
102 define_mask(DLM_GLUE
),
104 define_mask(UPTODATE
),
116 define_mask(KTHREAD
),
119 static struct attribute
*mlog_attr_ptrs
[MLOG_MAX_BITS
] = {NULL
, };
121 static ssize_t
mlog_show(struct kobject
*obj
, struct attribute
*attr
,
124 struct mlog_attribute
*mlog_attr
= to_mlog_attr(attr
);
126 return mlog_mask_show(mlog_attr
->mask
, buf
);
129 static ssize_t
mlog_store(struct kobject
*obj
, struct attribute
*attr
,
130 const char *buf
, size_t count
)
132 struct mlog_attribute
*mlog_attr
= to_mlog_attr(attr
);
134 return mlog_mask_store(mlog_attr
->mask
, buf
, count
);
137 static struct sysfs_ops mlog_attr_ops
= {
142 static struct kobj_type mlog_ktype
= {
143 .default_attrs
= mlog_attr_ptrs
,
144 .sysfs_ops
= &mlog_attr_ops
,
147 static struct kset mlog_kset
= {
148 .kobj
= {.ktype
= &mlog_ktype
},
151 int mlog_sys_init(struct kset
*o2cb_kset
)
155 while (mlog_attrs
[i
].attr
.mode
) {
156 mlog_attr_ptrs
[i
] = &mlog_attrs
[i
].attr
;
159 mlog_attr_ptrs
[i
] = NULL
;
161 kobject_set_name(&mlog_kset
.kobj
, "logmask");
162 mlog_kset
.kobj
.kset
= o2cb_kset
;
163 return kset_register(&mlog_kset
);
166 void mlog_sys_shutdown(void)
168 kset_unregister(&mlog_kset
);