aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/proc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /crypto/proc.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'crypto/proc.c')
-rw-r--r--crypto/proc.c112
1 files changed, 112 insertions, 0 deletions
diff --git a/crypto/proc.c b/crypto/proc.c
new file mode 100644
index 000000000000..630ba91c08f1
--- /dev/null
+++ b/crypto/proc.c
@@ -0,0 +1,112 @@
1/*
2 * Scatterlist Cryptographic API.
3 *
4 * Procfs information.
5 *
6 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 */
14#include <linux/init.h>
15#include <linux/crypto.h>
16#include <linux/rwsem.h>
17#include <linux/proc_fs.h>
18#include <linux/seq_file.h>
19#include "internal.h"
20
21extern struct list_head crypto_alg_list;
22extern struct rw_semaphore crypto_alg_sem;
23
24static void *c_start(struct seq_file *m, loff_t *pos)
25{
26 struct list_head *v;
27 loff_t n = *pos;
28
29 down_read(&crypto_alg_sem);
30 list_for_each(v, &crypto_alg_list)
31 if (!n--)
32 return list_entry(v, struct crypto_alg, cra_list);
33 return NULL;
34}
35
36static void *c_next(struct seq_file *m, void *p, loff_t *pos)
37{
38 struct list_head *v = p;
39
40 (*pos)++;
41 v = v->next;
42 return (v == &crypto_alg_list) ?
43 NULL : list_entry(v, struct crypto_alg, cra_list);
44}
45
46static void c_stop(struct seq_file *m, void *p)
47{
48 up_read(&crypto_alg_sem);
49}
50
51static int c_show(struct seq_file *m, void *p)
52{
53 struct crypto_alg *alg = (struct crypto_alg *)p;
54
55 seq_printf(m, "name : %s\n", alg->cra_name);
56 seq_printf(m, "module : %s\n", module_name(alg->cra_module));
57
58 switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
59 case CRYPTO_ALG_TYPE_CIPHER:
60 seq_printf(m, "type : cipher\n");
61 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
62 seq_printf(m, "min keysize : %u\n",
63 alg->cra_cipher.cia_min_keysize);
64 seq_printf(m, "max keysize : %u\n",
65 alg->cra_cipher.cia_max_keysize);
66 break;
67
68 case CRYPTO_ALG_TYPE_DIGEST:
69 seq_printf(m, "type : digest\n");
70 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
71 seq_printf(m, "digestsize : %u\n",
72 alg->cra_digest.dia_digestsize);
73 break;
74 case CRYPTO_ALG_TYPE_COMPRESS:
75 seq_printf(m, "type : compression\n");
76 break;
77 default:
78 seq_printf(m, "type : unknown\n");
79 break;
80 }
81
82 seq_putc(m, '\n');
83 return 0;
84}
85
86static struct seq_operations crypto_seq_ops = {
87 .start = c_start,
88 .next = c_next,
89 .stop = c_stop,
90 .show = c_show
91};
92
93static int crypto_info_open(struct inode *inode, struct file *file)
94{
95 return seq_open(file, &crypto_seq_ops);
96}
97
98static struct file_operations proc_crypto_ops = {
99 .open = crypto_info_open,
100 .read = seq_read,
101 .llseek = seq_lseek,
102 .release = seq_release
103};
104
105void __init crypto_init_proc(void)
106{
107 struct proc_dir_entry *proc;
108
109 proc = create_proc_entry("crypto", 0, NULL);
110 if (proc)
111 proc->proc_fops = &proc_crypto_ops;
112}