[PATCH] reiserfs: fix journaling issue regarding fsync()
[linux-2.6/mini2440.git] / crypto / proc.c
blobc0a5dd7ce2ccbacc98b419b8667853bcdf5c2d73
1 /*
2 * Scatterlist Cryptographic API.
4 * Procfs information.
6 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
7 * Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
15 #include <linux/init.h>
16 #include <linux/crypto.h>
17 #include <linux/rwsem.h>
18 #include <linux/proc_fs.h>
19 #include <linux/seq_file.h>
20 #include "internal.h"
22 static void *c_start(struct seq_file *m, loff_t *pos)
24 struct list_head *v;
25 loff_t n = *pos;
27 down_read(&crypto_alg_sem);
28 list_for_each(v, &crypto_alg_list)
29 if (!n--)
30 return list_entry(v, struct crypto_alg, cra_list);
31 return NULL;
34 static void *c_next(struct seq_file *m, void *p, loff_t *pos)
36 struct list_head *v = p;
38 (*pos)++;
39 v = v->next;
40 return (v == &crypto_alg_list) ?
41 NULL : list_entry(v, struct crypto_alg, cra_list);
44 static void c_stop(struct seq_file *m, void *p)
46 up_read(&crypto_alg_sem);
49 static int c_show(struct seq_file *m, void *p)
51 struct crypto_alg *alg = (struct crypto_alg *)p;
53 seq_printf(m, "name : %s\n", alg->cra_name);
54 seq_printf(m, "driver : %s\n", alg->cra_driver_name);
55 seq_printf(m, "module : %s\n", module_name(alg->cra_module));
56 seq_printf(m, "priority : %d\n", alg->cra_priority);
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;
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;
82 seq_putc(m, '\n');
83 return 0;
86 static struct seq_operations crypto_seq_ops = {
87 .start = c_start,
88 .next = c_next,
89 .stop = c_stop,
90 .show = c_show
93 static int crypto_info_open(struct inode *inode, struct file *file)
95 return seq_open(file, &crypto_seq_ops);
98 static struct file_operations proc_crypto_ops = {
99 .open = crypto_info_open,
100 .read = seq_read,
101 .llseek = seq_lseek,
102 .release = seq_release
105 void __init crypto_init_proc(void)
107 struct proc_dir_entry *proc;
109 proc = create_proc_entry("crypto", 0, NULL);
110 if (proc)
111 proc->proc_fops = &proc_crypto_ops;