aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/file.c
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2010-06-16 03:26:38 -0400
committerJames Morris <jmorris@namei.org>2010-08-02 01:34:34 -0400
commit71c282362d0672235c5205a7db1f3ac3fcf32981 (patch)
treeb359947179fad844767fc5b54a0761b7353babc1 /security/tomoyo/file.c
parentd795ef9e751b72c94600c91e31bdaef55987a9f6 (diff)
TOMOYO: Remove wrapper function for reading keyword.
Keyword strings are read-only. We can directly access them to reduce code size. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/tomoyo/file.c')
-rw-r--r--security/tomoyo/file.c65
1 files changed, 5 insertions, 60 deletions
diff --git a/security/tomoyo/file.c b/security/tomoyo/file.c
index 94e1493ab6b6..67e65c7dde70 100644
--- a/security/tomoyo/file.c
+++ b/security/tomoyo/file.c
@@ -10,7 +10,7 @@
10#include <linux/slab.h> 10#include <linux/slab.h>
11 11
12/* Keyword array for operations with one pathname. */ 12/* Keyword array for operations with one pathname. */
13static const char *tomoyo_path_keyword[TOMOYO_MAX_PATH_OPERATION] = { 13const char *tomoyo_path_keyword[TOMOYO_MAX_PATH_OPERATION] = {
14 [TOMOYO_TYPE_READ_WRITE] = "read/write", 14 [TOMOYO_TYPE_READ_WRITE] = "read/write",
15 [TOMOYO_TYPE_EXECUTE] = "execute", 15 [TOMOYO_TYPE_EXECUTE] = "execute",
16 [TOMOYO_TYPE_READ] = "read", 16 [TOMOYO_TYPE_READ] = "read",
@@ -25,22 +25,20 @@ static const char *tomoyo_path_keyword[TOMOYO_MAX_PATH_OPERATION] = {
25}; 25};
26 26
27/* Keyword array for operations with one pathname and three numbers. */ 27/* Keyword array for operations with one pathname and three numbers. */
28static const char *tomoyo_mkdev_keyword 28const char *tomoyo_mkdev_keyword[TOMOYO_MAX_MKDEV_OPERATION] = {
29[TOMOYO_MAX_MKDEV_OPERATION] = {
30 [TOMOYO_TYPE_MKBLOCK] = "mkblock", 29 [TOMOYO_TYPE_MKBLOCK] = "mkblock",
31 [TOMOYO_TYPE_MKCHAR] = "mkchar", 30 [TOMOYO_TYPE_MKCHAR] = "mkchar",
32}; 31};
33 32
34/* Keyword array for operations with two pathnames. */ 33/* Keyword array for operations with two pathnames. */
35static const char *tomoyo_path2_keyword[TOMOYO_MAX_PATH2_OPERATION] = { 34const char *tomoyo_path2_keyword[TOMOYO_MAX_PATH2_OPERATION] = {
36 [TOMOYO_TYPE_LINK] = "link", 35 [TOMOYO_TYPE_LINK] = "link",
37 [TOMOYO_TYPE_RENAME] = "rename", 36 [TOMOYO_TYPE_RENAME] = "rename",
38 [TOMOYO_TYPE_PIVOT_ROOT] = "pivot_root", 37 [TOMOYO_TYPE_PIVOT_ROOT] = "pivot_root",
39}; 38};
40 39
41/* Keyword array for operations with one pathname and one number. */ 40/* Keyword array for operations with one pathname and one number. */
42static const char *tomoyo_path_number_keyword 41const char *tomoyo_path_number_keyword[TOMOYO_MAX_PATH_NUMBER_OPERATION] = {
43[TOMOYO_MAX_PATH_NUMBER_OPERATION] = {
44 [TOMOYO_TYPE_CREATE] = "create", 42 [TOMOYO_TYPE_CREATE] = "create",
45 [TOMOYO_TYPE_MKDIR] = "mkdir", 43 [TOMOYO_TYPE_MKDIR] = "mkdir",
46 [TOMOYO_TYPE_MKFIFO] = "mkfifo", 44 [TOMOYO_TYPE_MKFIFO] = "mkfifo",
@@ -119,58 +117,6 @@ bool tomoyo_compare_number_union(const unsigned long value,
119 return value >= ptr->values[0] && value <= ptr->values[1]; 117 return value >= ptr->values[0] && value <= ptr->values[1];
120} 118}
121 119
122/**
123 * tomoyo_path2keyword - Get the name of single path operation.
124 *
125 * @operation: Type of operation.
126 *
127 * Returns the name of single path operation.
128 */
129const char *tomoyo_path2keyword(const u8 operation)
130{
131 return (operation < TOMOYO_MAX_PATH_OPERATION)
132 ? tomoyo_path_keyword[operation] : NULL;
133}
134
135/**
136 * tomoyo_mkdev2keyword - Get the name of path/number/number/number operations.
137 *
138 * @operation: Type of operation.
139 *
140 * Returns the name of path/number/number/number operation.
141 */
142const char *tomoyo_mkdev2keyword(const u8 operation)
143{
144 return (operation < TOMOYO_MAX_MKDEV_OPERATION)
145 ? tomoyo_mkdev_keyword[operation] : NULL;
146}
147
148/**
149 * tomoyo_path22keyword - Get the name of double path operation.
150 *
151 * @operation: Type of operation.
152 *
153 * Returns the name of double path operation.
154 */
155const char *tomoyo_path22keyword(const u8 operation)
156{
157 return (operation < TOMOYO_MAX_PATH2_OPERATION)
158 ? tomoyo_path2_keyword[operation] : NULL;
159}
160
161/**
162 * tomoyo_path_number2keyword - Get the name of path/number operations.
163 *
164 * @operation: Type of operation.
165 *
166 * Returns the name of path/number operation.
167 */
168const char *tomoyo_path_number2keyword(const u8 operation)
169{
170 return (operation < TOMOYO_MAX_PATH_NUMBER_OPERATION)
171 ? tomoyo_path_number_keyword[operation] : NULL;
172}
173
174static void tomoyo_add_slash(struct tomoyo_path_info *buf) 120static void tomoyo_add_slash(struct tomoyo_path_info *buf)
175{ 121{
176 if (buf->is_dir) 122 if (buf->is_dir)
@@ -266,8 +212,7 @@ static int tomoyo_audit_path2_log(struct tomoyo_request_info *r)
266 */ 212 */
267static int tomoyo_audit_mkdev_log(struct tomoyo_request_info *r) 213static int tomoyo_audit_mkdev_log(struct tomoyo_request_info *r)
268{ 214{
269 const char *operation = tomoyo_mkdev2keyword(r->param.mkdev. 215 const char *operation = tomoyo_mkdev_keyword[r->param.mkdev.operation];
270 operation);
271 const struct tomoyo_path_info *filename = r->param.mkdev.filename; 216 const struct tomoyo_path_info *filename = r->param.mkdev.filename;
272 const unsigned int major = r->param.mkdev.major; 217 const unsigned int major = r->param.mkdev.major;
273 const unsigned int minor = r->param.mkdev.minor; 218 const unsigned int minor = r->param.mkdev.minor;