オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Contents of /trunk/ccs-patch/fs/proc/ccs_proc.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 120 - (show annotations) (download) (as text)
Thu Mar 8 13:55:18 2007 UTC (17 years, 3 months ago) by kumaneko
File MIME type: text/x-csrc
File size: 3319 byte(s)


1
2 /*
3 * fs/proc/ccs_proc.c
4 *
5 * /proc interface for SAKURA and TOMOYO.
6 *
7 * Copyright (C) 2005-2007 NTT DATA CORPORATION
8 *
9 * Version: 1.3.2 2007/02/14
10 *
11 * This file is applicable to both 2.4.30 and 2.6.11 and later.
12 * See README.ccs for ChangeLog.
13 *
14 */
15
16 #include <linux/types.h>
17 #include <linux/kernel.h>
18 #include <asm/io.h>
19 #include <linux/proc_fs.h>
20 #include <linux/module.h>
21 #include <linux/version.h>
22 #include <linux/ccs_proc.h>
23 #include <linux/ccs_common.h>
24
25 #if defined(CONFIG_SAKURA) || defined(CONFIG_TOMOYO)
26
27 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23)
28 static inline struct proc_dir_entry *PDE(const struct inode *inode)
29 {
30 return (struct proc_dir_entry *) inode->u.generic_ip;
31 }
32 #endif
33
34 static int ccs_open(struct inode *inode, struct file *file)
35 {
36 return CCS_OpenControl(((u8 *) PDE(inode)->data) - ((u8 *) NULL), file);
37 }
38
39 static int ccs_release(struct inode *inode, struct file *file)
40 {
41 return CCS_CloseControl(file);
42 }
43
44 static unsigned int ccs_poll(struct file *file, poll_table *wait)
45 {
46 return CCS_PollControl(file, wait);
47 }
48
49 static ssize_t ccs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
50 {
51 return CCS_ReadControl(file, buf, count);
52 }
53
54 static ssize_t ccs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
55 {
56 return CCS_WriteControl(file, buf, count);
57 }
58
59 static struct file_operations ccs_operations = {
60 open: ccs_open,
61 release: ccs_release,
62 poll: ccs_poll,
63 read: ccs_read,
64 write: ccs_write
65 };
66
67 static __init void CreateEntry(const char *name, const mode_t mode, struct proc_dir_entry *parent, const int key)
68 {
69 struct proc_dir_entry *entry = create_proc_entry(name, mode, parent);
70 if (entry) {
71 entry->proc_fops = &ccs_operations;
72 entry->data = ((u8 *) NULL) + key;
73 }
74 }
75
76 void __init CCSProc_Init(void)
77 {
78 struct proc_dir_entry *ccs_dir = proc_mkdir("ccs", NULL);
79 struct proc_dir_entry *policy_dir = proc_mkdir("policy", ccs_dir),
80 *info_dir = proc_mkdir("info", ccs_dir);
81 extern void __init realpath_Init(void);
82 realpath_Init();
83 FindDomain(""); /* Set domainname of KERNEL domain. */
84 CreateEntry("query", 0600, policy_dir, CCS_POLICY_QUERY);
85 #ifdef CONFIG_SAKURA
86 CreateEntry("system_policy", 0600, policy_dir, CCS_POLICY_SYSTEMPOLICY);
87 #endif
88 #ifdef CONFIG_TOMOYO
89 CreateEntry("domain_policy", 0600, policy_dir, CCS_POLICY_DOMAINPOLICY);
90 CreateEntry("exception_policy", 0600, policy_dir, CCS_POLICY_EXCEPTIONPOLICY);
91 CreateEntry(".domain_status", 0600, policy_dir, CCS_POLICY_DOMAIN_STATUS);
92 CreateEntry(".process_status", 0400, info_dir, CCS_INFO_PROCESS_STATUS);
93 #ifdef CONFIG_TOMOYO_AUDIT
94 CreateEntry("grant_log", 0400, info_dir, CCS_INFO_GRANTLOG);
95 CreateEntry("reject_log", 0400, info_dir, CCS_INFO_REJECTLOG);
96 #endif
97 CreateEntry("self_domain", 0400, info_dir, CCS_INFO_SELFDOMAIN);
98 #ifdef CONFIG_TOMOYO_MAC_FOR_FILE
99 CreateEntry("mapping", 0400, info_dir, CCS_INFO_MAPPING);
100 #endif
101 #endif
102 CreateEntry("meminfo", 0400, info_dir, CCS_INFO_MEMINFO);
103 CreateEntry("status", 0600, ccs_dir, CCS_STATUS);
104 CreateEntry("manager", 0600, policy_dir, CCS_POLICY_MANAGER);
105 CreateEntry(".updates_counter", 0400, info_dir, CCS_INFO_UPDATESCOUNTER);
106 }
107
108 #else
109 void __init CCSProc_Init(void) {}
110 #endif
111
112 EXPORT_SYMBOL(CCSProc_Init);

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26